本文整理汇总了PHP中Bundle::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::parse方法的具体用法?PHP Bundle::parse怎么用?PHP Bundle::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle::parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseMethodReturnsElementAndIdentifier
/**
* Test the Bundle::parse method.
*
* @group laravel
*/
public function testParseMethodReturnsElementAndIdentifier()
{
$this->assertEquals(array('application', 'something'), Bundle::parse('something'));
$this->assertEquals(array('application', 'something.else'), Bundle::parse('something.else'));
$this->assertEquals(array('dashboard', 'something'), Bundle::parse('dashboard::something'));
$this->assertEquals(array('dashboard', 'something.else'), Bundle::parse('dashboard::something.else'));
}
示例2: render_partial
/**
* Return partial view rendered
*
* @param string $partial
* @param array $data
*/
public function render_partial($partial, $data = array())
{
if (\Event::listeners("themes.render.partial: {$partial}")) {
$result = \Event::until("themes.render.partial: {$partial}", array($view));
if (!is_null($result)) {
if ($result instanceof \DOMDocument) {
$view = $result->saveHTML();
} elseif (is_string($result)) {
$view = $result;
} elseif (is_array($result)) {
// array to dom
$view = '<!DOCTYPE html>';
$view .= Dom::arrayToDOMDocument($result, 'html')->saveHTML();
} else {
// trow exception
}
}
}
$data = $this->_share_data($data);
$bundle_parts = \Bundle::parse($partial);
$bundle_name = $bundle_parts['0'] == 'application' ? '' : $bundle_parts['0'] . DS;
$partial_path = str_replace('.', DS, $bundle_parts['1']);
$theme_view_folder = $this->_theme_absolute_path . DS . 'views' . DS;
// Check for a custom path
$has_partial = $this->_view_exists(str_replace('.', DS, $partial));
if ($has_partial) {
return View::make($has_partial, $data);
}
// Check on the themes views folder
$has_partial = $this->_view_exists($theme_view_folder . $bundle_name . 'partials' . DS . $partial_path);
if ($has_partial) {
return View::make($has_partial, $data);
}
// Check on custom folder (fallback for all themes)
$has_partial = $this->_view_exists(path('public') . 'custom' . DS . 'views' . DS . $bundle_name . 'partials' . DS . $partial_path);
if ($has_partial) {
return View::make($has_partial, $data);
}
// bundles folder
$has_partial = $this->_view_exists($partial);
if ($has_partial) {
return View::make($has_partial, $data);
}
// try to load from application views folder
$has_partial = $this->_view_exists('partials' . DS . $partial_path);
if ($has_partial) {
return View::make($has_partial, $data);
}
Log::error('Failed to render partial from ' . $partial);
throw new \Exception("Failed to render partial. Partial [{$partial}] doesn't exist. ");
}
示例3: fromStd
static function fromStd($controller)
{
list($bundle, $controller) = \Bundle::parse(strtok($controller, '@'));
if ($obj = \Controller::resolve($bundle, $controller)) {
return $obj;
} else {
throw new Error("Controller class of block [{$controller}] is undefined.");
}
}