本文整理汇总了PHP中Block::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::factory方法的具体用法?PHP Block::factory怎么用?PHP Block::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fill
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;
}
示例2: serve
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);
}
}
示例3: render_block
public function render_block($block, $block_name = NULL)
{
$block->data = isset($block->data) ? $block->data : array();
$block->data = !is_array($block->data) ? (array) @json_decode($block->data, TRUE) : $block->data;
$data['_block'] = $block;
$data['_data'] = $block->data;
$after = View::factory('page/block/_after', $data);
$view = Model_Page_Block_Template::view($block->page_block_template_id, $data);
$before = View::factory('page/block/_before', $data);
if (!$view) {
return View::factory('page/block/_not_found', ['name' => $block_name])->render();
}
// helpers
$view->helper = Block::factory($block, $block_name, $view);
if (!isset($view->page)) {
View::bind_global('page', $this);
}
return $before->render() . $view->render() . $after->render();
}