- Let's create an Entity directory in our module's src folder. First, we will create an interface for our entity by creating a MessageInterface.php file:
- The MessageInterface will extend \Drupal\Core\Entity\ContentEntityInterface:
<?php namespace Drupal\mymodule\Entity; use Drupal\Core\Entity\ContentEntityInterface; interface MessageInterface extends ContentEntityInterface { /** * Gets the message value. * * @return string */ public function getMessage(); }
This will be implemented by our entity and will provide the method requirements. It is best practice to provide an interface for entities. This allows you to provide ...