Ejemplo n.º 1
0
 /**
  * Handle delete entity object.
  *
  * @param mixed            $id
  * @param ApiEntityManager $manager
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $entity = $manager->find($id);
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     $em = $manager->getObjectManager();
     $this->checkPermissions($entity, $em);
     $this->deleteEntity($entity, $em);
     $em->flush();
 }
Ejemplo n.º 2
0
 /**
  * @param $id
  * @param ApiEntityManager $manager
  *
  * @throws \Exception
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     /** @var ContactPhone $contactPhone */
     $contactPhone = $manager->find($id);
     if (!$this->securityFacade->isGranted('EDIT', $contactPhone->getOwner())) {
         throw new AccessDeniedException();
     }
     if ($this->contactPhoneDeleteValidator->validate($contactPhone)) {
         $em = $manager->getObjectManager();
         $em->remove($contactPhone);
         $em->flush();
     } else {
         throw new \Exception("oro.contact.phone.error.delete.more_one", 500);
     }
 }
 /**
  * Handle delete entity object.
  *
  * @param RelationIdentifier $id
  * @param ApiEntityManager   $manager
  *
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $em = $manager->getObjectManager();
     /** @var ActivityInterface $entity */
     $entity = $em->find($id->getOwnerEntityClass(), $id->getOwnerEntityId());
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     $this->checkPermissions($entity, $em);
     $targetEntity = $em->find($id->getTargetEntityClass(), $id->getTargetEntityId());
     if (!$targetEntity) {
         throw new EntityNotFoundException();
     }
     $this->checkPermissionsForTargetEntity($targetEntity, $em);
     $this->activityManager->removeActivityTarget($entity, $targetEntity);
     $em->flush();
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function serializeOne($id)
 {
     list($fileId, $ownerEntityClass, $ownerEntityId) = $this->attachmentManager->parseFileKey($id);
     if (!$this->securityFacade->isGranted('VIEW', new ObjectIdentity($ownerEntityId, $ownerEntityClass))) {
         throw new AccessDeniedException();
     }
     return parent::serializeOne($fileId);
 }
 /**
  * @param ObjectManager $om
  * @param ChainDictionaryValueListProvider $dictionaryProvider
  * @param DictionaryHelper $dictionaryHelper
  * @param ConfigManager $entityConfigManager
  * @param PropertyAccessor $propertyAccessor
  */
 public function __construct(ObjectManager $om, ChainDictionaryValueListProvider $dictionaryProvider, DictionaryHelper $dictionaryHelper, ConfigManager $entityConfigManager, PropertyAccessor $propertyAccessor)
 {
     parent::__construct(null, $om);
     $this->dictionaryProvider = $dictionaryProvider;
     $this->dictionaryHelper = $dictionaryHelper;
     $this->entityConfigManager = $entityConfigManager;
     $this->propertyAccessor = $propertyAccessor;
 }
 /**
  * @param Attachment $entity
  *
  * @throws AccessDeniedException
  */
 protected function checkFoundEntity($entity)
 {
     parent::checkFoundEntity($entity);
     $attachmentTarget = $entity->getTarget();
     if ($attachmentTarget && !$this->securityFacade->isGranted('VIEW', $attachmentTarget)) {
         throw new AccessDeniedException();
     }
 }
