FOF30\Toolbar\Toolbar::__construct PHP Метод

__construct() публичный Метод

The $config array can contain the following optional values: renderFrontendButtons bool Should I render buttons in the front-end of the component? renderFrontendSubmenu bool Should I render the submenu in the front-end of the component? useConfigurationFile bool Should we use the configuration file (fof.xml) of the component?
public __construct ( Container $c, array $config = [] )
$c FOF30\Container\Container The container for the component
$config array The configuration overrides, see above
    public function __construct(Container $c, array $config = array())
    {
        // Store the container reference in this object
        $this->container = $c;
        // Get a reference to some useful objects
        $input = $this->container->input;
        $platform = $this->container->platform;
        // Get default permissions (can be overriden by the view)
        $perms = (object) array('manage' => $this->container->platform->authorise('core.manage', $input->getCmd('option', 'com_foobar')), 'create' => $this->container->platform->authorise('core.create', $input->getCmd('option', 'com_foobar')), 'edit' => $this->container->platform->authorise('core.edit', $input->getCmd('option', 'com_foobar')), 'editstate' => $this->container->platform->authorise('core.edit.state', $input->getCmd('option', 'com_foobar')), 'delete' => $this->container->platform->authorise('core.delete', $input->getCmd('option', 'com_foobar')));
        // Save front-end toolbar and submenu rendering flags if present in the config
        if (array_key_exists('renderFrontendButtons', $config)) {
            $this->renderFrontendButtons = $config['renderFrontendButtons'];
        }
        if (array_key_exists('renderFrontendSubmenu', $config)) {
            $this->renderFrontendSubmenu = $config['renderFrontendSubmenu'];
        }
        // If not in the administrative area, load the JToolbarHelper
        if (!$platform->isBackend()) {
            // Needed for tests, so we can inject our "special" helper class
            if (!class_exists('\\JToolbarHelper')) {
                $platformDirs = $platform->getPlatformBaseDirs();
                $path = $platformDirs['root'] . '/administrator/includes/toolbar.php';
                require_once $path;
            }
            // Things to do if we have to render a front-end toolbar
            if ($this->renderFrontendButtons) {
                // Load back-end toolbar language files in front-end
                $platform->loadTranslations('');
                // Needed for tests (we can fake we're not in the backend, but we are still in CLI!)
                if (!$platform->isCli()) {
                    // Load the core Javascript
                    \JHtml::_('behavior.core');
                    \JHtml::_('jquery.framework', true);
                }
            }
        }
        // Store permissions in the local toolbar object
        $this->perms = $perms;
    }