本文整理汇总了PHP中Pimcore\Model\Element\Service::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getType方法的具体用法?PHP Service::getType怎么用?PHP Service::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Element\Service
的用法示例。
在下文中一共展示了Service::getType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractRelations
public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
{
$foundRelations = [];
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()] = ["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()] = ["elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive];
}
}
}
return $foundRelations;
}
示例2: __construct
/**
* @param $webResource
*/
public function __construct($webResource)
{
$this->id = $webResource->getId();
if ($webResource instanceof Element\ElementInterface) {
$this->type = Element\Service::getType($webResource);
} else {
$this->type = "unknown";
}
}
示例3: getForWebserviceExport
/**
* converts data to be exposed via webservices
* @param string $object
* @return mixed
*/
public function getForWebserviceExport($object)
{
$data = $this->getDataFromObjectParam($object);
if ($data instanceof Element\ElementInterface) {
return array("type" => Element\Service::getType($data), "subtype" => $data->getType(), "id" => $data->getId());
} else {
return null;
}
}
示例4: setElement
/**
* @param ElementInterface $element
* @return $this
*/
public function setElement(ElementInterface $element)
{
$this->setCid($element->getId());
$this->setCtype(Service::getType($element));
return $this;
}
示例5: marshal
/** Encode value for packing it into a single column.
* @param mixed $value
* @param Model\Object\AbstractObject $object
* @param mixed $params
* @return mixed
*/
public function marshal($value, $object = null, $params = [])
{
if (is_array($value)) {
$result = [];
foreach ($value as $element) {
$type = Element\Service::getType($element);
$id = $element->getId();
$result[] = ["type" => $type, "id" => $id];
}
return $result;
}
return null;
}
示例6: getObjectType
/**
* get correct type of object as string
* @param mixed $data
* @return void
*/
public function getObjectType($object = null)
{
$this->load();
if (!$object) {
$object = $this->o;
}
if ($object instanceof Element\ElementInterface) {
return Element\Service::getType($object);
} else {
return false;
}
}
示例7: marshal
/** Encode value for packing it into a single column.
* @param mixed $value
* @param Model\Object\AbstractObject $object
* @param mixed $params
* @return mixed
*/
public function marshal($value, $object = null, $params = [])
{
if ($value instanceof Object\Data\Video) {
$result = [];
$result["type"] = $value->getType();
if ($value->getTitle()) {
$result["title"] = $value->getTitle();
}
if ($value->getDescription()) {
$result["description"] = $value->getDescription();
}
$poster = $value->getPoster();
if ($poster) {
$result["poster"] = ["type" => Model\Element\Service::getType($poster), "id" => $poster->getId()];
}
$data = $value->getData();
if ($data && $value->getType() == "asset") {
$result["data"] = ["type" => Model\Element\Service::getType($data), "id" => $data->getId()];
} else {
$result["data"] = $data;
}
return $result;
}
return null;
}
示例8: unlockPropagate
/**
*
*/
public function unlockPropagate()
{
$type = Service::getType($this);
$ids = $this->getDao()->unlockPropagate();
// invalidate cache items
foreach ($ids as $id) {
$element = Service::getElementById($type, $id);
if ($element) {
$element->clearDependentCache();
}
}
}
示例9: getForWebserviceExport
/**
* converts data to be exposed via webservices
* @param string $object
* @return mixed
*/
public function getForWebserviceExport($object)
{
$data = $this->getDataFromObjectParam($object);
if (is_array($data)) {
$items = array();
foreach ($data as $eo) {
if ($eo instanceof Element\ElementInterface) {
$items[] = array("type" => Element\Service::getType($eo), "subtype" => $eo->getType(), "id" => $eo->getId());
}
}
return $items;
} else {
return null;
}
}
示例10: marshal
/** Encode value for packing it into a single column.
* @param mixed $value
* @param Model\Object\AbstractObject $object
* @param mixed $params
* @return mixed
*/
public function marshal($value, $object = null, $params = [])
{
if ($value) {
$type = Element\Service::getType($value);
$id = $value->getId();
return ["type" => $type, "id" => $id];
}
}
示例11: create
/**
* @throws \Exception
* @param $rootElement
* @param $apiKey
* @param $path
* @param $apiElement
* @param bool $overwrite
* @param $elementCounter
* @return Element\ElementInterface
*/
public function create($rootElement, $apiKey, $path, $apiElement, $overwrite, $elementCounter)
{
//correct relative path
if (strpos($path, "/") !== 0) {
$path = $rootElement->getFullPath() . "/" . $path;
}
$type = $apiElement->type;
if ($apiElement instanceof Webservice\Data\Asset) {
$className = "\\Pimcore\\Model\\Asset\\" . ucfirst($type);
$parentClassName = "\\Pimcore\\Model\\Asset";
$maintype = "asset";
$fullPath = $path . $apiElement->filename;
} else {
if ($apiElement instanceof Webservice\Data\Object) {
$maintype = "object";
if ($type == "object") {
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($apiElement->className);
if (!Tool::classExists($className)) {
throw new \Exception("Unknown class [ " . $className . " ]");
}
} else {
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($type);
}
$parentClassName = "\\Pimcore\\Model\\Object";
$fullPath = $path . $apiElement->key;
} else {
if ($apiElement instanceof Webservice\Data\Document) {
$maintype = "document";
$className = "\\Pimcore\\Model\\Document\\" . ucfirst($type);
$parentClassName = "\\Pimcore\\Model\\Document";
$fullPath = $path . $apiElement->key;
} else {
throw new \Exception("Unknown import element");
}
}
}
$existingElement = $className::getByPath($fullPath);
if ($overwrite && $existingElement) {
$apiElement->parentId = $existingElement->getParentId();
return $existingElement;
}
$element = new $className();
$element->setId(null);
$element->setCreationDate(time());
if ($element instanceof Asset) {
$element->setFilename($apiElement->filename);
$element->setData(base64_decode($apiElement->data));
} else {
if ($element instanceof Object\Concrete) {
$element->setKey($apiElement->key);
$element->setClassName($apiElement->className);
$class = Object\ClassDefinition::getByName($apiElement->className);
if (!$class instanceof Object\ClassDefinition) {
throw new \Exception("Unknown object class [ " . $apiElement->className . " ] ");
}
$element->setClassId($class->getId());
} else {
$element->setKey($apiElement->key);
}
}
$this->setModificationParams($element, true);
$key = $element->getKey();
if (empty($key) and $apiElement->id == 1) {
if ($element instanceof Asset) {
$element->setFilename("home_" . uniqid());
} else {
$element->setKey("home_" . uniqid());
}
} else {
if (empty($key)) {
throw new \Exception("Cannot create element without key ");
}
}
$parent = $parentClassName::getByPath($path);
if (Element\Service::getType($rootElement) == $maintype and $parent) {
$element->setParentId($parent->getId());
$apiElement->parentId = $parent->getId();
$existingElement = $parentClassName::getByPath($parent->getFullPath() . "/" . $element->getKey());
if ($existingElement) {
//set dummy key to avoid duplicate paths
if ($element instanceof Asset) {
$element->setFilename(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getFilename());
} else {
$element->setKey(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getKey());
}
}
} else {
if (Element\Service::getType($rootElement) != $maintype) {
//this is a related element - try to import it to it's original path or set the parent to home folder
$potentialParent = $parentClassName::getByPath($path);
//.........这里部分代码省略.........
示例12: marshal
/** Encode value for packing it into a single column.
* @param mixed $value
* @param Model\Object\AbstractObject $object
* @param mixed $params
* @return mixed
*/
public function marshal($value, $object = null, $params = [])
{
if ($value instanceof Object\Data\Hotspotimage) {
$result = [];
$result["hotspots"] = $value->getHotspots();
$result["marker"] = $value->getMarker();
$result["crop"] = $value->getCrop();
$image = $value->getImage();
if ($image) {
$type = Element\Service::getType($image);
$id = $image->getId();
$result["image"] = ["type" => $type, "id" => $id];
}
return $result;
}
return null;
}
示例13: marshal
/** Encode value for packing it into a single column.
* @param mixed $value
* @param Model\Object\AbstractObject $object
* @param mixed $params
* @return mixed
*/
public function marshal($value, $object = null, $params = [])
{
if (is_array($value)) {
$result = [];
/** @var $elementMetadata Object\Data\ElementMetadata */
foreach ($value as $elementMetadata) {
$element = $elementMetadata->getElement();
$type = Element\Service::getType($element);
$id = $element->getId();
$result[] = ["element" => ["type" => $type, "id" => $id], "fieldname" => $elementMetadata->getFieldname(), "columns" => $elementMetadata->getColumns(), "data" => $elementMetadata->data];
}
return $result;
}
return null;
}
示例14: getForWebserviceExport
/**
* @param Object\AbstractObject $object
* @return array|mixed|null
*/
public function getForWebserviceExport($object)
{
$data = $this->getDataFromObjectParam($object);
if (is_array($data)) {
$items = array();
foreach ($data as $metaObject) {
$eo = $metaObject->getElement();
if ($eo instanceof Element\ElementInterface) {
$item = array();
$item["type"] = Element\Service::getType($eo);
$item["id"] = $eo->getId();
foreach ($this->getColumns() as $c) {
$getter = "get" . ucfirst($c['key']);
$item[$c['key']] = $metaObject->{$getter}();
}
$items[] = $item;
}
}
return $items;
} else {
return null;
}
}