Skip to content

Commit

Permalink
Изничтожение ненужного сеттера.
Browse files Browse the repository at this point in the history
  • Loading branch information
ProklUng committed Jul 17, 2021
1 parent 6de2e8e commit 90b0301
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
24 changes: 7 additions & 17 deletions src/CompilerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ProklUng\ContainerBoilerplate;

use InvalidArgumentException;
use ProklUng\ContainerBoilerplate\Resource\FileBitrixSettingsResource;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\Container;
Expand Down Expand Up @@ -40,10 +41,13 @@ class CompilerContainer
* CompilerContainer constructor.
*
* @param string $projectRoot DOCUMENT_ROOT.
* @param string $moduleId ID модуля.
*/
public function __construct(string $projectRoot)
public function __construct(string $projectRoot, string $moduleId)
{
$this->projectRoot = $projectRoot;
$this->moduleId = $moduleId;

$this->filesystem = new Filesystem();
}

Expand All @@ -65,7 +69,7 @@ public function isConfigFresh(string $configFile = '/bitrix/.settings.php') : bo

$content = file_get_contents($this->projectRoot . $meta);

/** @var \ProklUng\ContainerBoilerplate\Resource\FileBitrixSettingsResource $checker */
/** @var FileBitrixSettingsResource $checker */
$checker = unserialize($content);
// Кривизна в мета-файле = конфиг потенциально не свежий.
if ($checker === false) {
Expand All @@ -86,7 +90,7 @@ public function isConfigFresh(string $configFile = '/bitrix/.settings.php') : bo
*/
public function createConfigMeta(string $configFile = '/bitrix/.settings.php') : void
{
$checker = new \ProklUng\ContainerBoilerplate\Resource\FileBitrixSettingsResource($this->projectRoot . $configFile);
$checker = new FileBitrixSettingsResource($this->projectRoot . $configFile);

@file_put_contents($this->projectRoot . $configFile . '.meta', serialize($checker));
}
Expand Down Expand Up @@ -189,20 +193,6 @@ public function cacheContainer(
return new $classCompiledContainerName();
}

/**
* Задать ID модуля.
*
* @param string $moduleId ID модуля.
*
* @return CompilerContainer
*/
public function setModuleId(string $moduleId): self
{
$this->moduleId = $moduleId;

return $this;
}

/**
* Если надо создать директорию для компилированного контейнера.
*
Expand Down
6 changes: 2 additions & 4 deletions src/DI/AbstractServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ public function load() : void
return;
}

$this->createContainer();
$compilerContainer = new CompilerContainer($_SERVER['DOCUMENT_ROOT']);

if (!$this->moduleId) {
throw new LogicException('Children of AbstractServiceContainer must define moduleId property.');
}

$compilerContainer->setModuleId($this->moduleId);
$this->createContainer();
$compilerContainer = new CompilerContainer($_SERVER['DOCUMENT_ROOT'], $this->moduleId);

// Кэшировать контейнер?
if (!in_array($this->environment, $this->parameters['compile_container_envs'], true)) {
Expand Down

0 comments on commit 90b0301

Please sign in to comment.