/**
  * Creates a new news-item and set the data which are passed.
  *
  * @param array $data mandatory: title; optional: teaser, description
  *
  * @return NewsItem
  */
 public function create(array $data)
 {
     $entity = new NewsItem();
     $entity->setTitle($data['title']);
     $entity->setTeaser($this->getValue($data, 'teaser'));
     $entity->setDescription($this->getValue($data, 'description'));
     $this->entityManager->persist($entity);
     $this->entityManager->flush();
     return $entity;
 }
예제 #2
0
 /**
  * Bind data array to the given entity.
  *
  * @param NewsItem $entity
  * @param array $data
  *
  * @return NewsItem
  */
 protected function bind(NewsItem $entity, array $data)
 {
     $entity->setTitle($data['title']);
     $entity->setContent($this->getValue($data, 'content'));
     return $entity;
 }