Sulu\Bundle\CategoryBundle\Entity\Category::setCreator PHP Метод

setCreator() публичный Метод

public setCreator ( Sulu\Component\Security\Authentication\UserInterface $creator = null )
$creator Sulu\Component\Security\Authentication\UserInterface
    public function setCreator(UserInterface $creator = null)
    {
        $this->creator = $creator;
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Creates a new category with given data.
  *
  * @param $data
  * @param $user
  *
  * @return CategoryEntity
  */
 private function createCategory($data, $user)
 {
     $categoryEntity = new CategoryEntity();
     $categoryEntity->setCreator($user);
     $categoryEntity->setChanger($user);
     $categoryWrapper = $this->getApiObject($categoryEntity, $data['locale']);
     $categoryWrapper->setName($data['name']);
     if (array_key_exists('key', $data)) {
         $categoryWrapper->setKey($data['key']);
     }
     if (array_key_exists('meta', $data)) {
         $categoryWrapper->setMeta($data['meta']);
     }
     if (array_key_exists('parent', $data)) {
         $parentEntity = $this->findById($data['parent']);
         $categoryWrapper->setParent($parentEntity);
     }
     $categoryEntity = $categoryWrapper->getEntity();
     $this->em->persist($categoryEntity);
     $this->em->flush();
     return $categoryEntity;
 }