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


PHP ClassDefinition::create方法代码示例

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


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

示例1: createClass

 public function createClass($className)
 {
     $class = Object\ClassDefinition::getByName($className);
     if (!$class) {
         $result = Plugin::getEventManager()->trigger("install.class.getClass.{$className}", $this, array("className" => $className, "json" => $json), function ($v) {
             return $v instanceof Object\ClassDefinition;
         });
         if ($result->stopped()) {
             return $result->last();
         }
         $jsonFile = PIMCORE_PLUGINS_PATH . "/CoreShop/install/class-{$className}.json";
         $class = Object\ClassDefinition::create();
         $class->setName($className);
         $class->setUserOwner($this->_getUser()->getId());
         $json = file_get_contents($jsonFile);
         $result = Plugin::getEventManager()->trigger('install.class.preCreate', $this, array("className" => $className, "json" => $json), function ($v) {
             return !preg_match('/[^,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t]/', preg_replace('/"(\\.|[^"\\\\])*"/', '', $v));
         });
         if ($result->stopped()) {
             $resultJson = $result->last();
             if ($resultJson) {
                 $json = $resultJson;
             }
         }
         Object\ClassDefinition\Service::importClassDefinitionFromJson($class, $json, true);
         return $class;
     }
     return $class;
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:29,代码来源:Install.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: createClass

 /**
  * @param string $name
  * @return ClassDefinition
  * @throws \Exception
  */
 public function createClass($name)
 {
     $def = file_get_contents(sprintf('%s/class_%s.json', $this->baseDir, $name));
     $conf = json_decode($def, true);
     $layoutDefinitions = ClassDefinition\Service::generateLayoutTreeFromArray($conf['layoutDefinitions']);
     if (!$layoutDefinitions) {
         throw new \Exception('Unable to generate class layout for ' . $name);
     }
     $class = ClassDefinition::create();
     $class->setName($name);
     $class->setUserOwner($this->getUser()->getId());
     $class->setLayoutDefinitions($layoutDefinitions);
     $class->setIcon($conf['icon']);
     $class->setAllowInherit($conf['allowInherit']);
     $class->setAllowVariants($conf['allowVariants']);
     $class->setParentClass($conf['parentClass']);
     $class->setPreviewUrl($conf['previewUrl']);
     $class->setPropertyVisibility($conf['propertyVisibility']);
     $class->save();
     return $class;
 }
开发者ID:Pegasuz,项目名称:member,代码行数:26,代码来源:Installer.php

示例4: addAction

 public function addAction()
 {
     $class = Object\ClassDefinition::create(['name' => $this->correctClassname($this->getParam("name")), 'userOwner' => $this->user->getId()]);
     $class->save();
     $this->_helper->json(["success" => true, "id" => $class->getId()]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:6,代码来源:ClassController.php


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