/**
  * Remove marketing list entity item from list
  *
  * Returns
  * - HTTP_OK (200)
  *
  * @Rest\Get(
  *      "/marketinglist/{marketingList}/remove/{id}"
  * )
  * @ApiDoc(description="Remove marketing list entity item", resource=true)
  * @AclAncestor("orocrm_marketing_list_removed_item_delete")
  *
  * @param MarketingList $marketingList
  * @param int           $id
  *
  * @return Response
  */
 public function removeAction(MarketingList $marketingList, $id)
 {
     $item = new MarketingListRemovedItem();
     $item->setMarketingList($marketingList)->setEntityId($id);
     $violations = $this->get('validator')->validate($item);
     if ($violations->count()) {
         return $this->handleView($this->view($violations, Codes::HTTP_BAD_REQUEST));
     }
     $em = $this->getManager()->getObjectManager();
     $em->persist($item);
     $em->flush($item);
     $entityName = $this->get('oro_entity_config.provider.entity')->getConfig($marketingList->getEntity())->get('label');
     return $this->handleView($this->view(array('successful' => true, 'message' => $this->get('translator')->trans('orocrm.marketinglist.controller.removed', ['%entityName%' => $this->get('translator')->trans($entityName)])), Codes::HTTP_OK));
 }
Ejemplo n.º 2
0
 public function testBeforeSave()
 {
     $this->assertNull($this->entity->getCreatedAt());
     $this->entity->beforeSave();
     $this->assertInstanceOf('\\DateTime', $this->entity->getCreatedAt());
 }