/** * @param Entry $obj * @param string|null $key */ public static function addInstanceToPool($obj, $key = null) { if (\Propel::isInstancePoolingEnabled()) { $path = $obj->getPath(); $pathKey = self::_pathKey($obj->getEntityType(), $path); EntryPeer::$instances[$pathKey] = $obj; parent::addInstanceToPool($obj, $key); } }
/** * @param string $path * @param EntityInterface $entity * @param bool|Position|string $overwrite Flag to overwrite existing records (or $position) * @param Position|null $position * @throws Exception\PathNotFoundException * @throws Exception\PathAlreadyExistsException */ public function put($path, $entity, $overwrite = false, $position = null) { $connection = \Propel::getConnection(); $connection->beginTransaction(); $path = $this->_normalize($path); if ($position === null && (is_string($overwrite) || $overwrite instanceof Position)) { $position = $overwrite; $overwrite = false; } $e = EntryPeer::retrieveByPath($this->entityType, $path); if ($e && !$overwrite) { throw new PathAlreadyExistsException($path); } elseif (!$e) { if ($path != '/') { $parent = $this->_getParentPath($path); if (!EntryPeer::doesPathExist($this->entityType, $parent)) { throw new PathNotFoundException($parent); } } $e = new Entry(); $e->setPath($path); $e->setSlug(basename($path)); } $orderNumber = $this->_handleOrder($path, $position ?: Position::LAST); $e->setOrderNumber($orderNumber); $e->setEntityId($entity->getTreeId()); $e->setEntityType($this->entityType); $e->save(); $connection->commit(); }