protected function DomainCommands::getDomainFromArgument in Domain Access 8
Loads a domain based on a string identifier.
Parameters
string $argument: The machine name or the hostname of an existing domain.
Return value
\Drupal\domain\DomainInterface The domain entity.
Throws
\Drupal\domain\Commands\DomainCommandException
7 calls to DomainCommands::getDomainFromArgument()
- DomainCommands::defaultDomain in domain/
src/ Commands/ DomainCommands.php - Sets the default domain.
- DomainCommands::delete in domain/
src/ Commands/ DomainCommands.php - Delete a domain from the site.
- DomainCommands::disable in domain/
src/ Commands/ DomainCommands.php - Deactivates the domain.
- DomainCommands::enable in domain/
src/ Commands/ DomainCommands.php - Activates the domain.
- DomainCommands::renameDomain in domain/
src/ Commands/ DomainCommands.php - Changes a domain label.
File
- domain/
src/ Commands/ DomainCommands.php, line 998
Class
- DomainCommands
- Drush commands for the domain module.
Namespace
Drupal\domain\CommandsCode
protected function getDomainFromArgument($argument) {
// Try loading domain assuming arg is a machine name.
$domain = $this
->domainStorage()
->load($argument);
if (!$domain) {
// Try loading assuming it is a host name.
$domain = $this
->domainStorage()
->loadByHostname($argument);
}
// domain_id (an INT) is only used internally because the Node Access
// system demands the use of numeric keys. It should never be used to load
// or identify domain records. Use the machine_name or hostname instead.
if (!$domain) {
throw new DomainCommandException(dt('Domain record could not be found from "!a".', [
'!a' => $argument,
]));
}
return $domain;
}