public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options)
    {
        $isNew = $entity->isNew();
        if (($this->config('on') === 'update' && $isNew) ||
            ($this->config('on') === 'insert' && !$isNew) ||
            (isset($options['index']) && $options['index'] === false)
        ) {
            return;
        }

        $this->_table->dispatchEvent('Model.beforeIndex', compact('entity'));
        $success = $this->searchEngine()->index($entity);
        $this->_table->dispatchEvent('Model.afterIndex', compact('entity', 'success'));
    }
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options)
    {
        $isNew = $entity->isNew();
        if (($this->config('on') === 'update' && $isNew) ||
            ($this->config('on') === 'insert' && !$isNew) ||
            (isset($options['index']) && $options['index'] === false)
        ) {
            return;
        }

        $this->_table->dispatchEvent('Model.beforeIndex', compact('entity'));
        $success = $this->searchEngine()->index($entity);
        $this->_table->dispatchEvent('Model.afterIndex', compact('entity', 'success'));
    }
public function afterSave ( Event $ event , EntityInterface $ entity , ArrayObject $ options ) { $ isNew = $ entity -> isNew ( ) ; if ( ( $ this -> config ( 'on' ) === 'update' && $ isNew ) || ( $ this -> config ( 'on' ) === 'insert' && ! $ isNew ) || ( isset ( $ options [ 'index' ] ) && $ options [ 'index' ] === false ) ) { return ; } $ this -> _table -> dispatchEvent ( 'Model.beforeIndex' , compact ( 'entity' ) ) ; $ success = $ this -> searchEngine ( ) -> index ( $ entity ) ; $ this -> _table -> dispatchEvent ( 'Model.afterIndex' , compact ( 'entity' , 'success' ) ) ; }
Generates a list of words after each entity is saved.

Triggers the following events:

- `Model.beforeIndex`: Before entity gets indexed by the configured search
engine adapter. First argument is the entity instance being indexed.

- `Model.afterIndex`: After entity was indexed by the configured search
engine adapter. First argument is the entity instance that was indexed, and
second indicates whether the indexing process completed correctly or not.

@param \Cake\Event\Event $event The event that was triggered
@param \Cake\Datasource\EntityInterface $entity The entity that was saved
@param \ArrayObject $options Additional options
@return void
Generates a list of words after each entity is saved .