Ejemplo n.º 7
0
 /**
  * @param string          $class
  * @param ObjectManager   $om
  * @param ActivityManager $activityManager
  * @param ConfigManager   $configManager
  * @param SecurityFacade  $securityFacade
  * @param RouterInterface $router
  */
 public function __construct($class, ObjectManager $om, ActivityManager $activityManager, ConfigManager $configManager, SecurityFacade $securityFacade, RouterInterface $router)
 {
     parent::__construct($class, $om);
     $this->activityManager = $activityManager;
     $this->configManager = $configManager;
     $this->securityFacade = $securityFacade;
     $this->router = $router;
 }
 /**
  * @param ObjectManager         $om
  * @param ActivityManager       $activityManager
  * @param TokenStorageInterface $securityTokenStorage
  * @param ConfigManager         $configManager
  * @param RouterInterface       $router
  * @param EntityAliasResolver   $entityAliasResolver
  */
 public function __construct(ObjectManager $om, ActivityManager $activityManager, TokenStorageInterface $securityTokenStorage, ConfigManager $configManager, RouterInterface $router, EntityAliasResolver $entityAliasResolver)
 {
     parent::__construct(null, $om);
     $this->activityManager = $activityManager;
     $this->securityTokenStorage = $securityTokenStorage;
     $this->configManager = $configManager;
     $this->router = $router;
     $this->entityAliasResolver = $entityAliasResolver;
 }
 /**
  * @param ObjectManager         $om
  * @param ActivityManager       $activityManager
  * @param TokenStorageInterface $securityTokenStorage
  * @param ConfigManager         $configManager
  * @param RouterInterface       $router
  * @param EntityAliasResolver   $entityAliasResolver
  * @param ObjectMapper          $objectMapper
  * @param TranslatorInterface   $translator
  * @param DoctrineHelper        $doctrineHelper
  */
 public function __construct(ObjectManager $om, ActivityManager $activityManager, TokenStorageInterface $securityTokenStorage, ConfigManager $configManager, RouterInterface $router, EntityAliasResolver $entityAliasResolver, ObjectMapper $objectMapper, TranslatorInterface $translator, DoctrineHelper $doctrineHelper)
 {
     parent::__construct(null, $om);
     $this->activityManager = $activityManager;
     $this->securityTokenStorage = $securityTokenStorage;
     $this->configManager = $configManager;
     $this->router = $router;
     $this->entityAliasResolver = $entityAliasResolver;
     $this->mapper = $objectMapper;
     $this->translator = $translator;
     $this->doctrineHelper = $doctrineHelper;
 }
 /**
  * Handle delete entity object.
  *
  * @param RelationIdentifier $id
  * @param ApiEntityManager   $manager
  *
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $em = $manager->getObjectManager();
     /** @var ActivityInterface $entity */
     $entity = $em->find($id->getOwnerEntityClass(), $id->getOwnerEntityId());
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     if (!$this->securityFacade->isGranted('EDIT', $entity)) {
         throw new ForbiddenException('has no edit permissions for activity entity');
     }
     $targetEntity = $em->find($id->getTargetEntityClass(), $id->getTargetEntityId());
     if (!$targetEntity) {
         throw new EntityNotFoundException();
     }
     if (!$this->securityFacade->isGranted('VIEW', $targetEntity)) {
         throw new ForbiddenException('has no view permissions for related entity');
     }
     $this->activityManager->removeActivityTarget($entity, $targetEntity);
     $em->flush();
 }
