/** * Метод возвращает код для сущности фолдинга. * Этот код нужен для того, чтобы другие сущности могли ссылаться на него через базу. */ public function getEntityCode(FoldedEntity $entity) { $code = array_get_value('id', to_array($this->getRec('select id from ps_folded_codes where v_unique=?', $entity->getUnique()))); return 1 * (is_numeric($code) ? $code : $this->insert('insert into ps_folded_codes (v_unique) values (?)', $entity->getUnique())); }
public function setDependsOnEntity($ident, FoldedEntity $entity) { if (!$this->isCanDependsOnEntitys($ident)) { //Мы не используем кеш или сущность не видна, поэтому - не зависим от других сущностей фолдингов return; //--- } if (!$entity->getFolding()->isVisibleEntity($entity->getIdent())) { //Мы обнаружили, что в видимой сущности используется невидимая raise_error('Visible entity [' . $this->getUnique() . '] cannot depends on invisible entity [' . $entity->getUnique() . ']'); } if ($this->getUnique($ident) == $entity->getUnique()) { //Сущность не может зависеть от самой себя return; //--- } $depends = $this->getFromFoldedCache($ident, self::CACHE_DEPEND_ENTS); $depends = to_array($depends); if (in_array($entity->getUnique(), $depends)) { //Мы уже отметили, что зависим от данной сущности return; //--- } $this->LOGGER->info("Entity [{$ident}] is depends on entity [{$entity}]."); $depends[] = $entity->getUnique(); $this->saveToFoldedCache($depends, $ident, self::CACHE_DEPEND_ENTS); unset($this->WE_DEPENDS_ON_CACHE[$ident]); }