• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Common\Grav类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Grav\Common\Grav的典型用法代码示例。如果您正苦于以下问题:PHP Grav类的具体用法?PHP Grav怎么用?PHP Grav使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: onGetPageTemplates

 public function onGetPageTemplates($event)
 {
     $types = $event->types;
     $locator = Grav::instance()['locator'];
     $types->scanBlueprints($locator->findResources('plugin://' . $this->name . '/blueprints'));
     $types->scanTemplates($locator->findResources('plugin://' . $this->name . '/templates'));
 }
开发者ID:ellioseven,项目名称:grav-plugin-modular-component,代码行数:7,代码来源:component.php


示例2: serve

 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $grav = Grav::instance();
     $this->output->writeln('');
     $this->output->writeln('<yellow>Current Configuration:</yellow>');
     $this->output->writeln('');
     dump($grav['config']->get('plugins.email'));
     $this->output->writeln('');
     require_once __DIR__ . '/../vendor/autoload.php';
     $grav['Email'] = new Email();
     $email_to = $this->input->getOption('to') ?: $grav['config']->get('plugins.email.to');
     $subject = $this->input->getOption('subject');
     $body = $this->input->getOption('body');
     if (!$subject) {
         $subject = 'Testing Grav Email Plugin';
     }
     if (!$body) {
         $configuration = print_r($grav['config']->get('plugins.email'), true);
         $body = $grav['language']->translate(['PLUGIN_EMAIL.TEST_EMAIL_BODY', $configuration]);
     }
     $sent = EmailUtils::sendEmail($subject, $body, $email_to);
     if ($sent) {
         $this->output->writeln("<green>Message sent successfully!</green>");
     } else {
         $this->output->writeln("<red>Problem sending email...</red>");
     }
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:30,代码来源:TestEmailCommand.php


示例3: __construct

 /**
  * set some instance variable states
  */
 public function __construct()
 {
     $this->grav = Grav::instance();
     $this->shortcode = $this->grav['shortcode'];
     $this->config = $this->grav['config'];
     $this->twig = $this->grav['twig'];
 }
开发者ID:getgrav,项目名称:grav-plugin-shortcode-core,代码行数:10,代码来源:Shortcode.php


示例4: init

 public function init()
 {
     $grav = Grav::instance();
     /** @var Config $config */
     $config = $grav['config'];
     $mode = $config->get('system.debugger.mode');
     TracyDebugger::$logDirectory = $config->get('system.debugger.log.enabled') ? LOG_DIR : null;
     TracyDebugger::$maxDepth = $config->get('system.debugger.max_depth');
     // Switch debugger into development mode if configured
     if ($config->get('system.debugger.enabled')) {
         if ($config->get('system.debugger.strict')) {
             TracyDebugger::$strictMode = true;
         }
         if (function_exists('ini_set')) {
             ini_set('display_errors', true);
         }
         if ($mode == strtolower('detect')) {
             TracyDebugger::$productionMode = self::DETECT;
         } elseif ($mode == strtolower('production')) {
             TracyDebugger::$productionMode = self::PRODUCTION;
         } else {
             TracyDebugger::$productionMode = self::DEVELOPMENT;
         }
     }
 }
开发者ID:miguelramos,项目名称:grav,代码行数:25,代码来源:Debugger.php


示例5: backup

 /**
  * Backup
  *
  * @param null          $destination
  * @param callable|null $messager
  *
  * @return null|string
  */
 public static function backup($destination = null, callable $messager = null)
 {
     if (!$destination) {
         $destination = Grav::instance()['locator']->findResource('backup://', true);
         if (!$destination) {
             throw new \RuntimeException('The backup folder is missing.');
         }
     }
     $name = substr(strip_tags(Grav::instance()['config']->get('site.title', basename(GRAV_ROOT))), 0, 20);
     $inflector = new Inflector();
     if (is_dir($destination)) {
         $date = date('YmdHis', time());
         $filename = trim($inflector->hyphenize($name), '-') . '-' . $date . '.zip';
         $destination = rtrim($destination, DS) . DS . $filename;
     }
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => 'Creating new Backup "' . $destination . '"']);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => '']);
     $zip = new \ZipArchive();
     $zip->open($destination, \ZipArchive::CREATE);
     $max_execution_time = ini_set('max_execution_time', 600);
     static::folderToZip(GRAV_ROOT, $zip, strlen(rtrim(GRAV_ROOT, DS) . DS), $messager);
     $messager && $messager(['type' => 'progress', 'percentage' => false, 'complete' => true]);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => '']);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => 'Saving and compressing archive...']);
     $zip->close();
     if ($max_execution_time !== false) {
         ini_set('max_execution_time', $max_execution_time);
     }
     return $destination;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:38,代码来源:ZipBackup.php


