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


PHP Tool::getModelClassMapping方法代码示例

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


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

示例1: classSaved

 /**
  * @return void
  */
 public function classSaved($class)
 {
     $className = Tool::getModelClassMapping('\\Pimcore\\Model\\Object\\Data\\ObjectMetadata');
     $temp = new $className(null);
     $temp->getResource()->createOrUpdateTable($class);
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:9,代码来源:ObjectsMetadata.php

示例2: addAction

 public function addAction()
 {
     $success = false;
     $className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     // check for a mapped class
     $className = Tool::getModelClassMapping($className);
     $parent = Object::getById($this->getParam("parentId"));
     $message = "";
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getFullPath() . "/" . $this->getParam("key");
         if (!Object\Service::pathExists($intendedPath) || true) {
             $object = new $className();
             if ($object instanceof Object\Concrete) {
                 $object->setOmitMandatoryCheck(true);
                 // allow to save the object although there are mandatory fields
             }
             if ($this->getParam("variantViaTree")) {
                 $parentId = $this->getParam("parentId");
                 $parent = Object::getById($parentId);
                 $object->setClassId($parent->getClass()->getId());
             } else {
                 $object->setClassId($this->getParam("classId"));
             }
             $object->setClassName($this->getParam("className"));
             $object->setParentId($this->getParam("parentId"));
             $object->setKey($this->getParam("key"));
             $object->setCreationDate(time());
             $object->setUserOwner($this->getUser()->getId());
             $object->setUserModification($this->getUser()->getId());
             $object->setPublished(false);
             if ($this->getParam("objecttype") == Object\AbstractObject::OBJECT_TYPE_OBJECT || $this->getParam("objecttype") == Object\AbstractObject::OBJECT_TYPE_VARIANT) {
                 $object->setType($this->getParam("objecttype"));
             }
             try {
                 $object->save();
                 $success = true;
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         } else {
             $message = "prevented creating object because object with same path+key already exists";
             \Logger::debug($message);
         }
     } else {
         $message = "prevented adding object because of missing permissions";
         \Logger::debug($message);
     }
     if ($success) {
         $this->_helper->json(array("success" => $success, "id" => $object->getId(), "type" => $object->getType(), "message" => $message));
     } else {
         $this->_helper->json(array("success" => $success, "message" => $message));
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:53,代码来源:ObjectController.php

示例3: importProcessAction

 public function importProcessAction()
 {
     $success = true;
     $parentId = $this->getParam("parentId");
     $job = $this->getParam("job");
     $id = $this->getParam("id");
     $mappingRaw = \Zend_Json::decode($this->getParam("mapping"));
     $class = Object\ClassDefinition::getById($this->getParam("classId"));
     $skipFirstRow = $this->getParam("skipHeadRow") == "true";
     $fields = $class->getFieldDefinitions();
     $file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
     // currently only csv supported
     // determine type
     $dialect = Tool\Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
     $count = 0;
     if (($handle = fopen($file, "r")) !== false) {
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     if ($skipFirstRow && $job == 1) {
         //read the next row, we need to skip the head row
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     $tmpFile = $file . "_tmp";
     $tmpHandle = fopen($tmpFile, "w+");
     while (!feof($handle)) {
         $buffer = fgets($handle);
         fwrite($tmpHandle, $buffer);
     }
     fclose($handle);
     fclose($tmpHandle);
     unlink($file);
     rename($tmpFile, $file);
     // prepare mapping
     foreach ($mappingRaw as $map) {
         if ($map[0] !== "" && $map[1] && !empty($map[2])) {
             $mapping[$map[2]] = $map[0];
         } else {
             if ($map[1] == "published (system)") {
                 $mapping["published"] = $map[0];
             } else {
                 if ($map[1] == "type (system)") {
                     $mapping["type"] = $map[0];
                 }
             }
         }
     }
     // create new object
     $className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     $className = Tool::getModelClassMapping($className);
     $parent = Object::getById($this->getParam("parentId"));
     $objectKey = "object_" . $job;
     if ($this->getParam("filename") == "id") {
         $objectKey = null;
     } else {
         if ($this->getParam("filename") != "default") {
             $objectKey = File::getValidFilename($data[$this->getParam("filename")]);
         }
     }
     $overwrite = false;
     if ($this->getParam("overwrite") == "true") {
         $overwrite = true;
     }
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getFullPath() . "/" . $objectKey;
         if ($overwrite) {
             $object = Object::getByPath($intendedPath);
             if (!$object instanceof Object\Concrete) {
                 //create new object
                 $object = new $className();
             } else {
                 if ($object instanceof Object\Concrete and !$object instanceof $className) {
                     //delete the old object it is of a different class
                     $object->delete();
                     $object = new $className();
                 } else {
                     if ($object instanceof Object\Folder) {
                         //delete the folder
                         $object->delete();
                         $object = new $className();
                     } else {
                         //use the existing object
                     }
                 }
             }
         } else {
             $counter = 1;
             while (Object::getByPath($intendedPath) != null) {
                 $objectKey .= "_" . $counter;
                 $intendedPath = $parent->getFullPath() . "/" . $objectKey;
                 $counter++;
             }
             $object = new $className();
         }
         $object->setClassId($this->getParam("classId"));
         $object->setClassName($this->getParam("className"));
         $object->setParentId($this->getParam("parentId"));
         $object->setKey($objectKey);
         $object->setCreationDate(time());
         $object->setUserOwner($this->getUser()->getId());
         $object->setUserModification($this->getUser()->getId());
//.........这里部分代码省略.........
开发者ID:cannonerd,项目名称:pimcore,代码行数:101,代码来源:ObjectHelperController.php

示例4: createObjectConcrete

 /**
  * @param $wsDocument
  * @throws \Exception
  */
 public function createObjectConcrete($wsDocument)
 {
     try {
         if ($wsDocument instanceof Webservice\Data\Object\Concrete\In) {
             $classname = Tool::getModelClassMapping("\\Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className));
             if (Tool::classExists($classname)) {
                 $object = new $classname();
                 if ($object instanceof Object\Concrete) {
                     return $this->create($wsDocument, $object);
                 } else {
                     throw new \Exception("Unable to create new Object Concrete, could not instantiate Object with given class name [ {$classname} ]");
                 }
             } else {
                 throw new \Exception("Unable to create new Object Concrete, no class name provided");
             }
         }
         throw new \Exception("Unable to create new Object Concrete.");
     } catch (\Exception $e) {
         \Logger::error($e);
         throw $e;
     }
 }
开发者ID:Ahmad-Hilali,项目名称:pimcore,代码行数:26,代码来源:Service.php

示例5: getTotalCount

 /**
  * @param array $config
  * @return total count
  */
 public static function getTotalCount($config = array())
 {
     $className = "\\Pimcore\\Model\\Object";
     // get classname
     if (get_called_class() != "Pimcore\\Model\\Object\\AbstractObject" && get_called_class() != "Pimcore\\Model\\Object\\Concrete") {
         $tmpObject = new static();
         $className = "\\Pimcore\\Model\\Object\\" . ucfirst($tmpObject->getClassName());
     }
     if (!empty($config["class"])) {
         $className = "\\" . ltrim($config["class"], "\\");
     }
     if (is_array($config)) {
         if ($className) {
             $listClass = ucfirst($className) . "\\Listing";
             // check for a mapped class
             $listClass = Tool::getModelClassMapping($listClass);
             if (Tool::classExists($listClass)) {
                 $list = new $listClass();
             }
         }
         $list->setValues($config);
         $count = $list->getTotalCount();
         return $count;
     }
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:29,代码来源:AbstractObject.php

示例6: getTotalCount

 /**
  * @param array $config
  * @return total count
  */
 public static function getTotalCount($config = array())
 {
     if (is_array($config)) {
         $listClass = "\\Pimcore\\Model\\Document\\Listing";
         $listClass = Tool::getModelClassMapping($listClass);
         $list = new $listClass();
         $list->setValues($config);
         $count = $list->getTotalCount();
         return $count;
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:15,代码来源:Document.php

示例7: getObjectById

 public function getObjectById($id, $decode = true, $idMapper = null)
 {
     $url = $this->buildEndpointUrl("object/id/" . $id);
     if ($this->getEnableProfiling()) {
         $this->profilingInfo = null;
         $url .= "&profiling=1";
     }
     if ($this->getCondense()) {
         $url .= "&condense=1";
     }
     $response = $this->doRequest($url, "GET");
     if ($this->getEnableProfiling()) {
         $this->profilingInfo = $response->profiling;
     }
     $response = $response->data;
     $wsDocument = $this->fillWebserviceData("\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In", $response);
     if (!$decode) {
         return $wsDocument;
     }
     if ($wsDocument->type == "folder") {
         $object = new Object\Folder();
         $wsDocument->reverseMap($object);
         return $object;
     } else {
         if ($wsDocument->type == "object" || $wsDocument->type == "variant") {
             $classname = "\\Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className);
             // check for a mapped class
             $classname = Tool::getModelClassMapping($classname);
             if (Tool::classExists($classname)) {
                 $object = new $classname();
                 if ($object instanceof Object\Concrete) {
                     $curTime = microtime(true);
                     $wsDocument->reverseMap($object, $this->getDisableMappingExceptions(), $idMapper);
                     $timeConsumed = round(microtime(true) - $curTime, 3) * 1000;
                     if ($this->profilingInfo) {
                         $this->profilingInfo->reverse = $timeConsumed;
                     }
                     return $object;
                 } else {
                     throw new Exception("Unable to decode object, could not instantiate Object with given class name [ {$classname} ]");
                 }
             } else {
                 throw new Exception("Unable to deocode object, class [" . $classname . "] does not exist");
             }
         }
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:47,代码来源:RestClient.php


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