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


PHP Pimcore::getDiContainer方法代码示例

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


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

示例1: getTotalCount

 /**
  * @param array $config
  * @return total count
  */
 public static function getTotalCount($config = [])
 {
     if (is_array($config)) {
         $listClass = "Pimcore\\Model\\Asset\\Listing";
         $list = \Pimcore::getDiContainer()->make($listClass);
         $list->setValues($config);
         $count = $list->getTotalCount();
         return $count;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:14,代码来源:Asset.php

示例2: getTotalCount

 /**
  * @param array $config
  * @return total count
  */
 public static function getTotalCount($config = [])
 {
     $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";
             $list = \Pimcore::getDiContainer()->make($listClass);
         }
         $list->setValues($config);
         $count = $list->getTotalCount();
         return $count;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:25,代码来源:AbstractObject.php

示例3: createObjectConcrete

 /**
  * @param $wsDocument
  * @throws \Exception
  */
 public function createObjectConcrete($wsDocument)
 {
     try {
         if ($wsDocument instanceof Webservice\Data\Object\Concrete\In) {
             $className = "Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className);
             $object = \Pimcore::getDiContainer()->make($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} ]");
             }
         }
         throw new \Exception("Unable to create new Object Concrete.");
     } catch (\Exception $e) {
         \Logger::error($e);
         throw $e;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:22,代码来源:Service.php

示例4: addAction

 public function addAction()
 {
     $success = false;
     $className = "Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     $parent = Object::getById($this->getParam("parentId"));
     $message = "";
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getRealFullPath() . "/" . $this->getParam("key");
         if (!Object\Service::pathExists($intendedPath)) {
             $object = \Pimcore::getDiContainer()->make($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(["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(["success" => $success, "id" => $object->getId(), "type" => $object->getType(), "message" => $message]);
     } else {
         $this->_helper->json(["success" => $success, "message" => $message]);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:51,代码来源:ObjectController.php

示例5: classSaved

 /**
  * @return void
  */
 public function classSaved($class)
 {
     $temp = \Pimcore::getDiContainer()->make('Pimcore\\Model\\Object\\Data\\ElementMetadata', ["fieldname" => null]);
     $temp->getDao()->createOrUpdateTable($class);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:8,代码来源:MultihrefMetadata.php

示例6: getInstance

 /**
  * @return null|Adapter\GD|Adapter\Imagick
  * @throws \Exception
  */
 public static function getInstance()
 {
     $adapter = \Pimcore::getDiContainer()->make(Image\Adapter::class);
     return $adapter;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:9,代码来源:Image.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;
     } elseif ($wsDocument->type == "object" || $wsDocument->type == "variant") {
         $classname = "Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className);
         $object = \Pimcore::getDiContainer()->make($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} ]");
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:39,代码来源:RestClient.php

示例8: getModelClassMapping

 /**
  * @static
  * @param  $sourceClassName
  * @return string
  *
  * @deprecated
  */
 public static function getModelClassMapping($sourceClassName)
 {
     try {
         return get_class(\Pimcore::getDiContainer()->get($sourceClassName));
     } catch (\Exception $ex) {
     }
     return $sourceClassName;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:15,代码来源:Tool.php

示例9: 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];
         } elseif ($map[1] == "published (system)") {
             $mapping["published"] = $map[0];
         } elseif ($map[1] == "type (system)") {
             $mapping["type"] = $map[0];
         }
     }
     // create new object
     $className = "Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     $parent = Object::getById($this->getParam("parentId"));
     $objectKey = "object_" . $job;
     if ($this->getParam("filename") == "id") {
         $objectKey = null;
     } elseif ($this->getParam("filename") != "default") {
         $objectKey = Element\Service::getValidKey($data[$this->getParam("filename")], "object");
     }
     $overwrite = false;
     if ($this->getParam("overwrite") == "true") {
         $overwrite = true;
     }
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getRealFullPath() . "/" . $objectKey;
         if ($overwrite) {
             $object = Object::getByPath($intendedPath);
             if (!$object instanceof Object\Concrete) {
                 //create new object
                 $object = \Pimcore::getDiContainer()->make($className);
             } elseif ($object instanceof Object\Concrete and !$object instanceof $className) {
                 //delete the old object it is of a different class
                 $object->delete();
                 $object = \Pimcore::getDiContainer()->make($className);
             } elseif ($object instanceof Object\Folder) {
                 //delete the folder
                 $object->delete();
                 $object = \Pimcore::getDiContainer()->make($className);
             } else {
                 //use the existing object
             }
         } else {
             $counter = 1;
             while (Object::getByPath($intendedPath) != null) {
                 $objectKey .= "_" . $counter;
                 $intendedPath = $parent->getRealFullPath() . "/" . $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());
         if (in_array($data[$mapping["type"]], ["object", "variant"])) {
             $object->setType($data[$mapping["type"]]);
         } else {
             $object->setType("object");
         }
         if ($data[$mapping["published"]] === "1") {
             $object->setPublished(true);
         } else {
             $object->setPublished(false);
         }
         foreach ($class->getFieldDefinitions() as $key => $field) {
//.........这里部分代码省略.........
开发者ID:pimcore,项目名称:pimcore,代码行数:101,代码来源:ObjectHelperController.php


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