function domain_source_get in Domain Access 8
Returns the source domain associated to an entity.
Parameters
Drupal\Core\Entity\EntityInterface $entity: The entity to check.
Return value
string|null The value assigned to the entity, either a domain id string or NULL.
4 calls to domain_source_get()
- DomainAccessManager::getContentUrls in domain_access/
src/ DomainAccessManager.php - Get all possible URLs pointing to an entity.
- DomainSourceEntityReferenceTest::testDomainSourceFieldStorage in domain_source/
tests/ src/ Functional/ DomainSourceEntityReferenceTest.php - Tests the storage of the domain source field.
- DomainSourceLanguageTest::testDomainSourceLanguage in domain_source/
tests/ src/ Functional/ DomainSourceLanguageTest.php - Tests domain source language.
- DomainSourcePathProcessor::processOutbound in domain_source/
src/ HttpKernel/ DomainSourcePathProcessor.php - Processes the outbound path.
File
- domain_source/
domain_source.module, line 111 - Domain-based path rewrites for content.
Code
function domain_source_get(EntityInterface $entity) {
$source = NULL;
if (!isset($entity->{DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD})) {
return $source;
}
$value = $entity
->get(DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD)
->offsetGet(0);
if (!empty($value)) {
$target_id = $value->target_id;
if ($domain = \Drupal::entityTypeManager()
->getStorage('domain')
->load($target_id)) {
$source = $domain
->id();
}
}
return $source;
}