コード例 #1
0
ファイル: DeleteHandler.php プロジェクト: Maksold/platform
 /**
  * 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();
 }
コード例 #2
0
ファイル: ContactPhoneHandler.php プロジェクト: antrampa/crm
 /**
  * @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);
     }
 }
コード例 #3
0
 /**
  * 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();
 }
コード例 #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);
 }
コード例 #5
0
 /**
  * @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;
 }
コード例 #6
0
 /**
  * @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();
     }
 }
コード例 #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;
 }
コード例 #8
0
 /**
  * @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;
 }
コード例 #9
0
 /**
  * @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;
 }
コード例 #10
0
 /**
  * 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();
 }
コード例 #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);
 }
コード例 #12
0
ファイル: ApiEntityManager.php プロジェクト: Maksold/platform
 /**
  * {@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;
 }
コード例 #13
0
ファイル: CaseApiEntityManager.php プロジェクト: antrampa/crm
 /**
  * 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);
 }
コード例 #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;
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  * @param SearchIndexer $searchIndexer
  */
 public function __construct($class, ObjectManager $om, SearchIndexer $searchIndexer)
 {
     parent::__construct($class, $om);
     $this->searchIndexer = $searchIndexer;
 }
コード例 #16
0
 /**
  * @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;
 }
コード例 #17
0
 /**
  * @param string          $class
  * @param ObjectManager   $om
  */
 public function __construct($class, ObjectManager $om)
 {
     parent::__construct($class, $om);
 }
コード例 #18
0
 /**
  * @param string          $class
  * @param ObjectManager   $om
  * @param CalendarManager $calendarManager
  */
 public function __construct($class, ObjectManager $om, CalendarManager $calendarManager)
 {
     parent::__construct($class, $om);
     $this->calendarManager = $calendarManager;
 }
コード例 #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;
 }
コード例 #20
0
 /**
  * @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;
 }
コード例 #21
0
 /**
  * @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;
 }
コード例 #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;
 }
コード例 #23
0
 /**
  * @param string          $class
  * @param ObjectManager   $om
  * @param ActivityManager $activityManager
  */
 public function __construct($class, ObjectManager $om, ActivityManager $activityManager)
 {
     parent::__construct($class, $om);
     $this->activityManager = $activityManager;
 }
コード例 #24
0
 /**
  * @param string             $class
  * @param ObjectManager      $om
  * @param EntityNameResolver $resolver
  */
 public function __construct($class, ObjectManager $om, EntityNameResolver $resolver)
 {
     parent::__construct($class, $om);
     $this->entityNameResolver = $resolver;
 }
コード例 #25
0
 /**
  * @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;
 }