You are here

class EntityConflictResolutionEvent in Conflict 8.2

Hierarchy

Expanded class hierarchy of EntityConflictResolutionEvent

5 files declare their use of EntityConflictResolutionEvent
ConflictResolverManager.php in src/ConflictResolver/ConflictResolverManager.php
MergeRemoteOnlyChanges.php in src/ConflictResolution/MergeRemoteOnlyChanges.php
MergeRemoteStructure.php in modules/conflict_paragraphs/src/ConflictResolution/MergeRemoteStructure.php
MergeStrategyBase.php in src/ConflictResolution/MergeStrategyBase.php
MergeStrategyInterface.php in src/ConflictResolution/MergeStrategyInterface.php

File

src/Event/EntityConflictResolutionEvent.php, line 8

Namespace

Drupal\conflict\Event
View source
class EntityConflictResolutionEvent extends EntityConflictDiscoveryEvent {

  /**
   * The result entity.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $resultEntity;

  /**
   * Constructs a conflict discovery event object.
   *
   * @param \Drupal\Core\Entity\EntityInterface $local
   *   The local part of the comparision - for example the entity built of the
   *   user input on an entity form submission. This is basically the active
   *   entity object.
   * @param \Drupal\Core\Entity\EntityInterface $remote
   *   The remote part of the comparision - for example the current version of
   *   the entity from the storage.
   * @param \Drupal\Core\Entity\EntityInterface $base
   *   The initial entity version in concurrent editing or the lowest common
   *   ancestor in a revision tree scenario.
   * @param \Drupal\Core\Entity\EntityInterface $result
   *   The result entity, on which to apply the result. Usually this will be the
   *   active entity object - the local entity.
   * @param array $conflicts
   *   The conflicts.
   * @param \Symfony\Component\HttpFoundation\ParameterBag $context
   *   (optional) The context parameter bag.
   */
  public function __construct(EntityInterface $local, EntityInterface $remote, EntityInterface $base, EntityInterface $result, array $conflicts, ParameterBag $context = NULL) {
    parent::__construct($local, $remote, $base, $context);
    $this->conflicts = $conflicts;
    $this->resultEntity = $result;
  }

  /**
   * Creates a conflict resolution event object from a conflict discovery event.
   *
   * @param \Drupal\conflict\Event\EntityConflictDiscoveryEvent
   *   The conflict discovery event.
   * @param \Drupal\Core\Entity\EntityInterface $result
   *   The result entity, on which to apply the result.
   *
   * @return static
   */
  public static function createFromConflictDiscoveryEvent(EntityConflictDiscoveryEvent $event, EntityInterface $result) {
    return new static($event->LocalEntity, $event->RemoteEntity, $event->baseEntity, $result, $event->conflicts, $event->context);
  }

  /**
   * Returns the result entity.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   */
  public function getResultEntity() : EntityInterface {
    return $this->resultEntity;
  }

  /**
   * Removes a conflict.
   *
   * This method should called when a conflict has been resolved or the property
   * value on the resulting entity satisfies the merge strategy.
   *
   * @param string $property
   *   The conflicting property.
   */
  public function removeConflict($property) {
    unset($this->conflicts[$property]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityConflictDiscoveryEvent::$baseEntity protected property The base entity.
EntityConflictDiscoveryEvent::$conflicts protected property An array containing the conflicting properties.
EntityConflictDiscoveryEvent::$context protected property A context parameter bag.
EntityConflictDiscoveryEvent::$localEntity protected property The local entity.
EntityConflictDiscoveryEvent::$remoteEntity protected property The remote entity.
EntityConflictDiscoveryEvent::addConflict public function Adds a conflicting property.
EntityConflictDiscoveryEvent::getBaseEntity public function Returns the base entity.
EntityConflictDiscoveryEvent::getConflicts public function Returns the conflicts.
EntityConflictDiscoveryEvent::getContextParameter public function Returns a parameter value from the context bag.
EntityConflictDiscoveryEvent::getLocalEntity public function Return the local entity.
EntityConflictDiscoveryEvent::getRemoteEntity public function Returns the remote entity.
EntityConflictResolutionEvent::$resultEntity protected property The result entity.
EntityConflictResolutionEvent::createFromConflictDiscoveryEvent public static function Creates a conflict resolution event object from a conflict discovery event.
EntityConflictResolutionEvent::getResultEntity public function Returns the result entity.
EntityConflictResolutionEvent::removeConflict public function Removes a conflict.
EntityConflictResolutionEvent::__construct public function Constructs a conflict discovery event object. Overrides EntityConflictDiscoveryEvent::__construct