Return a container of commands by calling add[Name]Commands on the toolbar
object. If the toolbar is not set then.

@param string $name The command set name
@param array  $data Data pass to the controller toolbar

@return LibBaseTemplateObjectContainer
194693
public function commands($name, $data = array())
    {
        $toolbar = $this->_template->getHelper('controller')->getToolbar();

        if (isset($data['clone'])) {
            $toolbar = clone $toolbar;
        }

        if ($toolbar instanceof AnControllerToolbarAbstract) {
            //reset the toolbar
            $toolbar->reset();

            $method = 'add'.ucfirst($name).'Commands';

            if (method_exists($toolbar, $method)) {
                $toolbar->$method();
            }

            return $toolbar->getCommands();
        }
    }
517598
public function addCommand($name, $config = array())
    {
        if (!isset($config['label']) && in_array($name, self::$_default_buttons)) {
            $config['label'] = 'JTOOLBAR_'.$name;
        }

        return parent::addCommand($name, $config);
    }
1028009
public function getDataMapper($name = null)
    {
        $mapperName = $name ?: $this->dataMapper;

        if ($mapperName === false) {
            return new NullDataMapper();
        }

        $mapperName = $mapperName ?: $this->getName();

        // (1) If name is class, just new it.
        if (class_exists($mapperName)) {
            return new $mapperName($this->table, $this->keys, $this->db);
        }

        // (2): Find object from registered namespaces
        if ($mapper = DataMapperResolver::create($mapperName, $this->table, $this->keys, $this->db)) {
            return $mapper;
        }

        $errors[] = sprintf(
            'DataMapper: "%s" not found from namespaces: (%s)',
            $mapperName,
            implode(" |\n ", DataMapperResolver::dumpNamespaces())
        );

        // (3): Find from package directory.
        $class = sprintf(
            '%s\DataMapper\%sMapper',
            MvcHelper::getPackageNamespace(get_called_class(), 2),
            ucfirst($mapperName)
        );

        if (class_exists($class)) {
            return new $class($this->table, $this->keys, $this->db);
        }

        $errors[] = sprintf('Class: %s not exists.', $class);

        // If name is NULL and this model prepared a default mapper name.
        // We must throw exception to tell developers mapper not found.
        if (!$name && $this->dataMapper) {
            throw new \LogicException(implode("\n- ", $errors));
        }

        // If name not NULL, set it as table name, otherwise use pre-set table property.
        $table = $name ?: $this->table;

        if (!$table) {
            throw new \LogicException(sprintf(
                "Please add table property to %s to support DataMapper object. \n%s",
                static::class,
                implode("\n- ", $errors)
            ));
        }

        // (4): If name is null, we get default object with table name provided.
        return new DataMapper($table, $this->keys, $this->db);
    }
715213
public function set($name, array $data = [])
    {
        $this->setName($name);
        $this->setData($data);

        return $this->isValid();
    }
545673
public function createTemplate(array $data, $name = 'cookiebar')
    {
        $template = new FrontendTemplate($name);
        $this->setBasicData($template, $data);
        $this->setMoreLinkData($template, $data);
        $this->setAnalyticsCheckboxData($template, $data);

        // Cookie name
        $template->cookie = sprintf('COOKIEBAR_%s', $data['id']);

        return $template;
    }
799493
public function getCommand(string $name): AbstractCommand
	{
		$this->initCommands();

		if (!$this->hasCommand($name))
		{
			throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
		}

		// If the command isn't registered, pull it from the loader
		if (!isset($this->commands[$name]))
		{
			$this->addCommand($this->commandLoader->get($name));
		}

		$command = $this->commands[$name];

		// If the user requested help, we'll fetch the help command now and inject the user's command into it
		if ($this->wantsHelp)
		{
			$this->wantsHelp = false;

			/** @var HelpCommand $helpCommand */
			$helpCommand = $this->getCommand('help');
			$helpCommand->setCommand($command);

			return $helpCommand;
		}

		return $command;
	}
733895
public function get(string $name): AbstractCommand
	{
		if (!$this->has($name))
		{
			throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
		}

		return $this->container->get($this->commandMap[$name]);
	}
