/** * Register Bundles * * @param Container $container DI container. * * @return void */ protected function registerBundles(Container $container) { if (!is_dir(WINDWALKER_BUNDLE)) { return; } $paths = new PathCollection(array(WINDWALKER . '/bundles', WINDWALKER_BUNDLE)); $bundles = $paths->find('Bundle$'); $config = $container->get('windwalker.config'); foreach ($bundles as $bundle) { $bundleName = $bundle->getBasename(); $class = $bundleName . '\\' . $bundleName; \JLoader::registerNamespace($bundleName, dirname((string) $bundle)); if (class_exists($class) && is_subclass_of($class, 'Windwalker\\Bundle\\AbstractBundle')) { $config->set('bundle.' . $bundleName, $class); $class::registerProvider($container); } } }
/** * setPrefix description * * @param string * @param string * @param string * * @return string setPrefixReturn * * @since 2.0 */ public function testSetPrefix() { $this->setUp(); $this->collection->addPath('windwalker/dir/foo/bar', 'foo'); $this->collection->addPath('windwalker/dir/yoo/hoo', 'yoo'); $this->collection->setPrefix('/var/www'); $expects = array(Path::clean('/var/www/windwalker/dir/foo/bar'), Path::clean('/var/www/windwalker/dir/yoo/hoo')); $paths = array((string) $this->collection->getPath('foo'), (string) $this->collection->getPath('yoo')); $this->assertEquals($paths, $expects); }
/** * Searches the directory paths for a given file. * * @param mixed $paths An path string or array of path strings to search in * @param string $file The file name to look for. * * @return mixed The full path and file name for the target file, or boolean false if the file is not found in any of the paths. * * @since 2.0 */ public static function find($paths, $file) { /** * Files callback * * @param \SplFileInfo $current Current item's value * @param string $key Current item's key * @param \RecursiveDirectoryIterator $iterator Iterator being filtered * * @return boolean TRUE to accept the current item, FALSE otherwise */ $filter = function ($current, $key, $iterator) use($file) { return $current->getBasename() == $file; }; $collection = new PathCollection($paths); return $collection->findOne($filter); }
/** * test__construct description * * @param string * @param string * @param string * * @return string test__constructReturn * * @since 1.0 */ public function test__construct() { $collections = new PathCollection('/var/www/foo/bar'); $paths = $collections->getPaths(); $this->assertEquals(array(new PathLocator('/var/www/foo/bar')), $paths); }