/** * @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::supports */ public function testSupports() { $loader = new IniFileLoader(new ContainerBuilder(), new FileLocator()); $this->assertTrue($loader->supports('foo.ini'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); }
/** * Registers a new plugin from a directory. * @param \Symfony\Component\Finder\SplFileInfo $pluginClassPath * @throws \Exception */ protected function registerPlugin(SplFileInfo $pluginClassPath) { $pluginName = preg_replace('/Plugin\\.php$/', '', $pluginClassPath->getFilename()); $pluginClass = sprintf('Ladybug\\Plugin\\%s\\%sPlugin', $pluginName, $pluginName); $file = $pluginClass::getConfigFile(); $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $dir = pathinfo($file, PATHINFO_DIRNAME); $filename = pathinfo($file, PATHINFO_FILENAME); switch ($extension) { case 'xml': $loader = new Loader\XmlFileLoader($this->container, new FileLocator($dir)); break; case 'yml': $loader = new Loader\YamlFileLoader($this->container, new FileLocator($dir)); break; case 'php': $loader = new Loader\PhpFileLoader($this->container, new FileLocator($dir)); break; case 'ini': $loader = new Loader\IniFileLoader($this->container, new FileLocator($dir)); break; default: throw new \Exception('Invalid config file'); } $loader->load($filename . '.' . $extension); // helpers $this->container->setParameter('helpers', array_merge($this->container->getParameter('helpers'), $pluginClass::registerHelpers())); }