public function render()
    {
        /** @var CommandInterface[] $commands */
        $commands = $this
            ->environment
            ->getDataDefinition()
            ->getDefinition(Contao2BackendViewDefinitionInterface::NAME)
            ->getGlobalCommands()
            ->getCommands();

        if (!\is_array($commands)) {
            $commands = [];
        }

        $buttons = [];
        foreach ($commands as $command) {
            if ($command->isDisabled()) {
                continue;
            }
            $buttons[$command->getName()] = $this->renderButton($command);
        }

        $buttonsEvent = new GetGlobalButtonsEvent($this->environment);
        $buttonsEvent->setButtons($buttons);
        $this->dispatcher->dispatch(GetGlobalButtonsEvent::NAME, $buttonsEvent);

        return '<div id="tl_buttons">' . \implode('', $buttonsEvent->getButtons()) . '</div>';
    }