vendor/doctrine/doctrine-migrations-bundle/Collector/MigrationsCollector.php line 38

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Bundle\MigrationsBundle\Collector;
  4. use Doctrine\Migrations\DependencyFactory;
  5. use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpKernel\DataCollector\DataCollector;
  9. class MigrationsCollector extends DataCollector
  10. {
  11.     /** @var DependencyFactory */
  12.     private $dependencyFactory;
  13.     /** @var MigrationsFlattener */
  14.     private $flattener;
  15.     public function __construct(DependencyFactory $dependencyFactoryMigrationsFlattener $migrationsFlattener)
  16.     {
  17.         $this->dependencyFactory $dependencyFactory;
  18.         $this->flattener $migrationsFlattener;
  19.     }
  20.     public function collect(Request $requestResponse $response, \Throwable $exception null)
  21.     {
  22.         $metadataStorage $this->dependencyFactory->getMetadataStorage();
  23.         $planCalculator $this->dependencyFactory->getMigrationPlanCalculator();
  24.         $statusCalculator $this->dependencyFactory->getMigrationStatusCalculator();
  25.         $executedMigrations  $metadataStorage->getExecutedMigrations();
  26.         $availableMigrations $planCalculator->getMigrations();
  27.         $this->data['available_migrations'] = $this->flattener->flattenAvailableMigrations($availableMigrations$executedMigrations);
  28.         $this->data['executed_migrations'] = $this->flattener->flattenExecutedMigrations($executedMigrations$availableMigrations);
  29.         $this->data['new_migrations'] = $this->flattener->flattenAvailableMigrations($statusCalculator->getNewMigrations());
  30.         $this->data['unavailable_migrations'] = $this->flattener->flattenExecutedMigrations($statusCalculator->getExecutedUnavailableMigrations());
  31.         $this->data['storage'] = get_class($metadataStorage);
  32.         $configuration $this->dependencyFactory->getConfiguration();
  33.         $storage $configuration->getMetadataStorageConfiguration();
  34.         if ($storage instanceof TableMetadataStorageConfiguration) {
  35.             $this->data['table'] = $storage->getTableName();
  36.             $this->data['column'] = $storage->getVersionColumnName();
  37.         }
  38.         $connection $this->dependencyFactory->getConnection();
  39.         $this->data['driver'] = get_class($connection->getDriver());
  40.         $this->data['name'] = $connection->getDatabase();
  41.         $this->data['namespaces'] = $configuration->getMigrationDirectories();
  42.     }
  43.     public function getName()
  44.     {
  45.         return 'doctrine_migrations';
  46.     }
  47.     public function getData()
  48.     {
  49.         return $this->data;
  50.     }
  51.     public function reset()
  52.     {
  53.         $this->data = [];
  54.     }
  55. }