findByIds() public method

If an id of the array is not assigned to a category, no error is thrown.
public findByIds ( array $ids ) : Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[]
$ids array
return Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[]
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $data = [];
     $categoryIds = $node->getPropertyValueWithDefault($property->getName(), []);
     $categories = $this->categoryManager->findByIds($categoryIds);
     $categories = $this->categoryManager->getApiObjects($categories, $languageCode);
     foreach ($categories as $category) {
         $data[] = $category->toArray();
     }
     $this->setData($data, $property);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getContentData(PropertyInterface $property)
 {
     $ids = $property->getValue();
     if (!is_array($ids) || empty($ids)) {
         return [];
     }
     $data = [];
     $categoryEntities = $this->categoryManager->findByIds($ids);
     $categoryApiEntities = $this->categoryManager->getApiObjects($categoryEntities, $property->getStructure()->getLanguageCode());
     foreach ($categoryApiEntities as $category) {
         $data[] = $category->toArray();
     }
     return $data;
 }