Inheritance: implements Sulu\Bundle\ContactBundle\Contact\ContactManagerInterface, use trait Sulu\Component\Persistence\RelationTrait
Exemple #1
0
 /**
  * @param ObjectManager $em
  * @param TagManagerInterface $tagManager
  * @param MediaManagerInterface $mediaManager
  * @param AccountRepository $accountRepository
  * @param ContactTitleRepository $contactTitleRepository
  * @param ContactRepository $contactRepository
  */
 public function __construct(ObjectManager $em, TagManagerInterface $tagManager, MediaManagerInterface $mediaManager, AccountRepository $accountRepository, ContactTitleRepository $contactTitleRepository, ContactRepository $contactRepository)
 {
     parent::__construct($em, $tagManager, $mediaManager);
     $this->accountRepository = $accountRepository;
     $this->contactTitleRepository = $contactTitleRepository;
     $this->contactRepository = $contactRepository;
 }
 /**
  * Returns a view containing all media of an entity.
  *
  * @param string $entityName
  * @param string $routeName
  * @param AbstractContactManager $contactManager
  * @param string $id
  * @param Request $request
  *
  * @return Response
  */
 protected function getMultipleView($entityName, $routeName, AbstractContactManager $contactManager, $id, $request)
 {
     try {
         $locale = $this->getUser()->getLocale();
         if ($request->get('flat') === 'true') {
             /** @var RestHelperInterface $restHelper */
             $restHelper = $this->get('sulu_core.doctrine_rest_helper');
             /** @var DoctrineListBuilderFactory $factory */
             $factory = $this->get('sulu_core.doctrine_list_builder_factory');
             $listBuilder = $factory->create($entityName);
             $fieldDescriptors = $this->getFieldDescriptors($entityName, $id);
             $listBuilder->setIdField($fieldDescriptors['id']);
             $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
             $listResponse = $listBuilder->execute();
             $listResponse = $this->addThumbnails($listResponse, $locale);
             $listResponse = $this->addUrls($listResponse, $locale);
             $list = new ListRepresentation($listResponse, self::$mediaEntityKey, $routeName, array_merge(['id' => $id], $request->query->all()), $listBuilder->getCurrentPage(), $listBuilder->getLimit(), $listBuilder->count());
         } else {
             $media = $contactManager->getById($id, $locale)->getMedias();
             $list = new CollectionRepresentation($media, self::$mediaEntityKey);
         }
         $view = $this->view($list, 200);
     } catch (EntityNotFoundException $e) {
         $view = $this->view($e->toArray(), 404);
     }
     return $this->handleView($view);
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function deleteAllRelations($entity)
 {
     parent::deleteAllRelations($entity);
     // add bank-accounts for accounts
     $this->deleteBankAccounts($entity);
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function deleteAllRelations($entity)
 {
     parent::deleteAllRelations($entity);
     $this->deleteBankAccounts($entity);
 }