/** * Get the fully qualified location of the view. * * @param string $name * @return string */ public function find($name) { // Log::info('View Hook!! ' . $name); if (Agent::isMobile()) { try { return parent::find($name . '@phone'); } catch (Exception $e) { Log::debug(__METHOD__ . ": not find {$name}@phone"); } } return parent::find($name); }
/** * Get the fullly qualified location of the view. * * @param string $name * @return string * @throws \InvalidArgumentException */ public function find($name) { $name = str_replace('.', '/', $name); // If the theme bag instance has not been set, we will just let // the default handler take control of loading the views. if (!isset($this->themeBag)) { return parent::find($name); } // Parse the name $resolver = new NamespacedItemResolver(); list($section, $view) = $resolver->parseKey($name); try { // If we have a package listed, let's just check firstly // if it's actually referring to a hard-coded namespace. // Namespaces override packages in Themes, as they do in views. if (isset($section)) { if (isset($this->hints[$section])) { $sectionType = 'namespaces'; $paths = $this->themeBag->getCascadedNamespaceViewPaths($section); } else { $sectionType = 'packages'; $paths = $this->themeBag->getCascadedPackageViewPaths($section); } $view = $this->findInPaths($view, $paths); } else { $paths = $this->themeBag->getCascadedViewPaths(); $view = $this->findInPaths($view, $paths); } } catch (InvalidArgumentException $e) { // Let's fallback to the normal view system. try { return parent::find($name); } catch (InvalidArgumentException $e) { // Grab the relevent themes from the theme bag $active = $this->themeBag->getActive(); $fallback = $this->themeBag->getFallback(); // If we had a section, throw an Exception that's more aimed at // debugging why the package does not exist. if (isset($section)) { $message = sprintf('Theme [%s] view [%s] could not be found in theme [%s]', $sectionType, $name, $active->getSlug()); } else { $message = sprintf('Theme view [%s] could not be found in theme [%s]', $name, $active->getSlug()); } $message .= $active->getParentSlug() ? ' or any of it\'s parent themes' : ''; $message .= ($fallback and $fallback != $active) ? " or the fallback theme [{$fallback->getSlug()}]." : '.'; $message .= ' The standard view finder has also failed to find the view.'; throw new InvalidArgumentException($message); } } return $view; }
public static function blade(array $data, $debug = true) { $resolver = new EngineResolver(); $files = new Filesystem(); $compiler = new BladeCompiler($files, static::$cacheDirectory); $engine = new CompilerEngine($compiler); $resolver->register('blade', function () use($engine) { return $engine; }); /** @var Restler $restler */ $restler = Scope::get('Restler'); //Lets expose shortcuts for our classes spl_autoload_register(function ($className) use($restler) { if (isset($restler->apiMethodInfo->metadata['scope'][$className])) { return class_alias($restler->apiMethodInfo->metadata['scope'][$className], $className); } if (isset(Scope::$classAliases[$className])) { return class_alias(Scope::$classAliases[$className], $className); } return false; }, true, true); $viewFinder = new FileViewFinder($files, array(static::$viewPath)); $factory = new Factory($resolver, $viewFinder, new Dispatcher()); $path = $viewFinder->find(self::$view); $view = new View($factory, $engine, self::$view, $path, $data); $factory->callCreator($view); return $view->render(); }
/** * Get the fully qualified location of the view. * * @param string $name * @return string */ public function find($name) { // Detect device type $this->detectDevice(); return parent::find($name); }