当前位置: 首页>>代码示例>>PHP>>正文


PHP Gantry::instance方法代码示例

本文整理汇总了PHP中Gantry\Framework\Gantry::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Gantry::instance方法的具体用法?PHP Gantry::instance怎么用?PHP Gantry::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gantry\Framework\Gantry的用法示例。


在下文中一共展示了Gantry::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 protected function __construct()
 {
     parent::__construct();
     $gantry = Gantry::instance();
     if (isset($gantry['file.yaml.cache.path'])) {
         $this->setCachePath($gantry['file.yaml.cache.path']);
     }
 }
开发者ID:JozefAB,项目名称:neoacu,代码行数:8,代码来源:CompiledYamlFile.php

示例2: save

 /**
  * Save assignments for the configuration.
  *
  * @param array $data
  */
 public function save(array $data)
 {
     $data = $data['assignments'];
     foreach ($data as $tname => &$type) {
         foreach ($type as $gname => &$group) {
             foreach ($group as $key => $value) {
                 if (!$value) {
                     unset($group[$key]);
                 } else {
                     $group[$key] = (bool) $value;
                 }
             }
             if (empty($group)) {
                 unset($type[$gname]);
             }
         }
         if (empty($type)) {
             unset($data[$tname]);
         }
     }
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     // Save layout into custom directory for the current theme.
     $save_dir = $locator->findResource("gantry-config://{$this->configuration}", true, true);
     $filename = "{$save_dir}/assignments.yaml";
     $file = YamlFile::instance($filename);
     $file->save($data);
     $file->free();
 }
开发者ID:Tanver186,项目名称:gantry5,代码行数:35,代码来源:Assignments.php

示例3: getThemes

 /**
  * @return array
  */
 public static function getThemes()
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $files = Folder::all('gantry-themes://', ['recursive' => false, 'files' => false]);
     /** @var array|ThemeDetails[] $list */
     $list = [];
     natsort($files);
     foreach ($files as $theme) {
         if ($locator('gantry-themes://' . $theme . '/gantry/theme.yaml')) {
             $details = new ThemeDetails($theme);
             // Stream needs to be valid URL.
             $streamName = 'gantry-themes-' . preg_replace('|[^a-z\\d+.-]|ui', '-', $theme);
             if (!$locator->schemeExists($streamName)) {
                 $locator->addPath($streamName, '', $details->getPaths());
             }
             $details['name'] = $theme;
             $details['title'] = $details['details.name'];
             $details['preview_url'] = $gantry['platform']->getThemePreviewUrl($theme);
             $details['admin_url'] = $gantry['platform']->getThemeAdminUrl($theme);
             $details['params'] = [];
             $list[$details->name] = $details;
         }
     }
     // Add Thumbnails links after adding all the paths to the locator.
     foreach ($list as $details) {
         $details['thumbnail'] = $details->getUrl("details.images.thumbnail");
     }
     return $list;
 }
开发者ID:legutierr,项目名称:gantry5,代码行数:34,代码来源:ThemeList.php

示例4: onThemeInitialized

 public function onThemeInitialized()
 {
     /** @var UniformResourceLocator $locator */
     $locator = $this->grav['locator'];
     $path = $locator('theme://');
     $name = $this->name;
     if (!class_exists('\\Gantry5\\Loader')) {
         if ($this->isAdmin()) {
             $messages = $this->grav['messages'];
             $messages->add('Please enable Gantry 5 plugin in order to use current theme!', 'error');
             return;
         } else {
             throw new \LogicException('Please install and enable Gantry 5 Framework plugin!');
         }
     }
     // Setup Gantry 5 Framework or throw exception.
     \Gantry5\Loader::setup();
     // Get Gantry instance.
     $gantry = Gantry::instance();
     // Set the theme path from Grav variable.
     $gantry['theme.path'] = $path;
     $gantry['theme.name'] = $name;
     // Define the template.
     require $locator('theme://includes/theme.php');
     // Define Gantry services.
     $gantry['theme'] = function ($c) {
         return new \Gantry\Theme\Hydrogen($c['theme.path'], $c['theme.name']);
     };
 }
开发者ID:sam-suresh,项目名称:gantry5,代码行数:29,代码来源:theme.php

示例5: init

 /**
  * @see AbstractTheme::init()
  */
 protected function init()
 {
     parent::init();
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     \JPluginHelper::importPlugin('gantry5');
     // Trigger the onGantryThemeInit event.
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onGantry5ThemeInit', ['theme' => $this]);
     $lang = \JFactory::getLanguage();
     // FIXME: Do not hardcode this file.
     $lang->load('files_gantry5_nucleus', JPATH_SITE);
     if (\JFactory::getApplication()->isSite()) {
         // Load our custom positions file as frontend requires the strings to be there.
         $filename = $locator("gantry-theme://language/en-GB/en-GB.tpl_{$this->name}_positions.ini");
         if ($filename) {
             $lang->load("tpl_{$this->name}_positions", dirname(dirname(dirname($filename))), 'en-GB');
         }
     }
     $doc = \JFactory::getDocument();
     $this->language = $doc->language;
     $this->direction = $doc->direction;
     $this->url = \JUri::root(true) . '/templates/' . $this->name;
 }
