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()
        ));
    }
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()
        ));
    }
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 ( ) ) ) ; }
Registers a new plugin from a directory.
@param  \Symfony\Component\Finder\SplFileInfo $pluginClassPath
@throws \Exception
Registers a new plugin from a directory .