Ejemplo n.º 11
0
 /**
  * @param Registry                 $doctrine
  * @param SecurityFacade           $securityFacade
  * @param EntityNameResolver       $entityNameResolver
  * @param Pager                    $pager
  * @param EventDispatcherInterface $eventDispatcher
  * @param AttachmentManager        $attachmentManager
  * @param AclHelper                $aclHelper
  * @param ConfigManager            $configManager
  */
 public function __construct(Registry $doctrine, SecurityFacade $securityFacade, EntityNameResolver $entityNameResolver, Pager $pager, EventDispatcherInterface $eventDispatcher, AttachmentManager $attachmentManager, AclHelper $aclHelper, ConfigManager $configManager)
 {
     $this->em = $doctrine->getManager();
     $this->securityFacade = $securityFacade;
     $this->entityNameResolver = $entityNameResolver;
     $this->pager = $pager;
     $this->attachmentManager = $attachmentManager;
     $this->aclHelper = $aclHelper;
     $this->configManager = $configManager;
     parent::__construct(Comment::ENTITY_NAME, $this->em);
     $this->setEventDispatcher($eventDispatcher);
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function find($id)
 {
     $result = parent::find($id);
     if (!$result) {
         throw new EntityNotFoundException();
     }
     $entityId = null;
     $target = $result->getTarget();
     if ($target) {
         $entityId = new EntityIdSoap();
         $entityId->setEntity(ClassUtils::getClass($target))->setId($target->getId());
         $result->entityId = $entityId;
     } else {
         throw new \LogicException('Note entity cannot be unassigned.');
     }
     return $result;
 }
Ejemplo n.º 13
0
 /**
  * Constructor
  *
  * @param string $class Entity name
  * @param ObjectManager $om Object manager
  * @param CaseEntityManager $caseManager
  */
 public function __construct($class, ObjectManager $om, CaseEntityManager $caseManager)
 {
     $this->caseManager = $caseManager;
     parent::__construct($class, $om);
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  * @param SearchIndexer            $searchIndexer
  * @param EventDispatcherInterface $dispatcher
  */
 public function __construct($class, ObjectManager $om, SearchIndexer $searchIndexer, EventDispatcherInterface $dispatcher)
 {
     parent::__construct($class, $om);
     $this->searchIndexer = $searchIndexer;
     $this->dispatcher = $dispatcher;
 }
 /**
  * {@inheritdoc}
  * @param SearchIndexer $searchIndexer
  */
 public function __construct($class, ObjectManager $om, SearchIndexer $searchIndexer)
 {
     parent::__construct($class, $om);
     $this->searchIndexer = $searchIndexer;
 }
 /**
  * @param string                $class
  * @param ObjectManager         $om
  * @param ActivityManager       $activityManager
  * @param TokenStorageInterface $securityTokenStorage
  */
 public function __construct($class, ObjectManager $om, ActivityManager $activityManager, TokenStorageInterface $securityTokenStorage)
 {
     parent::__construct($class, $om);
     $this->activityManager = $activityManager;
     $this->securityTokenStorage = $securityTokenStorage;
 }
Ejemplo n.º 17
0
 /**
  * @param string          $class
  * @param ObjectManager   $om
  */
 public function __construct($class, ObjectManager $om)
 {
     parent::__construct($class, $om);
 }
 /**
  * @param string          $class
  * @param ObjectManager   $om
  * @param CalendarManager $calendarManager
  */
 public function __construct($class, ObjectManager $om, CalendarManager $calendarManager)
 {
     parent::__construct($class, $om);
     $this->calendarManager = $calendarManager;
 }
Ejemplo n.º 19
0
 /**
  * @param string            $class
  * @param ObjectManager     $om
  * @param AttachmentManager $attachmentManager
  */
 public function __construct($class, ObjectManager $om, AttachmentManager $attachmentManager)
 {
     parent::__construct($class, $om);
     $this->attachmentManager = $attachmentManager;
 }
 /**
  * @param ObjectManager $om
  * @param ChainDictionaryValueListProvider $dictionaryProvider
  * @param DictionaryHelper $dictionaryHelper
  */
 public function __construct(ObjectManager $om, ChainDictionaryValueListProvider $dictionaryProvider, DictionaryHelper $dictionaryHelper)
 {
     parent::__construct(null, $om);
     $this->dictionaryProvider = $dictionaryProvider;
     $this->dictionaryHelper = $dictionaryHelper;
 }
 /**
  * @param ObjectManager   $om
  * @param ActivityManager $activityManager
  * @param SearchIndexer   $searchIndexer
  */
 public function __construct(ObjectManager $om, ActivityManager $activityManager, SearchIndexer $searchIndexer)
 {
     parent::__construct(null, $om);
     $this->searchIndexer = $searchIndexer;
     $this->activityManager = $activityManager;
 }
Ejemplo n.º 22
0
 /**
  * @param string          $class Entity name
  * @param ObjectManager   $om    Object manager
  * @param GridViewManager $gridViewManager
  */
 public function __construct($class, ObjectManager $om, GridViewManager $gridViewManager)
 {
     parent::__construct($class, $om);
     $this->gridViewManager = $gridViewManager;
 }
 /**
  * @param string          $class
  * @param ObjectManager   $om
  * @param ActivityManager $activityManager
  */
 public function __construct($class, ObjectManager $om, ActivityManager $activityManager)
 {
     parent::__construct($class, $om);
     $this->activityManager = $activityManager;
 }
 /**
  * @param string             $class
  * @param ObjectManager      $om
  * @param EntityNameResolver $resolver
  */
 public function __construct($class, ObjectManager $om, EntityNameResolver $resolver)
 {
     parent::__construct($class, $om);
     $this->entityNameResolver = $resolver;
 }
 /**
  * @param string               $class
  * @param ObjectManager        $om
  * @param SecurityContext      $securityContext
  * @param AclExtensionSelector $aclSelector
  */
 public function __construct($class, ObjectManager $om, SecurityContext $securityContext, AclExtensionSelector $aclSelector)
 {
     parent::__construct($class, $om);
     $this->aclSelector = $aclSelector;
     $this->securityContext = $securityContext;
 }