public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
    {
        $status = array_key_exists('eav', $options) ? $options['eav'] : $this->config('status');

        if ($status) {
            $options['bundle'] = !isset($options['bundle']) ? null : $options['bundle'];
            $this->_initScopes();

            if (empty($this->_queryScopes['Eav\\Model\\Behavior\\QueryScope\\SelectScope'])) {
                return $query;
            }

            $selectedVirtual = $this->_queryScopes['Eav\\Model\\Behavior\\QueryScope\\SelectScope']->getVirtualColumns($query, $options['bundle']);
            $args = compact('options', 'primary', 'selectedVirtual');
            $query = $this->_scopeQuery($query, $options['bundle']);

            return $query->formatResults(function ($results) use ($args) {
                return $this->_hydrateEntities($results, $args);
            }, Query::PREPEND);
        }
    }
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
    {
        $status = array_key_exists('eav', $options) ? $options['eav'] : $this->config('status');

        if ($status) {
            $options['bundle'] = !isset($options['bundle']) ? null : $options['bundle'];
            $this->_initScopes();

            if (empty($this->_queryScopes['Eav\\Model\\Behavior\\QueryScope\\SelectScope'])) {
                return $query;
            }

            $selectedVirtual = $this->_queryScopes['Eav\\Model\\Behavior\\QueryScope\\SelectScope']->getVirtualColumns($query, $options['bundle']);
            $args = compact('options', 'primary', 'selectedVirtual');
            $query = $this->_scopeQuery($query, $options['bundle']);

            return $query->formatResults(function ($results) use ($args) {
                return $this->_hydrateEntities($results, $args);
            }, Query::PREPEND);
        }
    }
public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ status = array_key_exists ( 'eav' , $ options ) ? $ options [ 'eav' ] : $ this -> config ( 'status' ) ; if ( $ status ) { $ options [ 'bundle' ] = ! isset ( $ options [ 'bundle' ] ) ? null : $ options [ 'bundle' ] ; $ this -> _initScopes ( ) ; if ( empty ( $ this -> _queryScopes [ 'Eav\\Model\\Behavior\\QueryScope\\SelectScope' ] ) ) { return $ query ; } $ selectedVirtual = $ this -> _queryScopes [ 'Eav\\Model\\Behavior\\QueryScope\\SelectScope' ] -> getVirtualColumns ( $ query , $ options [ 'bundle' ] ) ; $ args = compact ( 'options' , 'primary' , 'selectedVirtual' ) ; $ query = $ this -> _scopeQuery ( $ query , $ options [ 'bundle' ] ) ; return $ query -> formatResults ( function ( $ results ) use ( $ args ) { return $ this -> _hydrateEntities ( $ results , $ args ) ; } , Query :: PREPEND ) ; } }
Attaches virtual properties to entities.

This method is also responsible of looking for virtual columns in SELECT and
WHERE clauses (if applicable) and properly scope the Query object. Query
scoping is performed by the `_scopeQuery()` method.

EAV can be enabled or disabled on the fly using `eav` finder option, or
`eav()` method. When mixing, `eav` option has the highest priority:

```php
$this->Articles->eav(false);
$articlesNoVirtual = $this->Articles->find('all');
$articlesWithVirtual = $this->Articles->find('all', ['eav' => true]);
```

@param \Cake\Event\Event $event The beforeFind event that was triggered
@param \Cake\ORM\Query $query The original query to modify
@param \ArrayObject $options Additional options given as an array
@param bool $primary Whether this find is a primary query or not
@return bool|null
Attaches virtual properties to entities .