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 = [];
    }
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 = [];
    }
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 = [ ] ; }
Before layout callback. beforeLayout is called before the layout is
rendered.
@param \Cake\Event\Event $event An Event instance
@param string $layoutFile The layout about to be rendered
@return void
@uses MeTools\View\Helper\HtmlHelper::scriptBlock()
@uses output
Before layout callback . beforeLayout is called before the layout is rendered .