src/CallbackLater.php
public function set($callback, $args = [])
    {
        if (!$this->app) {
            throw new Exception(['Call-back must be part of a RenderTree']);
        }

        if ($this->app->is_rendering) {
            return parent::set($callback, $args);
        }

        $this->app->addHook('beforeRender', function (...$args) use ($callback) {
            array_shift($args); // Hook will have first argument pointing to the app. We don't need that.
            return parent::set($callback, $args);
        }, $args);
    }
public function set($callback, $args = [])
    {
        if (!$this->app) {
            throw new Exception(['Call-back must be part of a RenderTree']);
        }

        if ($this->app->is_rendering) {
            return parent::set($callback, $args);
        }

        $this->app->addHook('beforeRender', function (...$args) use ($callback) {
            array_shift($args); // Hook will have first argument pointing to the app. We don't need that.
            return parent::set($callback, $args);
        }, $args);
    }
public function set ( $ callback , $ args = [ ] ) { if ( ! $ this -> app ) { throw new Exception ( [ 'Call-back must be part of a RenderTree' ] ) ; } if ( $ this -> app -> is_rendering ) { return parent :: set ( $ callback , $ args ) ; } $ this -> app -> addHook ( 'beforeRender' , function ( ... $ args ) use ( $ callback ) { array_shift ( $ args ) ; // Hook will have first argument pointing to the app. We don't need that. return parent :: set ( $ callback , $ args ) ; } , $ args ) ; }
Executes user-specified action before rendering or if App is
already in rendering state, then before output.

@param callable $callback
@param array    $args

@return mixed|null
Executes user - specified action before rendering or if App is already in rendering state then before output .