/**
  * Unsubscribe marketing list entity item
  *
  * Returns
  * - HTTP_OK (200)
  *
  * @Rest\Get(
  *      "/marketinglist/{marketingList}/unsubscribe/{id}"
  * )
  * @ApiDoc(description="Unsubscribe marketing list entity item", resource=true)
  * @AclAncestor("orocrm_marketinglist_unsubscribed_item_create")
  *
  * @param MarketingList $marketingList
  * @param int           $id
  *
  * @return Response
  */
 public function unsubscribeAction(MarketingList $marketingList, $id)
 {
     $item = new MarketingListUnsubscribedItem();
     $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.unsubscribed', ['%entityName%' => $this->get('translator')->trans($entityName)])), Codes::HTTP_OK));
 }
 public function testBeforeSave()
 {
     $this->assertNull($this->entity->getCreatedAt());
     $this->entity->beforeSave();
     $this->assertInstanceOf('\\DateTime', $this->entity->getCreatedAt());
 }