protected function _resolveSluggableBehavior(Garp_Model_Db $model) { $sluggable = $model->getObserver('Sluggable'); if (!is_null($sluggable)) { return array($sluggable, $model); } // Try on a derived model $translatable = $model->getObserver('Translatable'); if (!is_null($translatable)) { $model = $translatable->getI18nModel($model->getUnilingualModel()); return $this->_resolveSluggableBehavior($model); } return array(null, null); }
protected function _getPhpBehavior(Garp_Model_Db $model) { $phpBehavior = $model->getObserver(self::BEHAVIOR_NAME); return $phpBehavior; }
/** * Retrieve primary keys of affected records * * @param Garp_Model_Db $model * @param String $where * @return Array */ protected function _getPrimaryKeysOfAffectedRows(Garp_Model_Db $model, $where) { if ($draftableObserver = $model->getObserver('Draftable')) { // Unregister so it doesn't screw up the upcoming fetch call $model->unregisterObserver($draftableObserver); } $pkExtractor = new Garp_Db_PrimaryKeyExtractor($model, $where); $pks = $pkExtractor->extract(); if (count($pks)) { return array($pks); } $rows = $model->fetchAll($where); $pks = array(); foreach ($rows as $row) { if (!$row->isConnected()) { $row->setTable($model); } $pks[] = (array) $row->getPrimaryKey(); } if ($draftableObserver) { $model->registerObserver($draftableObserver); } return $pks; }
protected function _getRelatedBehavior(Garp_Model_Db $relatedModel) { $relatedBehavior = $relatedModel->getObserver('Elasticsearchable'); return $relatedBehavior; }