Skip to content

Commit

Permalink
Create new command for initilizing folder structure for migrations
Browse files Browse the repository at this point in the history
Move creation of intial structure for migration to own command to
also cover needs for creating extension folder.
  • Loading branch information
andrerom committed Apr 23, 2018
1 parent 253a297 commit 0b06e0d
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 17 deletions.
1 change: 1 addition & 0 deletions bundle/Command/LegacyConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$configurationDumper->dump($configurationConverter->fromLegacy($package, $adminSiteaccess), $options);

$output->writeln('Configuration written to ezpublish.yml and environment related ezpublish configuration files.');
$output->writeln('Make sure to apply the config relevant to your install to you ezplatform.yml file.');
}
}
92 changes: 92 additions & 0 deletions bundle/Command/LegacyInitCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* File containing the LegacySrcSymlinkCommand class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Bundle\EzPublishLegacyBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

class LegacySrcSymlinkCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('ezpublish:legacy:init')
->setDefinition(
array(
new InputArgument('src', InputArgument::OPTIONAL, 'The src directory for legacy files', 'src/legacy_files'),
)
)
->setDescription('Inits folders you can use when migrating from eZ Publihs install to eZ Platform with Legacy Bridge')
->setHelp(
<<<EOT
The command <info>%command.name%</info> creates the following folders for migration usage:
- src/AppBundle/ezpublish_legacy => Optionaly for extensions you want to version in your project source (as opposed to install using composer)
- src/legacy_files/design => Optionally for cusotm designs not already made part of an extension
- src/legacy_files/settings/override => Folder for override settings for legacy
- src/legacy_files/settings/siteaccess => Folder for siteaccess settings for legacy
<info>src/legacy_files</info> stored in your root project for
any design/extension/settings project files, and symlinks these into <info>ezpublish_legacy/</info> which is installed by composer.
The benefit of this is:
1. Being able to version your design/extension/settings files in git without versioning legacy itself
2. A predefined convention for where to place these files when migrating from older versions
3. Placing these files directly in ezpublish_legacy folder will lead to them getting removed in some cases when composer
needs to completely replace ezpublish-legacy package for different reasons.
<comment>NOTE: Look towards 'ezpublish:legacybundles:install_extensions' command for how you handle legacy extensions.</comment>
EOT
);
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$srcArg = rtrim($input->getArgument('src'), '/');

/**
* @var \Symfony\Component\Filesystem\Filesystem
*/
$filesystem = $this->getContainer()->get('filesystem');

$filesystem->mkdir([
$srcArg,
"$srcArg/design",
//"$srcArg/AppBundle",
"$srcArg/AppBundle/ezpublish_legacy",
"$srcArg/settings",
"$srcArg/settings/override",
"$srcArg/settings/siteaccess",
]);


$output->writeln(<<<EOT
The following folders should have been created (or where already present):
- src/AppBundle/ezpublish_legacy _(for extensions)_
- src/legacy_files/design
- src/legacy_files/settings/override
- src/legacy_files/settings/siteaccess
Move over files and directories from older installation and afterwards run the folling commands to setup symlinks into
legacy install:
- <info>ezpublish:legacy:symlink</info>
- <info>ezpublish:legacybundles:install_extensions</info>
- <info>ezpublish:legacy:assets_install</info>
EOT
);
}
}
20 changes: 3 additions & 17 deletions bundle/Command/LegacySrcSymlinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ protected function configure()
new InputArgument('src', InputArgument::OPTIONAL, 'The src directory for legacy files', 'src/legacy_files'),
)
)
->addOption('create', 'c', InputOption::VALUE_NONE, 'Create "src" directory structure if it does not exist')
->addOption('force', null, InputOption::VALUE_NONE, 'Force symlinking folders even if target already exists')
->setDescription('Installs legacy project settings and design files from "src" to corresponding folders in ezpublish_legacy/')
->setHelp(
Expand All @@ -49,7 +48,6 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$srcArg = rtrim($input->getArgument('src'), '/');
$create = (bool)$input->getOption('create');
$force = (bool)$input->getOption('force');

/**
Expand All @@ -58,11 +56,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$filesystem = $this->getContainer()->get('filesystem');

if (!$filesystem->exists($srcArg)) {
if (!$create) {
$output->writeln(<<<EOT
$output->writeln(<<<EOT
Aborting: The src directory "$srcArg" does not exist.
You can create the directory by running <info>ezpublish:legacy:symlink -c</info>, OR by creating the folders you need
You can create the directory by running <info>ezpublish:legacy:init</info>, OR by creating the folders you need
manually among the ones supported by this command:
- $srcArg/design
- $srcArg/settings/override
Expand All @@ -74,18 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
, OutputInterface::VERBOSITY_QUIET
);

return;
}

$filesystem->mkdir([
$srcArg,
"$srcArg/design",
"$srcArg/settings",
"$srcArg/settings/override",
"$srcArg/settings/siteaccess",
]);

$output->writeln("<comment>Empty legacy src folder was created in '$srcArg'.</comment>");
return;
}

$symlinkFolderStr = implode(' ,', $this->linkSrcFolders($filesystem, $srcArg, $force, $output));
Expand Down

0 comments on commit 0b06e0d

Please sign in to comment.