开发者ID:legutierr,项目名称:gantry5,代码行数:28,代码来源:Theme.php

示例6: gantry_admin_print_scripts

function gantry_admin_print_scripts()
{
    $scripts = \Gantry\Framework\Gantry::instance()->scripts();
    if ($scripts) {
        echo implode("\n", $scripts) . "\n";
    }
}
开发者ID:xmasviex,项目名称:gantry5,代码行数:7,代码来源:init.php

示例7: gantry

 /**
  * Get global Gantry instance.
  *
  * @return Gantry
  */
 public static function gantry()
 {
     // We cannot set variable directly for the trait as it doesn't work in HHVM.
     if (!self::$gantry) {
         self::$gantry = Gantry::instance();
     }
     return self::$gantry;
 }
开发者ID:JozefAB,项目名称:neoacu,代码行数:13,代码来源:GantryTrait.php

示例8: delete

 public static function delete($id)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $path = $locator->findResource('gantry-config://' . $id, true, true);
     if (is_dir($path)) {
         Folder::delete($path, true);
     }
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:10,代码来源:StyleHelper.php

示例9: widgets_init

 public function widgets_init()
 {
     $gantry = Gantry::instance();
     $positions = $gantry['configurations']->positions();
     foreach ($positions as $name => $title) {
         // FIXME
         // This should be handled by theme so translation plugins could catch it as part of theme.
         // This stuff might also need take Joomla chromes into account for cross-compatibility reasons
         register_sidebar(array('name' => __($title, 'gantry5'), 'id' => $name, 'description' => __($title, 'gantry5'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     }
 }
开发者ID:xmasviex,项目名称:gantry5,代码行数:11,代码来源:Theme.php

示例10: __construct

 public function __construct()
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $finder = new ConfigFileFinder();
     // Generate a flat list of all existing pages containing a list of file paths with timestamps.
     $this->items = $finder->listFiles($locator->findResources('gantry-pages://'), '|\\.html\\.twig|');
     // And list the pages in alphabetical order.
     ksort($this->items);
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:11,代码来源:Pages.php

示例11: bodyAttributes

 public function bodyAttributes($attributes = [])
 {
     $gantry = Gantry::instance();
     $classes = ['site', "dir-ltr", "outline-{$gantry['configuration']}"];
     $baseAttributes = (array) $this->config->get('page.body.attribs', []);
     if (!empty($baseAttributes['class'])) {
         $baseAttributes['class'] = array_merge((array) $baseAttributes['class'], $classes);
     } else {
         $baseAttributes['class'] = $classes;
     }
     return $this->getAttributes($baseAttributes, $attributes);
 }
开发者ID:Tanver186,项目名称:gantry5,代码行数:12,代码来源:Page.php

示例12: loadAssignments

 public function loadAssignments()
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     // Find all the assignment files.
     $paths = $locator->findResources("gantry-config://");
     $files = (new ConfigFileFinder())->locateFileInFolder('assignments', $paths);
     $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
     $config = new CompiledConfig($cache, [$files]);
     return $config->load();
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:12,代码来源:OutlineChooser.php

示例13: add_to_twig

 public function add_to_twig(\Twig_Environment $twig, \Twig_Loader_Filesystem $loader = null)
 {
     $gantry = \Gantry\Framework\Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     if (!$loader) {
         $loader = $twig->getLoader();
     }
     $loader->setPaths($locator->findResources('gantry-admin://templates'), 'gantry-admin');
     $twig->addExtension(new TwigExtension());
     return $twig;
 }
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:12,代码来源:Theme.php

示例14: onGlobalSave

 public function onGlobalSave(Event $event)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $filename = 'config://plugins/gantry5.yaml';
     $file = YamlFile::instance($locator->findResource($filename, true, true));
     $content = $file->content();
     $content['production'] = (bool) $event->data['production'];
     $file->save($content);
     $file->free();
 }
开发者ID:legutierr,项目名称:gantry5,代码行数:12,代码来源:EventListener.php

示例15: widgets_init

 public function widgets_init()
 {
     $gantry = Gantry::instance();
     $positions = (array) $gantry['config']->get('positions');
     foreach ($positions as $name => $params) {
         $params = (array) $params;
         if (!isset($params['name'])) {
             $params['name'] = ucfirst($name);
         }
         register_sidebar(array('name' => __($params['name'], 'gantry5'), 'id' => $name, 'description' => __($params['name'], 'gantry5'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     }
 }
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:12,代码来源:Theme.php


注:本文中的Gantry\Framework\Gantry::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。