class EntityStub in Better Normalizers 8
Defines a value object to track an entity type and ID pair.
Hierarchy
- class \Drupal\better_normalizers\Normalizer\EntityStub
Expanded class hierarchy of EntityStub
File
- src/
Normalizer/ EntityStub.php, line 8
Namespace
Drupal\better_normalizers\NormalizerView source
class EntityStub {
/**
* Entity Type ID.
*
* @var string
*/
protected $entityTypeId;
/**
* Entity ID.
*
* @var mixed
*/
protected $entityId;
/**
* Factory method to create new stub from entity URI.
*
* @param string $uri
* Entity URI to parse.
*
* @return static
* New instance.
*
* @throws \InvalidArgumentException
* When not an entity URI.
*/
public static function fromEntityUri($uri) {
$scheme = parse_url($uri, PHP_URL_SCHEME);
if ($scheme !== 'entity') {
throw new \InvalidArgumentException();
}
$path = parse_url($uri, PHP_URL_PATH);
$static = new static();
list($static->entityTypeId, $static->entityId) = explode('/', $path);
return $static;
}
/**
* Gets value of entity_id.
*
* @return mixed
* Value of entity_id
*/
public function getEntityId() {
return $this->entityId;
}
/**
* Gets value of entity_type_id.
*
* @return mixed
* Value of entity_type_id
*/
public function getEntityTypeId() {
return $this->entityTypeId;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityStub:: |
protected | property | Entity ID. | |
EntityStub:: |
protected | property | Entity Type ID. | |
EntityStub:: |
public static | function | Factory method to create new stub from entity URI. | |
EntityStub:: |
public | function | Gets value of entity_id. | |
EntityStub:: |
public | function | Gets value of entity_type_id. |