getMigrationNamespace example


                }
            }

            $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;
        }

        $params = [
            '%%timestamp%%' => $timestamp,
            '%%name%%' => $name,
            
public function deactivate(DeactivateContext $deactivateContext): void
    {
        if ($deactivateContext->getContext()->hasExtension(self::THROW_ERROR_ON_DEACTIVATE)) {
            throw new \BadFunctionCallException('Deactivate throws an error');
        }
        parent::deactivate($deactivateContext);
    }

    public function getMigrationNamespace(): string
    {
        return $_SERVER['FAKE_MIGRATION_NAMESPACE'] ?? parent::getMigrationNamespace();
    }

    public function getAdditionalBundles(AdditionalBundleParameters $parameters): array
    {
        require_once __DIR__ . '/../../../bundles/FooBarBundle.php';

        return [
            new FooBarBundle(),
        ];
    }

    
public function getMigrationNamespace(): string
    {
        return $this->getNamespace() . '\Migration';
    }

    public function getMigrationPath(): string
    {
        $migrationSuffix = str_replace(
            $this->getNamespace(),
            '',
            $this->getMigrationNamespace()
        );

        return $this->getPath() . str_replace('\\', '/', $migrationSuffix);
    }

    final public function getContainerPrefix(): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($this->getName());
    }

    public function configureRoutes(RoutingConfigurator $routes, string $environment): void
    {

    public function executeComposerCommands(): bool
    {
        return false;
    }

    final public function removeMigrations(): void
    {
        // namespace should not start with `shopware`         if (str_starts_with(mb_strtolower($this->getMigrationNamespace()), 'shopware') && !str_starts_with(mb_strtolower($this->getMigrationNamespace()), 'shopware\commercial')) {
            throw new \RuntimeException('Deleting Shopware migrations is not allowed');
        }

        $class = addcslashes($this->getMigrationNamespace(), '\\_%') . '%';
        Kernel::getConnection()->executeStatement('DELETE FROM migration WHERE class LIKE :class', ['class' => $class]);
    }

    public function getBasePath(): string
    {
        return $this->basePath;
    }

    
return $baseClass;
    }

    private function createMigrationCollection(Plugin $pluginBaseClass): MigrationCollection
    {
        $migrationPath = str_replace(
            '\\',
            '/',
            $pluginBaseClass->getPath() . str_replace(
                $pluginBaseClass->getNamespace(),
                '',
                $pluginBaseClass->getMigrationNamespace()
            )
        );

        if (!is_dir($migrationPath)) {
            return $this->migrationLoader->collect('null');
        }

        $this->migrationLoader->addSource(new MigrationSource($pluginBaseClass->getName()[
            $migrationPath => $pluginBaseClass->getMigrationNamespace(),
        ]));

        
public function deactivate(DeactivateContext $deactivateContext): void
    {
        if ($deactivateContext->getContext()->hasExtension(self::THROW_ERROR_ON_DEACTIVATE)) {
            throw new \BadFunctionCallException('Deactivate throws an error');
        }
        parent::deactivate($deactivateContext);
    }

    public function getMigrationNamespace(): string
    {
        return $_SERVER['FAKE_MIGRATION_NAMESPACE'] ?? parent::getMigrationNamespace();
    }

    public function getAdditionalBundles(AdditionalBundleParameters $parameters): array
    {
        require_once __DIR__ . '/../../../bundles/FooBarBundle.php';
        require_once __DIR__ . '/../../../bundles/GizmoBundle.php';

        return [
            new FooBarBundle(),
            -10 => new GizmoBundle(),
        ];
    }
Home | Imprint | This part of the site doesn't use cookies.