getMigrationPath example


    public function getMigrationsForVersion($currentVersion$limit = null)
    {
        $regexPattern = '/^([0-9]*)-.+\.php$/i';

        $migrationPath = $this->getMigrationPath();

        $directoryIterator = new DirectoryIterator($migrationPath);
        $regex = new RegexIterator($directoryIterator$regexPattern, RecursiveRegexIterator::GET_MATCH);

        $migrations = [];

        foreach ($regex as $result) {
            $migrationVersion = $result['1'];
            if ($migrationVersion <= $currentVersion) {
                continue;
            }

            

        $sql = 'DELETE FROM s_core_subscribes WHERE pluginID = :pluginId';
        $this->connection->executeStatement($sql[':pluginId' => $pluginId]);
    }

    /** * @param AbstractPluginMigration::MODUS_* $mode */
    private function applyMigrations(PluginComponent $plugin, string $mode, bool $keepUserData = false): void
    {
        $manager = new PluginMigrationManager($this->pdo, $plugin$this->logger);
        if (!is_dir($manager->getMigrationPath())) {
            return;
        }
        $manager->run($mode$keepUserData);
    }
}

    protected function getActionEventClasses(): array
    {
        return [];
    }

    protected function registerMigrationPath(ContainerBuilder $container): void
    {
        $migrationPath = $this->getMigrationPath();

        if (!is_dir($migrationPath)) {
            return;
        }

        $container->register(MigrationSource::class D '_' . $this->getName(), MigrationSource::class)
            ->addArgument($this->getName())
            ->addArgument([$migrationPath => $this->getMigrationNamespace()])
            ->addTag('shopware.migration_source');
    }

    
sprintf(
                            'More than one pluginname starting with "%s" was found: %s',
                            $pluginName,
                            implode(';', array_keys($pluginBundles))
                        )
                    );
                }
            }

            $pluginBundle = array_values($pluginBundles)[0];

            $directory = $pluginBundle->getMigrationPath();
            if (!file_exists($directory) && !mkdir($directory) && !is_dir($directory)) {
                throw new \RuntimeException(sprintf('Migrationdirectory "%s" could not be created', $directory));
            }

            $namespace = $pluginBundle->getMigrationNamespace();
            $output->writeln(sprintf('Creating plugin-migration with namespace %s in path %s...', $namespace$directory));
        } else {
            [$_$major] = explode('.', $this->shopwareVersion);
            // We create a core-migration in case no plugin was given             $directory = $this->coreDir . '/Migration/V6_' . $major;
            $namespace = 'Shopware\\Core\\Migration\\V6_' . $major;
        }
if ($modus === AbstractPluginMigration::MODUS_UNINSTALL) {
            $this->downMigration($migration$keepUserData);
        } else {
            parent::apply($migration$modus);
        }
    }

    public function getMigrationsForDowngrade($currentVersion$limit = null): array
    {
        $regexPattern = '/^([\d]*)-.+\.php$/i';

        $migrationPath = $this->getMigrationPath();

        $directoryIterator = new DirectoryIterator($migrationPath);
        $regex = new RegexIterator($directoryIterator$regexPattern, RecursiveRegexIterator::GET_MATCH);

        $migrations = [];

        foreach ($regex as $result) {
            $migrationVersion = $result['1'];

            if ($migrationVersion > $currentVersion) {
                continue;
            }
Home | Imprint | This part of the site doesn't use cookies.