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


PHP Common\Grav类代码示例

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


在下文中一共展示了Grav类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: redirect

 /**
  * Redirects an action
  */
 public function redirect()
 {
     if ($this->redirect) {
         $this->grav->redirect($this->redirect, $this->redirectCode);
     } else {
         if ($redirect = $this->grav['config']->get('plugins.login.redirect')) {
             $this->grav->redirect($redirect, $this->redirectCode);
         }
     }
 }
开发者ID:ulilu,项目名称:grav-toctoc,代码行数:13,代码来源:Controller.php


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