You are here

class DomainSourceCommands in Domain Access 8

Drush commands for the domain source module.

These commands mainly extend base Domain commands. See the documentation at https://github.com/consolidation/annotated-command for details.

Hierarchy

  • class \Drupal\domain\Commands\DomainCommands extends \Drush\Commands\DrushCommands implements \Consolidation\AnnotatedCommand\Events\CustomEventAwareInterface uses \Consolidation\AnnotatedCommand\Events\CustomEventAwareTrait

Expanded class hierarchy of DomainSourceCommands

1 string reference to 'DomainSourceCommands'
drush.services.yml in domain_source/drush.services.yml
domain_source/drush.services.yml
1 service uses DomainSourceCommands
domain_source.commands in domain_source/drush.services.yml
\Drupal\domain_source\Commands\DomainSourceCommands

File

domain_source/src/Commands/DomainSourceCommands.php, line 19

Namespace

Drupal\domain_source\Commands
View source
class DomainSourceCommands extends DomainCommands {

  /**
   * Registers additional information to domain:info.
   *
   * @hook init domain:info
   */
  public function initDomainInfo(InputInterface $input, AnnotationData $annotationData) {

    // To add a field label, append to the 'field-labels' item.
    // @TODO: watch https://github.com/consolidation/annotated-command/pull/174
    $annotationData['field-labels'] .= "\n" . 'domain_source_entities: Domain source entities';
  }

  /**
   * Provides additional information to domain:info.
   *
   * @hook alter domain:info
   */
  public function alterDomainInfo($result, CommandData $commandData) {

    // Display which entities are enabled for domain by checking for the fields.
    $result['domain_source_entities'] = $this
      ->getFieldEntities(DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD);
    return $result;
  }

  /**
   * @hook option domain:delete
   */
  public function deleteOptions(Command $command, AnnotationData $annotationData) {
    $command
      ->addOption('source-assign', '', InputOption::VALUE_OPTIONAL, 'Reassign content for Domain Source', null);
  }

  /**
   * @hook on-event domain-delete
   */
  public function domainSourceDomainDelete($target_domain, $options) {

    // Run our own deletion routine here.
    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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DomainCommands::$domainStorage protected property The domain entity storage service.
DomainCommands::$entityFieldMap protected property Local cache of entity field map, kept for performance.
DomainCommands::$isDryRun protected property Flag set by the --dryrun cli option.
DomainCommands::$reassignmentPolicies protected property Static array of special-case policies for reassigning field data.
DomainCommands::add public function Add a new domain to the site.
DomainCommands::checkDomain protected function Checks if a domain exists by trying to do an http request to it.
DomainCommands::checkHttpResponse protected function Checks the domain response.
DomainCommands::createDomain protected function Helper function: check a domain is responsive and create it.
DomainCommands::defaultDomain public function Sets the default domain.
DomainCommands::delete public function Delete a domain from the site.
DomainCommands::deleteDomain protected function Deletes a domain record.
DomainCommands::disable public function Deactivates the domain.
DomainCommands::domainStorage protected function Gets a domain storage object or throw an exception.
DomainCommands::doReassign public function Handles reassignment of entities to another domain.
DomainCommands::enable public function Activates the domain.
DomainCommands::ensureEntityFieldMap protected function Ensure the local entity field map has been defined.
DomainCommands::entityHasDomainField protected function Determines whether or not a given entity is domain-enabled.
DomainCommands::enumerateDomainEntities protected function Enumerate entity instances of the supplied type and domain.
DomainCommands::filterDomains protected function Filters a list of domains by specific exclude list.
DomainCommands::findDomainEnabledEntities protected function Returns a list of the entity types that are domain enabled.
DomainCommands::generate public function Generate domains for testing.
DomainCommands::getDomainFromArgument protected function Loads a domain based on a string identifier.
DomainCommands::getDomainInstanceFromPolicy protected function Return the Domain object corresponding to a policy string.
DomainCommands::getFieldEntities public function Finds entities that reference a specific field.
DomainCommands::infoDomains public function List general information about the domains on the site.
DomainCommands::listDomains public function List active domains for the site.
DomainCommands::reassignEntities protected function Reassign old_domain entities, of the supplied type, to the new_domain.
DomainCommands::reassignLinkedEntities protected function Reassign entities of the supplied type to the $policy domain.
DomainCommands::renameDomain public function Changes a domain label.
DomainCommands::scheme public function Changes a domain scheme.
DomainCommands::test public function Tests domains for proper response.
DomainCommands::validateDomain protected function Validates a domain meets the standards for a hostname.
DomainSourceCommands::alterDomainInfo public function Provides additional information to domain:info.
DomainSourceCommands::deleteOptions public function @hook option domain:delete
DomainSourceCommands::domainSourceDomainDelete public function @hook on-event domain-delete
DomainSourceCommands::initDomainInfo public function Registers additional information to domain:info.