maj grav
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Debugger;
|
||||
use Grav\Common\User\DataUser;
|
||||
use Grav\Common\User\FlexUser;
|
||||
use Grav\Common\User\User;
|
||||
use Grav\Framework\File\Formatter\YamlFormatter;
|
||||
use Grav\Framework\Flex\Flex;
|
||||
use Grav\Framework\Flex\FlexDirectory;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
use RocketTheme\Toolbox\Event\EventDispatcher;
|
||||
|
||||
class AccountsServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['accounts'] = function (Container $container) {
|
||||
$type = strtolower(defined('GRAV_USER_INSTANCE') ? GRAV_USER_INSTANCE : $container['config']->get('system.accounts.type', 'data'));
|
||||
if ($type === 'flex') {
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = $container['debugger'];
|
||||
$debugger->addMessage('User Accounts: Flex Directory');
|
||||
return $this->flexAccounts($container);
|
||||
}
|
||||
|
||||
return $this->dataAccounts($container);
|
||||
};
|
||||
|
||||
$container['users'] = $container->factory(function (Container $container) {
|
||||
user_error('Grav::instance()[\'users\'] is deprecated since Grav 1.6, use Grav::instance()[\'accounts\'] instead', E_USER_DEPRECATED);
|
||||
|
||||
return $container['accounts'];
|
||||
});
|
||||
}
|
||||
|
||||
protected function dataAccounts(Container $container)
|
||||
{
|
||||
if (!defined('GRAV_USER_INSTANCE')) {
|
||||
define('GRAV_USER_INSTANCE', 'DATA');
|
||||
}
|
||||
|
||||
// Use User class for backwards compatibility.
|
||||
return new DataUser\UserCollection(User::class);
|
||||
}
|
||||
|
||||
protected function flexAccounts(Container $container)
|
||||
{
|
||||
if (!defined('GRAV_USER_INSTANCE')) {
|
||||
define('GRAV_USER_INSTANCE', 'FLEX');
|
||||
}
|
||||
|
||||
/** @var Config $config */
|
||||
$config = $container['config'];
|
||||
|
||||
$options = [
|
||||
'enabled' => true,
|
||||
'data' => [
|
||||
'object' => User::class, // Use User class for backwards compatibility.
|
||||
'collection' => FlexUser\UserCollection::class,
|
||||
'index' => FlexUser\UserIndex::class,
|
||||
'storage' => $this->getFlexStorage($config->get('system.accounts.storage', 'file')),
|
||||
'search' => [
|
||||
'options' => [
|
||||
'contains' => 1
|
||||
],
|
||||
'fields' => [
|
||||
'key',
|
||||
'email'
|
||||
]
|
||||
]
|
||||
]
|
||||
] + ($config->get('plugins.flex-objects.object') ?: []);
|
||||
|
||||
$directory = new FlexDirectory('accounts', 'blueprints://user/accounts.yaml', $options);
|
||||
|
||||
/** @var EventDispatcher $dispatcher */
|
||||
$dispatcher = $container['events'];
|
||||
$dispatcher->addListener('onFlexInit', function (Event $event) use ($directory) {
|
||||
/** @var Flex $flex */
|
||||
$flex = $event['flex'];
|
||||
$flex->addDirectory($directory);
|
||||
});
|
||||
|
||||
return $directory->getIndex();
|
||||
}
|
||||
|
||||
protected function getFlexStorage($config)
|
||||
{
|
||||
if (\is_array($config)) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
if ($config === 'folder') {
|
||||
return [
|
||||
'class' => FlexUser\Storage\UserFolderStorage::class,
|
||||
'options' => [
|
||||
'formatter' => ['class' => YamlFormatter::class],
|
||||
'folder' => 'account://',
|
||||
'pattern' => '{FOLDER}/{KEY:2}/{KEY}/user.yaml',
|
||||
'key' => 'username',
|
||||
'indexed' => true
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'class' => FlexUser\Storage\UserFileStorage::class,
|
||||
'options' => [
|
||||
'formatter' => ['class' => YamlFormatter::class],
|
||||
'folder' => 'account://',
|
||||
'pattern' => '{FOLDER}/{KEY}.yaml',
|
||||
'key' => 'storage_key',
|
||||
'indexed' => true
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -16,6 +17,8 @@ class AssetsServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['assets'] = new Assets();
|
||||
$container['assets'] = function () {
|
||||
return new Assets();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Backup\Backups;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class BackupsServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['backups'] = function () {
|
||||
$backups = new Backups();
|
||||
$backups->setup();
|
||||
|
||||
return $backups;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -14,6 +15,7 @@ use Grav\Common\Config\CompiledLanguages;
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Config\ConfigFileFinder;
|
||||
use Grav\Common\Config\Setup;
|
||||
use Grav\Common\Language\Language;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
use RocketTheme\Toolbox\File\YamlFile;
|
||||
@@ -24,7 +26,10 @@ class ConfigServiceProvider implements ServiceProviderInterface
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['setup'] = function ($c) {
|
||||
return static::setup($c);
|
||||
$setup = new Setup($c);
|
||||
$setup->init();
|
||||
|
||||
return $setup;
|
||||
};
|
||||
|
||||
$container['blueprints'] = function ($c) {
|
||||
@@ -45,11 +50,10 @@ class ConfigServiceProvider implements ServiceProviderInterface
|
||||
$container['languages'] = function ($c) {
|
||||
return static::languages($c);
|
||||
};
|
||||
}
|
||||
|
||||
public static function setup(Container $container)
|
||||
{
|
||||
return new Setup($container);
|
||||
$container['language'] = function ($c) {
|
||||
return new Language($c);
|
||||
};
|
||||
}
|
||||
|
||||
public static function blueprints(Container $container)
|
||||
@@ -93,12 +97,15 @@ class ConfigServiceProvider implements ServiceProviderInterface
|
||||
$paths = $locator->findResources('plugins://');
|
||||
$files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths);
|
||||
|
||||
$config = new CompiledConfig($cache, $files, GRAV_ROOT);
|
||||
$config->setBlueprints(function() use ($container) {
|
||||
$compiled = new CompiledConfig($cache, $files, GRAV_ROOT);
|
||||
$compiled->setBlueprints(function() use ($container) {
|
||||
return $container['blueprints'];
|
||||
});
|
||||
|
||||
return $config->name("master-{$setup->environment}")->load();
|
||||
$config = $compiled->name("master-{$setup->environment}")->load();
|
||||
$config->environment = $setup->environment;
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function languages(Container $container)
|
||||
@@ -133,8 +140,8 @@ class ConfigServiceProvider implements ServiceProviderInterface
|
||||
/**
|
||||
* Find specific paths in plugins
|
||||
*
|
||||
* @param $plugins
|
||||
* @param $folder_path
|
||||
* @param array $plugins
|
||||
* @param string $folder_path
|
||||
* @return array
|
||||
*/
|
||||
private static function pluginFolderPaths($plugins, $folder_path)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -16,7 +17,6 @@ class ErrorServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$errors = new Errors;
|
||||
$container['errors'] = $errors;
|
||||
$container['errors'] = new Errors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Framework\Filesystem\Filesystem;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class FilesystemServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['filesystem'] = function () {
|
||||
return Filesystem::getInstance();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Inflector;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class InflectorServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['inflector'] = function () {
|
||||
return new Inflector();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
use \Monolog\Logger;
|
||||
use \Monolog\Handler\StreamHandler;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
|
||||
class LoggerServiceProvider implements ServiceProviderInterface
|
||||
@@ -25,7 +26,6 @@ class LoggerServiceProvider implements ServiceProviderInterface
|
||||
$locator = $c['locator'];
|
||||
|
||||
$log_file = $locator->findResource('log://grav.log', true, true);
|
||||
|
||||
$log->pushHandler(new StreamHandler($log_file, Logger::DEBUG));
|
||||
|
||||
return $log;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Page\Interfaces\PageInterface;
|
||||
use Grav\Common\Twig\Twig;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
@@ -21,7 +22,7 @@ class OutputServiceProvider implements ServiceProviderInterface
|
||||
/** @var Twig $twig */
|
||||
$twig = $c['twig'];
|
||||
|
||||
/** @var Page $page */
|
||||
/** @var PageInterface $page */
|
||||
$page = $c['page'];
|
||||
|
||||
return $twig->processSite($page->templateFormat());
|
||||
|
||||
+8
-3
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -17,10 +18,14 @@ use Grav\Common\Uri;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class PageServiceProvider implements ServiceProviderInterface
|
||||
class PagesServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['pages'] = function ($c) {
|
||||
return new Pages($c);
|
||||
};
|
||||
|
||||
$container['page'] = function ($c) {
|
||||
/** @var Grav $c */
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Uri;
|
||||
use Nyholm\Psr7\Factory\Psr17Factory;
|
||||
use Nyholm\Psr7Server\ServerRequestCreator;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class RequestServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['request'] = function () {
|
||||
$psr17Factory = new Psr17Factory();
|
||||
$creator = new ServerRequestCreator(
|
||||
$psr17Factory, // ServerRequestFactory
|
||||
$psr17Factory, // UriFactory
|
||||
$psr17Factory, // UploadedFileFactory
|
||||
$psr17Factory // StreamFactory
|
||||
);
|
||||
|
||||
return $creator->fromGlobals();
|
||||
};
|
||||
|
||||
$container['route'] = $container->factory(function() {
|
||||
return clone Uri::getCurrentRoute();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Scheduler\Scheduler;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class SchedulerServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['scheduler'] = function () {
|
||||
return new Scheduler();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -10,9 +11,9 @@ namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Debugger;
|
||||
use Grav\Common\Inflector;
|
||||
use Grav\Common\Session;
|
||||
use Grav\Common\Uri;
|
||||
use Grav\Common\Utils;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
use RocketTheme\Toolbox\Session\Message;
|
||||
@@ -49,14 +50,17 @@ class SessionServiceProvider implements ServiceProviderInterface
|
||||
// Activate admin if we're inside the admin path.
|
||||
$is_admin = false;
|
||||
if ($config->get('plugins.admin.enabled')) {
|
||||
$base = '/' . trim($config->get('plugins.admin.route'), '/');
|
||||
$admin_base = '/' . trim($config->get('plugins.admin.route'), '/');
|
||||
|
||||
// Uri::route() is not processed yet, let's quickly get what we need.
|
||||
$current_route = str_replace(Uri::filterPath($uri->rootUrl(false)), '', parse_url($uri->url(true), PHP_URL_PATH));
|
||||
|
||||
// Test to see if path starts with a supported language + admin base
|
||||
$lang = Utils::pathPrefixedByLangCode($current_route);
|
||||
$lang_admin_base = '/' . $lang . $admin_base;
|
||||
|
||||
// Check no language, simple language prefix (en) and region specific language prefix (en-US).
|
||||
$pos = strpos($current_route, $base);
|
||||
if ($pos === 0 || $pos === 3 || $pos === 6) {
|
||||
if (Utils::startsWith($current_route, $admin_base) || Utils::startsWith($current_route, $lang_admin_base)) {
|
||||
$cookie_lifetime = $config->get('plugins.admin.session.timeout', 1800);
|
||||
$enabled = $is_admin = true;
|
||||
}
|
||||
@@ -67,8 +71,11 @@ class SessionServiceProvider implements ServiceProviderInterface
|
||||
$cookie_lifetime = 9999999999;
|
||||
}
|
||||
|
||||
$inflector = new Inflector();
|
||||
$session_name = $inflector->hyphenize($config->get('system.session.name', 'grav_site')) . '-' . substr(md5(GRAV_ROOT), 0, 7);
|
||||
$session_prefix = $c['inflector']->hyphenize($config->get('system.session.name', 'grav-site'));
|
||||
$session_uniqueness = $config->get('system.session.uniqueness', 'path') === 'path' ? substr(md5(GRAV_ROOT), 0, 7) : md5($config->get('security.salt'));
|
||||
|
||||
$session_name = $session_prefix . '-' . $session_uniqueness;
|
||||
|
||||
if ($is_admin && $config->get('system.session.split', true)) {
|
||||
$session_name .= '-admin';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -20,22 +21,22 @@ class StreamsServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['locator'] = function($c) {
|
||||
$container['locator'] = function(Container $container) {
|
||||
$locator = new UniformResourceLocator(GRAV_ROOT);
|
||||
|
||||
/** @var Setup $setup */
|
||||
$setup = $c['setup'];
|
||||
$setup = $container['setup'];
|
||||
$setup->initializeLocator($locator);
|
||||
|
||||
return $locator;
|
||||
};
|
||||
|
||||
$container['streams'] = function($c) {
|
||||
$container['streams'] = function(Container $container) {
|
||||
/** @var Setup $setup */
|
||||
$setup = $c['setup'];
|
||||
$setup = $container['setup'];
|
||||
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $c['locator'];
|
||||
$locator = $container['locator'];
|
||||
|
||||
// Set locator to both streams.
|
||||
Stream::setLocator($locator);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Common.Service
|
||||
* @package Grav\Common\Service
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
@@ -16,9 +17,22 @@ class TaskServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['task'] = function ($c) {
|
||||
/** @var Grav $c */
|
||||
return !empty($_POST['task']) ? $_POST['task'] : $c['uri']->param('task');
|
||||
$container['task'] = function (Grav $c) {
|
||||
$task = $_POST['task'] ?? $c['uri']->param('task');
|
||||
if (null !== $task) {
|
||||
$task = filter_var($task, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
return $task ?: null;
|
||||
};
|
||||
|
||||
$container['action'] = function (Grav $c) {
|
||||
$action = $_POST['action'] ?? $c['uri']->param('action');
|
||||
if (null !== $action) {
|
||||
$action = filter_var($action, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
return $action ?: null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user