kreait/ezpublish-migrations-bundle

该包已被废弃,不再维护。作者建议使用kaliop/ezmigrationbundle包。

eZ Publish/eZ Platform 迁移

4.0 2016-02-26 15:43 UTC

README

eZ Publish/Platform 迁移

废弃/存档:自2016年以来,该包未收到更新,远远落后于eZ Publish/Platform的当前开发,因此已被标记为存档/废弃。请切换到kaliop/ezmigrationbundle

特性

除了来自DoctrineMigrationsBundle的命令外,此包还提供了额外的ezpublish:migrations:generate命令,该命令可以简化eZ Publish/Platform相关更改。

  • 自动设置执行更改的active eZ用户(默认:admin
  • 允许快速更改当前活动用户,例如,以特定用户的名义创建新内容。
  • 添加创建新内容的简写方法

如果您熟悉Doctrine Migrations,您会感到非常熟悉。

安装

composer require kreait/ezpublish-migrations-bundle

AppKernel.php(eZ Platform)或EzPublishKernel.php(eZ Publish 5)中启用DoctrineMigrationsBundle和KreaitEzPublishMigrationsBundle

public function registerBundles()
{
    $bundles = array(
        //...
        new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
        new Kreait\EzPublish\MigrationsBundle\KreaitEzPublishMigrationsBundle(),
    );
}

配置

您可以在您的config.yml中配置这些包。以下示例是默认值。

doctrine_migrations:
    dir_name: "%kernel.root_dir%/DoctrineMigrations"
    namespace: Application\Migrations
    table_name: migration_versions
    name: Application Migrations

ezpublish_migrations:
    # The login name of the user performing the migrations.
    ez_migrations_user: admin

使用方法

使用方法与Symfony的DoctrineMigrationBundle相同,增加了以下命令

# Generate a blank eZ Publish/Platform enabled migration class
$ ezpublish:migrations:generate

您可以在迁移中使用$this->repository访问eZ仓库。

请参阅src/Resources/doc/examples中的eZ Publish相关示例迁移。

辅助方法

在迁移过程中更改当前迁移用户

您可以通过以下命令在迁移中更改当前的eZ Publish用户

// All subsequent calls will be made as the user with the given name
$this->changeMigrationUser('another_username');

使用以下命令恢复默认迁移用户

// Restores the current user to the configured migrations user.
$this->restoreDefaultMigrationUser();

快速创建简单内容

$this->createContent($parentLocationId, $contentTypeIdentifier, $languageCode, array $fields);

请参阅创建新内容示例

已知问题

当您仅使用eZ Publish的API方法创建迁移时,在DoctrineMigrationsBundle的术语中不会执行任何SQL语句。这会导致以下消息

迁移已执行,但没有生成任何SQL语句。

替代方案