/** * 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')); }
/** * 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. "); }
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."); } }