本文整理汇总了PHP中Pimcore\Model\Element\Service::getElementType方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getElementType方法的具体用法?PHP Service::getElementType怎么用?PHP Service::getElementType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Element\Service
的用法示例。
在下文中一共展示了Service::getElementType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractRelations
public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
{
$foundRelations = array();
if ($includeRelations) {
$dependency = $element->getDependencies();
if ($dependency) {
foreach ($dependency->getRequires() as $r) {
if ($e = Element\Service::getDependedElement($r)) {
if ($element->getId() != $e->getId() and !in_array(Element\Service::getElementType($e) . "_" . $e->getId(), $apiElementKeys)) {
$foundRelations[Element\Service::getElementType($e) . "_" . $e->getId()] = array("elementType" => Element\Service::getType($e), "element" => $e->getId(), "recursive" => false);
}
}
}
}
}
$childs = $element->getChilds();
if ($recursive and $childs) {
foreach ($childs as $child) {
if (!in_array(Element\Service::getType($child) . "_" . $child->getId(), $apiElementKeys)) {
$foundRelations[Element\Service::getType($child) . "_" . $child->getId()] = array("elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive);
}
}
}
return $foundRelations;
}
示例2: getElementWorkflowConfig
/**
* gets workflow config for element. always returns first valid workflow config
*
* @param Asset|Document|ConcreteObject $element
* @return array
*/
public static function getElementWorkflowConfig(AbstractElement $element)
{
$config = self::getWorkflowManagementConfig();
if (!is_array($config)) {
return null;
}
$elementType = Service::getElementType($element);
$elementSubType = $element->getType();
foreach ($config['workflows'] as $workflow) {
//workflow is not enabled, continue with next
if (isset($workflow['enabled']) && !$workflow['enabled']) {
continue;
}
if (isset($workflow['workflowSubject']) && in_array($elementType, $workflow['workflowSubject']['types'])) {
switch ($elementType) {
case 'asset':
if (isset($workflow['workflowSubject']['assetTypes']) && is_array($workflow['workflowSubject']['assetTypes'])) {
if (in_array($elementSubType, $workflow['workflowSubject']['assetTypes'])) {
return $workflow;
}
} else {
\Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available asset types');
}
break;
case 'document':
if (isset($workflow['workflowSubject']['documentTypes']) && is_array($workflow['workflowSubject']['documentTypes'])) {
if (in_array($elementSubType, $workflow['workflowSubject']['documentTypes'])) {
return $workflow;
}
} else {
\Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available document types');
}
break;
case 'object':
if ($element instanceof ConcreteObject) {
if (isset($workflow['workflowSubject']['classes']) && is_array($workflow['workflowSubject']['classes'])) {
$classId = $element->getClassId();
if (in_array($classId, $workflow['workflowSubject']['classes'])) {
return $workflow;
}
} else {
\Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available class ID\'s');
}
}
break;
default:
//unknown element type, return null
return null;
}
}
}
return null;
}
示例3: interpret
public static function interpret($value, $config = null)
{
$result = array();
if (is_array($value)) {
foreach ($value as $v) {
$result[] = array("dest" => $v->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($v));
}
} else {
if ($value instanceof \Pimcore\Model\Element\AbstractElement) {
$result[] = array("dest" => $value->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($value));
}
}
return $result;
}
示例4: cleanAllForElement
/**
* Clear all relations in the database
* @param Element\ElementInterface $element
*/
public function cleanAllForElement($element)
{
try {
$id = $element->getId();
$type = Element\Service::getElementType($element);
//schedule for sanity check
$data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", array($id, $type));
if (is_array($data)) {
foreach ($data as $row) {
$sanityCheck = new Element\Sanitycheck();
$sanityCheck->setId($row['sourceid']);
$sanityCheck->setType($row['sourcetype']);
$sanityCheck->save();
}
}
$this->db->delete("dependencies", $this->db->quoteInto("sourceid = ?", $id) . " AND " . $this->db->quoteInto("sourcetype = ?", $type));
$this->db->delete("dependencies", $this->db->quoteInto("targetid = ?", $id) . " AND " . $this->db->quoteInto("targettype = ?", $type));
} catch (\Exception $e) {
\Logger::error($e);
}
}
示例5: resolveDependencies
/**
* @param $data
* @return array
*/
public function resolveDependencies($data)
{
$dependencies = [];
if (is_array($data) && count($data) > 0) {
foreach ($data as $e) {
if ($e instanceof Element\ElementInterface) {
$elementType = Element\Service::getElementType($e);
$dependencies[$elementType . "_" . $e->getId()] = ["id" => $e->getId(), "type" => $elementType];
}
}
}
return $dependencies;
}
示例6: getStorageFileBinary
/**
* @param $element
* @return string
*/
public function getStorageFileBinary($element)
{
return PIMCORE_RECYCLEBIN_DIRECTORY . "/" . $this->getId() . "_" . Element\Service::getElementType($element) . "-" . $element->getId() . ".bin";
}
示例7: resolveDependencies
/**
* @return array
*/
public function resolveDependencies()
{
$dependencies = [];
if ($this->getData() instanceof ElementInterface) {
$elementType = Element\Service::getElementType($this->getData());
$key = $elementType . "_" . $this->getData()->getId();
$dependencies[$key] = ["id" => $this->getData()->getId(), "type" => $elementType];
}
return $dependencies;
}
示例8: save
/**
* @param $object
* @param string $ownertype
* @param $ownername
* @param $position
*/
public function save($object, $ownertype = "object", $ownername, $position)
{
$element = $this->getElement();
$type = Model\Element\Service::getElementType($element);
$this->getDao()->save($object, $ownertype, $ownername, $position, $type);
}
示例9: rewriteIds
/**
* Rewrites id from source to target, $idMapping contains
* array(
* "document" => array(
* SOURCE_ID => TARGET_ID,
* SOURCE_ID => TARGET_ID
* ),
* "object" => array(...),
* "asset" => array(...)
* )
* @param mixed $object
* @param array $idMapping
* @param array $params
* @return Element\ElementInterface
*/
public function rewriteIds($object, $idMapping, $params = array())
{
$data = $this->getDataFromObjectParam($object, $params);
if (is_array($data)) {
foreach ($data as &$metaObject) {
$eo = $metaObject->getObject();
if ($eo instanceof Element\ElementInterface) {
$id = $eo->getId();
$type = Element\Service::getElementType($eo);
if (array_key_exists($type, $idMapping) && array_key_exists($id, $idMapping[$type])) {
$newElement = Element\Service::getElementById($type, $idMapping[$type][$id]);
$metaObject->setObject($newElement);
}
}
}
}
return $data;
}
示例10: setItem
/**
* @param $item
* @return $this
*/
public function setItem($item)
{
$this->setItemId($item->getId());
$this->setType(Model\Element\Service::getElementType($item));
$this->item = $item;
return $this;
}
示例11: addAction
public function addAction()
{
$element = Element\Service::getElementById($this->getParam("type"), $this->getParam("id"));
if ($element) {
$type = Element\Service::getElementType($element);
$listClass = "\\Pimcore\\Model\\" . ucfirst($type) . "\\Listing";
$list = new $listClass();
$list->setCondition(($type == "object" ? "o_" : "") . "path LIKE '" . $element->getFullPath() . "/%'");
$children = $list->getTotalCount();
if ($children <= 100) {
Recyclebin\Item::create($element, $this->getUser());
}
$this->_helper->json(array("success" => true));
} else {
$this->_helper->json(array("success" => false));
}
}
示例12: setData
/**
* @param mixed $data
* @return static
*/
public function setData($data)
{
if ($data instanceof ElementInterface) {
$this->setType(Service::getElementType($data));
$data = $data->getId();
}
$this->data = $data;
return $this;
}
示例13: resolveDependencies
/**
* @return array
*/
public function resolveDependencies()
{
$this->setElements();
$dependencies = [];
if (is_array($this->elements) && count($this->elements) > 0) {
foreach ($this->elements as $element) {
if ($element instanceof Element\ElementInterface) {
$elementType = Element\Service::getElementType($element);
$key = $elementType . "_" . $element->getId();
$dependencies[$key] = ["id" => $element->getId(), "type" => $elementType];
}
}
}
return $dependencies;
}
示例14: getWorkflowStateForElement
/**
* @return null|WorkflowState
*/
public function getWorkflowStateForElement()
{
$elementType = Service::getElementType($this->element);
$workflowState = WorkflowState::getByPrimary($this->element->getId(), $elementType, $this->workflow->getId());
if (empty($workflowState)) {
$workflowState = new WorkflowState();
$workflowState->setCid($this->element->getId());
$workflowState->setCtype($elementType);
$workflowState->setWorkflowId($this->workflow->getId());
}
return $workflowState;
}
示例15: maintenanceCleanUp
/**
*
*/
public function maintenanceCleanUp()
{
$conf["document"] = Config::getSystemConfig()->documents->versions;
$conf["asset"] = Config::getSystemConfig()->assets->versions;
$conf["object"] = Config::getSystemConfig()->objects->versions;
$elementTypes = array();
foreach ($conf as $elementType => $tConf) {
if (intval($tConf->days) > 0) {
$versioningType = "days";
$value = intval($tConf->days);
} else {
$versioningType = "steps";
$value = intval($tConf->steps);
}
if ($versioningType) {
$elementTypes[] = array("elementType" => $elementType, $versioningType => $value);
}
}
$ignoredIds = array();
while (true) {
$versions = $this->getDao()->maintenanceGetOutdatedVersions($elementTypes, $ignoredIds);
if (count($versions) == 0) {
break;
}
$counter = 0;
\Logger::debug("versions to check: " . count($versions));
if (is_array($versions) && !empty($versions)) {
$totalCount = count($versions);
foreach ($versions as $index => $id) {
try {
$version = Version::getById($id);
} catch (\Exception $e) {
$ignoredIds[] = $id;
\Logger::debug("Version with " . $id . " not found\n");
continue;
}
$counter++;
// do not delete public versions
if ($version->getPublic()) {
$ignoredIds[] = $version->getId();
continue;
}
if ($version->getCtype() == "document") {
$element = Document::getById($version->getCid());
} elseif ($version->getCtype() == "asset") {
$element = Asset::getById($version->getCid());
} elseif ($version->getCtype() == "object") {
$element = Object::getById($version->getCid());
}
if ($element instanceof ElementInterface) {
\Logger::debug("currently checking Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element) . " in cycle: " . $counter . "/" . $totalCount);
if ($element->getModificationDate() >= $version->getDate()) {
// delete version if it is outdated
\Logger::debug("delete version: " . $version->getId() . " because it is outdated");
$version->delete();
} else {
$ignoredIds[] = $version->getId();
\Logger::debug("do not delete version (" . $version->getId() . ") because version's date is newer than the actual modification date of the element. Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element));
}
} else {
// delete version if the corresponding element doesn't exist anymore
\Logger::debug("delete version (" . $version->getId() . ") because the corresponding element doesn't exist anymore");
$version->delete();
}
// call the garbage collector if memory consumption is > 100MB
if (memory_get_usage() > 100000000) {
\Pimcore::collectGarbage();
}
}
}
}
}