public function beforeLayout(Event $event, $layoutFile)
    {
        if (!$this->output) {
            return;
        }

        //Writes the output
        $output = array_map(function ($v) {
            return "    " . $v;
        }, $this->output);

        $this->Html->scriptBlock(
            sprintf('$(function() {%s});', PHP_EOL . implode(PHP_EOL, $output) . PHP_EOL),
            ['block' => 'script_bottom']
        );

        //Resets the output
        $this->output = [];
    }