51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Domain;
|
|
|
|
/**
|
|
* Interface pour dire qu'un objet peut avoir un lien avec un autre objet par une table.
|
|
* Il s'agit d'une interface qui s'utilise sur des repositories de meta-données (Tag, Ingrédients)
|
|
*
|
|
* Les champs de toutes les méthodes se présentent de la même façon.
|
|
* $linkedTo : Champ qui va désigner le nom de la table de liens que vous avez dans getStructure().
|
|
* $linkingField : Champ dans la BDD qui va permettre de lier l'élément courant et l'étranger.
|
|
* $linkedEntity : Une instance de l'entité étrangère que l'on veut lier.
|
|
*/
|
|
interface LinkableInterface {
|
|
|
|
/**
|
|
* Permet de récupérer tous les liens entre notre entité implémentée et notre entité étrangère.
|
|
*
|
|
* @param string $linkedTo
|
|
* @param string $linkingField
|
|
* @param Model $linkedEntity
|
|
*
|
|
* @return array|null
|
|
*/
|
|
public function getIdLinkedTo( string $linkedTo, string $linkingField, Model $linkedEntity ): ?array;
|
|
|
|
/**
|
|
* Permet d'ajouter un lien entre notre entité implémentée et notre entité étrangère.
|
|
*
|
|
* @param string $linkedTo
|
|
* @param string $linkingField
|
|
* @param Model $linkedEntity
|
|
* @param Model $entity
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function addLinkBetween( string $linkedTo, string $linkingField, Model $linkedEntity, Model $entity ): bool;
|
|
|
|
/**
|
|
* Permet de retirer un lien entre notre entité implémentée et notre entité étrangère.
|
|
*
|
|
* @param string $linkedTo
|
|
* @param string $linkingField
|
|
* @param Model $linkedEntity
|
|
* @param Model $entity
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function removeLinkBetween( string $linkedTo, string $linkingField, Model $linkedEntity, Model $entity ): bool;
|
|
|
|
} |