當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。