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


PHP Loader\Autoloader类代码示例

本文整理汇总了PHP中Pop\Loader\Autoloader的典型用法代码示例。如果您正苦于以下问题:PHP Autoloader类的具体用法?PHP Autoloader怎么用?PHP Autoloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testRegister

 public function testRegister()
 {
     $a = new Autoloader(false);
     $a->register('Pop', __DIR__ . '/../../../src');
     $this->assertInstanceOf('Pop\\Loader\\Autoloader', $a);
 }
开发者ID:nicksagona,项目名称:PopPHP,代码行数:6,代码来源:LoaderTest.php

示例2: testString

 * @author     Nick Sagona, III <nick@popphp.org>
 * @copyright  Copyright (c) 2009-2014 Moc 10 Media, LLC. (http://www.moc10media.com)
 * @license    http://www.popphp.org/license     New BSD License
 */
/**
 * @namespace
 */
namespace Pop;

use Pop\Loader\Autoloader;
use Pop\Filter\String;
use Pop\Validator;
// Require the library's autoloader.
require_once __DIR__ . '/../../../src/Pop/Loader/Autoloader.php';
// Call the autoloader's bootstrap function.
Autoloader::factory()->splAutoloadRegister();
class StringTest extends \PHPUnit_Framework_TestCase
{
    public $string = 'Hello World';
    public $key = '123456789';
    public function testString()
    {
        $this->assertEquals('hello-world', String::camelCaseToDash('HelloWorld'));
        $this->assertEquals('hello_world', String::camelCaseToUnderscore('HelloWorld'));
        $this->assertEquals('helloWorld', String::dashToCamelCase('hello-world'));
        $this->assertEquals('hello_world', String::dashToUnderscore('hello-world'));
    }
    public function testStringRandom()
    {
        $s = String::random(6);
        $this->assertEquals(6, strlen($s));
开发者ID:nicksagona,项目名称:PopPHP,代码行数:31,代码来源:StringTest.php

示例3: load

 /**
  * Register and load any other modules
  *
  * @param  \Pop\Loader\Autoloader $autoloader
  * @param  boolean                $site
  * @throws Exception
  * @return self
  */
 public function load($autoloader, $site = false)
 {
     if ($site) {
         $s = Table\Sites::getSite();
         $docRoot = $s->document_root;
         $basePath = $s->base_path;
     } else {
         $docRoot = $_SERVER['DOCUMENT_ROOT'];
         $basePath = BASE_PATH;
     }
     $events = array();
     // Load Phire any overriding Phire configuration
     if (!$site) {
         $this->loadAssets(__DIR__ . '/../../../Phire/data', 'Phire', $docRoot);
     }
     // Check if Phire is installed
     self::isInstalled();
     $sess = Session::getInstance();
     $errors = self::checkDirsQuick($docRoot . $basePath . CONTENT_PATH, true, $docRoot);
     if (count($errors) > 0) {
         $sess->errors = '            ' . implode('<br />' . PHP_EOL . '            ', $errors) . PHP_EOL;
     } else {
         unset($sess->errors);
     }
     $modulesAry = array();
     $modulesDirs = array(__DIR__ . '/../../../', __DIR__ . '/../../../../module/', __DIR__ . '/../../../../..' . CONTENT_PATH . '/extensions/modules/');
     // Check for overriding Phire config
     if (file_exists($docRoot . BASE_PATH . CONTENT_PATH . '/extensions/modules/config/phire.php')) {
         $phireCfg = (include $docRoot . BASE_PATH . CONTENT_PATH . '/extensions/modules/config/phire.php');
         if (isset($phireCfg['Phire'])) {
             // If the overriding config is set to allow changes, merge new nav with the original nav
             // else, the entire original nav will be overwritten with the new nav.
             if (isset($phireCfg['Phire']->nav) && $phireCfg['Phire']->changesAllowed()) {
                 $nav = array_merge($phireCfg['Phire']->nav->asArray(), $this->module('Phire')->nav->asArray());
                 $phireCfg['Phire']->nav = new \Pop\Config($nav);
             }
             $this->module('Phire')->merge($phireCfg['Phire']);
             // Get any Phire event
             if (null !== $this->module('Phire')->events) {
                 $events['Phire'] = $this->module('Phire')->events->asArray();
             }
         }
     }
     // Register and load any other modules
     foreach ($modulesDirs as $directory) {
         if (file_exists($directory) && is_dir($directory)) {
             $dir = new Dir($directory);
             $dirs = $dir->getFiles();
             sort($dirs);
             foreach ($dirs as $d) {
                 $moduleCfg = null;
                 if ($d != 'PopPHPFramework' && $d != 'Phire' && $d != 'config' && $d != 'vendor' && is_dir($directory . $d)) {
                     $ext = Table\Extensions::findBy(array('name' => $d));
                     if (!isset($ext->id) || isset($ext->id) && $ext->active) {
                         $modulesAry[] = $d;
                         // Load assets
                         if (!$site) {
                             $this->loadAssets($directory . $d . '/data', $d, $docRoot);
                         }
                         // Get module config
                         if (file_exists($directory . $d . '/config/module.php')) {
                             $moduleCfg = (include $directory . $d . '/config/module.php');
                         }
                         // Check for any module config overrides
                         if (file_exists($directory . '/config/' . strtolower($d) . '.php')) {
                             $override = (include $directory . '/config/' . strtolower($d) . '.php');
                             if (isset($override[$d]) && null !== $moduleCfg) {
                                 $moduleCfg[$d]->merge($override[$d]);
                             }
                         }
                         // Load module configs
                         if (null !== $moduleCfg) {
                             // Register the module source
                             if (file_exists($moduleCfg[$d]->src)) {
                                 $autoloader->register($d, $moduleCfg[$d]->src);
                             }
                             // Get any module events
                             if (null !== $moduleCfg[$d]->events) {
                                 $events[$d] = $moduleCfg[$d]->events->asArray();
                             }
                             $this->loadModule($moduleCfg);
                         }
                     }
                 }
             }
         }
     }
     // Attach any event hooks
     if (count($events) > 0) {
         foreach ($events as $module => $evts) {
             foreach ($evts as $event => $action) {
                 $act = null;
//.........这里部分代码省略.........
开发者ID:akinyeleolubodun,项目名称:PhireCMS2,代码行数:101,代码来源:Project.php


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