Throw an Exception if the bundle type is incorrect
This commit is contained in:
parent
9f175475c5
commit
2daeca7f8e
|
@ -6,7 +6,13 @@ use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
final class PostWrapper {
|
final class PostWrapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
public function __construct(private NodeInterface $post) {
|
public function __construct(private NodeInterface $post) {
|
||||||
|
if ($post->bundle() !== 'post') {
|
||||||
|
throw new \InvalidArgumentException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType(): string {
|
public function getType(): string {
|
||||||
|
|
Loading…
Reference in a new issue