getId() public method

public getId ( ) : integer
return integer
Esempio n. 1
0
 /**
  * @param  Model\Asset $target
  * @param  Model\Asset $source
  * @return Model\Asset copied asset
  */
 public function copyRecursive($target, $source)
 {
     // avoid recursion
     if (!$this->_copyRecursiveIds) {
         $this->_copyRecursiveIds = [];
     }
     if (in_array($source->getId(), $this->_copyRecursiveIds)) {
         return;
     }
     $source->getProperties();
     $new = clone $source;
     $new->id = null;
     if ($new instanceof Asset\Folder) {
         $new->setChilds(null);
     }
     $new->setFilename(Element\Service::getSaveCopyName("asset", $new->getFilename(), $target));
     $new->setParentId($target->getId());
     $new->setUserOwner($this->_user->getId());
     $new->setUserModification($this->_user->getId());
     $new->setDao(null);
     $new->setLocked(false);
     $new->setCreationDate(time());
     $new->setStream($source->getStream());
     $new->save();
     // add to store
     $this->_copyRecursiveIds[] = $new->getId();
     foreach ($source->getChilds() as $child) {
         $this->copyRecursive($new, $child);
     }
     if ($target instanceof Asset\Folder) {
         $this->updateChilds($target, $new);
     }
     return $new;
 }
Esempio n. 2
0
 /**
  * @throws DAV\Exception\Forbidden
  * @throws \Exception
  */
 function delete()
 {
     if ($this->asset->isAllowed("delete")) {
         Asset\Service::loadAllFields($this->asset);
         $this->asset->delete();
         // add the asset to the delete history, this is used so come over problems with programs like photoshop (delete, create instead of replace => move)
         // for details see Asset\WebDAV\Tree::move()
         $log = Asset\WebDAV\Service::getDeleteLog();
         $this->asset->_fulldump = true;
         $log[$this->asset->getFullpath()] = array("id" => $this->asset->getId(), "timestamp" => time(), "data" => \Pimcore\Tool\Serialize::serialize($this->asset));
         unset($this->asset->_fulldump);
         Asset\WebDAV\Service::saveDeleteLog($log);
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
Esempio n. 3
0
 /**
  * @param string $name
  * @throws DAV\Exception\Forbidden
  */
 function createDirectory($name)
 {
     $user = AdminTool::getCurrentUser();
     if ($this->asset->isAllowed("create")) {
         $asset = Asset::create($this->asset->getId(), array("filename" => File::getValidFilename($name), "type" => "folder", "userModification" => $user->getId(), "userOwner" => $user->getId()));
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
Esempio n. 4
0
 /**
  * @param string $name
  * @throws DAV\Exception\Forbidden
  */
 public function createDirectory($name)
 {
     $user = AdminTool::getCurrentUser();
     if ($this->asset->isAllowed("create")) {
         $asset = Asset::create($this->asset->getId(), ["filename" => Element\Service::getValidKey($name, "asset"), "type" => "folder", "userModification" => $user->getId(), "userOwner" => $user->getId()]);
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
Esempio n. 5
0
 /**
  * Returns the available statuses given an action and a state
  *
  * @param $actionName
  * @param $stateName
  * @return array
  * @throws \Exception
  */
 public function getAvailableStatuses($actionName, $stateName)
 {
     $actionConfig = $this->workflow->getActionConfig($actionName);
     $globalAction = $this->workflow->isGlobalAction($actionName);
     $hasTransition = $this->actionHasTransition($actionConfig);
     if ($globalAction || !$hasTransition) {
         $objectStatus = $this->getElementStatus();
         $availableStatuses = [$objectStatus => $this->workflow->getStatusConfig($objectStatus)];
     } else {
         //we have a check here for the state being an existing one
         if (!isset($actionConfig['transitionTo'][$stateName])) {
             throw new \Exception("Workflow::getAvailableStatuses, State [{$stateName}] not valid for action [{$actionName}] on element [{$this->element->getId()}] with status [{$this->getElementStatus()}]");
         }
         $availableStatuses = [];
         foreach ($actionConfig['transitionTo'][$stateName] as $statusName) {
             $availableStatuses[$statusName] = $this->workflow->getStatusConfig($statusName);
         }
     }
     return $availableStatuses;
 }
Esempio n. 6
0
 /**
  * @see Object\ClassDefinition\Data::getDataForEditmode
  * @param Asset|Document|Object\AbstractObject $data
  * @param null|Model\Object\AbstractObject $object
  * @return array
  */
 public function getDataForEditmode($data, $object = null)
 {
     if ($data instanceof Element\ElementInterface) {
         $r = array("id" => $data->getId(), "path" => $data->getFullPath(), "subtype" => $data->getType(), "type" => Element\Service::getElementType($data));
         return $r;
     }
     return;
 }
Esempio n. 7
0
 /**
  * @see Object\ClassDefinition\Data::getDataForQueryResource
  * @param Asset $data
  * @param null|Model\Object\AbstractObject $object
  * @return integer|null
  */
 public function getDataForQueryResource($data, $object = null)
 {
     if ($data instanceof Asset) {
         return $data->getId();
     }
     return null;
 }
Esempio n. 8
0
 /**
  * @param Asset $parent
  * @return void
  */
 public function setParent($parent)
 {
     $this->parent = $parent;
     if ($parent instanceof Asset) {
         $this->parentId = $parent->getId();
     }
     return $this;
 }
 /**
  * @see Object\ClassDefinition\Data::getDataForResource
  * @param Asset $data
  * @param null|Model\Object\AbstractObject $object
  * @return integer|null
  */
 public function getDataForResource($data, $object = null)
 {
     if ($data instanceof Object\CoreShopOrderState) {
         return $data->getId();
     }
     return null;
 }
Esempio n. 10
0
 /**
  * @param Document|Asset|Object\AbstractObject $element
  * @return array
  */
 public static function getDependencyForFrontend($element)
 {
     if ($element instanceof ElementInterface) {
         return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => self::getElementType($element), "subtype" => $element->getType());
     }
 }