You are here

class DomainAccessCommands in Domain Access 8

Drush commands for the domain access 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 DomainAccessCommands

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

File

domain_access/src/Commands/DomainAccessCommands.php, line 19

Namespace

Drupal\domain_access\Commands
View source
class DomainAccessCommands 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_access_entities: Domain access 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_access_entities'] = $this
      ->getFieldEntities(DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD);
    return $result;
  }

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

  /**
   * @hook on-event domain-delete
   */
  public function domainAccessDomainDelete($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' => DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD,
    ];
    return $this
      ->doReassign($target_domain, $delete_options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DomainAccessCommands::alterDomainInfo public function Provides additional information to domain:info.
DomainAccessCommands::deleteOptions public function @hook option domain:delete
DomainAccessCommands::domainAccessDomainDelete public function @hook on-event domain-delete
DomainAccessCommands::initDomainInfo public function Registers additional information to domain:info.
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.