Ejemplo n.º 1
0
 /**
  * @param TaxonomyTermInterface|TaxonomyInterface $object
  * @return TaxonomyTermInterface
  * @throws \Taxonomy\Exception\InvalidArgumentException
  */
 public function getAllowedChildren($object)
 {
     if ($object instanceof TaxonomyInterface) {
         $name = $object->getName();
     } elseif ($object instanceof TaxonomyTermInterface) {
         $name = $object->getTaxonomy()->getName();
     } else {
         throw new Exception\InvalidArgumentException(sprintf('Expected $nameOrObject to be TaxonomyInterface, TaxonomyTermInterface or string but got "%s"', is_object($object) ? get_class($object) : gettype($object)));
     }
     $taxonomies = [];
     $children = $this->moduleOptions->getType($name)->getAllowedChildren();
     $instance = $object->getInstance();
     foreach ($children as $child) {
         $taxonomies[] = $this->taxonomyManager->findTaxonomyByName($child, $instance);
     }
     return $taxonomies;
 }