You are here

function hook_domain_source_alter in Domain Access 8

Same name and namespace in other branches
  1. 6.2 API.php \hook_domain_source_alter()
  2. 7.3 domain.api.php \hook_domain_source_alter()
  3. 7.2 domain.api.php \hook_domain_source_alter()

Allows modules to specify the target domain for an entity.

There is no return value for this hook. Modify $source by reference by loading a valid domain record or set $source = NULL to discard an existing $source value and not rewrite the path.

Note that $options['entity'] is the entity for the path request and $options['entity_type'] is the type of entity (e.g. 'node'). These values have already been verified before this hook is called.

If the entity's path is a translation, the requested translation of the entity will be passed as the $entity value.

Parameters

\Drupal\domain\Entity\Domain|null &$source: A domain object or NULL if not set.

string $path: The outbound path request.

array $options: The options for the url, as defined by \Drupal\Core\PathProcessor\OutboundPathProcessorInterface.

1 function implements hook_domain_source_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

domain_source_test_domain_source_alter in domain_source/tests/modules/domain_source_test/domain_source_test.module
Implements hook_domain_source_path_alter()
1 invocation of hook_domain_source_alter()
DomainSourcePathProcessor::processOutbound in domain_source/src/HttpKernel/DomainSourcePathProcessor.php
Processes the outbound path.

File

domain_source/domain_source.api.php, line 30
API documentation file for Domain Source module.

Code

function hook_domain_source_alter(array &$source, $path, array $options) {

  // Always link to the default domain.
  $source = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->loadDefaultDomain();
}