Commit 1761ed09 authored by tino.goratsch@hotmail.com's avatar [email protected]

- refactored di services inclusion

- some minor docblock improvements
parent f07b8ded
......@@ -10,6 +10,7 @@ use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Patchwork\Utf8;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
......@@ -144,31 +145,22 @@ class Application
*/
public function initializeClasses()
{
Utf8\Bootup::initAll(); // Enables the portablity layer and configures PHP for UTF-8
Utf8\Bootup::initAll(); // Enables the portability layer and configures PHP for UTF-8
Utf8\Bootup::filterRequestUri(); // Redirects to an UTF-8 encoded URL if it's not already the case
Utf8\Bootup::filterRequestInputs(); // Normalizes HTTP inputs to UTF-8 NFC
$file = CACHE_DIR . 'sql/container.php';
$containerConfigCache = new ConfigCache($file, (defined('DEBUG') && DEBUG === true));
if (is_file($file) && (!defined('DEBUG') || DEBUG === false)) {
require_once $file;
$this->container = new \ACP3ServiceContainer();
// Load system settings
$this->systemSettings = $this->container->get('system.config')->getSettings();
$this->_setThemeConstants();
$this->container->get('core.view')->setRenderer('smarty');
} else {
$this->container = new ContainerBuilder();
$loader = new YamlFileLoader($this->container, new FileLocator(__DIR__));
if (!$containerConfigCache->isFresh()) {
$containerBuilder = new ContainerBuilder();
$loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__));
$loader->load(ACP3_DIR . 'config/services.yml');
$loader->load(CLASSES_DIR . 'View/Renderer/Smarty/config/services.yml');
// Try to get all available services
/** @var Modules $modules */
$modules = $this->container->get('core.modules');
$modules = $containerBuilder->get('core.modules');
$activeModules = $modules->getActiveModules();
foreach ($activeModules as $module) {
$path = MODULES_DIR . $module['dir'] . '/config/services.yml';
......@@ -177,18 +169,24 @@ class Application
}
}
// Load system settings
$this->systemSettings = $this->container->get('system.config')->getSettings();
$containerBuilder->compile();
$this->_setThemeConstants();
$dumper = new PhpDumper($containerBuilder);
$containerConfigCache->write(
$dumper->dump(['class' => 'ACP3ServiceContainer']),
$containerBuilder->getResources()
);
}
$this->container->get('core.view')->setRenderer('smarty');
require_once $file;
$this->container = new \ACP3ServiceContainer();
$this->container->compile();
// Load system settings
$this->systemSettings = $this->container->get('system.config')->getSettings();
$dumper = new PhpDumper($this->container);
file_put_contents($file, $dumper->dump(['class' => 'ACP3ServiceContainer']));
}
$this->_setThemeConstants();
$this->container->get('core.view')->setRenderer('smarty');
}
/**
......
......@@ -79,7 +79,7 @@ class Breadcrumb
$this->lang = $lang;
$this->request = $request;
$this->router = $router;
$this->seoConfig = $seoConfig->getSettings();
$this->seoConfig = $seoConfig;
}
/**
......@@ -218,7 +218,7 @@ class Breadcrumb
*/
public function getSiteTitle()
{
return $this->seoConfig['title'];
return $this->seoConfig->getSettings()['title'];
}
/**
......
......@@ -25,7 +25,7 @@ class Modules
/**
* @var \ACP3\Core\Cache
*/
protected $cache;
protected $modulesCache;
/**
* @var \ACP3\Modules\System\Model
*/
......@@ -57,7 +57,7 @@ class Modules
$this->container = $container;
$this->lang = $lang;
$this->xml = $xml;
$this->cache = $modulesCache;
$this->modulesCache = $modulesCache;
$this->systemModel = $systemModel;
}
......@@ -116,10 +116,10 @@ class Modules
$module = strtolower($module);
if (empty($this->parseModules)) {
$filename = $this->_getCacheKey();
if ($this->cache->contains($filename) === false) {
if ($this->modulesCache->contains($filename) === false) {
$this->setModulesCache();
}
$this->parseModules = $this->cache->fetch($filename);
$this->parseModules = $this->modulesCache->fetch($filename);
}
return !empty($this->parseModules[$module]) ? $this->parseModules[$module] : [];
}
......@@ -175,7 +175,7 @@ class Modules
}
}
$this->cache->save($this->_getCacheKey(), $infos);
$this->modulesCache->save($this->_getCacheKey(), $infos);
}
/**
......
......@@ -16,17 +16,17 @@ class MoveToBottom extends AbstractFilter
protected $filterType = 'output';
/**
* @var Assets
* @var \ACP3\Core\Assets
*/
protected $assets;
/**
* @var Request
* @var \ACP3\Core\Request
*/
protected $request;
/**
* @param Assets $assets
* @param Request $request
* @param \ACP3\Core\Assets $assets
* @param \ACP3\Core\Request $request
*/
public function __construct(
Assets $assets,
......
......@@ -10,27 +10,27 @@ use ACP3\Core;
class CheckAccess extends AbstractFunction
{
/**
* @var Core\ACL
* @var \ACP3\Core\ACL
*/
protected $acl;
/**
* @var Core\Lang
* @var \ACP3\Core\Lang
*/
protected $lang;
/**
* @var Core\Router
* @var \ACP3\Core\Router
*/
protected $router;
/**
* @var Icon
* @var \ACP3\Core\View\Renderer\Smarty\Functions\Icon
*/
protected $icon;
/**
* @param Core\ACL $acl
* @param Core\Lang $lang
* @param Core\Router $router
* @param Icon $icon
* @param \ACP3\Core\ACL $acl
* @param \ACP3\Core\Lang $lang
* @param \ACP3\Core\Router $router
* @param \ACP3\Core\View\Renderer\Smarty\Functions\Icon $icon
*/
public function __construct(
Core\ACL $acl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment