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


PHP ClassDefinition::getById方法代码示例

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


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

示例1: load

 /**
  * Loads a list of object-classes for the specicifies parameters, returns an array of Object|Class elements
  *
  * @return array
  */
 public function load()
 {
     $classes = array();
     $classesRaw = $this->db->fetchCol("SELECT id FROM classes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($classesRaw as $classRaw) {
         $classes[] = Object\ClassDefinition::getById($classRaw);
     }
     $this->model->setClasses($classes);
     return $classes;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:15,代码来源:Dao.php

示例2: indexAction

 /**
  * @todo refactor steps into proper methods instead of doing it all in the action
  * @throws Exception
  */
 public function indexAction()
 {
     // reachable via http://your.domain/plugin/Prototyper/admin/index
     $this->view->previewData = null;
     $this->view->csvText = $this->getParam('csv');
     $this->view->classname = $this->getParam('classname');
     $csvData = array();
     $rowNr = 0;
     $rows = str_getcsv($this->view->csvText, "\n");
     //parse the rows
     foreach ($rows as $row) {
         $rowNr++;
         $rowData = str_getcsv($row, ";");
         $csvData[] = $rowData;
         if ($rowNr == 1) {
             $fieldNames = array();
             $fieldTitles = array();
             foreach ($rowData as $cell) {
                 $fieldTitles[] = $cell;
                 $fieldNames[] = $this->getFieldName($cell);
             }
             $csvData[] = $fieldNames;
         }
         if ($rowNr > 10) {
             break;
         }
     }
     $this->view->previewTable = $csvData;
     $fieldList = array();
     foreach ($fieldNames as $fieldName) {
         $fieldTitle = array_shift($fieldTitles);
         ob_start();
         include __DIR__ . "/../classes/field.json.php";
         $fieldList[] = ob_get_clean();
     }
     $fields = implode(',', $fieldList);
     ob_start();
     include __DIR__ . "/../classes/object.json.php";
     $jsonText = ob_get_clean();
     if ($this->getParam('generate') != '') {
         $class = Object\ClassDefinition::getByName($this->correctClassname($this->getParam("classname")));
         if ($class == null) {
             $class = Object\ClassDefinition::create(array('name' => $this->correctClassname($this->getParam("classname")), 'userOwner' => $this->user->getId()));
             $class->save();
         }
         $class = Object\ClassDefinition::getById($class->getId());
         $success = Object\ClassDefinition\Service::importClassDefinitionFromJson($class, $jsonText);
         if ($success) {
             $this->view->successMessage = '<strong>Class generation successful.</strong>';
         }
     }
 }
开发者ID:basilicom,项目名称:pimcore-plugin-prototyper,代码行数:56,代码来源:AdminController.php

示例3: exceptionHandler

 /**
  * @param $e
  * @return array
  * @throws
  * @throws \Exception
  */
 protected function exceptionHandler($e)
 {
     // create view if it doesn't exist already // HACK
     $pdoMySQL = preg_match("/Base table or view not found/", $e->getMessage());
     $Mysqli = preg_match("/Table (.*) doesn't exist/", $e->getMessage());
     if (($Mysqli || $pdoMySQL) && $this->firstException) {
         $this->firstException = false;
         $localizedFields = new Object\Localizedfield();
         $localizedFields->setClass(Object\ClassDefinition::getById($this->model->getClassId()));
         $localizedFields->createUpdateTable();
         return $this->load();
     }
     throw $e;
 }
开发者ID:krugerke,项目名称:pimcore,代码行数:20,代码来源:Resource.php

示例4: __construct

 /**
  * @param null $classId
  * @throws \Exception
  */
 public function __construct($classId = null)
 {
     $class = null;
     if (is_string($classId)) {
         $class = Object\ClassDefinition::getByName($classId);
     } elseif (is_int($classId)) {
         $class = Object\ClassDefinition::getById($classId);
     } elseif ($classId !== null) {
         throw new \Exception("No valid class identifier given (class name or ID)");
     }
     if ($class instanceof Object\ClassDefinition) {
         $this->setClass($class);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:18,代码来源:Newsletter.php

示例5: getClass

 /**
  * @return Object\ClassDefinition
  */
 public function getClass()
 {
     $class = Object\ClassDefinition::getById($this->getClassId());
     return $class;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:8,代码来源:Concrete.php

示例6: gridProxyAction

 public function gridProxyAction()
 {
     if ($this->getParam("language")) {
         $this->setLanguage($this->getParam("language"), true);
     }
     if ($this->getParam("data")) {
         if ($this->getParam("xaction") == "update") {
             try {
                 $data = \Zend_Json::decode($this->getParam("data"));
                 // save
                 $object = Object::getById($data["id"]);
                 /** @var Object\ClassDefinition $class */
                 $class = $object->getClass();
                 if (!$object->isAllowed("publish")) {
                     throw new \Exception("Permission denied. You don't have the rights to save this object.");
                 }
                 $user = Tool\Admin::getCurrentUser();
                 if (!$user->isAdmin()) {
                     $languagePermissions = $object->getPermissions("lEdit", $user);
                     $languagePermissions = explode(",", $languagePermissions["lEdit"]);
                 }
                 $objectData = array();
                 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 {
                         if (!$user->isAdmin() && $languagePermissions) {
                             $fd = $class->getFieldDefinition($key);
                             if (!$fd) {
                                 // try to get via localized fields
                                 $localized = $class->getFieldDefinition("localizedfields");
                                 if ($localized instanceof Object\ClassDefinition\Data\Localizedfields) {
                                     $field = $localized->getFieldDefinition($key);
                                     if ($field) {
                                         $currentLocale = (string) \Zend_Registry::get("Zend_Locale");
                                         if (!in_array($currentLocale, $languagePermissions)) {
                                             continue;
                                         }
                                     }
                                 }
                             }
                         }
                         $objectData[$key] = $value;
                     }
                 }
                 $object->setValues($objectData);
                 $object->save();
                 $this->_helper->json(array("data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true));
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         }
     } else {
         // get list of objects
         $folder = Object::getById($this->getParam("folderId"));
         $class = Object\ClassDefinition::getById($this->getParam("classId"));
         $className = $class->getName();
         $colMappings = array("filename" => "o_key", "fullpath" => array("o_path", "o_key"), "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate");
         $start = 0;
         $limit = 20;
         $orderKey = "o_id";
         $order = "ASC";
         $fields = array();
         $bricks = array();
         if ($this->getParam("fields")) {
             $fields = $this->getParam("fields");
             foreach ($fields as $f) {
                 $parts = explode("~", $f);
                 $sub = substr($f, 0, 1);
                 if (substr($f, 0, 1) == "~") {
                     //                        $type = $parts[1];
                     //                        $field = $parts[2];
//.........这里部分代码省略.........
开发者ID:emanuel-london,项目名称:pimcore,代码行数:101,代码来源:ObjectController.php

示例7: enrichLayoutDefinition

 /**
  *
  */
 public function enrichLayoutDefinition($object)
 {
     $classId = $this->allowedClassId;
     $class = Object\ClassDefinition::getById($classId);
     if (!$classId) {
         return;
     }
     if (!$this->visibleFields) {
         return;
     }
     $this->visibleFieldDefinitions = array();
     $t = \Zend_Registry::get("Zend_Translate");
     $visibleFields = explode(',', $this->visibleFields);
     foreach ($visibleFields as $field) {
         $fd = $class->getFieldDefinition($field);
         if (!$fd) {
             $fieldFound = false;
             if ($localizedfields = $class->getFieldDefinitions()['localizedfields']) {
                 if ($fd = $localizedfields->getFieldDefinition($field)) {
                     $this->visibleFieldDefinitions[$field]["name"] = $fd->getName();
                     $this->visibleFieldDefinitions[$field]["title"] = $fd->getTitle();
                     $this->visibleFieldDefinitions[$field]["fieldtype"] = $fd->getFieldType();
                     if ($fd instanceof Object\ClassDefinition\Data\Select) {
                         $this->visibleFieldDefinitions[$field]["options"] = $fd->getOptions();
                     }
                     $fieldFound = true;
                 }
             }
             if (!$fieldFound) {
                 $this->visibleFieldDefinitions[$field]["name"] = $field;
                 $this->visibleFieldDefinitions[$field]["title"] = $t->translate($field);
                 $this->visibleFieldDefinitions[$field]["fieldtype"] = "input";
             }
         } else {
             $this->visibleFieldDefinitions[$field]["name"] = $fd->getName();
             $this->visibleFieldDefinitions[$field]["title"] = $fd->getTitle();
             $this->visibleFieldDefinitions[$field]["fieldtype"] = $fd->getFieldType();
             $this->visibleFieldDefinitions[$field]["noteditable"] = true;
             if ($fd instanceof Object\ClassDefinition\Data\Select) {
                 $this->visibleFieldDefinitions[$field]["options"] = $fd->getOptions();
             }
         }
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:47,代码来源:ObjectsMetadata.php

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

示例9: getBatchJobsAction

 public function getBatchJobsAction()
 {
     if ($this->getParam("language")) {
         $this->setLanguage($this->getParam("language"), true);
     }
     $folder = Object::getById($this->getParam("folderId"));
     $class = Object\ClassDefinition::getById($this->getParam("classId"));
     $conditionFilters = array("o_path = ? OR o_path LIKE '" . str_replace("//", "/", $folder->getFullPath() . "/") . "%'");
     if ($this->getParam("filter")) {
         $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
     }
     if ($this->getParam("condition")) {
         $conditionFilters[] = " (" . $this->getParam("condition") . ")";
     }
     $className = $class->getName();
     $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
     $list = new $listClass();
     $list->setCondition(implode(" AND ", $conditionFilters), array($folder->getFullPath()));
     $list->setOrder("ASC");
     $list->setOrderKey("o_id");
     if ($this->getParam("objecttype")) {
         $list->setObjectTypes(array($this->getParam("objecttype")));
     }
     $jobs = $list->loadIdList();
     $this->_helper->json(array("success" => true, "jobs" => $jobs));
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:26,代码来源:ObjectHelperController.php

示例10: getClasses

 public function getClasses()
 {
     if ($this->getChildAmount()) {
         $path = $this->model->getFullPath();
         if (!$this->model->getId() || $this->model->getId() == 1) {
             $path = "";
         }
         $classIds = $this->db->fetchCol("SELECT o_classId FROM objects WHERE o_path LIKE ? AND o_type = 'object' GROUP BY o_classId", $path . "/%");
         $classes = array();
         foreach ($classIds as $classId) {
             $classes[] = Object\ClassDefinition::getById($classId);
         }
         return $classes;
     } else {
         return array();
     }
 }
开发者ID:Ahmad-Hilali,项目名称:pimcore,代码行数:17,代码来源:Resource.php

示例11: generateObjectBrickJson

 /**
  * @param $objectBrick
  * @return string
  */
 public static function generateObjectBrickJson($objectBrick)
 {
     unset($objectBrick->key);
     unset($objectBrick->fieldDefinitions);
     // set classname attribute to the real class name not to the class ID
     // this will allow to import the brick on a different instance with identical class names but different class IDs
     if (is_array($objectBrick->classDefinitions)) {
         foreach ($objectBrick->classDefinitions as &$cd) {
             $class = Object\ClassDefinition::getById($cd["classname"]);
             if ($class) {
                 $cd["classname"] = $class->getName();
             }
         }
     }
     $json = \Zend_Json::encode($objectBrick);
     $json = \Zend_Json::prettyPrint($json);
     return $json;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:22,代码来源:Service.php

示例12: delete

 /**
  * @return void
  */
 public function delete()
 {
     @unlink($this->getDefinitionFile());
     @unlink($this->getPhpClassFile());
     $processedClasses = [];
     if (!empty($this->classDefinitions)) {
         foreach ($this->classDefinitions as $cl) {
             unset($this->oldClassDefinitions[$cl['classname']]);
             if (!$processedClasses[$cl['classname']]) {
                 $class = Object\ClassDefinition::getById($cl['classname']);
                 $this->getDao()->delete($class);
                 $processedClasses[$cl['classname']] = true;
                 foreach ($class->getFieldDefinitions() as $fieldDef) {
                     if ($fieldDef instanceof Object\ClassDefinition\Data\Objectbricks) {
                         $allowedTypes = $fieldDef->getAllowedTypes();
                         $idx = array_search($this->getKey(), $allowedTypes);
                         if ($idx !== false) {
                             array_splice($allowedTypes, $idx, 1);
                         }
                         $fieldDef->setAllowedTypes($allowedTypes);
                     }
                 }
                 $class->save();
             }
         }
     }
     // update classes
     $classList = new Object\ClassDefinition\Listing();
     $classes = $classList->load();
     if (is_array($classes)) {
         foreach ($classes as $class) {
             foreach ($class->getFieldDefinitions() as $fieldDef) {
                 if ($fieldDef instanceof Object\ClassDefinition\Data\Objectbricks) {
                     if (in_array($this->getKey(), $fieldDef->getAllowedTypes())) {
                         break;
                     }
                 }
             }
         }
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:44,代码来源:Definition.php

示例13: delete

 /**
  * @return void
  */
 public function delete()
 {
     $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/objectbricks";
     $fieldFile = $fieldCollectionFolder . "/" . $this->getKey() . ".psf";
     @unlink($fieldFile);
     $fieldClassFolder = PIMCORE_CLASS_DIRECTORY . "/Object/Objectbrick/Data";
     $fieldClass = $fieldClassFolder . "/" . ucfirst($this->getKey()) . ".php";
     @unlink($fieldClass);
     $processedClasses = array();
     if (!empty($this->classDefinitions)) {
         foreach ($this->classDefinitions as $cl) {
             unset($this->oldClassDefinitions[$cl['classname']]);
             if (!$processedClasses[$cl['classname']]) {
                 $class = Object\ClassDefinition::getById($cl['classname']);
                 $this->getDao()->delete($class);
                 $processedClasses[$cl['classname']] = true;
                 foreach ($class->getFieldDefinitions() as $fieldDef) {
                     if ($fieldDef instanceof Object\ClassDefinition\Data\Objectbricks) {
                         $allowedTypes = $fieldDef->getAllowedTypes();
                         $idx = array_search($this->getKey(), $allowedTypes);
                         if ($idx !== false) {
                             array_splice($allowedTypes, $idx, 1);
                         }
                         $fieldDef->setAllowedTypes($allowedTypes);
                     }
                 }
                 $class->save();
             }
         }
     }
     // update classes
     $classList = new Object\ClassDefinition\Listing();
     $classes = $classList->load();
     if (is_array($classes)) {
         foreach ($classes as $class) {
             foreach ($class->getFieldDefinitions() as $fieldDef) {
                 if ($fieldDef instanceof Object\ClassDefinition\Data\Objectbricks) {
                     if (in_array($this->getKey(), $fieldDef->getAllowedTypes())) {
                         break;
                     }
                 }
             }
         }
     }
 }
开发者ID:AtomLaw,项目名称:pimcore,代码行数:48,代码来源:Definition.php

示例14: getOwnerClassName

 /**
  * @return string
  */
 public function getOwnerClassName()
 {
     //fallback for legacy data
     if (empty($this->ownerClassName)) {
         try {
             $class = Object\ClassDefinition::getById($this->ownerClassId);
             $this->ownerClassName = $class->getName();
         } catch (\Exception $e) {
             \Logger::error($e->getMessage());
         }
     }
     return $this->ownerClassName;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:16,代码来源:Nonownerobjects.php

示例15: setLocalizedValue

 /**
  * @param $name
  * @param $value
  * @param null $language
  * @return void
  */
 public function setLocalizedValue($name, $value, $language = null)
 {
     if (self::$strictMode) {
         if (!$language || !in_array($language, Tool::getValidLanguages())) {
             throw new \Exception("Language " . $language . " not accepted in strict mode");
         }
     }
     $language = $this->getLanguage($language);
     if (!$this->languageExists($language)) {
         $this->items[$language] = [];
     }
     $contextInfo = $this->getContext();
     if ($contextInfo && $contextInfo["containerType"] == "block") {
         $classId = $contextInfo["classId"];
         $containerDefinition = ClassDefinition::getById($classId);
         $blockDefinition = $containerDefinition->getFieldDefinition($contextInfo["fieldname"]);
         $fieldDefinition = $blockDefinition->getFieldDefinition("localizedfields");
     } else {
         if ($contextInfo && $contextInfo["containerType"] == "fieldcollection") {
             $containerKey = $contextInfo["containerKey"];
             $containerDefinition = Fieldcollection\Definition::getByKey($containerKey);
         } else {
             $containerDefinition = $this->getObject()->getClass();
         }
         $localizedFieldDefinition = $containerDefinition->getFieldDefinition("localizedfields");
         $fieldDefinition = $localizedFieldDefinition->getFieldDefinition($name);
     }
     if (method_exists($fieldDefinition, "preSetData")) {
         $value = $fieldDefinition->preSetData($this, $value, ["language" => $language, "name" => $name]);
     }
     $this->items[$language][$name] = $value;
     return $this;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:39,代码来源:Localizedfield.php


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