public static function Token::create in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/core_event_dispatcher/src/ValueObject/Token.php \Drupal\core_event_dispatcher\ValueObject\Token::create()
Token factory function.
Parameters
string $type: The group name, like 'node'.
string $token: The token, like 'url' or 'id'.
string|\Drupal\Component\Render\MarkupInterface $name: The print-able name of the type.
Return value
\Drupal\core_event_dispatcher\ValueObject\Token Creates a new token.
Throws
\UnexpectedValueException
2 calls to Token::create()
- TokenEventTest::testTokenInfoEvent in modules/
core_event_dispatcher/ tests/ src/ Unit/ Token/ TokenEventTest.php - Test TokenInfoEvent.
- TokenTest::testTokenInvalidNameException in modules/
core_event_dispatcher/ tests/ src/ Unit/ Token/ TokenTest.php - Test Token invalid token exception.
File
- modules/
core_event_dispatcher/ src/ ValueObject/ Token.php, line 68
Class
- Token
- Token ValueObject.
Namespace
Drupal\core_event_dispatcher\ValueObjectCode
public static function create(string $type, string $token, $name) : self {
$instance = new self();
if (!is_string($name) && !$name instanceof MarkupInterface) {
throw new UnexpectedValueException('Name should be a string or an instance of MarkupInterface');
}
$instance->type = $type;
$instance->token = $token;
$instance->name = $name;
return $instance;
}