getSourceDirectories example



    /** * @return array<string> */
    public function getSourceDirectories(): array
    {
        $sources = [];

        foreach ($this->sources as $directory => $namespace) {
            if ($namespace instanceof MigrationSource) {
                $sources = array_merge($sources$namespace->getSourceDirectories());
            } else {
                $sources[$directory] = $namespace;
            }
        }

        return $sources;
    }

    public function getNamespacePattern(): string
    {
        $patterns = [];

        
__DIR__ . '/a/2' => 'My\Test\A1',
            __DIR__ . '/a/3' => 'My\Test\A2',
        ];
        $b = [
            __DIR__ . '/b/1' => 'My\Test\B1',
            __DIR__ . '/b/2' => 'My\Test\B2',
        ];
        $sourceA = new MigrationSource('a', $a);
        $sourceB = new MigrationSource('b', $b);

        $sourceAb = new MigrationSource('ab', [$sourceA$sourceB]);
        static::assertSame(array_merge($a$b)$sourceAb->getSourceDirectories());

        $sourceBa = new MigrationSource('ba', [$sourceB$sourceA]);
        static::assertSame(array_merge($b$a)$sourceBa->getSourceDirectories());
    }

    public function testNestedMigrationSourcesExtension(): void
    {
        $a = [
            __DIR__ . '/a/2' => 'My\Test\A1',
            __DIR__ . '/a/3' => 'My\Test\A2',
        ];
        


    /** * @throws InvalidMigrationClassException * * @return array<class-string<MigrationStep>, MigrationStep> */
    private function loadMigrationSteps(): array
    {
        $migrations = [];

        foreach ($this->migrationSource->getSourceDirectories() as $directory => $namespace) {
            if (!is_readable($directory)) {
                if ($this->logger !== null) {
                    $this->logger->warning(
                        'Migration directory "{directory}" for namespace "{namespace}" does not exist or is not readable.',
                        [
                            'directory' => $directory,
                            'namespace' => $namespace,
                        ]
                    );
                }

                
Home | Imprint | This part of the site doesn't use cookies.