982325
public function getCommand($name, $config = array())
    {
        if(!isset($this->__commands[$name]))
        {
            //Create the config object
            $command = new ControllerToolbarCommand($name, $config);

            //Attach the command to the toolbar
            $command->setToolbar($this);

            //Find the command function to call
            if (method_exists($this, '_command' . ucfirst($name)))
            {
                $function = '_command' . ucfirst($name);
                $this->$function($command);
            }
            else
            {
                //Don't set an action for GET commands
                if (!isset($command->href))
                {
                    $command->append(array(
                        'data' => array(
                            'action' => $command->getName()
                        )
                    ));
                }
            }
        }
        else $command = $this->__commands[$name];

        return $command;
    }
1203912
final public function setName($name): Command
    {
        if (!$this->namespace) {
            parent::setName($name);
            return $this;
        }
        parent::setName(sprintf('%s:%s', $this->namespace, $name));
        return $this;
    }
974791
public function createContent(
        ?ContentCreateData $data = null,
        ?string $name = null
    ): FormInterface {
        $data = $data ?? new ContentCreateData();
        $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentCreateType::class);

        return $this->formFactory->createNamed($name, ContentCreateType::class, $data);
    }
647447
public static function createFromArray($name, array $data = [])
    {
        $proxy = new static($name);
        $proxy->setDefinition($data);
        if (!isset($data['type'])) {
            throw new \InvalidArgumentException('Missing "type" key in $data param to determine datatype!');
        }
        if (isset($data['properties'])) {
            $proxy->properties = $data['properties'];
        }

        $proxy->setType($data['type']);
        if ($name !== $data['type']) {
            $proxy->setParent($data['type']);
        }

        return $proxy;
    }
1191646
public function save($name, array $data = [])
    {
        $table  = $this->_getTable();
        $entity = $table->findByName($name)->first();

        $newData = [
            'name'   => $name,
            'params' => $data
        ];

        if ($entity !== null && $entity->get('name') === $name) {
            $entity = $table->patchEntity($entity, $newData);
        } else {
            $entity = $table->newEntity($newData);
        }

        return $table->save($entity);
    }
829686
private function getView(string $name, array $data = [])
    {
        $filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
        $templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
        return $templating->render($name . '.phtml', $data);
    }
146197
public function insert($name, array $data=null)
	{
		// Register the template file (to find the custom templates)
		if (!array_key_exists($name, TemplateLoader::getFiles()))
		{
			$objTheme = \LayoutModel::findById(Controller::getLayoutId($this->ptable, $this->pid))->getRelated('pid');
			
			TemplateLoader::addFile($name, $objTheme->templates);
		}
		
		/** @var \Template $tpl */
		if ($this instanceof \Template)
		{
			$tpl = new static($name);
		}
		elseif (TL_MODE == 'BE')
		{
			$tpl = new BackendTemplate($name);
		}
		else
		{
			$tpl = new FrontendTemplate($name);
		}
		if ($data !== null)
		{
			$tpl->setData($data);
		}
		
		echo $tpl->parse();
	}
553323
public function view(string $name, array $data = [])
    {
        return $this->add(View::create($name, $data));
    }
408120
public function getCommand($name, $config = array())
    {
        if(!$this->getDelegate()->hasCommand($name))
        {
            //Create the config object
            $command = new ControllerToolbarCommand($name, $config);

            //Attach the command to the toolbar
            $command->setToolbar($this);

            //Find the command function to call
            if (method_exists($this, '_command' . ucfirst($name)))
            {
                $function = '_command' . ucfirst($name);
                $this->$function($command);
            }
            else $this->getDelegate()->getCommand($name, $config);

        }
        else $command = $this->getDelegate()->getCommand($name, $config);

        return $command;
    }
735152
private static function _object(&$data, $name)
	{
		?>
		<li class="krumo-child">

			<div <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
				class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>" >

					<a class="krumo-name"><?php echo $name;?></a>
					(<em class="krumo-type">Object</em>)
					<strong class="krumo-class"><?php echo get_class($data);?></strong>
			</div>

			<?php if (count($data))
			{
				self::_vars($data);
			} ?>
		</li>
		<?php
	}