<commit_before><?php
/*
 * This file is part of the Swoopaholic Framework Bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Swoopaholic\Bundle\FrameworkBundle\Navigation;

use Swoopaholic\Component\Navigation\NavigationFactoryInterface;
use Swoopaholic\Component\Navigation\NavigationInterface;
use Swoopaholic\Component\Navigation\ProviderInterface;
use Swoopaholic\Component\Navigation\Type\BarType;
use Swoopaholic\Component\Navigation\Type\ButtonType;
use Swoopaholic\Component\Navigation\Type\MenuType;
use Swoopaholic\Component\Navigation\Type\NavigationType;

/**
 * Factory object building the navigation top-bar
 */
class TopbarBuilder
{
    /**
     * @var \Swoopaholic\Component\Navigation\ProviderInterface
     */
    private $provider;

    /**
     * @var \Swoopaholic\Component\Navigation\NavigationFactoryInterface
     */
    private $factory;

    /**
     * @param ProviderInterface $provider
     * @param NavigationFactoryInterface $factory
     */
    public function __construct(ProviderInterface $provider, NavigationFactoryInterface $factory)
    {
        $this->provider = $provider;
        $this->factory = $factory;
    }

    /**
     * @return ProviderInterface
     */
    public function getProvider()
    {
        return $this->provider;
    }

    /**
     * @return NavigationFactoryInterface
     */
    public function getFactory()
    {
        return $this->factory;
    }

    /**
     * Builds the topBar
     *
     * @return \Swoopaholic\Component\Navigation\NavigationInterface
     */
    public function buildTopBar()
    {
        $topBar = $this->createBar();

        $this->addSidebarToggle($topBar, 'mainSidebarToggle', 'left', 'menu');
        $this->addBarElements($topBar);
        $this->addSidebarToggle($topBar, 'profileSidebarToggle', 'right', 'user4');

        return $topBar;
    }

    /**
     * @param $topBar
     * @param $id
     * @param $side
     * @param $icon
     */
    protected function addSidebarToggle($topBar, $id, $side, $icon)
    {
        $topBar->add($this->factory->create(
            $id,
            new ButtonType(),
            array(
                'align' => $side,
                'icon' => $icon,
                'attr' => array(
                    'data-togglepanelnav' => $side
                )
            )
        ));
    }

    /**
     * Adds the bar sub-elements. Extend this to add extra elements to the bar
     * @param $topBar
     */
    protected function addBarElements(NavigationInterface $topBar)
    {
    }

    /**
     * Creates the toplevel bar element
     * @return \Swoopaholic\Component\Navigation\NavigationInterface
     */
    private function createBar()
    {
        return $this->factory->create(
            'topbar',
            new BarType(),
            array(
                'orientation' => 'top',
            )
        );
    }
}<commit_msg>Changed private method to protected to allow override of topbar build method<commit_after><?php
/*
 * This file is part of the Swoopaholic Framework Bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Swoopaholic\Bundle\FrameworkBundle\Navigation;

use Swoopaholic\Component\Navigation\NavigationFactoryInterface;
use Swoopaholic\Component\Navigation\NavigationInterface;
use Swoopaholic\Component\Navigation\ProviderInterface;
use Swoopaholic\Component\Navigation\Type\BarType;
use Swoopaholic\Component\Navigation\Type\ButtonType;
use Swoopaholic\Component\Navigation\Type\MenuType;
use Swoopaholic\Component\Navigation\Type\NavigationType;

/**
 * Factory object building the navigation top-bar
 */
class TopbarBuilder
{
    /**
     * @var \Swoopaholic\Component\Navigation\ProviderInterface
     */
    private $provider;

    /**
     * @var \Swoopaholic\Component\Navigation\NavigationFactoryInterface
     */
    private $factory;

    /**
     * @param ProviderInterface $provider
     * @param NavigationFactoryInterface $factory
     */
    public function __construct(ProviderInterface $provider, NavigationFactoryInterface $factory)
    {
        $this->provider = $provider;
        $this->factory = $factory;
    }

    /**
     * @return ProviderInterface
     */
    public function getProvider()
    {
        return $this->provider;
    }

    /**
     * @return NavigationFactoryInterface
     */
    public function getFactory()
    {
        return $this->factory;
    }

    /**
     * Builds the topBar
     *
     * @return \Swoopaholic\Component\Navigation\NavigationInterface
     */
    public function buildTopBar()
    {
        $topBar = $this->createBar();

        $this->addSidebarToggle($topBar, 'mainSidebarToggle', 'left', 'menu');
        $this->addSidebarToggle($topBar, 'profileSidebarToggle', 'right', 'user4');
        $this->addBarElements($topBar);

        return $topBar;
    }

    /**
     * @param $topBar
     * @param $id
     * @param $side
     * @param $icon
     */
    protected function addSidebarToggle($topBar, $id, $side, $icon)
    {
        $topBar->add($this->factory->create(
            $id,
            new ButtonType(),
            array(
                'align' => $side,
                'icon' => $icon,
                'attr' => array(
                    'data-togglepanelnav' => $side
                )
            )
        ));
    }

    /**
     * Adds the bar sub-elements. Extend this to add extra elements to the bar
     * @param $topBar
     */
    protected function addBarElements(NavigationInterface $topBar)
    {
    }

    /**
     * Creates the toplevel bar element
     * @return \Swoopaholic\Component\Navigation\NavigationInterface
     */
    protected function createBar()
    {
        return $this->factory->create(
            'topbar',
            new BarType(),
            array(
                'orientation' => 'top',
            )
        );
    }
}
{'fraction_non_alphanumeric': 0.11496140581376252, 'fraction_numerical': 0.00032846115946789294, 'mean_word_length': 2.299024918743229, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '896990', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1683, 'n_words': 369}