当前位置: 首页>>代码示例>>PHP>>正文


PHP Concrete::getId方法代码示例

本文整理汇总了PHP中Pimcore\Model\Object\Concrete::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Concrete::getId方法的具体用法?PHP Concrete::getId怎么用?PHP Concrete::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Model\Object\Concrete的用法示例。


在下文中一共展示了Concrete::getId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * @param Model\Object\Concrete $object
  * @throws \Exception
  */
 public function save(Model\Object\Concrete $object)
 {
     $tableName = $this->model->getDefinition()->getTableName($object->getClass());
     $data = array("o_id" => $object->getId(), "index" => $this->model->getIndex(), "fieldname" => $this->model->getFieldname());
     try {
         foreach ($this->model->getDefinition()->getFieldDefinitions() as $fd) {
             $getter = "get" . ucfirst($fd->getName());
             if (method_exists($fd, "save")) {
                 // for fieldtypes which have their own save algorithm eg. objects, multihref, ...
                 $fd->save($this->model);
             } else {
                 if ($fd->getColumnType()) {
                     if (is_array($fd->getColumnType())) {
                         $insertDataArray = $fd->getDataForResource($this->model->{$getter}(), $object);
                         $data = array_merge($data, $insertDataArray);
                     } else {
                         $data[$fd->getName()] = $fd->getDataForResource($this->model->{$getter}(), $object);
                     }
                 }
             }
         }
         $this->db->insert($tableName, $data);
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:30,代码来源:Resource.php

示例2: getLocalizedValue

 /**
  * @param $name
  * @param null $language
  * @return 
  */
 public function getLocalizedValue($name, $language = null, $ignoreFallbackLanguage = false)
 {
     $data = null;
     $language = $this->getLanguage($language);
     $fieldDefinition = $this->getObject()->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($name);
     if ($fieldDefinition instanceof Model\Object\ClassDefinition\Data\CalculatedValue) {
         $valueData = new Model\Object\Data\CalculatedValue($fieldDefinition->getName());
         $valueData->setContextualData("localizedfield", "localizedfields", null, $language);
         $data = Service::getCalculatedFieldValue($this->getObject(), $valueData);
         return $data;
     }
     if ($this->languageExists($language)) {
         if (array_key_exists($name, $this->items[$language])) {
             $data = $this->items[$language][$name];
         }
     }
     // check for inherited value
     $doGetInheritedValues = AbstractObject::doGetInheritedValues();
     if ($fieldDefinition->isEmpty($data) && $doGetInheritedValues) {
         $object = $this->getObject();
         $class = $object->getClass();
         $allowInherit = $class->getAllowInherit();
         if ($allowInherit) {
             if ($object->getParent() instanceof AbstractObject) {
                 $parent = $object->getParent();
                 while ($parent && $parent->getType() == "folder") {
                     $parent = $parent->getParent();
                 }
                 if ($parent && ($parent->getType() == "object" || $parent->getType() == "variant")) {
                     if ($parent->getClassId() == $object->getClassId()) {
                         $method = "getLocalizedfields";
                         if (method_exists($parent, $method)) {
                             $localizedFields = $parent->getLocalizedFields();
                             if ($localizedFields instanceof Localizedfield) {
                                 if ($localizedFields->object->getId() != $this->object->getId()) {
                                     $data = $localizedFields->getLocalizedValue($name, $language, true);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // check for fallback value
     if ($fieldDefinition->isEmpty($data) && !$ignoreFallbackLanguage && self::doGetFallbackValues()) {
         foreach (Tool::getFallbackLanguagesFor($language) as $l) {
             if ($this->languageExists($l)) {
                 if (array_key_exists($name, $this->items[$l])) {
                     $data = $this->getLocalizedValue($name, $l);
                 }
             }
         }
     }
     if ($fieldDefinition && method_exists($fieldDefinition, "preGetData")) {
         $data = $fieldDefinition->preGetData($this, array("data" => $data, "language" => $language, "name" => $name));
     }
     return $data;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:64,代码来源:Localizedfield.php

示例3: getLocalizedKeyValue

 /**
  * @param $keyId
  * @param $groupId
  * @param string $language
  * @param bool|false $ignoreFallbackLanguage
  * @return null
  */
 public function getLocalizedKeyValue($groupId, $keyId, $language = "default", $ignoreFallbackLanguage = false, $ignoreDefaultLanguage = false)
 {
     $oid = $this->object->getId();
     $keyConfig = Model\Object\Classificationstore\DefinitionCache::get($keyId);
     if ($keyConfig->getType() == "calculatedValue") {
         $data = new Model\Object\Data\CalculatedValue($this->getFieldname());
         $childDef = Model\Object\Classificationstore\Service::getFieldDefinitionFromKeyConfig($keyConfig);
         $data->setContextualData("classificationstore", $this->getFieldname(), null, $language, $groupId, $keyId, $childDef);
         $data = Model\Object\Service::getCalculatedFieldValueForEditMode($this->getObject(), $data);
         return $data;
     }
     $fieldDefinition = Model\Object\Classificationstore\Service::getFieldDefinitionFromKeyConfig($keyConfig);
     $language = $this->getLanguage($language);
     $data = null;
     if (array_key_exists($groupId, $this->items) && array_key_exists($keyId, $this->items[$groupId]) && array_key_exists($language, $this->items[$groupId][$keyId])) {
         $data = $this->items[$groupId][$keyId][$language];
     }
     // check for fallback value
     if ($fieldDefinition->isEmpty($data) && !$ignoreFallbackLanguage && self::doGetFallbackValues()) {
         $data = $this->getFallbackValue($groupId, $keyId, $language, $fieldDefinition);
     }
     if ($fieldDefinition->isEmpty($data) && !$ignoreDefaultLanguage && $language != "default") {
         $data = $this->items[$groupId][$keyId]["default"];
     }
     // check for inherited value
     $doGetInheritedValues = AbstractObject::doGetInheritedValues();
     if ($fieldDefinition->isEmpty($data) && $doGetInheritedValues) {
         $object = $this->getObject();
         $class = $object->getClass();
         $allowInherit = $class->getAllowInherit();
         if ($allowInherit) {
             if ($object->getParent() instanceof AbstractObject) {
                 $parent = $object->getParent();
                 while ($parent && $parent->getType() == "folder") {
                     $parent = $parent->getParent();
                 }
                 if ($parent && ($parent->getType() == "object" || $parent->getType() == "variant")) {
                     if ($parent->getClassId() == $object->getClassId()) {
                         $method = "getLocalizedfields";
                         if (method_exists($parent, $method)) {
                             $getter = "get" . ucfirst($this->fieldname);
                             $classificationStore = $parent->{$getter}();
                             if ($classificationStore instanceof Classificationstore) {
                                 if ($classificationStore->object->getId() != $this->object->getId()) {
                                     $data = $classificationStore->getLocalizedKeyValue($groupId, $keyId, $language, false);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($fieldDefinition && method_exists($fieldDefinition, "preGetData")) {
         $data = $fieldDefinition->preGetData($this, array("data" => $data, "language" => $language, "name" => $groupId . "-" . $keyId));
     }
     return $data;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:65,代码来源:Classificationstore.php

示例4: load

 /**
  * @param Object\Concrete $object
  * @return array
  */
 public function load(Object\Concrete $object)
 {
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     $values = array();
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             $definition = Object\Objectbrick\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass(), false);
         try {
             $results = $this->db->fetchAll("SELECT * FROM " . $tableName . " WHERE o_id = ? AND fieldname = ?", array($object->getId(), $this->model->getFieldname()));
         } catch (\Exception $e) {
             $results = array();
         }
         //$allRelations = $this->db->fetchAll("SELECT * FROM object_relations_" . $object->getO_classId() . " WHERE src_id = ? AND ownertype = 'objectbrick' AND ownername = ?", array($object->getO_id(), $this->model->getFieldname()));
         $fieldDefinitions = $definition->getFieldDefinitions();
         $brickClass = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($type);
         foreach ($results as $result) {
             $brick = new $brickClass($object);
             $brick->setFieldname($result["fieldname"]);
             $brick->setObject($object);
             foreach ($fieldDefinitions as $key => $fd) {
                 if (method_exists($fd, "load")) {
                     // datafield has it's own loader
                     $value = $fd->load($brick);
                     if ($value === 0 || !empty($value)) {
                         $brick->setValue($key, $value);
                     }
                 } else {
                     if (is_array($fd->getColumnType())) {
                         $multidata = array();
                         foreach ($fd->getColumnType() as $fkey => $fvalue) {
                             $multidata[$key . "__" . $fkey] = $result[$key . "__" . $fkey];
                         }
                         $brick->setValue($key, $fd->getDataFromResource($multidata));
                     } else {
                         $brick->setValue($key, $fd->getDataFromResource($result[$key]));
                     }
                 }
             }
             $setter = "set" . ucfirst($type);
             $this->model->{$setter}($brick);
             $values[] = $brick;
         }
     }
     return $values;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:53,代码来源:Resource.php

示例5: 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;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:28,代码来源:Manager.php

示例6: processRemoteOwnerRelations

 /**
  * @param  Object\Concrete $object
  * @param  array $toDelete
  * @param  array $toAdd
  * @param  string $ownerFieldName
  * @return void
  */
 protected function processRemoteOwnerRelations($object, $toDelete, $toAdd, $ownerFieldName)
 {
     $getter = "get" . ucfirst($ownerFieldName);
     $setter = "set" . ucfirst($ownerFieldName);
     foreach ($toDelete as $id) {
         $owner = Object::getById($id);
         //TODO: lock ?!
         if (method_exists($owner, $getter)) {
             $currentData = $owner->{$getter}();
             if (is_array($currentData)) {
                 for ($i = 0; $i < count($currentData); $i++) {
                     if ($currentData[$i]->getId() == $object->getId()) {
                         unset($currentData[$i]);
                         $owner->{$setter}($currentData);
                         $owner->setUserModification($this->getUser()->getId());
                         $owner->save();
                         \Logger::debug("Saved object id [ " . $owner->getId() . " ] by remote modification through [" . $object->getId() . "], Action: deleted [ " . $object->getId() . " ] from [ {$ownerFieldName}]");
                         break;
                     }
                 }
             }
         }
     }
     foreach ($toAdd as $id) {
         $owner = Object::getById($id);
         //TODO: lock ?!
         if (method_exists($owner, $getter)) {
             $currentData = $owner->{$getter}();
             $currentData[] = $object;
             $owner->{$setter}($currentData);
             $owner->setUserModification($this->getUser()->getId());
             $owner->save();
             \Logger::debug("Saved object id [ " . $owner->getId() . " ] by remote modification through [" . $object->getId() . "], Action: added [ " . $object->getId() . " ] to [ {$ownerFieldName} ]");
         }
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:43,代码来源:ObjectController.php

示例7: delete

 /**
  * @param Object\Concrete $object
  * @return void
  */
 public function delete(Object\Concrete $object)
 {
     // update data for store table
     $storeTable = $this->model->getDefinition()->getTableName($object->getClass(), false);
     $this->db->delete($storeTable, $this->db->quoteInto("o_id = ?", $object->getId()));
     // update data for query table
     $queryTable = $this->model->getDefinition()->getTableName($object->getClass(), true);
     $oldData = $this->db->fetchRow("SELECT * FROM " . $queryTable . " WHERE o_id = ?", $object->getId());
     $this->db->delete($queryTable, $this->db->quoteInto("o_id = ?", $object->getId()));
     //update data for relations table
     $this->db->delete("object_relations_" . $object->getClassId(), "src_id = " . $object->getId() . " AND ownertype = 'objectbrick' AND ownername = '" . $this->model->getFieldname() . "' AND position = '" . $this->model->getType() . "'");
     $this->inheritanceHelper = new Object\Concrete\Dao\InheritanceHelper($object->getClassId(), "o_id", $storeTable, $queryTable);
     $this->inheritanceHelper->resetFieldsToCheck();
     $objectVars = get_object_vars($this->model);
     foreach ($objectVars as $key => $value) {
         $fd = $this->model->getDefinition()->getFieldDefinition($key);
         if ($fd) {
             if ($fd->getQueryColumnType()) {
                 //exclude untouchables if value is not an array - this means data has not been loaded
                 //get changed fields for inheritance
                 if ($fd instanceof Object\ClassDefinition\Data\CalculatedValue) {
                     continue;
                 }
                 if ($fd->isRelationType()) {
                     if ($oldData[$key] != null) {
                         $this->inheritanceHelper->addRelationToCheck($key, $fd);
                     }
                 } else {
                     if ($oldData[$key] != null) {
                         $this->inheritanceHelper->addFieldToCheck($key, $fd);
                     }
                 }
                 if (method_exists($fd, "delete")) {
                     $fd->delete($object);
                 }
             }
         }
     }
     $this->inheritanceHelper->doDelete($object->getId());
     $this->inheritanceHelper->resetFieldsToCheck();
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:45,代码来源:Dao.php

示例8: delete

 /**
  * @param Object\Concrete $object
  * @return void
  */
 public function delete($object)
 {
     $db = Resource::get();
     $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:9,代码来源:ObjectsMetadata.php

示例9: delete

 /**
  * @param Object\Concrete $object
  */
 public function delete(Object\Concrete $object)
 {
     // empty or create all relevant tables
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             $definition = Object\Fieldcollection\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass());
         try {
             $this->db->delete($tableName, $this->db->quoteInto("o_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname()));
         } catch (\Exception $e) {
             // create definition if it does not exist
             $definition->createUpdateTable($object->getClass());
         }
     }
     // empty relation table
     $this->db->delete("object_relations_" . $object->getClassId(), "ownertype = 'fieldcollection' AND " . $this->db->quoteInto("ownername = ?", $this->model->getFieldname()) . " AND " . $this->db->quoteInto("src_id = ?", $object->getId()));
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:24,代码来源:Resource.php

示例10: delete

 /**
  * @param Object\Concrete $object
  */
 public function delete(Object\Concrete $object)
 {
     // empty or create all relevant tables
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             /** @var  $definition Definition */
             $definition = Object\Fieldcollection\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass());
         try {
             $this->db->delete($tableName, $this->db->quoteInto("o_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname()));
         } catch (\Exception $e) {
             // create definition if it does not exist
             $definition->createUpdateTable($object->getClass());
         }
         if ($definition->getFieldDefinition("localizedfields")) {
             $tableName = $definition->getLocalizedTableName($object->getClass());
             try {
                 $this->db->delete($tableName, $this->db->quoteInto("ooo_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname()));
             } catch (\Exception $e) {
                 \Logger::error($e);
             }
         }
         $childDefinitions = $definition->getFielddefinitions();
         if (is_array($childDefinitions)) {
             foreach ($childDefinitions as $fd) {
                 if (method_exists($fd, "delete")) {
                     $fd->delete($object, ["context" => ["containerType" => "fieldcollection", "containerKey" => $type, "fieldname" => $this->model->getFieldname()]]);
                 }
             }
         }
     }
     // empty relation table
     $this->db->delete("object_relations_" . $object->getClassId(), "(ownertype = 'fieldcollection' AND " . $this->db->quoteInto("ownername = ?", $this->model->getFieldname()) . " AND " . $this->db->quoteInto("src_id = ?", $object->getId()) . ")" . " OR (ownertype = 'localizedfield' AND " . $this->db->quoteInto("ownername LIKE ?", "/fieldcollection~" . $this->model->getFieldname() . "/%") . ")");
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:41,代码来源:Dao.php

示例11: delete

 /**
  * @param Object\Concrete $object
  * @return void
  */
 public function delete($object, $params = [])
 {
     $db = Db::get();
     if ($params && $params["context"] && $params["context"]["containerType"] == "fieldcollection" && $params["context"]["subContainerType"] == "localizedfield") {
         $context = $params["context"];
         $index = $context["index"];
         $containerName = $context["fieldname"];
         $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND ownertype = 'localizedfield' AND " . $db->quoteInto("ownername LIKE ?", "/fieldcollection~" . $containerName . "/" . $index . "/%") . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
     } else {
         $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:16,代码来源:MultihrefMetadata.php


注:本文中的Pimcore\Model\Object\Concrete::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。