mirror of
https://github.com/flextype/flextype.git
synced 2025-08-23 05:16:03 +02:00
- next round of code improvements
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* Flextype Admin Plugin
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <hello@romanenko.digital>
|
||||
* @link http://romanenko.digital
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use function is_file;
|
||||
|
||||
/**
|
||||
* Set base admin route
|
||||
*/
|
||||
@@ -21,7 +23,7 @@ $admin_route = $flextype->registry->get('plugins.admin.route');
|
||||
/**
|
||||
* Ensure vendor libraries exist
|
||||
*/
|
||||
!is_file($admin_autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: <i>composer install</i>");
|
||||
! is_file($admin_autoload = __DIR__ . '/vendor/autoload.php') and exit('Please run: <i>composer install</i>');
|
||||
|
||||
/**
|
||||
* Register The Auto Loader
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @package Flextype
|
||||
*
|
||||
* @author Romanenko Sergey <hello@romanenko.digital>
|
||||
* @link http://romanenko.digital
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
@@ -12,7 +11,6 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\Arr\Arr;
|
||||
use Flextype\Component\I18n\I18n;
|
||||
use function Flextype\Component\I18n\__;
|
||||
|
||||
@@ -31,46 +29,46 @@ $flextype->registry->set('admin_navigation.settings.settings', ['title' => '<i c
|
||||
// Add Global Vars Admin Twig Extension
|
||||
$flextype->view->addExtension(new GlobalVarsAdminTwigExtension($flextype));
|
||||
|
||||
$flextype['DashboardController'] = function ($container) {
|
||||
$flextype['DashboardController'] = static function ($container) {
|
||||
return new DashboardController($container);
|
||||
};
|
||||
|
||||
$flextype['SettingsController'] = function ($container) {
|
||||
$flextype['SettingsController'] = static function ($container) {
|
||||
return new SettingsController($container);
|
||||
};
|
||||
|
||||
$flextype['InformationController'] = function ($container) {
|
||||
$flextype['InformationController'] = static function ($container) {
|
||||
return new InformationController($container);
|
||||
};
|
||||
|
||||
$flextype['PluginsController'] = function ($container) {
|
||||
$flextype['PluginsController'] = static function ($container) {
|
||||
return new PluginsController($container);
|
||||
};
|
||||
|
||||
$flextype['EntriesController'] = function ($container) {
|
||||
$flextype['EntriesController'] = static function ($container) {
|
||||
return new EntriesController($container);
|
||||
};
|
||||
|
||||
$flextype['FieldsetsController'] = function ($container) {
|
||||
$flextype['FieldsetsController'] = static function ($container) {
|
||||
return new FieldsetsController($container);
|
||||
};
|
||||
|
||||
$flextype['SnippetsController'] = function ($container) {
|
||||
$flextype['SnippetsController'] = static function ($container) {
|
||||
return new SnippetsController($container);
|
||||
};
|
||||
|
||||
$flextype['ThemesController'] = function ($container) {
|
||||
$flextype['ThemesController'] = static function ($container) {
|
||||
return new ThemesController($container);
|
||||
};
|
||||
|
||||
$flextype['TemplatesController'] = function ($container) {
|
||||
$flextype['TemplatesController'] = static function ($container) {
|
||||
return new TemplatesController($container);
|
||||
};
|
||||
|
||||
$flextype['UsersController'] = function ($container) {
|
||||
$flextype['UsersController'] = static function ($container) {
|
||||
return new UsersController($container);
|
||||
};
|
||||
|
||||
$flextype['ToolsController'] = function ($container) {
|
||||
$flextype['ToolsController'] = static function ($container) {
|
||||
return new ToolsController($container);
|
||||
};
|
||||
|
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
// UsersController
|
||||
$app->group('/' . $admin_route, function () use ($flextype, $app) {
|
||||
$app->group('/' . $admin_route, static function () use ($app) : void {
|
||||
$app->get('/installation', 'UsersController:installation')->setName('admin.users.installation');
|
||||
$app->post('/installation', 'UsersController:installationProcess')->setName('admin.users.installationProcess');
|
||||
$app->get('/login', 'UsersController:login')->setName('admin.users.login');
|
||||
$app->post('/login', 'UsersController:loginProcess')->setName('admin.users.loginProcess');
|
||||
});
|
||||
|
||||
$app->group('/' . $admin_route, function () use ($flextype, $app) {
|
||||
|
||||
$app->group('/' . $admin_route, static function () use ($app) : void {
|
||||
// Dashboard
|
||||
$app->get('', 'DashboardController:index')->setName('admin.dashboard.index');
|
||||
|
||||
@@ -88,5 +89,4 @@ $app->group('/' . $admin_route, function () use ($flextype, $app) {
|
||||
$app->get('/tools/cache', 'ToolsController:cache')->setName('admin.tools.cache');
|
||||
$app->post('/tools/cache', 'ToolsController:clearCacheProcess')->setName('admin.tools.clearCacheProcess');
|
||||
$app->post('/tools/cache-all', 'ToolsController:clearCacheAllProcess')->setName('admin.tools.clearCacheAllProcess');
|
||||
|
||||
})->add(new AuthMiddleware($flextype));
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @package Flextype
|
||||
*
|
||||
* @author Sergey Romanenko <hello@romanenko.digital>
|
||||
* @link http://romanenko.digital
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
@@ -13,8 +12,10 @@
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\Session\Session;
|
||||
use Twig_Extension;
|
||||
use Twig_Extension_GlobalsInterface;
|
||||
|
||||
class GlobalVarsAdminTwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
|
||||
class GlobalVarsAdminTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface
|
||||
{
|
||||
/**
|
||||
* Flextype Dependency Container
|
||||
@@ -35,9 +36,9 @@ class GlobalVarsAdminTwigExtension extends \Twig_Extension implements \Twig_Exte
|
||||
public function getGlobals()
|
||||
{
|
||||
return [
|
||||
'is_logged' => ((Session::exists('role') && Session::get('role') == 'admin') ? true : false),
|
||||
'is_logged' => (Session::exists('role') && Session::get('role') === 'admin'),
|
||||
'username' => Session::exists('username') ? Session::get('username') : '',
|
||||
'rolename' => Session::exists('role') ? Session::get('role') : ''
|
||||
'rolename' => Session::exists('role') ? Session::get('role') : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user