getId() публичный Метод

Returns the ID of the User.
public getId ( ) : integer
Результат integer
Пример #1
0
 /**
  * Data can be set over by array.
  *
  * @param $media
  * @param $data
  * @param UserInterface $user
  *
  * @return Media
  */
 protected function setDataToMedia(Media $media, $data, $user)
 {
     foreach ($data as $attribute => $value) {
         if ($value || $attribute === 'tags' && $value !== null || $attribute === 'size' && $value !== null || $attribute === 'description' && $value !== null || $attribute === 'copyright' && $value !== null) {
             switch ($attribute) {
                 case 'size':
                     $media->setSize($value);
                     break;
                 case 'title':
                     $media->setTitle($value);
                     break;
                 case 'description':
                     $media->setDescription($value);
                     break;
                 case 'copyright':
                     $media->setCopyright($value);
                     break;
                 case 'version':
                     $media->setVersion($value);
                     break;
                 case 'name':
                     $media->setName($value);
                     break;
                 case 'url':
                     $media->setUrl($value);
                     break;
                 case 'formats':
                     $media->setFormats($value);
                     break;
                 case 'storageOptions':
                     $media->setStorageOptions($value);
                     break;
                 case 'publishLanguages':
                     $media->setPublishLanguages($value);
                     break;
                 case 'contentLanguages':
                     $media->setContentLanguages($value);
                     break;
                 case 'tags':
                     $media->removeTags();
                     if (count($value)) {
                         foreach ($value as $tag) {
                             $tagEntity = $this->tagManager->findOrCreateByName($tag, $user->getId());
                             $media->addTag($tagEntity);
                         }
                     }
                     break;
                 case 'properties':
                     $media->setProperties($value);
                     break;
                 case 'changed':
                     $media->setChanged($value);
                     break;
                 case 'created':
                     break;
                 case 'changer':
                     if ($value instanceof UserInterface) {
                         $media->setChanger($value);
                     }
                     break;
                 case 'creator':
                     if ($value instanceof UserInterface) {
                         $media->setCreator($value);
                     }
                     break;
                 case 'mimeType':
                     $media->setMimeType($value);
                     break;
                 case 'collection':
                     $collectionEntity = $this->getCollectionById($value);
                     $media->setCollection($collectionEntity);
                     // set parent
                     break;
                 case 'type':
                     if (isset($value['id'])) {
                         $type = $this->typeManager->get($value['id']);
                         $media->setType($type);
                     }
                     break;
             }
         }
     }
     return $media;
 }
Пример #2
0
 /**
  * Map the creator and changer to the document.
  *
  * @param Document      $document
  * @param UserInterface $creator
  * @param UserInterface $changer
  */
 private function mapCreatorAndChanger(Document $document, UserInterface $creator = null, UserInterface $changer = null)
 {
     $document->addField($this->factory->createField('changer', $changer ? $changer->getUsername() : null, 'string'));
     $document->addField($this->factory->createField('changer_id', $changer ? $changer->getId() : null, 'string'));
     $document->addField($this->factory->createField('creator', $creator ? $creator->getUsername() : null, 'string'));
     $document->addField($this->factory->createField('creator_id', $creator ? $creator->getId() : null, 'string'));
 }
Пример #3
0
 /**
  * Updates the collaborator with the given connection and user to the entity with the specified identifier.
  *
  * @param ConnectionInterface $conn The connection of the user
  * @param string $type The type of the entity
  * @param mixed $id The id of the entity
  * @param string $connectionId The id of the connection of the user
  * @param UserInterface $user The user being added as collaborator
  */
 private function updateCollaboration(ConnectionInterface $conn, $type, $id, $connectionId, UserInterface $user)
 {
     $entityCollaborationUpdated = false;
     $connectionCollaborationUpdated = false;
     $identifier = $this->getUniqueCollaborationKey($type, $id);
     $userId = $user->getId();
     /** @var Collaboration[] $entityCollaborations */
     $entityCollaborations = $this->collaborationsEntityCache->fetch($identifier) ?: [];
     /** @var Collaboration[] $connectionCollaborations */
     $connectionCollaborations = $this->collaborationsConnectionCache->fetch($connectionId) ?: [];
     if (!array_key_exists($connectionId, $this->connections)) {
         $this->connections[$connectionId] = $conn;
     }
     if (array_key_exists($identifier, $entityCollaborations)) {
         $entityCollaborations[$identifier]->setChanged(time());
         $entityCollaborationUpdated = true;
     }
     if (array_key_exists($connectionId, $connectionCollaborations)) {
         $connectionCollaborations[$connectionId]->setChanged(time());
         $connectionCollaborationUpdated = true;
     }
     $collaboration = new Collaboration($connectionId, $userId, $user->getUsername(), $user->getFullName(), $type, $id);
     if (!$entityCollaborationUpdated) {
         $entityCollaborations[$connectionId] = $collaboration;
     }
     if (!$connectionCollaborationUpdated) {
         $connectionCollaborations[$identifier] = $collaboration;
     }
     $this->collaborationsEntityCache->save($identifier, $entityCollaborations);
     $this->collaborationsConnectionCache->save($connectionId, $connectionCollaborations);
 }