Remove AdminView class

This commit is contained in:
Giuseppe Criscione 2020-12-26 15:57:28 +01:00
parent e3a8f4b00e
commit a83f19b614
3 changed files with 13 additions and 50 deletions

View File

@ -1,3 +1,7 @@
<?php
return [];
return [
'assets' => static function () {
return \Formwork\Formwork::instance()->admin()->assets();
}
];

View File

@ -1,47 +0,0 @@
<?php
namespace Formwork\Admin;
use Formwork\Assets;
use Formwork\Formwork;
use Formwork\Parsers\PHP;
use Formwork\View\View;
class AdminView extends View
{
/**
* @inheritdoc
*/
protected const TYPE = 'admin view';
/**
* @inheritdoc
*/
protected static $helpers = [];
/**
* View assets instance
*
* @var Assets
*/
protected $assets;
/**
* Get Assets instance
*/
public function assets(): Assets
{
if ($this->assets !== null) {
return $this->assets;
}
return $this->assets = new Assets(ADMIN_PATH . 'assets' . DS, Formwork::instance()->admin()->realUri('/assets/'));
}
/**
* @inheritdoc
*/
protected function helpers(): array
{
return PHP::parseFile(ADMIN_PATH . 'helpers.php') + parent::helpers();
}
}

View File

@ -3,14 +3,15 @@
namespace Formwork\Admin\Controllers;
use Formwork\Admin\Admin;
use Formwork\Admin\AdminView;
use Formwork\Admin\Security\CSRFToken;
use Formwork\Admin\Users\User;
use Formwork\Formwork;
use Formwork\Parsers\JSON;
use Formwork\Parsers\PHP;
use Formwork\Site;
use Formwork\Utils\Date;
use Formwork\Utils\Str;
use Formwork\View\View;
abstract class AbstractController
{
@ -132,7 +133,12 @@ abstract class AbstractController
*/
protected function view(string $name, array $data = [], bool $return = false)
{
$view = new AdminView($name, array_merge($this->defaults(), $data), Formwork::instance()->config()->get('views.paths.admin'));
$view = new View(
$name,
array_merge($this->defaults(), $data),
Formwork::instance()->config()->get('views.paths.admin'),
PHP::parseFile(ADMIN_PATH . 'helpers.php')
);
return $view->render($return);
}