/**
  * @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();
 }
 /**
  * @param EntityInterface $entity
  * @return \PropelCollection|Entry[]
  */
 public function findAll($entity)
 {
     return EntryQuery::create()->filterByEntityType($entity->getTreeType())->filterByEntityId($entity->getTreeId())->find();
 }