library/Garp/Model/Behavior/Elasticsearchable.php
public function afterSave(Garp_Model_Db $model, $primaryKey) {
        if (is_array($primaryKey)) {
            throw new Exception(self::ERROR_PRIMARY_KEY_CANNOT_BE_ARRAY);
        }

        $boundModel = new Garp_Service_Elasticsearch_Db_BoundModel($model);
        $row = $boundModel->fetchRow($primaryKey);

        if (!$row) {
            /* This is not supposed to happen,
            but due to concurrency it theoretically might. */
            return;
        }

        if (!$this->getRootable()) {
            /* This record should not appear directly in the index,
            *  but only as related records.
            */
            return;
        }

        $rowFilter          = new Garp_Service_Elasticsearch_Db_RowFilter($model);
        $columns            = $this->getColumns();
        $filteredRow        = $rowFilter->filter($row, $columns);

        $elasticModel       = $this->_getElasticModel($model);
        $pkMash             = $this->_mashPrimaryKey($primaryKey);
        $filteredRow['id']  = $pkMash;

        $elasticModel->save($filteredRow);
    }
public function afterSave(Garp_Model_Db $model, $primaryKey) {
        if (is_array($primaryKey)) {
            throw new Exception(self::ERROR_PRIMARY_KEY_CANNOT_BE_ARRAY);
        }

        $boundModel = new Garp_Service_Elasticsearch_Db_BoundModel($model);
        $row = $boundModel->fetchRow($primaryKey);

        if (!$row) {
            /* This is not supposed to happen,
            but due to concurrency it theoretically might. */
            return;
        }

        if (!$this->getRootable()) {
            /* This record should not appear directly in the index,
            *  but only as related records.
            */
            return;
        }

        $rowFilter          = new Garp_Service_Elasticsearch_Db_RowFilter($model);
        $columns            = $this->getColumns();
        $filteredRow        = $rowFilter->filter($row, $columns);

        $elasticModel       = $this->_getElasticModel($model);
        $pkMash             = $this->_mashPrimaryKey($primaryKey);
        $filteredRow['id']  = $pkMash;

        $elasticModel->save($filteredRow);
    }
public function afterSave ( Garp_Model_Db $ model , $ primaryKey ) { if ( is_array ( $ primaryKey ) ) { throw new Exception ( self :: ERROR_PRIMARY_KEY_CANNOT_BE_ARRAY ) ; } $ boundModel = new Garp_Service_Elasticsearch_Db_BoundModel ( $ model ) ; $ row = $ boundModel -> fetchRow ( $ primaryKey ) ; if ( ! $ row ) { /* This is not supposed to happen,
            but due to concurrency it theoretically might. */ return ; } if ( ! $ this -> getRootable ( ) ) { /* This record should not appear directly in the index,
            *  but only as related records.
            */ return ; } $ rowFilter = new Garp_Service_Elasticsearch_Db_RowFilter ( $ model ) ; $ columns = $ this -> getColumns ( ) ; $ filteredRow = $ rowFilter -> filter ( $ row , $ columns ) ; $ elasticModel = $ this -> _getElasticModel ( $ model ) ; $ pkMash = $ this -> _mashPrimaryKey ( $ primaryKey ) ; $ filteredRow [ 'id' ] = $ pkMash ; $ elasticModel -> save ( $ filteredRow ) ; }
Generic method for pushing a database row to the indexer.
@param Garp_Model_Db $model
@param int $primaryKey
Generic method for pushing a database row to the indexer .