src/Listener/RelatedModelsListener.php
public function beforePaginate(Event $event)
    {
        $method = 'contain';
        if (method_exists($event->getSubject()->query, 'getContain')) {
            $method = 'getContain';
        }
        $contained = $event->getSubject()->query->$method();

        if (!empty($contained)) {
            return;
        }

        $models = $this->models();
        if (empty($models)) {
            return;
        }

        $event->getSubject()->query->contain(array_keys($models));
    }
public function beforePaginate(Event $event)
    {
        $method = 'contain';
        if (method_exists($event->getSubject()->query, 'getContain')) {
            $method = 'getContain';
        }
        $contained = $event->getSubject()->query->$method();

        if (!empty($contained)) {
            return;
        }

        $models = $this->models();
        if (empty($models)) {
            return;
        }

        $event->getSubject()->query->contain(array_keys($models));
    }
public function beforePaginate ( Event $ event ) { $ method = 'contain' ; if ( method_exists ( $ event -> getSubject ( ) -> query , 'getContain' ) ) { $ method = 'getContain' ; } $ contained = $ event -> getSubject ( ) -> query -> $ method ( ) ; if ( ! empty ( $ contained ) ) { return ; } $ models = $ this -> models ( ) ; if ( empty ( $ models ) ) { return ; } $ event -> getSubject ( ) -> query -> contain ( array_keys ( $ models ) ) ; }
Automatically parse and contain related table classes

@param \Cake\Event\Event $event Before paginate event
@return void
Automatically parse and contain related table classes