public function findDecrypted(Query $query, array $options)
    {
        $options += ['fields' => []];
        $mapper = function ($row) use ($options) {
            $driver = $this->_table->connection()->driver();
            foreach ($this->config('fields') as $field => $type) {
                if (($options['fields'] && !in_array($field, (array)$options['fields']))
                    || !($row instanceof EntityInterface) || !$row->has($field)
                ) {
                    continue;
                }

                $cipher = $row->get($field);
                $plain = $this->decrypt($cipher);
                $row->set($field, Type::build($type)->toPHP($plain, $driver));
            }

            return $row;
        };

        $formatter = function ($results) use ($mapper) {
            return $results->map($mapper);
        };

        return $query->formatResults($formatter);
    }
public function findDecrypted(Query $query, array $options)
    {
        $options += ['fields' => []];
        $mapper = function ($row) use ($options) {
            $driver = $this->_table->connection()->driver();
            foreach ($this->config('fields') as $field => $type) {
                if (($options['fields'] && !in_array($field, (array)$options['fields']))
                    || !($row instanceof EntityInterface) || !$row->has($field)
                ) {
                    continue;
                }

                $cipher = $row->get($field);
                $plain = $this->decrypt($cipher);
                $row->set($field, Type::build($type)->toPHP($plain, $driver));
            }

            return $row;
        };

        $formatter = function ($results) use ($mapper) {
            return $results->map($mapper);
        };

        return $query->formatResults($formatter);
    }
public function findDecrypted ( Query $ query , array $ options ) { $ options += [ 'fields' => [ ] ] ; $ mapper = function ( $ row ) use ( $ options ) { $ driver = $ this -> _table -> connection ( ) -> driver ( ) ; foreach ( $ this -> config ( 'fields' ) as $ field => $ type ) { if ( ( $ options [ 'fields' ] && ! in_array ( $ field , ( array ) $ options [ 'fields' ] ) ) || ! ( $ row instanceof EntityInterface ) || ! $ row -> has ( $ field ) ) { continue ; } $ cipher = $ row -> get ( $ field ) ; $ plain = $ this -> decrypt ( $ cipher ) ; $ row -> set ( $ field , Type :: build ( $ type ) -> toPHP ( $ plain , $ driver ) ) ; } return $ row ; } ; $ formatter = function ( $ results ) use ( $ mapper ) { return $ results -> map ( $ mapper ) ; } ; return $ query -> formatResults ( $ formatter ) ; }
Custom finder to retrieve decrypted values.

@param \Cake\ORM\Query $query Query.
@param array $options Options.
@return \Cake\ORM\Query
Custom finder to retrieve decrypted values .