コード例 #1
0
 /**
  * Gets the available theme paths from the given theme source.
  * Will only return valid package, namespace, view and asset paths
  * and nothing else.
  *
  * @param  string  $source
  * @return array   $paths
  */
 public function getThemePaths($source)
 {
     $patterns = array();
     $maxSectionDepth = $this->themeBag->getMaxSectionDepth();
     for ($i = $maxSectionDepth; $i >= 1; $i--) {
         $patterns[] = sprintf('/{%s}%s/{%s}', implode(',', array('packages', 'namespaces')), str_repeat('/*', $i), implode(',', array('views', 'assets')));
     }
     // Add a pattern for the views and assets folder directly beneath
     // the source
     $patterns[] = sprintf('/{%s}', implode(',', array('views', 'assets')));
     return $this->manipulatePathResults($source, $patterns, false);
 }
コード例 #2
0
ファイル: Theme.php プロジェクト: sohailaammarocs/lfc
 /**
  * Loads the Theme Info JSON file for the theme.
  *
  * @return void
  */
 protected function loadInfoFile()
 {
     $file = "{$this->path}/theme.json";
     $json = $this->themeBag->getFilesystem()->get($file);
     $data = json_decode($json);
     if (is_null($data) and !is_null($json)) {
         $this->validateSyntax($json, $file);
     }
     $this->validateSchema($data, $file);
     $data = json_decode($json, true);
     $resolver = new NamespacedItemResolver();
     list($this->area, $this->key) = $resolver->parseKey($data['slug']);
     unset($data['slug']);
     $this->setAttributes($data);
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: AssetManager.php プロジェクト: sohailaammarocs/lfc
 /**
  * Returns the file prefix.
  *
  * @return string
  */
 protected function getCompilePrefix()
 {
     $theme = $this->themeBag->getActive();
     return $theme->getArea() . '.' . $theme->getKey() . '.';
 }
コード例 #5
0
 /**
  * Create a new theme publisher.
  *
  * @param  \Cartalyst\Themes\ThemeBag  $themeBag
  * @return void
  */
 public function __construct(ThemeBag $themeBag)
 {
     $this->themeBag = $themeBag;
     $this->filesystem = $themeBag->getFilesystem();
 }
コード例 #6
0
ファイル: ThemeBagTest.php プロジェクト: sohailaammarocs/lfc
 /**
  * @expectedException RuntimeException
  */
 public function testRegisteringThemeWithInvalidThemeDepth()
 {
     $bag = new ThemeBag($filesystem = new Filesystem(), array(__DIR__));
     $bag->register('bar::baz/bat/corge');
 }
コード例 #7
0
 /**
  * Register the theme bag which holds all the themes.
  *
  * @return void
  */
 protected function registerThemeBag()
 {
     $this->app['themes'] = $this->app->share(function ($app) {
         $config = $app['config']->get('cartalyst.themes');
         $themeBag = new ThemeBag($app['files'], array_get($config, 'paths'));
         $themeBag->setPackagesPath(array_get($config, 'packages_path'));
         $themeBag->setNamespacesPath(array_get($config, 'namespaces_path'));
         $themeBag->setViewsPath(array_get($config, 'views_path'));
         $themeBag->setAssetsPath(array_get($config, 'assets_path'));
         return $themeBag;
     });
 }