示例6: fromFile

 /**
  * Create Medium from a file
  *
  * @param  string $file
  * @param  array  $params
  * @return Medium
  */
 public static function fromFile($file, array $params = [])
 {
     if (!file_exists($file)) {
         return null;
     }
     $path = dirname($file);
     $filename = basename($file);
     $parts = explode('.', $filename);
     $ext = array_pop($parts);
     $basename = implode('.', $parts);
     $config = Grav::instance()['config'];
     $media_params = $config->get("media.types." . strtolower($ext));
     if (!$media_params) {
         return null;
     }
     $params += $media_params;
     // Add default settings for undefined variables.
     $params += $config->get('media.types.defaults');
     $params += ['type' => 'file', 'thumb' => 'media/thumb.png', 'mime' => 'application/octet-stream', 'filepath' => $file, 'filename' => $filename, 'basename' => $basename, 'extension' => $ext, 'path' => $path, 'modified' => filemtime($file), 'thumbnails' => []];
     $locator = Grav::instance()['locator'];
     $file = $locator->findResource("image://{$params['thumb']}");
     if ($file) {
         $params['thumbnails']['default'] = $file;
     }
     return static::fromArray($params);
 }
开发者ID:dweelie,项目名称:grav,代码行数:33,代码来源:MediumFactory.php


