addPath() public static method

Add a path to the include path.
public static addPath ( string $path, string $prefix = null ) : void
$path string Path to add
$prefix string Prefix to trim off of the requested class name before trying to load the corresponding file
return void
Ejemplo n.º 1
0
 /**
  * Tests that the autoloader can add a path to the include path.
  *
  * @return void
  */
 public function testAddPath()
 {
     $path = dirname(__FILE__);
     Phergie_Autoload::addPath($path);
     $paths = explode(PATH_SEPARATOR, get_include_path());
     $this->assertContains($path, $paths);
 }
Ejemplo n.º 2
0
 /**
  * Tests that the autoloader strips off prefixes given to addPath() from class names before trying to find their
  * corresponding files. If it fails to do that, the class in this test shouldn't be loaded.
  *
  * @return void
  */
 public function testRemovesPrefixFromClassFileName()
 {
     // Fake environment and register autoloader
     $path = dirname(__FILE__) . '/Autoload/_PrefixRemovedFromClassFileNameTest';
     Phergie_Autoload::registerAutoloader();
     Phergie_Autoload::addPath($path, 'Phergie_Prefixed_');
     $this->assertTrue(class_exists('Phergie_Prefixed_Class', true));
 }
Ejemplo n.º 3
0
 /**
  * Constructor to initialize class properties and add the path for core
  * plugins.
  *
  * @param Phergie_Config        $config configuration to pass to any
  *        instantiated plugin
  * @param Phergie_Event_Handler $events event handler to pass to any
  *        instantiated plugin
  *
  * @return void
  */
 public function __construct(Phergie_Config $config, Phergie_Event_Handler $events)
 {
     $this->config = $config;
     $this->events = $events;
     $this->plugins = array();
     $this->paths = array();
     $this->autoload = false;
     if (!empty($config['plugins.paths'])) {
         foreach ($config['plugins.paths'] as $dir => $prefix) {
             $this->addPath($dir, $prefix);
             Phergie_Autoload::addPath($dir, $prefix);
         }
     }
     $this->addPath(dirname(__FILE__), 'Phergie_Plugin_');
 }