diff --git a/src/Command/ObjectConversionCommand.php b/src/Command/ObjectConversionCommand.php index 18f855a..de02a3a 100644 --- a/src/Command/ObjectConversionCommand.php +++ b/src/Command/ObjectConversionCommand.php @@ -10,7 +10,6 @@ namespace Oveleon\ContaoComponentStyleManager\Command; -use Contao\CoreBundle\Framework\ContaoFramework; use Oveleon\ContaoComponentStyleManager\StyleManager\Sync; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidArgumentException; @@ -28,15 +27,10 @@ class ObjectConversionCommand extends Command { protected static $defaultName = 'contao:stylemanager:object-conversion'; - - protected ContaoFramework $framework; private Sync $sync; - public function __construct(ContaoFramework $contaoFramework, Sync $sync) + public function __construct(Sync $sync) { - $this->framework = $contaoFramework; - $this->framework->initialize(); - $this->sync = $sync; parent::__construct(); diff --git a/src/Migration/Version30/ObjectConversionMigration.php b/src/Migration/Version30/ObjectConversionMigration.php index 29f0785..bfbe220 100644 --- a/src/Migration/Version30/ObjectConversionMigration.php +++ b/src/Migration/Version30/ObjectConversionMigration.php @@ -2,7 +2,6 @@ namespace Oveleon\ContaoComponentStyleManager\Migration\Version30; -use Contao\CoreBundle\Framework\ContaoFramework; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; use Doctrine\DBAL\Connection; @@ -15,23 +14,14 @@ class ObjectConversionMigration extends AbstractMigration */ private $connection; - /** - * @var ContaoFramework - */ - private $framework; - /** * @var Sync */ private $sync; - public function __construct(Connection $connection, ContaoFramework $framework, Sync $sync) + public function __construct(Connection $connection, Sync $sync) { $this->connection = $connection; - - $this->framework = $framework; - $this->framework->initialize(); - $this->sync = $sync; } diff --git a/src/StyleManager/Sync.php b/src/StyleManager/Sync.php index ea1961e..22fe2d5 100644 --- a/src/StyleManager/Sync.php +++ b/src/StyleManager/Sync.php @@ -31,7 +31,6 @@ class Sync public function __construct(ContaoFramework $framework, Connection $connection) { $this->framework = $framework; - $this->framework->initialize(); $this->connection = $connection; } @@ -42,6 +41,8 @@ public function __construct(ContaoFramework $framework, Connection $connection) */ public function shouldRunObjectConversion($table = null): bool { + $this->framework->initialize(); + $schemaManager = method_exists($this->connection, 'createSchemaManager') ? $this->connection->createSchemaManager() : $this->connection->getSchemaManager() @@ -77,6 +78,8 @@ public function shouldRunObjectConversion($table = null): bool */ public function performObjectConversion($table = null): void { + $this->framework->initialize(); + $schemaManager = method_exists($this->connection, 'createSchemaManager') ? $this->connection->createSchemaManager() : $this->connection->getSchemaManager() @@ -265,6 +268,8 @@ public static function mergeGroupObjects(?StyleManagerModel $objOriginal, ?Style */ public function export(?DataContainer $dc, $objArchives = null, bool $blnSendToBrowser = true) { + $this->framework->initialize(); + // Create a new XML document $xml = new DOMDocument('1.0', 'UTF-8'); $xml->formatOutput = true;