示例7: __construct

 public function __construct(array $items = array(), Grav $grav = null, $environment = null)
 {
     $this->grav = $grav ?: Grav::instance();
     $this->finder = new ConfigFinder();
     $this->environment = $environment ?: 'localhost';
     $this->messages[] = 'Environment Name: ' . $this->environment;
     if (isset($items['@class'])) {
         if ($items['@class'] != get_class($this)) {
             throw new \InvalidArgumentException('Unrecognized config cache file!');
         }
         // Loading pre-compiled configuration.
         $this->timestamp = (int) $items['timestamp'];
         $this->checksum = $items['checksum'];
         $this->items = (array) $items['data'];
     } else {
         // Make sure that
         if (!isset($items['streams']['schemes'])) {
             $items['streams']['schemes'] = [];
         }
         $items['streams']['schemes'] += $this->streams;
         $items = $this->autoDetectEnvironmentConfig($items);
         $this->messages[] = $items['streams']['schemes']['config']['prefixes'][''];
         parent::__construct($items);
     }
     $this->check();
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:26,代码来源:Config.php


示例8: __construct

 /**
  * Create a RecursiveFilterIterator from a RecursiveIterator
  *
  * @param RecursiveIterator $iterator
  */
 public function __construct(\RecursiveIterator $iterator)
 {
     parent::__construct($iterator);
     if (empty($this::$folder_ignores)) {
         $this::$folder_ignores = Grav::instance()['config']->get('system.pages.ignore_folders');
     }
 }
开发者ID:dweelie,项目名称:grav,代码行数:12,代码来源:RecursiveFolderFilterIterator.php


示例9: getSubscribedEvents

 /**
  * @return array
  */
 public static function getSubscribedEvents()
 {
     if (!Grav::instance()['config']->get('plugins.admin-pro.enabled')) {
         return ['onPluginsInitialized' => [['setup', 100000], ['onPluginsInitialized', 1001]], 'onShutdown' => ['onShutdown', 1000], 'onFormProcessed' => ['onFormProcessed', 0], 'onAdminDashboard' => ['onAdminDashboard', 0]];
     }
     return [];
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:10,代码来源:admin.php


示例10: loadBlueprint

 /**
  * Load blueprints.
  */
 protected function loadBlueprint()
 {
     if (!$this->blueprint) {
         $grav = Grav::instance();
         $themes = $grav['themes'];
         $this->blueprint = $themes->get($this->name)->blueprints();
     }
 }
开发者ID:dweelie,项目名称:grav,代码行数:11,代码来源:Theme.php


示例11: url

 public function url(array $args = [])
 {
     $grav = Grav::instance();
     $url = $grav['uri']->url;
     $parts = Url::parse($url, true);
     $parts['vars'] = array_replace($parts['vars'], $args);
     return Url::build($parts);
 }
开发者ID:Tanver186,项目名称:gantry5,代码行数:8,代码来源:Page.php


示例12: init

 public function init()
 {
     $this->grav = Grav::instance();
     if ($this->enabled()) {
         $this->debugbar->addCollector(new \DebugBar\DataCollector\ConfigCollector((array) $this->grav['config']->get('system')));
     }
     return $this;
 }
开发者ID:clee03,项目名称:metal,代码行数:8,代码来源:Debugger.php


示例13: resetHandlers

 public function resetHandlers()
 {
     $grav = Grav::instance();
     $config = $grav['config']->get('system.errors');
     $jsonRequest = $_SERVER && isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/json';
     // Setup Whoops-based error handler
     $whoops = new \Whoops\Run();
     $verbosity = 1;
     if (isset($config['display'])) {
         if (is_int($config['display'])) {
             $verbosity = $config['display'];
         } else {
             $verbosity = $config['display'] ? 1 : 0;
         }
     }
     switch ($verbosity) {
         case 1:
             $error_page = new Whoops\Handler\PrettyPageHandler();
             $error_page->setPageTitle('Crikey! There was an error...');
             $error_page->addResourcePath(GRAV_ROOT . '/system/assets');
             $error_page->addCustomCss('whoops.css');
             $whoops->pushHandler($error_page);
             break;
         case -1:
             $whoops->pushHandler(new BareHandler());
             break;
         default:
             $whoops->pushHandler(new SimplePageHandler());
             break;
     }
     if (method_exists('Whoops\\Util\\Misc', 'isAjaxRequest')) {
         //Whoops 2.0
         if (Whoops\Util\Misc::isAjaxRequest() || $jsonRequest) {
             $whoops->pushHandler(new Whoops\Handler\JsonResponseHandler());
         }
     } elseif (function_exists('Whoops\\isAjaxRequest')) {
         //Whoops 2.0.0-alpha
         if (Whoops\isAjaxRequest() || $jsonRequest) {
             $whoops->pushHandler(new Whoops\Handler\JsonResponseHandler());
         }
     } else {
         //Whoops 1.x
         $json_page = new Whoops\Handler\JsonResponseHandler();
         $json_page->onlyForAjaxRequests(true);
     }
     if (isset($config['log']) && $config['log']) {
         $logger = $grav['log'];
         $whoops->pushHandler(function ($exception, $inspector, $run) use($logger) {
             try {
                 $logger->addCritical($exception->getMessage() . ' - Trace: ' . $exception->getTraceAsString());
             } catch (\Exception $e) {
                 echo $e;
             }
         }, 'log');
     }
     $whoops->register();
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:57,代码来源:Errors.php


示例14: __construct

 /**
  * initialize some internal instance variables
  */
 public function __construct()
 {
     $this->grav = Grav::instance();
     $this->config = $this->grav['config'];
     $this->handlers = new HandlerContainer();
     $this->events = new EventContainer();
     $this->states = [];
     $this->assets = [];
     $this->objects = [];
 }
开发者ID:getgrav,项目名称:grav-plugin-shortcode-core,代码行数:13,代码来源:ShortcodeManager.php


示例15: init

 /**
  * Initialize the debugger
  *
  * @return $this
  * @throws \DebugBar\DebugBarException
  */
 public function init()
 {
     $this->grav = Grav::instance();
     $this->config = $this->grav['config'];
     if ($this->enabled()) {
         $this->debugbar->addCollector(new ConfigCollector((array) $this->config->get('system'), 'Config'));
         $this->debugbar->addCollector(new ConfigCollector((array) $this->config->get('plugins'), 'Plugins'));
     }
     return $this;
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:16,代码来源:Debugger.php


示例16: getAssetsPaths

 public function getAssetsPaths()
 {
     $grav = Grav::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $grav['locator'];
     if (is_link($locator('user://gantry5/assets'))) {
         // Development environment.
         return ['' => ['gantry-theme://', "user://gantry5/assets/{$this->name}", 'user://gantry5/assets/common']];
     }
     return ['' => ['gantry-theme://', 'user://gantry5/assets']];
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:11,代码来源:Platform.php


示例17: init

 public function init()
 {
     if (empty($this->plural)) {
         $language = Grav::instance()['language'];
         $this->plural = $language->translate('INFLECTOR_PLURALS', null, true);
         $this->singular = $language->translate('INFLECTOR_SINGULAR', null, true);
         $this->uncountable = $language->translate('INFLECTOR_UNCOUNTABLE', null, true);
         $this->irregular = $language->translate('INFLECTOR_IRREGULAR', null, true);
         $this->ordinals = $language->translate('INFLECTOR_ORDINALS', null, true);
     }
 }
开发者ID:dweelie,项目名称:grav,代码行数:11,代码来源:Inflector.php


示例18: load

 /**
  * @throws \LogicException
  */
 protected static function load()
 {
     $container = parent::load();
     $container['site'] = function ($c) {
         return new Site();
     };
     // Use locator from Grav.
     $container['locator'] = function ($c) {
         return Grav::instance()['locator'];
     };
     return $container;
 }
开发者ID:pensesmart,项目名称:gantry5,代码行数:15,代码来源:Gantry.php


示例19: resetHandlers

 public function resetHandlers()
 {
     $grav = Grav::instance();
     $config = $grav['config']->get('system.errors');
     if (isset($config['display']) && !$config['display']) {
         unset($this->handlerStack['pretty']);
         $this->handlerStack = array('simple' => new SimplePageHandler()) + $this->handlerStack;
     }
     if (isset($config['log']) && !$config['log']) {
         unset($this->handlerStack['log']);
     }
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:12,代码来源:Errors.php


示例20: serve

 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $this->gpm = new GPM($this->input->getOption('force'));
     $packages = $this->input->getArgument('package');
     $installed = false;
     if (!count($packages)) {
         $packages = ['grav'];
     }
     foreach ($packages as $package) {
         $package = strtolower($package);
         $name = null;
         $version = null;
         $updatable = false;
         if ($package == 'grav') {
             $name = 'Grav';
             $version = GRAV_VERSION;
             $upgrader = new Upgrader();
             if ($upgrader->isUpgradable()) {
                 $updatable = ' [upgradable: v<green>' . $upgrader->getRemoteVersion() . '</green>]';
             }
         } else {
             // get currently installed version
             $locator = \Grav\Common\Grav::instance()['locator'];
             $blueprints_path = $locator->findResource('plugins://' . $package . DS . 'blueprints.yaml');
             if (!file_exists($blueprints_path)) {
                 // theme?
                 $blueprints_path = $locator->findResource('themes://' . $package . DS . 'blueprints.yaml');
                 if (!file_exists($blueprints_path)) {
                     continue;
                 }
             }
             $package_yaml = Yaml::parse(file_get_contents($blueprints_path));
             $version = $package_yaml['version'];
             if (!$version) {
                 continue;
             }
             $installed = $this->gpm->findPackage($package);
             if ($installed) {
                 $name = $installed->name;
                 if ($this->gpm->isUpdatable($package)) {
                     $updatable = ' [updatable: v<green>' . $installed->available . '</green>]';
                 }
             }
         }
         $updatable = $updatable ?: '';
         if ($installed || $package == 'grav') {
             $this->output->writeln('You are running <white>' . $name . '</white> v<cyan>' . $version . '</cyan>' . $updatable);
         } else {
             $this->output->writeln('Package <red>' . $package . '</red> not found');
         }
     }
 }
开发者ID:dweelie,项目名称:grav,代码行数:55,代码来源:VersionCommand.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Common\Utils类代码示例发布时间:2022-05-23
下一篇:
PHP Definition\Type类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap