本文整理汇总了PHP中Pimcore\Model\Object\AbstractObject::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractObject::getById方法的具体用法?PHP AbstractObject::getById怎么用?PHP AbstractObject::getById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Object\AbstractObject
的用法示例。
在下文中一共展示了AbstractObject::getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProduct
/**
* @return OnlineShop_Framework_ProductInterfaces_ICheckoutable
*/
public function getProduct()
{
if ($this->product) {
return $this->product;
}
$this->product = \Pimcore\Model\Object\AbstractObject::getById($this->productId);
return $this->product;
}
示例2: getById
/**
* @static
* @param int $id
* @return null|\Pimcore\Model\Object\AbstractObject
*/
public static function getById($id)
{
$object = \Pimcore\Model\Object\AbstractObject::getById($id);
if ($object instanceof OnlineShop_Framework_AbstractFilterDefinition) {
return $object;
}
return null;
}
示例3: getGroupByValuesForFilterGroup
/**
* returns all possible group by values for given column group, product list and field combination
*
* @param $columnGroup
* @param OnlineShop_Framework_IProductList $productList
* @param string $field
* @return array
*/
public static function getGroupByValuesForFilterGroup($columnGroup, OnlineShop_Framework_IProductList $productList, $field)
{
$columnType = self::getColumnTypeForColumnGroup($columnGroup);
$data = array();
if ($columnType == "relation") {
$productList->prepareGroupByRelationValues($field);
$values = $productList->getGroupByRelationValues($field);
foreach ($values as $v) {
$obj = \Pimcore\Model\Object\AbstractObject::getById($v);
if ($obj) {
$name = $obj->getKey();
if (method_exists($obj, "getName")) {
$name = $obj->getName();
}
$data[$v] = array("key" => $v, "value" => $name . " (" . $obj->getId() . ")");
}
}
} else {
if ($columnType == "multiselect") {
$values = $productList->getGroupByValues($field);
sort($values);
foreach ($values as $v) {
$helper = explode(OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER, $v);
foreach ($helper as $h) {
$data[$h] = array("key" => $h, "value" => $h);
}
}
} else {
if ($columnType == "category") {
$values = $productList->getGroupByValues($field);
foreach ($values as $v) {
$helper = explode(",", $v);
foreach ($helper as $h) {
$obj = \Pimcore\Model\Object\AbstractObject::getById($h);
if ($obj) {
$name = $obj->getKey();
if (method_exists($obj, "getName")) {
$name = $obj->getName();
}
$data[$h] = array("key" => $h, "value" => $name . " (" . $obj->getId() . ")");
}
}
}
} else {
$values = $productList->getGroupByValues($field);
sort($values);
foreach ($values as $v) {
$data[] = array("key" => $v, "value" => $v);
}
}
}
}
return $data;
}
示例4: loadObjectDataAction
public function loadObjectDataAction()
{
$object = Object\AbstractObject::getById($this->getParam("id"));
$result = [];
if ($object) {
$result['success'] = true;
$fields = $this->getParam("fields");
$result['fields'] = Object\Service::gridObjectData($object, $fields);
} else {
$result['success'] = false;
}
$this->_helper->json($result);
}
示例5: __call
/**
* @param $method
* @param $args
*
* @return mixed
* @throws \Exception
*/
public function __call($method, $args)
{
$field = substr($method, 3);
if (substr($method, 0, 3) == 'get' && array_key_exists($field, $this->resultRow)) {
return $this->resultRow[$field];
}
$object = \Pimcore\Model\Object\AbstractObject::getById($this->getId());
if ($object) {
return call_user_func_array(array($object, $method), $args);
} else {
throw new \Exception("Object with {$this->getId()} not found.");
}
}
示例6: getById
/**
* @param $id
* @throws \Exception
*/
public function getById($id)
{
$data = $this->db->fetchRow("SELECT * FROM notes WHERE id = ?", $id);
if (!$data["id"]) {
throw new \Exception("Note item with id " . $id . " not found");
}
$this->assignVariablesToModel($data);
// get key-value data
$keyValues = $this->db->fetchAll("SELECT * FROM notes_data WHERE id = ?", $id);
$preparedData = array();
foreach ($keyValues as $keyValue) {
$data = $keyValue["data"];
$type = $keyValue["type"];
$name = $keyValue["name"];
if ($type == "document") {
if ($data) {
$data = Document::getById($data);
}
} else {
if ($type == "asset") {
if ($data) {
$data = Asset::getById($data);
}
} else {
if ($type == "object") {
if ($data) {
$data = Object\AbstractObject::getById($data);
}
} else {
if ($type == "date") {
if ($data > 0) {
$data = new \Zend_Date($data);
}
} else {
if ($type == "bool") {
$data = (bool) $data;
}
}
}
}
}
$preparedData[$name] = array("data" => $data, "type" => $type);
}
$this->model->setData($preparedData);
}
示例7: getFilterFrontend
public function getFilterFrontend(OnlineShop_Framework_AbstractFilterDefinitionType $filterDefinition, OnlineShop_Framework_IProductList $productList, $currentFilter)
{
$field = $this->getField($filterDefinition);
$values = $productList->getGroupByRelationValues($field, true);
$objects = array();
Logger::log("Load Objects...", Zend_Log::INFO);
$availableRelations = array();
if ($filterDefinition->getAvailableRelations()) {
$availableRelations = $this->loadAllAvailableRelations($filterDefinition->getAvailableRelations());
}
foreach ($values as $v) {
if (empty($availableRelations) || $availableRelations[$v['value']] === true) {
$objects[$v['value']] = \Pimcore\Model\Object\AbstractObject::getById($v['value']);
}
}
Logger::log("done.", Zend_Log::INFO);
if ($filterDefinition->getScriptPath()) {
$script = $filterDefinition->getScriptPath();
} else {
$script = $this->script;
}
return $this->view->partial($script, array("hideFilter" => $filterDefinition->getRequiredFilterField() && empty($currentFilter[$filterDefinition->getRequiredFilterField()]), "label" => $filterDefinition->getLabel(), "currentValue" => $currentFilter[$field], "values" => $values, "objects" => $objects, "fieldname" => $field, "metaData" => $filterDefinition->getMetaData()));
}
示例8: getCustomGridFieldDefinitions
public static function getCustomGridFieldDefinitions($classId, $objectId)
{
$object = AbstractObject::getById($objectId);
$class = ClassDefinition::getById($classId);
$masterFieldDefinition = $class->getFieldDefinitions();
if (!$object) {
return null;
}
$user = AdminTool::getCurrentUser();
if ($user->isAdmin()) {
return null;
}
$permissionList = array();
$parentPermissionSet = $object->getPermissions(null, $user, true);
if ($parentPermissionSet) {
$permissionList[] = $parentPermissionSet;
}
$childPermissions = $object->getChildPermissions(null, $user);
$permissionList = array_merge($permissionList, $childPermissions);
$layoutDefinitions = array();
foreach ($permissionList as $permissionSet) {
$allowedLayoutIds = self::getLayoutPermissions($classId, $permissionSet);
if (is_array($allowedLayoutIds)) {
foreach ($allowedLayoutIds as $allowedLayoutId) {
if ($allowedLayoutId) {
if (!$layoutDefinitions[$allowedLayoutId]) {
$customLayout = ClassDefinition\CustomLayout::getById($allowedLayoutId);
if (!$customLayout) {
continue;
}
$layoutDefinitions[$allowedLayoutId] = $customLayout;
}
}
}
}
}
$mergedFieldDefinition = unserialize(serialize($masterFieldDefinition));
if (count($layoutDefinitions)) {
foreach ($mergedFieldDefinition as $key => $def) {
if ($def instanceof ClassDefinition\Data\Localizedfields) {
$mergedLocalizedFieldDefinitions = $mergedFieldDefinition[$key]->getFieldDefinitions();
foreach ($mergedLocalizedFieldDefinitions as $locKey => $locValue) {
$mergedLocalizedFieldDefinitions[$locKey]->setInvisible(false);
$mergedLocalizedFieldDefinitions[$locKey]->setNotEditable(false);
}
$mergedFieldDefinition[$key]->setChilds($mergedLocalizedFieldDefinitions);
} else {
$mergedFieldDefinition[$key]->setInvisible(false);
$mergedFieldDefinition[$key]->setNotEditable(false);
}
}
}
foreach ($layoutDefinitions as $customLayoutDefinition) {
$layoutName = $customLayoutDefinition->getName();
$layoutDefinitions = $customLayoutDefinition->getLayoutDefinitions();
$dummyClass = new ClassDefinition();
$dummyClass->setLayoutDefinitions($layoutDefinitions);
$customFieldDefinitions = $dummyClass->getFieldDefinitions();
foreach ($mergedFieldDefinition as $key => $value) {
if (!$customFieldDefinitions[$key]) {
unset($mergedFieldDefinition[$key]);
}
}
foreach ($customFieldDefinitions as $key => $def) {
if ($def instanceof ClassDefinition\Data\Localizedfields) {
if (!$mergedFieldDefinition[$key]) {
continue;
}
$customLocalizedFieldDefinitions = $def->getFieldDefinitions();
$mergedLocalizedFieldDefinitions = $mergedFieldDefinition[$key]->getFieldDefinitions();
foreach ($mergedLocalizedFieldDefinitions as $locKey => $locValue) {
self::mergeFieldDefinition($mergedLocalizedFieldDefinitions, $customLocalizedFieldDefinitions, $locKey);
}
$mergedFieldDefinition[$key]->setChilds($mergedLocalizedFieldDefinitions);
} else {
self::mergeFieldDefinition($mergedFieldDefinition, $customFieldDefinitions, $key);
}
}
}
return $mergedFieldDefinition;
}
示例9: __wakeup
/**
*
*/
public function __wakeup()
{
if (isset($this->_fulldump) && !self::$doNotRestoreKeyAndPath) {
// set current key and path this is necessary because the serialized data can have a different path than the original element ( element was renamed or moved )
$originalElement = AbstractObject::getById($this->getId());
if ($originalElement) {
$this->setKey($originalElement->getKey());
$this->setPath($originalElement->getPath());
}
}
if (isset($this->_fulldump) && $this->o_properties !== null) {
$this->renewInheritedProperties();
}
if (isset($this->_fulldump)) {
unset($this->_fulldump);
}
}
示例10: getBatchAssignmentJobsAction
public function getBatchAssignmentJobsAction()
{
$elementId = intval($this->getParam("elementId"));
$elementType = strip_tags($this->getParam("elementType"));
$idList = [];
switch ($elementType) {
case "object":
$object = \Pimcore\Model\Object\AbstractObject::getById($elementId);
if ($object) {
$idList = $this->getSubObjectIds($object);
}
break;
case "asset":
$asset = \Pimcore\Model\Asset::getById($elementId);
if ($asset) {
$idList = $this->getSubAssetIds($asset);
}
break;
case "document":
$document = \Pimcore\Model\Document::getById($elementId);
if ($document) {
$idList = $this->getSubDocumentIds($document);
}
break;
}
$size = 2;
$offset = 0;
$idListParts = [];
while ($offset < count($idList)) {
$idListParts[] = array_slice($idList, $offset, $size);
$offset += $size;
}
$this->_helper->json(['success' => true, 'idLists' => $idListParts, 'totalCount' => count($idList)]);
}
示例11: getFromWebserviceImport
/**
* @param Document\Webservice\Data\Document\Element $wsElement
* @param null $idMapper
* @throws \Exception
*/
public function getFromWebserviceImport($wsElement, $idMapper = null)
{
$data = $wsElement->value;
if ($data->id !== null) {
$this->type = $data->type;
$this->subtype = $data->subtype;
$this->id = $data->id;
if (!is_numeric($this->id)) {
throw new \Exception("cannot get values from web service import - id is not valid");
}
if ($idMapper) {
$this->id = $idMapper->getMappedId($this->type, $data->id);
}
if ($this->type == "asset") {
$this->element = Asset::getById($this->id);
if (!$this->element instanceof Asset) {
if ($idMapper && $idMapper->ignoreMappingFailures()) {
$idMapper->recordMappingFailure("document", $this->getDocumentId(), $data->type, $data->id);
} else {
throw new \Exception("cannot get values from web service import - referenced asset with id [ " . $data->id . " ] is unknown");
}
}
} else {
if ($this->type == "document") {
$this->element = Document::getById($this->id);
if (!$this->element instanceof Document) {
if ($idMapper && $idMapper->ignoreMappingFailures()) {
$idMapper->recordMappingFailure("document", $this->getDocumentId(), $data->type, $data->id);
} else {
throw new \Exception("cannot get values from web service import - referenced document with id [ " . $data->id . " ] is unknown");
}
}
} else {
if ($this->type == "object") {
$this->element = Object\AbstractObject::getById($this->id);
if (!$this->element instanceof Object\AbstractObject) {
if ($idMapper && $idMapper->ignoreMappingFailures()) {
$idMapper->recordMappingFailure("document", $this->getDocumentId(), $data->type, $data->id);
} else {
throw new \Exception("cannot get values from web service import - referenced object with id [ " . $data->id . " ] is unknown");
}
}
} else {
if ($idMapper && $idMapper->ignoreMappingFailures()) {
$idMapper->recordMappingFailure("document", $this->getDocumentId(), $data->type, $data->id);
} else {
throw new \Exception("cannot get values from web service import - type is not valid");
}
}
}
}
}
}
示例12: getById
/**
* @static
* @param int $id
* @return null|\Pimcore\Model\Object\AbstractObject
*/
public static function getById($id)
{
$object = \Pimcore\Model\Object\AbstractObject::getById($id);
if ($object instanceof OnlineShop_OfferTool_AbstractOfferToolProduct) {
return $object;
}
return null;
}
示例13: treeGetChildsByIdAction
public function treeGetChildsByIdAction()
{
$object = Object\AbstractObject::getById($this->getParam("node"));
$objectTypes = null;
$objects = [];
$cv = false;
$offset = 0;
$total = 0;
if ($object instanceof Object\Concrete) {
$class = $object->getClass();
if ($class->getShowVariants()) {
$objectTypes = [Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT];
}
}
if (!$objectTypes) {
$objectTypes = [Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER];
}
if ($object->hasChilds($objectTypes)) {
$limit = intval($this->getParam("limit"));
if (!$this->getParam("limit")) {
$limit = 100000000;
}
$offset = intval($this->getParam("start"));
$childsList = new Object\Listing();
$condition = "objects.o_parentId = '" . $object->getId() . "'";
// custom views start
if ($this->getParam("view")) {
$cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view"));
if ($cv["classes"]) {
$cvConditions = [];
$cvClasses = explode(",", $cv["classes"]);
foreach ($cvClasses as $cvClass) {
$cvConditions[] = "objects.o_classId = '" . $cvClass . "'";
}
$cvConditions[] = "objects.o_type = 'folder'";
if (count($cvConditions) > 0) {
$condition .= " AND (" . implode(" OR ", $cvConditions) . ")";
}
}
}
// custom views end
if (!$this->getUser()->isAdmin()) {
$userIds = $this->getUser()->getRoles();
$userIds[] = $this->getUser()->getId();
$condition .= " AND (\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(o_path,o_key),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n OR\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(o_path,o_key))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )";
}
$childsList->setCondition($condition);
$childsList->setLimit($limit);
$childsList->setOffset($offset);
$childsList->setOrderKey("FIELD(objects.o_type, 'folder') DESC, objects.o_key ASC", false);
$childsList->setObjectTypes($objectTypes);
Element\Service::addTreeFilterJoins($cv, $childsList);
$childs = $childsList->load();
foreach ($childs as $child) {
$tmpObject = $this->getTreeNodeConfig($child);
if ($child->isAllowed("list")) {
$objects[] = $tmpObject;
}
}
//pagination for custom view
$total = $cv ? $childsList->count() : $object->getChildAmount([Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_VARIANT], $this->getUser());
}
//Hook for modifying return value - e.g. for changing permissions based on object data
//data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
$returnValueContainer = new Model\Tool\Admin\EventDataContainer($objects);
\Pimcore::getEventManager()->trigger("admin.object.treeGetChildsById.preSendData", $this, ["returnValueContainer" => $returnValueContainer]);
if ($this->getParam("limit")) {
$this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $total, "nodes" => $returnValueContainer->getData(), "fromPaging" => intval($this->getParam("fromPaging"))]);
} else {
$this->_helper->json($returnValueContainer->getData());
}
}
示例14: prepareDataForIndex
/**
* prepare data for index creation and store is in store table
*
* @param OnlineShop_Framework_ProductInterfaces_IIndexable $object
*/
public function prepareDataForIndex(OnlineShop_Framework_ProductInterfaces_IIndexable $object)
{
$subObjectIds = $this->tenantConfig->createSubIdsForObject($object);
foreach ($subObjectIds as $subObjectId => $object) {
/**
* @var OnlineShop_Framework_ProductInterfaces_IIndexable $object
*/
if ($object->getOSDoIndexProduct() && $this->tenantConfig->inIndex($object)) {
$a = Pimcore::inAdmin();
$b = \Pimcore\Model\Object\AbstractObject::doGetInheritedValues();
Pimcore::unsetAdminMode();
\Pimcore\Model\Object\AbstractObject::setGetInheritedValues(true);
$hidePublishedMemory = \Pimcore\Model\Object\AbstractObject::doHideUnpublished();
\Pimcore\Model\Object\AbstractObject::setHideUnpublished(false);
$categories = $object->getCategories();
$categoryIds = array();
$parentCategoryIds = array();
if ($categories) {
foreach ($categories as $c) {
$parent = $c;
if ($parent != null) {
if ($parent->getOSProductsInParentCategoryVisible()) {
while ($parent && $parent instanceof OnlineShop_Framework_AbstractCategory) {
$parentCategoryIds[$parent->getId()] = $parent->getId();
$parent = $parent->getParent();
}
} else {
$parentCategoryIds[$parent->getId()] = $parent->getId();
}
$categoryIds[$c->getId()] = $c->getId();
}
}
}
ksort($categoryIds);
$virtualProductId = $subObjectId;
$virtualProductActive = $object->isActive();
if ($object->getOSIndexType() == "variant") {
$virtualProductId = $this->tenantConfig->createVirtualParentIdForSubId($object, $subObjectId);
}
$virtualProduct = \Pimcore\Model\Object\AbstractObject::getById($virtualProductId);
if ($virtualProduct && method_exists($virtualProduct, "isActive")) {
$virtualProductActive = $virtualProduct->isActive();
}
$data = array("o_id" => $subObjectId, "o_classId" => $object->getClassId(), "o_virtualProductId" => $virtualProductId, "o_virtualProductActive" => $virtualProductActive, "o_parentId" => $object->getOSParentId(), "o_type" => $object->getOSIndexType(), "categoryIds" => ',' . implode(",", $categoryIds) . ",", "parentCategoryIds" => ',' . implode(",", $parentCategoryIds) . ",", "priceSystemName" => $object->getPriceSystemName(), "active" => $object->isActive(), "inProductList" => $object->isActive(true));
$relationData = array();
$columnConfig = $this->columnConfig->column;
if (!empty($columnConfig->name)) {
$columnConfig = array($columnConfig);
} else {
if (empty($columnConfig)) {
$columnConfig = array();
}
}
foreach ($columnConfig as $column) {
try {
//$data[$column->name] = null;
$value = null;
if (!empty($column->getter)) {
$getter = $column->getter;
$value = $getter::get($object, $column->config, $subObjectId, $this->tenantConfig);
} else {
if (!empty($column->fieldname)) {
$getter = "get" . ucfirst($column->fieldname);
} else {
$getter = "get" . ucfirst($column->name);
}
if (method_exists($object, $getter)) {
$value = $object->{$getter}($column->locale);
}
}
if (!empty($column->interpreter)) {
$interpreter = $column->interpreter;
$value = $interpreter::interpret($value, $column->config);
$interpreterObject = new $interpreter();
if ($interpreterObject instanceof OnlineShop_Framework_IndexService_RelationInterpreter) {
foreach ($value as $v) {
$relData = array();
$relData['src'] = $subObjectId;
$relData['src_virtualProductId'] = $virtualProductId;
$relData['dest'] = $v['dest'];
$relData['fieldname'] = $column->name;
$relData['type'] = $v['type'];
$relationData[] = $relData;
}
} else {
$data[$column->name] = $value;
}
} else {
$data[$column->name] = $value;
}
if (is_array($data[$column->name])) {
$data[$column->name] = OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER . implode($data[$column->name], OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER) . OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER;
}
} catch (Exception $e) {
Logger::err("Exception in IndexService: " . $e->getMessage(), $e);
//.........这里部分代码省略.........
示例15: cleanupReservationsAction
/**
* Removes token reservations due to given duration.
*
* @throws OnlineShop_Framework_Exception_InvalidConfigException
*/
public function cleanupReservationsAction()
{
$duration = $this->getParam('duration');
$id = $this->getParam('id');
if (isset($duration)) {
$onlineShopVoucherSeries = \Pimcore\Model\Object\AbstractObject::getById($this->getParam('id'));
if ($onlineShopVoucherSeries instanceof \Pimcore\Model\Object\OnlineShopVoucherSeries) {
if ($tokenManager = $onlineShopVoucherSeries->getTokenManager()) {
if ($tokenManager->cleanUpReservations($duration)) {
$this->forward('voucher-Code-Tab', 'Voucher', null, ['success' => $this->view->ts('plugin_onlineshop_voucherservice_msg-success-cleanup-reservations'), 'id' => $id]);
}
}
} else {
$this->forward('voucher-Code-Tab', 'Voucher', null, ['error' => $this->view->ts('plugin_onlineshop_voucherservice_msg-error-cleanup-reservations'), 'id' => $id]);
}
} else {
$this->forward('voucher-Code-Tab', 'Voucher', null, ['error' => $this->view->ts('plugin_onlineshop_voucherservice_msg-error-cleanup-reservations-duration-missing'), 'id' => $id]);
}
}