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


PHP ClassLoader::addClass方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     $this->import('Config');
     // Load required translation-fields classes
     \ClassLoader::addNamespace('TranslationFields');
     \ClassLoader::addClass('TranslationFields\\TranslationFieldsWidgetHelper', 'system/modules/translation-fields/classes/TranslationFieldsWidgetHelper.php');
     \ClassLoader::addClass('TranslationFields\\TranslationFieldsModel', 'system/modules/translation-fields/models/TranslationFieldsModel.php');
     \ClassLoader::register();
 }
开发者ID:craffft,项目名称:contao-accountmail,代码行数:10,代码来源:Updater.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     // Disable debug mode
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     // Load required classes
     \ClassLoader::addNamespace('Photoalbums2');
     \ClassLoader::addClass('Photoalbums2\\Updater', 'system/modules/photoalbums2/classes/Updater.php');
     \ClassLoader::register();
     // Load updater
     $this->import('\\Photoalbums2\\Updater', 'Updater');
 }
开发者ID:craffft,项目名称:contao-photoalbums2,代码行数:12,代码来源:_runonce.php

示例3: loadResources

 protected function loadResources()
 {
     $contextFile = $this->getContextCacheFile();
     if (!$this->hotDeploy && !$this->oneOffRedeploy && file_exists($contextFile) && (include $contextFile) == true) {
     } else {
         $this->oneOffRedeploy = true;
         // ADD PSR-0 Compliant Classes from the APP
         /*
          * For the application itself we'll piggy back on composer's autoload class map if there's a composer.json
          * present.  If not, the old school method.  It is recommended to use composer though, for real mane.
          *
          */
         if (defined('PATH_ROOT') && file_exists(PATH_ROOT . '/composer.json')) {
             if (!file_exists(PATH_ROOT . '/composer.lock') || !file_exists(PATH_ROOT . '/vendor/composer/autoload_classmap.php')) {
                 throw new Exception('You must run "composer install -o" before booting the application.');
             }
             $classMap = (include PATH_ROOT . '/vendor/composer/autoload_classmap.php');
             foreach ($classMap as $className => $classPath) {
                 ClassLoader::addClass($className, $classPath);
             }
         } else {
             if (defined('PATH_APP') && is_dir(PATH_APP . DIRECTORY_SEPARATOR . 'src')) {
                 ClassLoader::addClassDirectory(PATH_APP . DIRECTORY_SEPARATOR . 'src');
             }
         }
         //add new variable here
         $contextResources = $this->contextResources;
         $configurationLoader = new Configuration();
         foreach ($contextResources as $contextResource) {
             if (!is_dir($contextResource)) {
                 if (file_exists($contextResource) && strrchr($contextResource, '.') === '.xml') {
                     $plugin = array();
                     $plugin['enabled'] = true;
                     $plugin['id'] = basename($contextResource);
                     $plugin['context'] = $this->loadContextFile($configurationLoader, $contextResource);
                     if (array_key_exists('priority', $plugin['context'])) {
                         $plugin['priority'] = $plugin['context']['priority'];
                     } else {
                         $plugin['priority'] = ++$this->lastPriority;
                     }
                     if ($plugin['priority'] > $this->lastPriority) {
                         $this->lastPriority = $plugin['priority'];
                     }
                     $this->plugins[] = $plugin;
                     continue;
                 } else {
                     throw new ApplicationContextException('Context resource does not exist: ' . $contextResource);
                 }
             }
             //LOAD EXPLICIT PLUGIN DIRECTORY (NOT A DIRECTORY OF PLUGIN DIRECTORIES)
             if (file_exists($contextResource . DIRECTORY_SEPARATOR . 'plugin.xml')) {
                 //$this->pluginDirectories[] = $contextResource.DIRECTORY_SEPARATOR;
                 $plugin = $this->loadPluginDirectory($configurationLoader, new SplFileInfo($contextResource), $checkStatus = false);
                 if ($plugin != null) {
                     $this->plugins[] = $plugin;
                 }
             } else {
                 $objects = new DirectoryIterator($contextResource);
                 foreach ($objects as $object) {
                     if (!$object->isDot() && $object->isDir() && substr($object->getFilename(), 0, 1) != '.') {
                         $this->pluginDirectories[] = $object->getPathname() . DIRECTORY_SEPARATOR;
                         $plugin = $this->loadPluginDirectory($configurationLoader, new SplFileInfo($object->getPathname()));
                         if ($plugin != null) {
                             $this->plugins[] = $plugin;
                         }
                     }
                 }
             }
         }
         usort($this->plugins, array(__CLASS__, '_priorityCompare'));
         foreach ($this->plugins as &$plugin) {
             if (!empty($plugin['directory'])) {
                 $this->enabledPluginDirectories[] = $plugin['directory'];
                 $const = $this->getPluginConstant($plugin);
                 if (defined($const) === FALSE) {
                     define($const, $plugin['directory']);
                 }
             }
             if (!empty($plugin['context'])) {
                 $objectsContext = $plugin['context'];
                 if (isset($objectsContext['objects'])) {
                     foreach ((array) $objectsContext['objects'] as $object) {
                         $this->addObjectContext($object);
                     }
                     unset($plugin['context']['objects']);
                 }
                 if (isset($objectsContext['events'])) {
                     foreach ((array) $objectsContext['events'] as $mode => $events) {
                         foreach ($events as $event) {
                             if (strtolower($mode) == 'unbind') {
                                 $this->addUnbindEventContext($event);
                             } else {
                                 $this->addBindEventContext($event);
                             }
                         }
                     }
                     unset($plugin['context']['events']);
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:101,代码来源:ApplicationContext.php


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