src/Smf/Menu/Config/Extension.php
public function loadConfiguration()
    {
        $builder = $this->getContainerBuilder();
        $config = $this->getConfig($this->defaults);

        // Create instance of extension
        $menuFactory = $builder->addDefinition($this->prefix('extension'))
            ->setClass('Smf\Menu\MenuExtension');

        // Create instance of menufactory
        $menuFactory = $builder->addDefinition($this->prefix('factory'))
            ->addSetup('addExtension', array($this->prefix('@extension')))
            ->setClass('Knp\Menu\MenuFactory');

        // Create renderers manager
        $rendererManager = $builder->addDefinition($this->prefix('rendererManager'))
            ->setClass('Smf\Menu\Renderer\Manager')
            ->addSetup(get_called_class() . '::setupRenderers', array('@self', '@container'))
            ->addSetup('setDefaultRenderer', array($config['defaultRenderer']));;

        // Create a factory for control
        $builder->addDefinition($this->prefix('controlFactory'))
            ->setClass('Smf\Menu\Control\Factory', array($menuFactory, $rendererManager));

        // Matcher
        $matcher = $builder->addDefinition($this->prefix('matcher'))
            ->addSetup(get_called_class() . '::setupVoters', array('@self', '@container'))
            ->setClass('Smf\Menu\Matcher\Matcher');

        // Create a default renderers
        $renderers = array(
            'Smf\Menu\Renderer\ListRenderer',
            'Smf\Menu\Renderer\BootstrapNavRenderer',
        );
        foreach ($renderers as $renderer) {
            $name = explode('\\', $renderer);
            $name = lcfirst(preg_replace('#Renderer$#', '', end($name)));
            $builder->addDefinition($this->prefix('renderer_' . $name))
                ->setClass($renderer, array($matcher))
                ->addTag(self::RENDERER_TAG_NAME, $name);
        }

        // Create default voter
        $builder->addDefinition($this->prefix('presenterVoter'))
            ->setClass('Smf\Menu\Matcher\Voter\PresenterVoter')
            ->addTag(self::VOTER_TAG_NAME);
    }
public function loadConfiguration()
    {
        $builder = $this->getContainerBuilder();
        $config = $this->getConfig($this->defaults);

        // Create instance of extension
        $menuFactory = $builder->addDefinition($this->prefix('extension'))
            ->setClass('Smf\Menu\MenuExtension');

        // Create instance of menufactory
        $menuFactory = $builder->addDefinition($this->prefix('factory'))
            ->addSetup('addExtension', array($this->prefix('@extension')))
            ->setClass('Knp\Menu\MenuFactory');

        // Create renderers manager
        $rendererManager = $builder->addDefinition($this->prefix('rendererManager'))
            ->setClass('Smf\Menu\Renderer\Manager')
            ->addSetup(get_called_class() . '::setupRenderers', array('@self', '@container'))
            ->addSetup('setDefaultRenderer', array($config['defaultRenderer']));;

        // Create a factory for control
        $builder->addDefinition($this->prefix('controlFactory'))
            ->setClass('Smf\Menu\Control\Factory', array($menuFactory, $rendererManager));

        // Matcher
        $matcher = $builder->addDefinition($this->prefix('matcher'))
            ->addSetup(get_called_class() . '::setupVoters', array('@self', '@container'))
            ->setClass('Smf\Menu\Matcher\Matcher');

        // Create a default renderers
        $renderers = array(
            'Smf\Menu\Renderer\ListRenderer',
            'Smf\Menu\Renderer\BootstrapNavRenderer',
        );
        foreach ($renderers as $renderer) {
            $name = explode('\\', $renderer);
            $name = lcfirst(preg_replace('#Renderer$#', '', end($name)));
            $builder->addDefinition($this->prefix('renderer_' . $name))
                ->setClass($renderer, array($matcher))
                ->addTag(self::RENDERER_TAG_NAME, $name);
        }

        // Create default voter
        $builder->addDefinition($this->prefix('presenterVoter'))
            ->setClass('Smf\Menu\Matcher\Voter\PresenterVoter')
            ->addTag(self::VOTER_TAG_NAME);
    }
public function loadConfiguration ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ config = $ this -> getConfig ( $ this -> defaults ) ; // Create instance of extension $ menuFactory = $ builder -> addDefinition ( $ this -> prefix ( 'extension' ) ) -> setClass ( 'Smf\Menu\MenuExtension' ) ; // Create instance of menufactory $ menuFactory = $ builder -> addDefinition ( $ this -> prefix ( 'factory' ) ) -> addSetup ( 'addExtension' , array ( $ this -> prefix ( '@extension' ) ) ) -> setClass ( 'Knp\Menu\MenuFactory' ) ; // Create renderers manager $ rendererManager = $ builder -> addDefinition ( $ this -> prefix ( 'rendererManager' ) ) -> setClass ( 'Smf\Menu\Renderer\Manager' ) -> addSetup ( get_called_class ( ) . '::setupRenderers' , array ( '@self' , '@container' ) ) -> addSetup ( 'setDefaultRenderer' , array ( $ config [ 'defaultRenderer' ] ) ) ; ; // Create a factory for control $ builder -> addDefinition ( $ this -> prefix ( 'controlFactory' ) ) -> setClass ( 'Smf\Menu\Control\Factory' , array ( $ menuFactory , $ rendererManager ) ) ; // Matcher $ matcher = $ builder -> addDefinition ( $ this -> prefix ( 'matcher' ) ) -> addSetup ( get_called_class ( ) . '::setupVoters' , array ( '@self' , '@container' ) ) -> setClass ( 'Smf\Menu\Matcher\Matcher' ) ; // Create a default renderers $ renderers = array ( 'Smf\Menu\Renderer\ListRenderer' , 'Smf\Menu\Renderer\BootstrapNavRenderer' , ) ; foreach ( $ renderers as $ renderer ) { $ name = explode ( '\\' , $ renderer ) ; $ name = lcfirst ( preg_replace ( '#Renderer$#' , '' , end ( $ name ) ) ) ; $ builder -> addDefinition ( $ this -> prefix ( 'renderer_' . $ name ) ) -> setClass ( $ renderer , array ( $ matcher ) ) -> addTag ( self :: RENDERER_TAG_NAME , $ name ) ; } // Create default voter $ builder -> addDefinition ( $ this -> prefix ( 'presenterVoter' ) ) -> setClass ( 'Smf\Menu\Matcher\Voter\PresenterVoter' ) -> addTag ( self :: VOTER_TAG_NAME ) ; }
Configuration - container building
Configuration - container building