本文整理汇总了PHP中Pimcore\Model\Object\Concrete::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Concrete::getById方法的具体用法?PHP Concrete::getById怎么用?PHP Concrete::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Object\Concrete
的用法示例。
在下文中一共展示了Concrete::getById方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReplacement
/**
* Gets a object by it's id and replaces the placeholder width the value form the called "method"
*
* example: %Object(object_id,{"method" : "getId"});
* @return string
*/
public function getReplacement()
{
$string = '';
$object = is_object($this->getValue()) ? $this->getValue() : Model\Object\Concrete::getById($this->getValue());
if ($object) {
if (is_string($this->getPlaceholderConfig()->method) && method_exists($object, $this->getPlaceholderConfig()->method)) {
$string = $object->{$this->getPlaceholderConfig()->method}($this->getLocale());
}
}
return $string;
}
示例2: preDispatch
public function preDispatch()
{
parent::preDispatch();
if ($this->getParam('ctype') === 'document') {
$this->element = Document::getById((int) $this->getParam('cid', 0));
} elseif ($this->getParam('ctype') === 'asset') {
$this->element = Asset::getById((int) $this->getParam('cid', 0));
} elseif ($this->getParam('ctype') === 'object') {
$this->element = ConcreteObject::getById((int) $this->getParam('cid', 0));
}
if (!$this->element) {
throw new \Exception('Cannot load element' . $this->getParam('cid') . ' of type \'' . $this->getParam('ctype') . '\'');
}
//get the latest available version of the element -
//$this->element = $this->getLatestVersion($this->element);
$this->element->setUserModification($this->getUser()->getId());
}
示例3: testAction
public function testAction()
{
// $t = new OnlineShop_Framework_AbstractProduct();
// p_r($t);
$x = OnlineShop_Framework_Factory::getInstance();
// p_r($x);
$e = $x->getEnvironment();
$e->setCurrentUserId(-1);
p_r($e);
// p_r($e->getAllCustomItems());
$cm = $x->getCartManager();
// $key = $cm->createCart(array("name" => "mycart"));
$cm->addToCart(\Pimcore\Model\Object\Concrete::getById(430), 4, 14, array());
//array("key" => 'mycart', "itemid" => 4459, "count" => 4));
// $e->setCustomItem("myitem2", "88776688");
// $e->save();
$e = $x->getEnvironment();
p_r($e);
$x->saveState();
// $p = new OnlineShop_Plugin();
// p_r($p);
die("meins");
}
示例4: getObjectMetadataById
/**
* @param $id
* @throws \Exception
*/
public function getObjectMetadataById($id)
{
try {
$object = Object\Concrete::getById($id);
if ($object instanceof Object\Concrete) {
// load all data (eg. lazy loaded fields like multihref, object, ...)
$classId = $object->getClassId();
return $this->getClassById($classId);
}
throw new \Exception("Object with given ID (" . $id . ") does not exist.");
} catch (\Exception $e) {
\Logger::error($e);
throw $e;
}
}
示例5: getNicePathAction
public function getNicePathAction()
{
$source = \Zend_Json::decode($this->getParam("source"));
if ($source["type"] != "object") {
throw new \Exception("currently only objects as source elements are supported");
}
$result = [];
$id = $source["id"];
$source = Object\Concrete::getById($id);
if ($this->getParam("context")) {
$context = \Zend_Json::decode($this->getParam("context"));
} else {
$context = [];
}
$ownerType = $context["containerType"];
$fieldname = $context["fieldname"];
if ($ownerType == "object") {
$fd = $source->getClass()->getFieldDefinition($fieldname);
} elseif ($ownerType == "localizedfield") {
$fd = $source->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($fieldname);
} elseif ($ownerType == "objectbrick") {
$fdBrick = Object\Objectbrick\Definition::getByKey($context["containerKey"]);
$fd = $fdBrick->getFieldDefinition($fieldname);
} elseif ($ownerType == "fieldcollection") {
$containerKey = $context["containerKey"];
$fdCollection = Object\Fieldcollection\Definition::getByKey($containerKey);
if ($context["subContainerType"] == "localizedfield") {
$fdLocalizedFields = $fdCollection->getFieldDefinition("localizedfields");
$fd = $fdLocalizedFields->getFieldDefinition($fieldname);
} else {
$fd = $fdCollection->getFieldDefinition($fieldname);
}
}
if (method_exists($fd, "getPathFormatterClass")) {
$formatterClass = $fd->getPathFormatterClass();
if (Pimcore\Tool::classExists($formatterClass)) {
$targets = \Zend_Json::decode($this->getParam("targets"));
$result = call_user_func($formatterClass . "::formatPath", $result, $source, $targets, ["fd" => $fd, "context" => $context]);
} else {
Logger::error("Formatter Class does not exist: " . $formatterClass);
}
}
$this->_helper->json(["success" => true, "data" => $result]);
}
示例6: getVariantsAction
public function getVariantsAction()
{
// get list of variants
if ($this->getParam("language")) {
$this->setLanguage($this->getParam("language"), true);
}
if ($this->getParam("xaction") == "update") {
$data = \Zend_Json::decode($this->getParam("data"));
// save
$object = Object::getById($data["id"]);
if ($object->isAllowed("publish")) {
$objectData = [];
foreach ($data as $key => $value) {
$parts = explode("~", $key);
if (substr($key, 0, 1) == "~") {
$type = $parts[1];
$field = $parts[2];
$keyid = $parts[3];
$getter = "get" . ucfirst($field);
$setter = "set" . ucfirst($field);
$keyValuePairs = $object->{$getter}();
if (!$keyValuePairs) {
$keyValuePairs = new Object\Data\KeyValue();
$keyValuePairs->setObjectId($object->getId());
$keyValuePairs->setClass($object->getClass());
}
$keyValuePairs->setPropertyWithId($keyid, $value, true);
$object->{$setter}($keyValuePairs);
} elseif (count($parts) > 1) {
$brickType = $parts[0];
$brickKey = $parts[1];
$brickField = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
$fieldGetter = "get" . ucfirst($brickField);
$brickGetter = "get" . ucfirst($brickType);
$valueSetter = "set" . ucfirst($brickKey);
$brick = $object->{$fieldGetter}()->{$brickGetter}();
if (empty($brick)) {
$classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
$brickSetter = "set" . ucfirst($brickType);
$brick = new $classname($object);
$object->{$fieldGetter}()->{$brickSetter}($brick);
}
$brick->{$valueSetter}($value);
} else {
$objectData[$key] = $value;
}
}
$object->setValues($objectData);
try {
$object->save();
$this->_helper->json(["data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true]);
} catch (\Exception $e) {
$this->_helper->json(["success" => false, "message" => $e->getMessage()]);
}
} else {
throw new \Exception("Permission denied");
}
} else {
$parentObject = Object\Concrete::getById($this->getParam("objectId"));
if (empty($parentObject)) {
throw new \Exception("No Object found with id " . $this->getParam("objectId"));
}
if ($parentObject->isAllowed("view")) {
$class = $parentObject->getClass();
$className = $parentObject->getClass()->getName();
$start = 0;
$limit = 15;
$orderKey = "o_id";
$order = "ASC";
$fields = [];
$bricks = [];
if ($this->getParam("fields")) {
$fields = $this->getParam("fields");
foreach ($fields as $f) {
$parts = explode("~", $f);
if (count($parts) > 1) {
$bricks[$parts[0]] = $parts[0];
}
}
}
if ($this->getParam("limit")) {
$limit = $this->getParam("limit");
}
if ($this->getParam("start")) {
$start = $this->getParam("start");
}
$orderKey = "o_id";
$order = "ASC";
$colMappings = ["filename" => "o_key", "fullpath" => ["o_path", "o_key"], "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate"];
$sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
if ($sortingSettings['orderKey'] && $sortingSettings['order']) {
$orderKey = $sortingSettings['orderKey'];
if (array_key_exists($orderKey, $colMappings)) {
$orderKey = $colMappings[$orderKey];
}
$order = $sortingSettings['order'];
}
if ($this->getParam("dir")) {
$order = $this->getParam("dir");
}
//.........这里部分代码省略.........
示例7: testmagicAction
public function testmagicAction()
{
$obj = Object\Concrete::getById(61071);
$pairs = $obj->getKeyValuePairs();
$value = $pairs->getab123();
\Logger::debug("value=" . $value);
$pairs->setab123("new valuexyz");
$pairs->setdddd("dvalue");
$obj->save();
}
示例8: loadCategory
/**
* @param $id
*
* @return \Pimcore\Model\Object\Concrete|null
*/
protected function loadCategory($id)
{
return \Pimcore\Model\Object\Concrete::getById($id);
}
示例9: loadProduct
/**
* @param $id
*
* @return \Pimcore\Model\Object\Concrete|null
*/
protected function loadProduct($id)
{
return \Pimcore\Model\Object\Concrete::getById($id);
}
示例10: addCollectionsAction
public function addCollectionsAction()
{
$ids = \Zend_Json::decode($this->getParam("collectionIds"));
if ($ids) {
$db = \Pimcore\Db::get();
$query = "select * from classificationstore_groups g, classificationstore_collectionrelations c where colId IN (" . implode(",", $ids) . ") and g.id = c.groupId";
$mappedData = [];
$groupsData = $db->fetchAll($query);
foreach ($groupsData as $groupData) {
$mappedData[$groupData["id"]] = $groupData;
}
$groupIdList = [];
$allowedGroupIds = null;
if ($this->getParam("oid")) {
$object = Object\Concrete::getById($this->getParam("oid"));
$class = $object->getClass();
$fd = $class->getFieldDefinition($this->getParam("fieldname"));
$allowedGroupIds = $fd->getAllowedGroupIds();
}
foreach ($groupsData as $groupItem) {
$groupId = $groupItem["groupId"];
if (!$allowedGroupIds || $allowedGroupIds && in_array($groupId, $allowedGroupIds)) {
$groupIdList[] = $groupId;
}
}
if ($groupIdList) {
$groupList = new Classificationstore\GroupConfig\Listing();
$groupCondition = "id in (" . implode(",", $groupIdList) . ")";
$groupList->setCondition($groupCondition);
$groupList = $groupList->load();
$keyCondition = "groupId in (" . implode(",", $groupIdList) . ")";
$keyList = new Classificationstore\KeyGroupRelation\Listing();
$keyList->setCondition($keyCondition);
$keyList->setOrderKey(["sorter", "id"]);
$keyList->setOrder(["ASC", "ASC"]);
$keyList = $keyList->load();
foreach ($groupList as $groupData) {
$data[$groupData->getId()] = ["name" => $groupData->getName(), "id" => $groupData->getId(), "description" => $groupData->getDescription(), "keys" => [], "collectionId" => $mappedData[$groupId]["colId"]];
}
foreach ($keyList as $keyData) {
$groupId = $keyData->getGroupId();
$keyList = $data[$groupId]["keys"];
$definition = $keyData->getDefinition();
$keyList[] = ["name" => $keyData->getName(), "id" => $keyData->getKeyId(), "description" => $keyData->getDescription(), "definition" => json_decode($definition)];
$data[$groupId]["keys"] = $keyList;
}
}
}
return $this->_helper->json($data);
}