/**
  * @todo improve logic
  * @param EntityInterface $entity
  * @param array           $array
  */
 protected function retrieveTermsThroughParents(EntityInterface $entity, array &$array)
 {
     foreach ($entity->getParentLinks() as $link) {
         if ($link->getType()->getName() == 'link') {
             /* @var $parent EntityInterface */
             $parent = $link->getParent();
             $this->retrieveTerms($parent, $array);
         }
     }
 }
 /**
  * @param EntityInterface $entity
  * @param string          $id
  * @return \Versioning\Entity\RevisionInterface|null
  */
 protected function getRevision(EntityInterface $entity, $id = null)
 {
     try {
         if ($id === null) {
             return $entity->getCurrentRevision();
         } else {
             return $this->getRepositoryManager()->findRevision($entity, $id);
         }
     } catch (RevisionNotFoundException $e) {
         return null;
     }
 }
Example #3
0
 protected function addEntities(EntityInterface $entity)
 {
     // Build new relation object to handle join entity correct
     $rel = new TaxonomyTermEntity($this, $entity);
     // Add relation object to collection
     $this->getEntityNodes()->add($rel);
     $entity->addTaxonomyTerm($this, $rel);
 }
Example #4
0
 protected function iterLinks(EntityInterface $entity, $collection, $callback)
 {
     $this->iterEntities($entity->getChildren('link'), $collection, $callback);
 }
Example #5
0
 protected function getCategories(EntityInterface $entity)
 {
     $categories = [];
     $i = 0;
     foreach ($entity->getTaxonomyTerms() as $term) {
         $categories[$i] = '';
         while ($term->hasParent()) {
             $categories[$i] = $term->getName() . '/' . $categories[$i];
             $term = $term->getParent();
         }
         $categories[$i] = substr($categories[$i], 0, -1);
         $i++;
     }
     return $categories;
 }
Example #6
0
 public function getPreviousValidSibling($linkType, EntityInterface $following)
 {
     $children = $this->getChildren($linkType, $following->getType()->getName());
     if (($index = $children->indexOf($following)) === false) {
         return null;
     }
     for ($i = $index - 1; $i >= 0; --$i) {
         $child = $children->get($i);
         if ($child->hasCurrentRevision() && !$child->isTrashed()) {
             return $child;
         }
     }
     return null;
 }
Example #7
0
 public function getOptions(EntityInterface $entity)
 {
     return $this->getModuleOptions()->getType($entity->getType()->getName());
 }