sites_group_overrides-1.x-dev/src/SitesGroupOverridesServiceInterface.php
src/SitesGroupOverridesServiceInterface.php
<?php
declare(strict_types=1);
namespace Drupal\sites_group_overrides;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\group\Entity\GroupRelationshipInterface;
/**
* The sites_group_overrides service interface.
*/
interface SitesGroupOverridesServiceInterface {
/**
* Syncs the field values of an entity to another entity.
*
* @param \Drupal\group\Entity\GroupRelationshipInterface $relationship
* The source entity to copy from.
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The target entity.
*
* @return \Drupal\Core\Entity\FieldableEntityInterface
* The manipulated target entity.
*/
public function syncFieldsToEntity(GroupRelationshipInterface $relationship, ContentEntityInterface $entity): ContentEntityInterface;
/**
* Determines the synchronizable fields.
*
* @param \Drupal\group\Entity\GroupRelationshipInterface $relationship
* The source entity to copy from.
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The target entity.
*
* @return \Drupal\Core\Field\FieldItemListInterface[]
* An array of field item lists implementing, keyed by field name.
*/
public function getSynchronizableFields(GroupRelationshipInterface $relationship, ContentEntityInterface $entity): array;
/**
* Get entity types that are synced to relationships.
*
* @return
*/
public function getSourceBundleEntityTypes(): array;
/**
* Determines whether an entity is overriable.
*
* An entity is overriable if it contains at least one overideable field.
*
* @param ContentEntityInterface $entity
* The entity
* @return boolean
* TRUE, if the entity is overideable.
*/
public function entityIsOveridable(ContentEntityInterface $entity): bool;
/**
* See SitesGroupServiceInterface::getRelationship()
*/
public function getRelationship(ContentEntityInterface $entity): ?GroupRelationshipInterface;
/**
* Get the target (relationship) LB field name.
*
* @param GroupRelationshipInterface $relationship
* The group relationship
* @param string $field_name
* The source field name
* @return string|null
* The field name or NULL if overrides are disbaled or field is missing.
*/
public function getTargetFieldName(GroupRelationshipInterface $relationship, string $field_name): ?string;
/**
* Check whether an entity is overridden.
*
* @param ContentEntityInterface $entity
* The entity to check for overrides.
* @param GroupRelationshipInterface $relationship
* The relationship that may contain overrides.
* @return boolean
* TRUE, if the entity is overridden.
*/
public function entityIsOverridden(ContentEntityInterface $entity, GroupRelationshipInterface $relationship): bool;
/**
* Get all relationships for an entity that contain overrides.
*
* @param ContentEntityInterface $entity
* The entity to check for ovverides.
* @return GroupRelationshipInterface[]
* The relationships.
*/
public function getRelationshipsWithOverrides(ContentEntityInterface $entity): array;
/**
* Revert ovverides of a relationship.
*
* @param GroupRelationshipInterface $relationship
* The relationship to revert overrides on.
*/
public function revertOverride(GroupRelationshipInterface $relationship);
}
