<?php // \Drupal\Core\Entity\EntityInterface interface EntityInterface { // ... } // \Drupal\Core\Entity\OwnerInterface interface OwnerInterface extends EntityInterface { // Just a marker interface (for now?). } // \Drupal\user\UserInterface interface UserInterface extends OwnerInterface { // ... } // \Drupal\user\User class User implements UserInterface { } // \Drupal\Core\Entity\OwnedEntityInterface interface OwnedEntityInterface { // For callers this work fine when you pass an object whose class implements // UserInterface. Implementors may need to adapt but this is fine according to // our current policies (https://www.drupal.org/core/d8-bc-policy): // "Interfaces follow a similar pattern as above with respect to @api, // @internal, or neither. However, in case of neither tag, the interface is // treated as an API for callers but not for implementers." public function setOwner(OwnerInterface $owner); // ... } // Example class. class OwnedEntity implements OwnedEntityInterface { public function setOwner(OwnerInterface $owner) {} } /** * @deprecated */ // \Drupal\user\EntityOwnerInterface interface EntityOwnerInterface extends OwnedEntityInterface { // This now empty, all methods are in "OwnedEntityInterface". } $user = new User(); $entity = new OwnedEntity(); $entity->setOwner($user);
You have javascript disabled. You will not be able to edit any code.