本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例4: autoLoad
public function autoLoad($className)
{
return parent::autoLoad($className);
}