function fill() { if (!$this->filled) { $this->filled = true; if ($custom = $this->fullCustomID()) { $handler = Block::factory($custom); $func = 'menu_' . strtolower($action = Block::actionFrom($custom)); if (method_exists($handler, $func)) { $handler->{$func}($this); } else { $this->html = $handler->execute($action, $this->argArray())->render(); } } } return $this; }
function serve($args = array()) { if ($server = $this->findServer()) { // replace (:N) patterns inside controller string, e.g.: 'user@(;1)'. static::references($server, $args); // prepend arguments that can be defined in the server string after // a space: 'help@show contacts'. $server = strtok($server, ' '); $prepend = '' . strtok(null); $prepend === '' or $args = array_merge(explode(' ', $prepend), $args); // construct server instance (either a Block or a regular Controller). $this->lastArgs = $args; $block = $this->lastServer = Block::factory($server); // if server is not a traditional controller but a Vane block - set it up. if ($block instanceof Block) { $block->top = $this->lastLayout; $block->isServer = true; } // produce response (can be of arbitrary type). $this->lastArgs = $args; $response = $block->execute(Block::actionFrom($server), $args); // convert response to a Laravel\Response descendant. return with(new Block())->toResponse($response); } }