Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.

Update compatibility #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions console.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
content_sync.import:
class: Drupal\content_sync\Command\ImportCommand
arguments: []
tags:
- { name: drupal.command }
16 changes: 13 additions & 3 deletions src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

namespace Drupal\content_sync\Command;

use Drupal\Console\Command\ContainerAwareCommand;
use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Symfony\Component\Console\Input\InputArgument;

/**
* Class AbstractCommand.
*
* @package Drupal\content_sync\Command
*/
abstract class AbstractCommand extends ContainerAwareCommand {
abstract class AbstractCommand extends Command {

use ContainerAwareCommandTrait;

/**
* Content manager service.
Expand All @@ -28,8 +31,15 @@ abstract class AbstractCommand extends ContainerAwareCommand {
* {@inheritdoc}
*/
protected function configure() {
$this->contentManager = $this->getService('content_sync.manager');
$this->addArgument('folder', InputArgument::REQUIRED, $this->trans('command.content-sync.arguments.folder'));
}

/**
* @return \Drupal\content_sync\ContentSyncManagerInterface
*/
protected function getContentManager() {
$this->contentManager = $this->get('content_sync.manager');
return $this->contentManager;
}

}
2 changes: 1 addition & 1 deletion src/Command/AbstractExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure() {
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$this->contentManager->exportContentToFolder($input->getArgument('folder'), $this->getEntityTypeId(), $input->getOption('conditions'));
$this->getContentManager()->exportContentToFolder($input->getArgument('folder'), $this->getEntityTypeId(), $input->getOption('conditions'));
$output->writeln("Content exported to " . $input->getArgument('folder'), OutputInterface::OUTPUT_NORMAL);
}

Expand Down
12 changes: 9 additions & 3 deletions src/Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@

namespace Drupal\content_sync\Command;

use Drupal\Console\Annotations\DrupalCommand;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class ImportCommand.
*
* @package Drupal\content_sync
* @DrupalCommand (
* extension="content_sync",
* extensionType="module"
* )
*/
class ImportCommand extends AbstractCommand {

Expand All @@ -23,15 +28,16 @@ class ImportCommand extends AbstractCommand {
*/
protected function configure() {
parent::configure();
$this->setName('content-sync:import')->setDescription($this->trans('command.content-sync.import.description'));
$this->setName('content-sync:import')
->setDescription($this->trans('command.content-sync.import.description'));
$this->addOption('update', 'u', InputOption::VALUE_NONE, $this->trans('command.content-sync.import.options.update'));
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$this->contentManager->importContentFromFolder($input->getArgument('folder'), $input->getOption('update'));
$this->getContentManager()->importContentFromFolder($input->getArgument('folder'), $input->getOption('update'));
$output->writeln("Content imported from " . $input->getArgument('folder'), OutputInterface::OUTPUT_NORMAL);
}

Expand Down