Example #1
0
 /**
  * @param string      $itemId
  * @param array       $data
  * @param string|null $collection
  * @return Item
  */
 public function post($itemId, array $data, $collection = null)
 {
     $this->setCollection($collection);
     // create new Item
     $item = new Item();
     $item->setId($itemId);
     $item->setAttributes($data);
     // save
     $this->dm->persist($item);
     $this->dm->flush();
     return $item;
 }
Example #2
0
 /**
  * Removes all "similar" references of the given item
  *
  * @param Item $item
  */
 public function removeAllSimilarReferencesForItem(Item $item)
 {
     $this->createQueryBuilder()->update()->field('similar')->pull(['item' => $item->getId()])->multiple(true)->getQuery()->execute();
 }