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


PHP Pimcore_Tool::classExists方法代码示例

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


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

示例1: createClassMappings

 /**
  * @static
  * @return array
  */
 public static function createClassMappings()
 {
     $modelsDir = PIMCORE_PATH . "/models/";
     $files = rscandir($modelsDir);
     $includePatterns = array("/Webservice\\/Data/");
     foreach ($files as $file) {
         if (is_file($file)) {
             $file = str_replace($modelsDir, "", $file);
             $file = str_replace(".php", "", $file);
             $class = str_replace(DIRECTORY_SEPARATOR, "_", $file);
             if (Pimcore_Tool::classExists($class)) {
                 $match = false;
                 foreach ($includePatterns as $pattern) {
                     if (preg_match($pattern, $file)) {
                         $match = true;
                         break;
                     }
                 }
                 if (strpos($file, "Webservice" . DIRECTORY_SEPARATOR . "Data") !== false) {
                     $match = true;
                 }
                 if (!$match) {
                     continue;
                 }
                 $classMap[str_replace("Webservice_Data_", "", $class)] = $class;
             }
         }
     }
     return $classMap;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:34,代码来源:Tool.php

示例2: generateLayoutTreeFromArray

 public static function generateLayoutTreeFromArray($array)
 {
     if (is_array($array) && count($array) > 0) {
         $class = "Object_Class_" . ucfirst($array["datatype"]) . "_" . ucfirst($array["fieldtype"]);
         if (Pimcore_Tool::classExists($class)) {
             $item = new $class();
             if (method_exists($item, "addChild")) {
                 // allows childs
                 $item->setValues($array, array("childs"));
                 if ($array["childs"]["datatype"]) {
                     $childO = self::generateLayoutTreeFromArray($array["childs"]);
                     $item->addChild($childO);
                 } else {
                     if (is_array($array["childs"]) && count($array["childs"]) > 0) {
                         foreach ($array["childs"] as $child) {
                             $childO = self::generateLayoutTreeFromArray($child);
                             $item->addChild($childO);
                         }
                     }
                 }
             } else {
                 $item->setValues($array);
             }
             return $item;
         }
     }
     return false;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:28,代码来源:Service.php

示例3: map

 /**
  * @static
  * @param Element_Interface $object
  * @param string $type  "in" or "out"
  * @param  string $class
  * @return array
  */
 public static function map($object, $apiclass, $type)
 {
     if ($object instanceof Zend_Date) {
         $object = $object->toString();
     } else {
         if (is_object($object)) {
             if (Pimcore_Tool::classExists($apiclass)) {
                 $new = new $apiclass();
                 if (method_exists($new, "map")) {
                     $new->map($object);
                     $object = $new;
                 }
             } else {
                 throw new Exception("Webservice_Data_Mapper: Cannot map [ {$apiclass} ] - class does not exist");
             }
         } else {
             if (is_array($object)) {
                 $tmpArray = array();
                 foreach ($object as $v) {
                     $className = self::findWebserviceClass($v, $type);
                     $tmpArray[] = self::map($v, $className, $type);
                 }
                 $object = $tmpArray;
             }
         }
     }
     return $object;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:35,代码来源:Mapper.php

示例4: registerModule

 /**
  * @param string $module
  * @return void
  */
 public function registerModule($module)
 {
     if (Pimcore_Tool::classExists($module)) {
         $this->_systemModules[] = new $module();
     } else {
         throw new Exception("unknown module [ {$module} ].");
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:12,代码来源:Broker.php

示例5: getInstance

 /**
  * @static
  * @return null|Pimcore_Video_Adapter
  */
 public static function getInstance($adapter = null)
 {
     try {
         if ($adapter) {
             $adapterClass = "Pimcore_Video_Adapter_" . $adapter;
             if (Pimcore_Tool::classExists($adapterClass)) {
                 return new $adapterClass();
             } else {
                 throw new Exception("Video-transcode adapter `" . $adapter . "´ does not exist.");
             }
         } else {
             return new Pimcore_Video_Adapter_Ffmpeg();
         }
     } catch (Exception $e) {
         Logger::crit("Unable to load video adapter: " . $e->getMessage());
         throw $e;
     }
     return null;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:23,代码来源:Video.php

示例6: getInstance

 /**
  * @static
  * @return null|Pimcore_Image_Adapter
  */
 public static function getInstance($adapter = null)
 {
     try {
         if ($adapter) {
             $adapterClass = "Pimcore_Image_Adapter_" . $adapter;
             if (Pimcore_Tool::classExists($adapterClass)) {
                 return new $adapterClass();
             } else {
                 throw new Exception("Image-transform adapter `" . $adapter . "´ does not exist.");
             }
         } else {
             if (extension_loaded("imagick")) {
                 return new Pimcore_Image_Adapter_Imagick();
             } else {
                 return new Pimcore_Image_Adapter_GD();
             }
         }
     } catch (Exception $e) {
         Logger::crit("Unable to load image extensions: " . $e->getMessage());
         throw $e;
     }
     return null;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:27,代码来源:Image.php

示例7: reverseMap

 public function reverseMap($object, $disableMappingExceptions = false)
 {
     $keys = get_object_vars($this);
     foreach ($keys as $key => $value) {
         $method = "setO_" . $key;
         if (method_exists($object, $method)) {
             $object->{$method}($value);
         }
     }
     //must be after generic setters above!!
     parent::reverseMap($object, $disableMappingExceptions);
     if (is_array($this->elements)) {
         foreach ($this->elements as $element) {
             $class = "Object_Class_Data_" . ucfirst($element->type);
             if (Pimcore_Tool::classExists($class)) {
                 $setter = "set" . ucfirst($element->name);
                 if (method_exists($object, $setter)) {
                     $tag = $object->getO_class()->getFieldDefinition($element->name);
                     if ($class instanceof Object_Class_Data_Fieldcollections) {
                         $object->{$setter}($tag->getFromWebserviceImport($element->fieldcollection));
                     } else {
                         $object->{$setter}($tag->getFromWebserviceImport($element->value, $object));
                     }
                 } else {
                     if (!$disableMappingExceptions) {
                         throw new Exception("Unable to reverse map element [ " . $element->name . " ] of type [ " . $element->type . " ]. Setter not found");
                     }
                 }
             } else {
                 if (!$disableMappingExceptions) {
                     throw new Exception("Unable to reverse map element [ " . $element->name . " ] of type [ " . $element->type . " ]. Object_Class_Data type not found. ");
                 }
             }
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:36,代码来源:Concrete.php

示例8: getObjectList

 /**
  * @param string $condition
  * @param string $order
  * @param string $orderKey
  * @param string $offset
  * @param string $limit
  * @param string $groupBy
  * @param string $objectClass
  * @return Webservice_Data_Object_List_Item[]
  */
 public function getObjectList($condition = null, $order = null, $orderKey = null, $offset = null, $limit = null, $groupBy = null, $objectClass = null)
 {
     try {
         $params = array();
         if (!empty($condition)) {
             $params["condition"] = $condition;
         }
         if (!empty($order)) {
             $params["order"] = $order;
         }
         if (!empty($orderKey)) {
             $params["orderKey"] = $orderKey;
         }
         if (!empty($offset)) {
             $params["offset"] = $offset;
         }
         if (!empty($limit)) {
             $params["limit"] = $limit;
         }
         if (!empty($groupBy)) {
             $params["groupBy"] = $groupBy;
         }
         $listClassName = "Object_Abstract";
         if (!empty($objectClass)) {
             $listClassName = "Object_" . ucfirst($objectClass);
             if (!Pimcore_Tool::classExists($listClassName)) {
                 $listClassName = "Object_Abstract";
             }
         }
         $list = $listClassName::getList($params);
         $items = array();
         foreach ($list as $object) {
             $item = new Webservice_Data_Object_List_Item();
             $item->id = $object->getId();
             $item->type = $object->getType();
             $items[] = $item;
         }
         return $items;
     } catch (Exception $e) {
         Logger::error($e);
         throw $e;
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:53,代码来源:Service.php

示例9: create

 /**
  * @throws Exception
  * @param  $rootElement
  * @param  $apiKey
  * @param  $path
  * @param  $apiElement
  * @param  bool $overwrite
  * @param  $elementCounter
  * @return Element_Interface
  */
 public function create($rootElement, $apiKey, $path, $apiElement, $overwrite, $elementCounter)
 {
     //correct relative path
     if (strpos($path, "/") !== 0) {
         $path = $rootElement->getFullPath() . "/" . $path;
     }
     $type = $apiElement->type;
     if ($apiElement instanceof Webservice_Data_Asset) {
         $className = "Asset_" . ucfirst($type);
         $parentClassName = "Asset";
         $maintype = "asset";
         $fullPath = $path . $apiElement->filename;
     } else {
         if ($apiElement instanceof Webservice_Data_Object) {
             $maintype = "object";
             if ($type == "object") {
                 $className = "Object_" . ucfirst($apiElement->className);
                 if (!Pimcore_Tool::classExists($className)) {
                     throw new Exception("Unknown class [ " . $className . " ]");
                 }
             } else {
                 $className = "Object_" . ucfirst($type);
             }
             $parentClassName = "Object_Abstract";
             $fullPath = $path . $apiElement->key;
         } else {
             if ($apiElement instanceof Webservice_Data_Document) {
                 $maintype = "document";
                 $className = "Document_" . ucfirst($type);
                 $parentClassName = "Document";
                 $fullPath = $path . $apiElement->key;
             } else {
                 throw new Exception("Unknown import element");
             }
         }
     }
     $existingElement = $className::getByPath($fullPath);
     if ($overwrite && $existingElement) {
         $apiElement->parentId = $existingElement->getParentId();
         return $existingElement;
     }
     $element = new $className();
     $element->setId(null);
     $element->setCreationDate(time());
     if ($element instanceof Asset) {
         $element->setFilename($apiElement->filename);
         $element->setData(base64_decode($apiElement->data));
     } else {
         if ($element instanceof Object_Concrete) {
             $element->setKey($apiElement->key);
             $element->setO_className($apiElement->className);
             $class = Object_Class::getByName($apiElement->className);
             if (!$class instanceof Object_Class) {
                 throw new Exception("Unknown object class [ " . $apiElement->className . " ] ");
             }
             $element->setO_classId($class->getId());
         } else {
             $element->setKey($apiElement->key);
         }
     }
     $this->setModificationParams($element, true);
     $key = $element->getKey();
     if (empty($key) and $apiElement->id == 1) {
         if ($element instanceof Asset) {
             $element->setFilename("home_" . uniqid());
         } else {
             $element->setKey("home_" . uniqid());
         }
     } else {
         if (empty($key)) {
             throw new Exception("Cannot create element without key ");
         }
     }
     $parent = $parentClassName::getByPath($path);
     if (Element_Service::getType($rootElement) == $maintype and $parent) {
         $element->setParentId($parent->getId());
         $apiElement->parentId = $parent->getId();
         $existingElement = $parentClassName::getByPath($parent->getFullPath() . "/" . $element->getKey());
         if ($existingElement) {
             //set dummy key to avoid duplicate paths
             if ($element instanceof Asset) {
                 $element->setFilename(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getFilename());
             } else {
                 $element->setKey(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getKey());
             }
         }
     } else {
         if (Element_Service::getType($rootElement) != $maintype) {
             //this is a related element - try to import it to it's original path or set the parent to home folder
             $potentialParent = $parentClassName::getByPath($path);
//.........这里部分代码省略.........
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Service.php

示例10: getList

 /**
  * @param array $config
  * @return Object_List
  */
 public static function getList($config = array())
 {
     $className = "Object";
     // get classname
     if (get_called_class() != "Object_Abstract" && get_called_class() != "Object_Concrete") {
         $tmpObject = new static();
         $className = "Object_" . ucfirst($tmpObject->getO_className());
     }
     if (!empty($config["class"])) {
         $className = $config["class"];
     }
     //echo $className;exit;
     if (is_array($config)) {
         if ($className) {
             $listClass = ucfirst($className) . "_List";
             // check for a mapped class
             $listClass = Pimcore_Tool::getModelClassMapping($listClass);
             if (Pimcore_Tool::classExists($listClass)) {
                 $list = new $listClass();
             }
         }
         $list->setValues($config);
         $list->load();
         return $list;
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:30,代码来源:Abstract.php

示例11: load

 public function load($object, $params = array())
 {
     $classname = "Object_" . ucfirst($object->getClass()->getName()) . "_" . ucfirst($this->getName());
     if (Pimcore_Tool::classExists($classname)) {
         $container = new $classname($object, $this->getName());
         $container->load($object);
         return $container;
     } else {
         return null;
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:11,代码来源:Objectbricks.php

示例12: initPlugins

 public static function initPlugins()
 {
     // add plugin include paths
     $autoloader = Zend_Loader_Autoloader::getInstance();
     try {
         $pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs();
         if (!empty($pluginConfigs)) {
             $includePaths = array(get_include_path());
             //adding plugin include paths and namespaces
             if (count($pluginConfigs) > 0) {
                 foreach ($pluginConfigs as $p) {
                     if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                         continue;
                     }
                     if (is_array($p['plugin']['pluginIncludePaths']['path'])) {
                         foreach ($p['plugin']['pluginIncludePaths']['path'] as $path) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $path;
                         }
                     } else {
                         if ($p['plugin']['pluginIncludePaths']['path'] != null) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $p['plugin']['pluginIncludePaths']['path'];
                         }
                     }
                     if (is_array($p['plugin']['pluginNamespaces']['namespace'])) {
                         foreach ($p['plugin']['pluginNamespaces']['namespace'] as $namespace) {
                             $autoloader->registerNamespace($namespace);
                         }
                     } else {
                         if ($p['plugin']['pluginNamespaces']['namespace'] != null) {
                             $autoloader->registerNamespace($p['plugin']['pluginNamespaces']['namespace']);
                         }
                     }
                 }
             }
             set_include_path(implode(PATH_SEPARATOR, $includePaths));
             $broker = Pimcore_API_Plugin_Broker::getInstance();
             //registering plugins
             foreach ($pluginConfigs as $p) {
                 if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                     continue;
                 }
                 $jsPaths = array();
                 if (is_array($p['plugin']['pluginJsPaths']['path'])) {
                     $jsPaths = $p['plugin']['pluginJsPaths']['path'];
                 } else {
                     if ($p['plugin']['pluginJsPaths']['path'] != null) {
                         $jsPaths[0] = $p['plugin']['pluginJsPaths']['path'];
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($jsPaths) and count($jsPaths) > 0) {
                     for ($i = 0; $i < count($jsPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) {
                             $jsPaths[$i] = "/plugins" . $jsPaths[$i];
                         }
                     }
                 }
                 $cssPaths = array();
                 if (is_array($p['plugin']['pluginCssPaths']['path'])) {
                     $cssPaths = $p['plugin']['pluginCssPaths']['path'];
                 } else {
                     if ($p['plugin']['pluginCssPaths']['path'] != null) {
                         $cssPaths[0] = $p['plugin']['pluginCssPaths']['path'];
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($cssPaths) and count($cssPaths) > 0) {
                     for ($i = 0; $i < count($cssPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) {
                             $cssPaths[$i] = "/plugins" . $cssPaths[$i];
                         }
                     }
                 }
                 try {
                     $className = $p['plugin']['pluginClassName'];
                     if (!empty($className) && Pimcore_Tool::classExists($className)) {
                         $plugin = new $className($jsPaths, $cssPaths);
                         if ($plugin instanceof Pimcore_API_Plugin_Abstract) {
                             $broker->registerPlugin($plugin);
                         }
                     }
                 } catch (Exeption $e) {
                     Logger::err("Could not instantiate and register plugin [" . $p['plugin']['pluginClassName'] . "]");
                 }
             }
             Zend_Registry::set("Pimcore_API_Plugin_Broker", $broker);
         }
     } catch (Exception $e) {
         Logger::alert("there is a problem with the plugin configuration");
         Logger::alert($e);
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:92,代码来源:Pimcore.php

示例13: determineResourceClass

 protected function determineResourceClass($className)
 {
     $fileToInclude = str_replace("_", "/", $className) . ".php";
     if (Pimcore_File::isIncludeable($fileToInclude)) {
         include_once $fileToInclude;
         if (Pimcore_Tool::classExists($className)) {
             return $className;
         }
     } else {
         Logger::debug("Couldn't find resource implementation " . $className . " for " . get_class($this));
     }
     return;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:13,代码来源:Abstract.php

示例14: __call

 /**
  * @throws Exception
  * @param $method
  * @param $arguments
  * @return mixed|string|Tag
  */
 public function __call($method, $arguments)
 {
     $class = "Document_Tag_" . ucfirst(strtolower($method));
     $tagFile = str_replace("_", "/", $class) . ".php";
     if (Pimcore_File::isIncludeable($tagFile)) {
         include_once $tagFile;
         if (@Pimcore_Tool::classExists($class)) {
             if (!isset($arguments[0])) {
                 throw new Exception("You have to set a name for the called tag (editable): " . $method);
             }
             // set default if there is no editable configuration provided
             if (!isset($arguments[1])) {
                 $arguments[1] = array();
             }
             return $this->tag($method, $arguments[0], $arguments[1]);
         }
     }
     if ($this->document instanceof Document) {
         if (method_exists($this->document, $method)) {
             return call_user_func_array(array($this->document, $method), $arguments);
         }
     }
     return parent::__call($method, $arguments);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:30,代码来源:View.php

示例15: getById

 /**
  * Static helper to get an asset by the passed id (returned is not the concrete asset like Asset_Folder!)
  *
  * @param integer $id
  * @return Asset
  */
 public static function getById($id)
 {
     $id = intval($id);
     if ($id < 1) {
         return null;
     }
     $cacheKey = "asset_" . $id;
     try {
         $asset = Zend_Registry::get($cacheKey);
         if (!$asset) {
             throw new Exception("Asset in registry is null");
         }
     } catch (Exception $e) {
         try {
             if (!($asset = Pimcore_Model_Cache::load($cacheKey))) {
                 $asset = new Asset();
                 $asset->getResource()->getById($id);
                 $typeClass = "Asset_" . ucfirst($asset->getType());
                 $typeClass = Pimcore_Tool::getModelClassMapping($typeClass);
                 if (Pimcore_Tool::classExists($typeClass)) {
                     $asset = new $typeClass();
                     Zend_Registry::set($cacheKey, $asset);
                     $asset->getResource()->getById($id);
                     Pimcore_Model_Cache::save($asset, $cacheKey);
                 }
             } else {
                 Zend_Registry::set($cacheKey, $asset);
             }
         } catch (Exception $e) {
             Logger::warning($e);
             return null;
         }
     }
     if (!$asset) {
         return null;
     }
     return $asset;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:44,代码来源:Asset.php


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