EntityStub.php in Better Normalizers 8
File
src/Normalizer/EntityStub.php
View source
<?php
namespace Drupal\better_normalizers\Normalizer;
class EntityStub {
protected $entityTypeId;
protected $entityId;
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;
}
public function getEntityId() {
return $this->entityId;
}
public function getEntityTypeId() {
return $this->entityTypeId;
}
}
Classes
Name |
Description |
EntityStub |
Defines a value object to track an entity type and ID pair. |