DomainSourceCommands.php in Domain Access 8
File
domain_source/src/Commands/DomainSourceCommands.php
View source
<?php
namespace Drupal\domain_source\Commands;
use Consolidation\AnnotatedCommand\AnnotationData;
use Consolidation\AnnotatedCommand\CommandData;
use Drupal\domain\Commands\DomainCommands;
use Drupal\domain_source\DomainSourceElementManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
class DomainSourceCommands extends DomainCommands {
public function initDomainInfo(InputInterface $input, AnnotationData $annotationData) {
$annotationData['field-labels'] .= "\n" . 'domain_source_entities: Domain source entities';
}
public function alterDomainInfo($result, CommandData $commandData) {
$result['domain_source_entities'] = $this
->getFieldEntities(DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD);
return $result;
}
public function deleteOptions(Command $command, AnnotationData $annotationData) {
$command
->addOption('source-assign', '', InputOption::VALUE_OPTIONAL, 'Reassign content for Domain Source', null);
}
public function domainSourceDomainDelete($target_domain, $options) {
if (is_null($options['content-assign'])) {
$policy_content = 'prompt';
}
if (!empty($options['content-assign'])) {
if (in_array($options['content-assign'], $this->reassignment_policies, TRUE)) {
$policy_content = $options['content-assign'];
}
}
$delete_options = [
'entity_filter' => 'node',
'policy' => $policy_content,
'field' => DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD,
];
return $this
->doReassign($target_domain, $delete_options);
}
}