New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature to easily copy to other locale. #2092

Open
jeroendesloovere opened this Issue Jun 13, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@jeroendesloovere
Member

jeroendesloovere commented Jun 13, 2017

Type

  • Feature

Problem description

Fork CMS is a "multi-language" CMS.
Sometimes you need to add another language to the CMS and want to have everything duplicated in the new language by using bin/console forkcms:locale:enable.

Currently the following modules have "CopyToOtherLocale" methods/commands available:

  • Pages
  • ContentBlocks

These are automatically executed when you run bin/console forkcms:locale:enable.

But in other (custom) modules you have to create such feature yourself and you have to execute them yourself.

Expected behavior / Proposed solutions

What if this could be automated very easily by adding the following method in the module installer?!?

$this->addModule('ContentBlocks');
$this->addCopyCommand(CopyContentBlocksToOtherLocale::class);

[Edited]: the above can be replaced by a command bus handler using a specific "symfony tag".

In Fork CMS we are working towards a Domain-base structure with Commands.
I guess if we have a Core CopyToOtherLocale command that we can extend, things will be awesome.

<?php

namespace Backend\Core\Command\Base;

use Backend\Core\Language\Locale;

final class CopyToOtherLocale
{
    /** @var Locale */
    public $toLocale;

    /** @var Locale */
    public $fromLocale;

    public function __construct(Locale $toLocale, Locale $fromLocale = null)
    {
        if ($fromLocale === null) {
            $fromLocale = Locale::workingLocale();
        }

        $this->toLocale = $toLocale;
        $this->fromLocale = $fromLocale;
    }
}
<?php

namespace Backend\Modules\ContentBlocks\Domain\ContentBlock\Command;

use Backend\Core\Command\Base\CopyToOtherLocale;

final class CopyContentBlocksToOtherLocale extends CopyToOtherLocale
{
}

Seems like something that can be integrated easily.

Some thoughts?

@jeroendesloovere

This comment has been minimized.

Show comment
Hide comment
@jeroendesloovere

jeroendesloovere Jun 13, 2017

Member

Another solution

Using service tags to get all available "copy commands".

Member

jeroendesloovere commented Jun 13, 2017

Another solution

Using service tags to get all available "copy commands".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment