Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! Migrate to doctrine/migration v3 #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions Classes/Command/DiffCommand.php

This file was deleted.

46 changes: 0 additions & 46 deletions Classes/Command/ExecuteCommand.php

This file was deleted.

46 changes: 0 additions & 46 deletions Classes/Command/MigrateCommand.php

This file was deleted.

43 changes: 0 additions & 43 deletions Classes/Command/RollupCommand.php

This file was deleted.

43 changes: 0 additions & 43 deletions Classes/Command/StatusCommand.php

This file was deleted.

43 changes: 0 additions & 43 deletions Classes/Command/UpToDateCommand.php

This file was deleted.

43 changes: 0 additions & 43 deletions Classes/Command/VersionCommand.php

This file was deleted.

40 changes: 9 additions & 31 deletions Classes/Migration/AbstractDataHandlerMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

namespace KayStrobach\Migrations\Migration;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\Migrations\Version\Version;
use KayStrobach\Migrations\DataHandling\DryRunDataHandler;
use KayStrobach\Migrations\Service\DoctrineMigrationCoordinator;
use KayStrobach\Migrations\Service\DoctrineService;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

/**
* Base class for migrations using the TYPO3 DataHandler
Expand All @@ -40,31 +35,12 @@ abstract class AbstractDataHandlerMigration extends AbstractMigration

private DoctrineMigrationCoordinator $doctrineMigrationCoordinator;

private DoctrineService $doctrineService;

public function __construct(Version $version)
public function __construct(Connection $connection, LoggerInterface $logger)
{
parent::__construct($version);
parent::__construct($connection, $logger);

$this->doctrineMigrationCoordinator = new DoctrineMigrationCoordinator();
$this->doctrineMigrationCoordinator->setCurrentVersion(static::class);

if (VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) < 100000) {
$dependencyOrderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
$packageManager = GeneralUtility::makeInstance(PackageManager::class, $dependencyOrderingService);
} else {
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
}

// todo: refactor this with proper dependency injection if possible
/** @var DoctrineService $doctrineService */
$doctrineService = GeneralUtility::makeInstance(
DoctrineService::class,
$packageManager,
GeneralUtility::makeInstance(ConnectionPool::class),
GeneralUtility::makeInstance(LogManager::class),
);
$this->doctrineService = $doctrineService;
}

/**
Expand Down Expand Up @@ -101,7 +77,7 @@ public function preUp(Schema $schema): void

$this->getMigrationCoordinator()->setCurrentVersion($version);

Bootstrap::initializeBackendAuthentication(true);
Bootstrap::initializeBackendAuthentication();
}

public function postUp(Schema $schema): void
Expand All @@ -113,7 +89,7 @@ public function postUp(Schema $schema): void

public function preDown(Schema $schema): void
{
Bootstrap::initializeBackendAuthentication(true);
Bootstrap::initializeBackendAuthentication();
}

/**
Expand All @@ -124,7 +100,9 @@ public function preDown(Schema $schema): void
*/
protected function getDataHandler(array $dataMap = [], array $commandMap = []): DataHandler
{
$dataHandlerClass = $this->doctrineService->isDryRun() ? DryRunDataHandler::class : DataHandler::class;
// @todo Find a way to pass the information about --dry-run from the Command to here:
//$dataHandlerClass = $isDryRun ? DryRunDataHandler::class : DataHandler::class;
$dataHandlerClass = DataHandler::class;

/** @var DataHandler $dataHandler */
$dataHandler = GeneralUtility::makeInstance($dataHandlerClass);
Expand Down
Loading