Sulu\Bundle\CategoryBundle\Entity\CategoryMeta::setCategory PHP Méthode

setCategory() public méthode

public setCategory ( Sulu\Bundle\CategoryBundle\Entity\CategoryInterface $category )
$category Sulu\Bundle\CategoryBundle\Entity\CategoryInterface
    public function setCategory(CategoryInterface $category)
    {
        $this->category = $category;
        return $this;
    }

Usage Example

Exemple #1
0
 /**
  * Takes meta as array and sets it to the entity.
  *
  * @param array $meta
  *
  * @return Category
  */
 public function setMeta($meta)
 {
     $meta = is_array($meta) ? $meta : [];
     $currentMeta = $this->entity->getMeta();
     foreach ($meta as $singleMeta) {
         $metaEntity = null;
         if (isset($singleMeta['id'])) {
             $metaEntity = $this->getSingleMetaById($currentMeta, $singleMeta['id']);
         }
         if (!$metaEntity) {
             $metaEntity = new CategoryMeta();
             $metaEntity->setCategory($this->entity);
             $this->entity->addMeta($metaEntity);
         }
         $metaEntity->setKey($singleMeta['key']);
         $metaEntity->setValue($singleMeta['value']);
         if (array_key_exists('locale', $singleMeta)) {
             $metaEntity->setLocale($singleMeta['locale']);
         }
     }
     return $this;
 }
All Usage Examples Of Sulu\Bundle\CategoryBundle\Entity\CategoryMeta::setCategory