From c8283cca62eeb38892fd015395e2e04c425f2fc6 Mon Sep 17 00:00:00 2001 From: Gunnstein Lye Date: Thu, 20 Oct 2016 13:14:33 +0200 Subject: [PATCH] EZP-26391: ez-support-tools factory called on every request (#21) * EZP-26391: ez-support-tools factory called on every request Part 2, fixes Command by wrapping ezcSystemInfo and exposing magic properties. --- Resources/config/services.yml | 14 ++-- .../EzcHardwareSystemInfoCollector.php | 8 +-- .../Collector/EzcPhpSystemInfoCollector.php | 8 +-- SystemInfo/EzcSystemInfoFactory.php | 22 ------ SystemInfo/EzcSystemInfoWrapper.php | 69 +++++++++++++++++++ .../EzcHardwareSystemInfoCollectorTest.php | 8 ++- .../EzcPhpSystemInfoCollectorTest.php | 8 ++- 7 files changed, 90 insertions(+), 47 deletions(-) delete mode 100644 SystemInfo/EzcSystemInfoFactory.php create mode 100644 SystemInfo/EzcSystemInfoWrapper.php diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 87b5ff54..2cc5ea80 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -4,7 +4,7 @@ imports: parameters: support_tools.command.dump_info.class: EzSystems\EzSupportToolsBundle\Command\SystemInfoDumpCommand support_tools.system_info.collector_registry.class: EzSystems\EzSupportToolsBundle\SystemInfo\Registry\IdentifierBased - support_tools.system_info.ezc.factory.class: EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoFactory + support_tools.system_info.ezc.wrapper.class: EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper support_tools.system_info.collector.composer.lock_file.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector support_tools.system_info.collector.database.doctrine.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\DoctrineDatabaseSystemInfoCollector support_tools.system_info.collector.hardware.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcHardwareSystemInfoCollector @@ -22,14 +22,10 @@ services: support_tools.system_info.collector_registry: class: "%support_tools.system_info.collector_registry.class%" - support_tools.system_info.ezc: - class: ezcSystemInfo - factory: ["@support_tools.system_info.ezc.factory", buildEzcSystemInfo] + support_tools.system_info.ezc.wrapper: + class: "%support_tools.system_info.ezc.wrapper.class%" lazy: true - support_tools.system_info.ezc.factory: - class: "%support_tools.system_info.ezc.factory.class%" - # SystemInfoCollectors @@ -50,14 +46,14 @@ services: support_tools.system_info.collector.hardware.ezc: class: "%support_tools.system_info.collector.hardware.ezc.class%" arguments: - - "@support_tools.system_info.ezc" + - "@support_tools.system_info.ezc.wrapper" tags: - { name: "support_tools.system_info.collector", identifier: "hardware" } support_tools.system_info.collector.php.ezc: class: "%support_tools.system_info.collector.php.ezc.class%" arguments: - - "@support_tools.system_info.ezc" + - "@support_tools.system_info.ezc.wrapper" tags: - { name: "support_tools.system_info.collector", identifier: "php" } diff --git a/SystemInfo/Collector/EzcHardwareSystemInfoCollector.php b/SystemInfo/Collector/EzcHardwareSystemInfoCollector.php index c99686a2..3510da8c 100644 --- a/SystemInfo/Collector/EzcHardwareSystemInfoCollector.php +++ b/SystemInfo/Collector/EzcHardwareSystemInfoCollector.php @@ -8,7 +8,7 @@ */ namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector; -use ezcSystemInfo; +use EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper; use EzSystems\EzSupportToolsBundle\SystemInfo\Value; /** @@ -17,13 +17,11 @@ class EzcHardwareSystemInfoCollector implements SystemInfoCollector { /** - * ezcSystemInfo from eZ Components - * - * @var \ezcSystemInfo + * @var \EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper */ private $ezcSystemInfo; - public function __construct(ezcSystemInfo $ezcSystemInfo) + public function __construct(EzcSystemInfoWrapper $ezcSystemInfo) { $this->ezcSystemInfo = $ezcSystemInfo; } diff --git a/SystemInfo/Collector/EzcPhpSystemInfoCollector.php b/SystemInfo/Collector/EzcPhpSystemInfoCollector.php index f507d370..f17f4fe4 100644 --- a/SystemInfo/Collector/EzcPhpSystemInfoCollector.php +++ b/SystemInfo/Collector/EzcPhpSystemInfoCollector.php @@ -8,7 +8,7 @@ */ namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector; -use ezcSystemInfo; +use EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper; use EzSystems\EzSupportToolsBundle\SystemInfo\Value; /** @@ -17,13 +17,11 @@ class EzcPhpSystemInfoCollector implements SystemInfoCollector { /** - * ezcSystemInfo from eZ Components - * - * @var \ezcSystemInfo + * @var \EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper */ private $ezcSystemInfo; - public function __construct(ezcSystemInfo $ezcSystemInfo) + public function __construct(EzcSystemInfoWrapper $ezcSystemInfo) { $this->ezcSystemInfo = $ezcSystemInfo; } diff --git a/SystemInfo/EzcSystemInfoFactory.php b/SystemInfo/EzcSystemInfoFactory.php deleted file mode 100644 index 3b16d984..00000000 --- a/SystemInfo/EzcSystemInfoFactory.php +++ /dev/null @@ -1,22 +0,0 @@ -$var = $ezcSystemInfo->$var; + } + } +} diff --git a/Tests/SystemInfo/Collector/EzcHardwareSystemInfoCollectorTest.php b/Tests/SystemInfo/Collector/EzcHardwareSystemInfoCollectorTest.php index fa868f35..ae8dd583 100644 --- a/Tests/SystemInfo/Collector/EzcHardwareSystemInfoCollectorTest.php +++ b/Tests/SystemInfo/Collector/EzcHardwareSystemInfoCollectorTest.php @@ -10,13 +10,12 @@ use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcHardwareSystemInfoCollector; use EzSystems\EzSupportToolsBundle\SystemInfo\Value\HardwareSystemInfo; -use ezcSystemInfo; use PHPUnit_Framework_TestCase; class EzcHardwareSystemInfoCollectorTest extends PHPUnit_Framework_TestCase { /** - * @var ezcSystemInfo|\PHPUnit_Framework_MockObject_MockObject + * @var \EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper|\PHPUnit_Framework_MockObject_MockObject */ private $ezcSystemInfoMock; @@ -27,7 +26,10 @@ class EzcHardwareSystemInfoCollectorTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->ezcSystemInfoMock = $this->getMockBuilder('ezcSystemInfo')->disableOriginalConstructor()->getMock(); + $this->ezcSystemInfoMock = $this + ->getMockBuilder('EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper') + ->disableOriginalConstructor() + ->getMock(); $this->ezcSystemInfoMock->cpuType = 'Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz'; $this->ezcSystemInfoMock->cpuSpeed = '2591.9000000000001'; $this->ezcSystemInfoMock->cpuCount = '1'; diff --git a/Tests/SystemInfo/Collector/EzcPhpSystemInfoCollectorTest.php b/Tests/SystemInfo/Collector/EzcPhpSystemInfoCollectorTest.php index 668c956e..0c5e10b4 100644 --- a/Tests/SystemInfo/Collector/EzcPhpSystemInfoCollectorTest.php +++ b/Tests/SystemInfo/Collector/EzcPhpSystemInfoCollectorTest.php @@ -10,13 +10,12 @@ use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcPhpSystemInfoCollector; use EzSystems\EzSupportToolsBundle\SystemInfo\Value\PhpSystemInfo; -use ezcSystemInfo; use PHPUnit_Framework_TestCase; class EzcPhpSystemInfoCollectorTest extends PHPUnit_Framework_TestCase { /** - * @var ezcSystemInfo|\PHPUnit_Framework_MockObject_MockObject + * @var \EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper|\PHPUnit_Framework_MockObject_MockObject */ private $ezcSystemInfoMock; @@ -27,7 +26,10 @@ class EzcPhpSystemInfoCollectorTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->ezcSystemInfoMock = $this->getMockBuilder('ezcSystemInfo')->disableOriginalConstructor()->getMock(); + $this->ezcSystemInfoMock = $this + ->getMockBuilder('EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper') + ->disableOriginalConstructor() + ->getMock(); $this->ezcSystemInfoMock->phpVersion = phpversion(); $this->ezcSystemInfoMock->phpAccelerator = $this