/** * @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; } }
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); }
protected function iterLinks(EntityInterface $entity, $collection, $callback) { $this->iterEntities($entity->getChildren('link'), $collection, $callback); }
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; }
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; }
public function getOptions(EntityInterface $entity) { return $this->getModuleOptions()->getType($entity->getType()->getName()); }