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


PHP Loader::autoLoad方法代码示例

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


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

示例1: autoloadClass

 /**
  * If the class isn't already loaded, and an autoloader hasn't been set up
  * for the class (i.e. class not loaded), we will set up our own autoloader
  * for all namespaces and dirs registered and attempt to load the class
  *
  * @param $className
  * @throws Exception
  */
 protected function autoloadClass($className)
 {
     // has the class be loaded?
     if (class_exists($className)) {
         return;
     }
     if (!$this->ourLoader) {
         $this->ourLoader = new Loader();
         $ourLoaderNamespaces = array();
         $ourLoaderDirs = array();
         foreach ($this->namespaces as $ns) {
             if ($ns['ns']) {
                 $ourLoaderNamespaces[$ns['ns']] = $ns['dir'];
             } else {
                 $ourLoaderDirs[] = $ns['dir'];
             }
         }
         $this->ourLoader->registerNamespaces($ourLoaderNamespaces);
         $this->ourLoader->registerDirs($ourLoaderDirs);
     }
     $loaded = $this->ourLoader->autoLoad($className);
     if (!$loaded) {
         throw new \Exception('Unable to load autoload class ' . $className);
     }
 }
开发者ID:aodkrisda,项目名称:phalcon-micro-route-annotations,代码行数:33,代码来源:MicroRouteAnnotations.php

示例2: autoLoad

 /**
  * AutoLoad
  *
  * @param string $className
  */
 function autoLoad($className)
 {
     $array = explode('\\', $className);
     if (array_key_exists($array[0], $this->_namespaces)) {
         $array[0] = $this->_namespaces[$array[0]];
         $class = array_pop($array);
         array_push($array, str_replace("_", DIRECTORY_SEPARATOR, $class));
         $file = implode($array, DIRECTORY_SEPARATOR);
         foreach ($this->_extensions as $ext) {
             if (file_exists($file . ".{$ext}")) {
                 require $file . ".{$ext}";
                 return true;
             }
         }
     }
     //If it did not fit standard PSR-0, pass it on to the original Phalcon autoloader
     parent::autoLoad($className);
 }
开发者ID:sneakybobito,项目名称:incubator,代码行数:23,代码来源:PSR.php

示例3: build

 /**
  * Collects information from input directory
  * Returns collection of all information grabbed from input directory
  *
  * @return array
  */
 public function build()
 {
     if ($this->eventsManager instanceof ManagerInterface) {
         $this->eventsManager->fire('generator:beforeBuild', $this);
     }
     $collections = array();
     $files = $this->setupClassesAutoloader();
     foreach ($files as $className => $file) {
         if (isset($this->options['verbose']) && $this->options['verbose']) {
             echo '# Processing file : ' . $file . PHP_EOL;
         }
         $this->loader->autoLoad($className);
         $collection = $this->getClassCollection($className);
         if (empty($collection)) {
             continue;
         }
         $collections[$className] = $this->getClassCollection($className);
     }
     if ($this->eventsManager instanceof ManagerInterface) {
         $this->eventsManager->fire('generator:afterBuild', $this, $collections);
     }
     return $collections;
 }
开发者ID:vegas-cmf,项目名称:apidoc,代码行数:29,代码来源:Generator.php

示例4: autoLoad

 public function autoLoad($className)
 {
     return parent::autoLoad($className);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Loader.php


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