| 1 | <?php |
||
| 5 | trait EntityManagerAwareEntity |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var \Kaliop\eZObjectWrapperBundle\Core\EntityManager $entityManager |
||
| 9 | */ |
||
| 10 | private $entityManager; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param \Kaliop\eZObjectWrapperBundle\Core\EntityManager $entityManager |
||
| 14 | * @return $this |
||
| 15 | */ |
||
| 16 | 10 | public function setEntityManager($entityManager) |
|
| 21 | |||
| 22 | /** |
||
| 23 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityManager |
||
| 24 | */ |
||
| 25 | 1 | protected function getEntityManager() |
|
| 29 | |||
| 30 | /** |
||
| 31 | * A helper function made available for subclasses of Entity: returns the repository used for the current entity |
||
| 32 | * |
||
| 33 | * @return \Kaliop\eZObjectWrapperBundle\Core\RepositoryInterface |
||
| 34 | */ |
||
| 35 | 2 | protected function getRepository() |
|
| 39 | } |
||
| 40 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.