当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getId方法代码示例

本文整理汇总了PHP中Pimcore\Model\User::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getId方法的具体用法?PHP User::getId怎么用?PHP User::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Model\User的用法示例。


在下文中一共展示了User::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copyContents

 /**
  * @param $target
  * @param $source
  * @return mixed
  * @throws \Exception
  */
 public function copyContents($target, $source)
 {
     // check if the type is the same
     if (get_class($source) != get_class($target)) {
         throw new \Exception("Source and target have to be the same type");
     }
     if (!$source instanceof Asset\Folder) {
         $target->setStream($source->getStream());
         $target->setCustomSettings($source->getCustomSettings());
     }
     $target->setUserModification($this->_user->getId());
     $target->setProperties($source->getProperties());
     $target->save();
     return $target;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:21,代码来源:Service.php

示例2: copyContents

 /**
  * @param $target
  * @param $source
  * @return AbstractObject
  * @throws \Exception
  */
 public function copyContents($target, $source)
 {
     // check if the type is the same
     if (get_class($source) != get_class($target)) {
         throw new \Exception("Source and target have to be the same type");
     }
     //load all in case of lazy loading fields
     self::loadAllObjectFields($source);
     $new = clone $source;
     $new->setChilds($target->getChilds());
     $new->setId($target->getId());
     $new->setPath($target->getPath());
     $new->setKey($target->getKey());
     $new->setParentId($target->getParentId());
     $new->setScheduledTasks($source->getScheduledTasks());
     $new->setProperties($source->getProperties());
     $new->setUserModification($this->_user->getId());
     $new->save();
     $target = AbstractObject::getById($new->getId());
     return $target;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:27,代码来源:Service.php

示例3: getAvailablePerspectives

 /** Returns a list of available perspectives for the given user
  * @param Model\User $user
  * @return array
  */
 public static function getAvailablePerspectives($user)
 {
     $currentConfigName = null;
     $masterConfig = self::getPerspectivesConfig()->toArray();
     if ($user instanceof Model\User) {
         if ($user->isAdmin()) {
             $config = self::getPerspectivesConfig()->toArray();
         } else {
             $config = [];
             $roleIds = $user->getRoles();
             $userIds = [$user->getId()];
             $userIds = array_merge($userIds, $roleIds);
             foreach ($userIds as $userId) {
                 if (in_array($userId, $roleIds)) {
                     $userOrRoleToCheck = Model\User\Role::getById($userId);
                 } else {
                     $userOrRoleToCheck = Model\User::getById($userId);
                 }
                 $perspectives = $userOrRoleToCheck->getPerspectives();
                 if ($perspectives) {
                     foreach ($perspectives as $perspectiveName) {
                         $masterDef = $masterConfig[$perspectiveName];
                         if ($masterDef) {
                             $config[$perspectiveName] = $masterDef;
                         }
                     }
                 }
             }
             if (!$config) {
                 $config = self::getPerspectivesConfig()->toArray();
             }
         }
         if ($config) {
             $tmpConfig = [];
             $validPerspectiveNames = array_keys($config);
             // sort the stuff
             foreach ($masterConfig as $masterConfigName => $masterConfiguration) {
                 if (in_array($masterConfigName, $validPerspectiveNames)) {
                     $tmpConfig[$masterConfigName] = $masterConfiguration;
                 }
             }
             $config = $tmpConfig;
         }
         $currentConfigName = $user->getActivePerspective();
         if ($config && !in_array($currentConfigName, array_keys($config))) {
             $currentConfigName = reset(array_keys($config));
         }
     } else {
         $config = self::getPerspectivesConfig()->toArray();
     }
     $result = [];
     foreach ($config as $configName => $configItem) {
         $item = ["name" => $configName, "icon" => isset($configItem["icon"]) ? $configItem["icon"] : null, "iconCls" => isset($configItem["iconCls"]) ? $configItem["iconCls"] : null];
         if ($user) {
             $item["active"] = $configName == $currentConfigName;
         }
         $result[] = $item;
     }
     return $result;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:64,代码来源:Config.php

示例4: performAction

 /**
  *
  * Performs an action
  *
  * @param mixed $actionName
  * @param array $formData
  * @throws \Exception
  */
 public function performAction($actionName, $formData = [])
 {
     //store the current action data
     $this->setActionData($formData);
     \Pimcore::getEventManager()->trigger("workflowmanagement.preAction", $this, ['actionName' => $actionName]);
     //refresh the local copy after the event
     $formData = $this->getActionData();
     $actionConfig = $this->workflow->getActionConfig($actionName, $this->getElementStatus());
     $additional = $formData['additional'];
     //setup event listeners
     $this->registerActionEvents($actionConfig);
     //setup an array to hold the additional data that is not saved via a setterFn
     $actionNoteData = [];
     //process each field in the additional fields configuration
     if (isset($actionConfig['additionalFields']) && is_array($actionConfig['additionalFields'])) {
         foreach ($actionConfig['additionalFields'] as $additionalFieldConfig) {
             /**
             * Additional Field example
             * [
                             'name' => 'dateLastContacted',
                             'fieldType' => 'date',
                             'label' => 'Date of Conversation',
                             'required' => true,
                             'setterFn' => ''
                             ]
             */
             $fieldName = $additionalFieldConfig['name'];
             //check required
             if ($additionalFieldConfig['required'] && empty($additional[$fieldName])) {
                 throw new \Exception("Workflow::performAction, fieldname [{$fieldName}] required for action [{$actionName}]");
             }
             //work out whether or not to set the value directly to the object or to add it to the note data
             if (!empty($additionalFieldConfig['setterFn'])) {
                 $setter = $additionalFieldConfig['setterFn'];
                 try {
                     //todo check here that the setter is being called on an Object
                     //TODO check that the field has a fieldType, (i.e if a workflow config has getter then the field should only be a pimcore tag and therefore 'fieldType' rather than 'type'.
                     //otherwise we could be erroneously setting pimcore fields
                     $additional[$fieldName] = Workflow\Service::getDataFromEditmode($additional[$fieldName], $additionalFieldConfig['fieldType']);
                     $this->element->{$setter}($additional[$fieldName]);
                 } catch (\Exception $e) {
                     Logger::error($e->getMessage());
                     throw new \Exception("Workflow::performAction, cannot set fieldname [{$fieldName}] using setter [{$setter}] in action [{$actionName}]");
                 }
             } else {
                 $actionNoteData[] = Workflow\Service::createNoteData($additionalFieldConfig, $additional[$fieldName]);
             }
         }
     }
     //save the old state and status in the form so that we can reference it later
     $formData['oldState'] = $this->getElementState();
     $formData['oldStatus'] = $this->getElementStatus();
     if ($this->element instanceof Concrete || $this->element instanceof Document\PageSnippet) {
         if (!$this->workflow->getAllowUnpublished() || in_array($this->getElementStatus(), $this->workflow->getPublishedStatuses())) {
             $this->element->setPublished(true);
             if ($this->element instanceof Concrete) {
                 $this->element->setOmitMandatoryCheck(false);
             }
             $task = 'publish';
         } else {
             $this->element->setPublished(false);
             if ($this->element instanceof Concrete) {
                 $this->element->setOmitMandatoryCheck(true);
             }
             $task = 'unpublish';
         }
     } else {
         //all other elements do not support published or unpublished
         $task = "publish";
     }
     try {
         $response = \Pimcore::getEventManager()->trigger("workflowmanagement.action.before", $this, ['actionConfig' => $actionConfig, 'data' => $formData]);
         //todo add some support to stop the action given the result from the event
         $this->element->setUserModification($this->user->getId());
         if ($task === "publish" && $this->element->isAllowed("publish") || $task === "unpublish" && $this->element->isAllowed("unpublish")) {
             $this->element->save();
         } elseif ($this->element instanceof Concrete || $this->element instanceof Document\PageSnippet) {
             $this->element->saveVersion();
         } else {
             throw new \Exception("Operation not allowed for this element");
         }
         //transition the element
         $this->setElementState($formData['newState']);
         $this->setElementStatus($formData['newStatus']);
         // record a note against the object to show the transition
         $decorator = new Workflow\Decorator($this->workflow);
         $description = $formData['notes'];
         // create a note for this action
         $note = Workflow\Service::createActionNote($this->element, $decorator->getNoteType($actionName, $formData), $decorator->getNoteTitle($actionName, $formData), $description, $actionNoteData);
         //notify users
         if (isset($actionConfig['notificationUsers']) && is_array($actionConfig['notificationUsers'])) {
             Workflow\Service::sendEmailNotification($actionConfig['notificationUsers'], $note);
//.........这里部分代码省略.........
开发者ID:pimcore,项目名称:pimcore,代码行数:101,代码来源:Manager.php


注:本文中的Pimcore\Model\User::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。