本文整理汇总了PHP中Pimcore\Model\Document::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::getId方法的具体用法?PHP Document::getId怎么用?PHP Document::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Document
的用法示例。
在下文中一共展示了Document::getId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableStatuses
/**
* 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;
}
示例2: getDataForEditmode
/**
* @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;
}
示例3: setParent
/**
* @param Document $parent
* @return void
*/
public function setParent($parent)
{
$this->parent = $parent;
if ($parent instanceof Document) {
$this->parentId = $parent->getId();
}
return $this;
}
示例4: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
if ($this->enabled) {
$targets = array();
$personas = array();
$dataPush = array("personas" => $this->personas, "method" => strtolower($this->getRequest()->getMethod()));
if (count($this->events) > 0) {
$dataPush["events"] = $this->events;
}
if ($this->document instanceof Document\Page && !Model\Staticroute::getCurrentRoute()) {
$dataPush["document"] = $this->document->getId();
if ($this->document->getPersonas()) {
if ($_GET["_ptp"]) {
// if a special version is requested only return this id as target group for this page
$dataPush["personas"][] = (int) $_GET["_ptp"];
} else {
$docPersonas = explode(",", trim($this->document->getPersonas(), " ,"));
// cast the values to int
array_walk($docPersonas, function (&$value) {
$value = (int) trim($value);
});
$dataPush["personas"] = array_merge($dataPush["personas"], $docPersonas);
}
}
// check for persona specific variants of this page
$personaVariants = array();
foreach ($this->document->getElements() as $key => $tag) {
if (preg_match("/^persona_-([0-9]+)-_/", $key, $matches)) {
$id = (int) $matches[1];
if (Model\Tool\Targeting\Persona::isIdActive($id)) {
$personaVariants[] = $id;
}
}
}
if (!empty($personaVariants)) {
$personaVariants = array_values(array_unique($personaVariants));
$dataPush["personaPageVariants"] = $personaVariants;
}
}
// no duplicates
$dataPush["personas"] = array_unique($dataPush["personas"]);
$activePersonas = array();
foreach ($dataPush["personas"] as $id) {
if (Model\Tool\Targeting\Persona::isIdActive($id)) {
$activePersonas[] = $id;
}
}
$dataPush["personas"] = $activePersonas;
if ($this->document) {
// @TODO: cache this
$list = new Model\Tool\Targeting\Rule\Listing();
$list->setCondition("active = 1");
foreach ($list->load() as $target) {
$redirectUrl = $target->getActions()->getRedirectUrl();
if (is_numeric($redirectUrl)) {
$doc = \Document::getById($redirectUrl);
if ($doc instanceof \Document) {
$target->getActions()->redirectUrl = $doc->getFullPath();
}
}
$targets[] = $target;
}
$list = new Model\Tool\Targeting\Persona\Listing();
$list->setCondition("active = 1");
foreach ($list->load() as $persona) {
$personas[] = $persona;
}
}
$code = '<script type="text/javascript" src="/pimcore/static/js/frontend/geoip.js/"></script>';
$code .= '<script type="text/javascript">';
$code .= 'var pimcore = pimcore || {};';
$code .= 'pimcore["targeting"] = {};';
$code .= 'pimcore["targeting"]["dataPush"] = ' . \Zend_Json::encode($dataPush) . ';';
$code .= 'pimcore["targeting"]["targetingRules"] = ' . \Zend_Json::encode($targets) . ';';
$code .= 'pimcore["targeting"]["personas"] = ' . \Zend_Json::encode($personas) . ';';
$code .= '</script>';
$code .= '<script type="text/javascript" src="/pimcore/static/js/frontend/targeting.js"></script>';
$code .= "\n";
// analytics
$body = $this->getResponse()->getBody();
// search for the end <head> tag, and insert the google analytics code before
// this method is much faster than using simple_html_dom and uses less memory
$headEndPosition = stripos($body, "<head>");
if ($headEndPosition !== false) {
$body = substr_replace($body, "<head>\n" . $code, $headEndPosition, 7);
}
$this->getResponse()->setBody($body);
}
}
示例5: getSiteForDocument
/**
* @param Document $document
*/
public static function getSiteForDocument($document)
{
$cacheKey = "sites_full_list";
if (\Zend_Registry::isRegistered($cacheKey)) {
$sites = \Zend_Registry::get($cacheKey);
} else {
$sites = new Site\Listing();
$sites = $sites->load();
\Zend_Registry::set($cacheKey, $sites);
}
foreach ($sites as $site) {
if (preg_match("@^" . $site->getRootPath() . "/@", $document->getRealFullPath()) || $site->getRootDocument()->getId() == $document->getId()) {
return $site;
}
}
return;
}
示例6: getDependencyForFrontend
/**
* @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());
}
}
示例7: copyRecursive
/**
* @param Document $target
* @param Document $source
* @return Document copied document
*/
public function copyRecursive($target, $source)
{
// avoid recursion
if (!$this->_copyRecursiveIds) {
$this->_copyRecursiveIds = array();
}
if (in_array($source->getId(), $this->_copyRecursiveIds)) {
return;
}
if (method_exists($source, "getElements")) {
$source->getElements();
}
$source->getProperties();
$new = clone $source;
$new->id = null;
$new->setChilds(null);
$new->setKey(Element\Service::getSaveCopyName("document", $new->getKey(), $target));
$new->setParentId($target->getId());
$new->setUserOwner($this->_user->getId());
$new->setUserModification($this->_user->getId());
$new->setResource(null);
$new->setLocked(false);
$new->setCreationDate(time());
if (method_exists($new, "setPrettyUrl")) {
$new->setPrettyUrl(null);
}
$new->save();
// add to store
$this->_copyRecursiveIds[] = $new->getId();
foreach ($source->getChilds() as $child) {
$this->copyRecursive($new, $child);
}
$this->updateChilds($target, $new);
return $new;
}
示例8: getDocumentIdFromHardlinkInSameSite
/**
* @param Site $site
* @param Document $document
* @return int
*/
public function getDocumentIdFromHardlinkInSameSite(Site $site, Document $document)
{
return $this->db->fetchOne("SELECT documents.id FROM documents\n LEFT JOIN documents_hardlink ON documents.id = documents_hardlink.id\n WHERE documents_hardlink.sourceId = ? AND documents.path LIKE ?", array($document->getId(), $site->getRootPath() . "/%"));
}
示例9: removeTranslation
/**
* @param Document $document
*/
public function removeTranslation(Document $document)
{
$this->db->delete("documents_translations", "id = " . $document->getId());
// if $document is a source-document, we need to move them over to a new document
$newSourceId = $this->db->fetchOne("SELECT id FROM documents_translations WHERE sourceId = ?", $document->getId());
if ($newSourceId) {
$this->db->update("documents_translations", ["sourceId" => $newSourceId], "sourceId = " . $document->getId());
$this->db->delete("documents_translations", "id = " . $newSourceId);
}
}
示例10: copyRecursive
/**
* @param Document $target
* @param Document $source
* @return Document copied document
*/
public function copyRecursive($target, $source)
{
// avoid recursion
if (!$this->_copyRecursiveIds) {
$this->_copyRecursiveIds = [];
}
if (in_array($source->getId(), $this->_copyRecursiveIds)) {
return;
}
if (method_exists($source, "getElements")) {
$source->getElements();
}
$source->getProperties();
$new = clone $source;
$new->id = null;
$new->setChilds(null);
$new->setKey(Element\Service::getSaveCopyName("document", $new->getKey(), $target));
$new->setParentId($target->getId());
$new->setUserOwner($this->_user->getId());
$new->setUserModification($this->_user->getId());
$new->setDao(null);
$new->setLocked(false);
$new->setCreationDate(time());
if (method_exists($new, "setPrettyUrl")) {
$new->setPrettyUrl(null);
}
$new->save();
// add to store
$this->_copyRecursiveIds[] = $new->getId();
foreach ($source->getChilds() as $child) {
$this->copyRecursive($new, $child);
}
$this->updateChilds($target, $new);
// triggers actions after the complete document cloning
\Pimcore::getEventManager()->trigger('document.postCopy', $new, ['base_element' => $source]);
return $new;
}