예제 #1
0
 function findByOwnerGroupedByGroup(\MapasCulturais\Entity $owner)
 {
     $metalists = $this->findBy(array('objectId' => $owner->id, 'objectType' => $owner->getClassName()));
     $result = array();
     if ($metalists) {
         foreach ($metalists as $metalist) {
             if (!key_exists($metalist->group, $result)) {
                 $result[trim($metalist->group)] = array();
             }
             $result[trim($metalist->group)][] = $metalist;
         }
     }
     ksort($result);
     return $result;
 }
예제 #2
0
 function jsonSerialize()
 {
     $result = parent::jsonSerialize();
     $result['owner'] = $this->owner->simplify('className,id,name,terms,avatar,singleUrl');
     $result['agent'] = $this->agent->simplify('id,name,type,terms,avatar,singleUrl');
     return $result;
 }
예제 #3
0
 function findByOwnerGroupedByGroup(\MapasCulturais\Entity $owner)
 {
     $app = App::i();
     $files = $this->findBy(array('objectId' => $owner->id, 'objectType' => $owner->getClassName()));
     $result = array();
     if ($files) {
         foreach ($files as $file) {
             $registeredGroup = $app->getRegisteredFileGroup($owner->controllerId, $file->group);
             if ($registeredGroup && $registeredGroup->unique || $app->getRegisteredImageTransformation($file->group) || !$registeredGroup && !$app->getRegisteredImageTransformation($file->group)) {
                 $result[trim($file->group)] = $file;
             } else {
                 if (!key_exists($file->group, $result)) {
                     $result[trim($file->group)] = array();
                 }
                 $result[trim($file->group)][] = $file;
             }
         }
     }
     ksort($result);
     return $result;
 }
예제 #4
0
 function findByOwnerGroupedByGroup(\MapasCulturais\Entity $owner)
 {
     $app = App::i();
     $repo = $app->repo($owner->getFileClassName());
     $files = $repo->findBy(['owner' => $owner]);
     $result = [];
     if ($files) {
         foreach ($files as $file) {
             $registeredGroup = $app->getRegisteredFileGroup($owner->controllerId, $file->group);
             if ($registeredGroup && $registeredGroup->unique) {
                 $result[trim($file->group)] = $file;
             } else {
                 if (!key_exists($file->group, $result)) {
                     $result[trim($file->group)] = [];
                 }
                 $result[trim($file->group)][] = $file;
             }
         }
         ksort($result);
     }
     return $result;
 }
예제 #5
0
 /**
  * Tries to replace the parent by the new parent.
  * 
  * If the logged in user can not perform the operation a new RequestChildEntity object is created.
  * 
  * @throws \MapasCulturais\Exceptions\PermissionDenied
  * @throws \MapasCulturais\Exceptions\WorkflowRequestTransport
  * 
  * @workflow RequestChildEntity
  */
 protected function _saveNested()
 {
     if ($this->_newParent !== false) {
         try {
             if ($this->_newParent) {
                 $this->_newParent->checkPermission('createChild');
             }
             $this->parent = $this->_newParent;
         } catch (\MapasCulturais\Exceptions\PermissionDenied $e) {
             if (!App::i()->isWorkflowEnabled()) {
                 throw $e;
             }
             $request = new \MapasCulturais\Entities\RequestChildEntity();
             $request->origin = $this;
             $request->destination = $this->_newParent;
             $this->_newParent = false;
             throw new \MapasCulturais\Exceptions\WorkflowRequestTransport($request);
         }
     }
 }
 /** @ORM\PostUpdate */
 public function postUpdate($args = null)
 {
     parent::postUpdate($args);
 }
예제 #7
0
 /**
  * Returns the Entity Type of the given entity.
  *
  * @param \MapasCulturais\Entity $object The entity.
  *
  * @return \MapasCulturais\Definitions\EntityType
  */
 function getRegisteredEntityType(Entity $object)
 {
     return @$this->_register['entity_types'][$object->getClassName()][$object->type];
 }
예제 #8
0
 function addEntityToJs(MapasCulturais\Entity $entity)
 {
     $this->jsObject['entity'] = ['id' => $entity->id, 'ownerId' => $entity->owner->id, 'ownerUserId' => $entity->ownerUser->id, 'definition' => $entity->getPropertiesMetadata(), 'userHasControl' => $entity->canUser('@control'), 'canUserCreateRelatedAgentsWithControl' => $entity->canUser('createAgentRelationWithControl'), 'status' => $entity->status, 'object' => $entity];
     if ($entity->usesNested() && $entity->id) {
         $this->jsObject['entity']['childrenIds'] = $entity->getChildrenIds();
     }
 }
예제 #9
0
 function delete($flush = false)
 {
     $this->checkPermission('remove');
     // ($originType, $originId, $destinationType, $destinationId, $metadata)
     $ruid = RequestAgentRelation::generateRequestUid($this->owner->getClassName(), $this->owner->id, $this->agent->getClassName(), $this->agent->id, ['class' => $this->getClassName(), 'relationId' => $this->id]);
     $requests = App::i()->repo('RequestAgentRelation')->findBy(['requestUid' => $ruid]);
     foreach ($requests as $r) {
         $r->delete($flush);
     }
     parent::delete($flush);
 }
 function setDestination(\MapasCulturais\Entity $agent)
 {
     $this->metadata['type'] = $agent->canUser('@control') ? self::TYPE_REQUEST : self::TYPE_GIVE;
     parent::setDestination($agent);
 }