You are here

class AcsfDuplicationScrubNodeHandler in Acquia Cloud Site Factory Connector 8.2

Same name and namespace in other branches
  1. 8 src/Event/AcsfDuplicationScrubNodeHandler.php \Drupal\acsf\Event\AcsfDuplicationScrubNodeHandler

Handles the scrubbing of Drupal nodes.

Hierarchy

Expanded class hierarchy of AcsfDuplicationScrubNodeHandler

1 file declares its use of AcsfDuplicationScrubNodeHandler
AcsfDuplicationCommands.php in acsf_duplication/src/Commands/AcsfDuplicationCommands.php

File

src/Event/AcsfDuplicationScrubNodeHandler.php, line 8

Namespace

Drupal\acsf\Event
View source
class AcsfDuplicationScrubNodeHandler extends AcsfDuplicationScrubEntityHandler {

  /**
   * Constructor.
   *
   * @param AcsfEvent $event
   *   The event that has been initiated.
   */
  public function __construct(AcsfEvent $event) {
    $this->entityTypeId = 'node';
    parent::__construct($event);
  }

  /**
   * Implements AcsfEventHandler::handle().
   */
  public function handle() {
    $options = $this->event->context['scrub_options'];
    if ($options['retain_content']) {

      // We still want to log that we were here.
      $this
        ->consoleLog(dt('Entered @class', [
        '@class' => get_class($this),
      ]));
      return;
    }
    parent::handle();
  }

  /**
   * {@inheritdoc}
   */
  protected function getBaseQuery() {
    $entity_query = parent::getBaseQuery();
    $entity_query
      ->condition('uid', $this
      ->getPreservedUsers(), 'NOT IN');
    return $entity_query;
  }

  /**
   * {@inheritdoc}
   */
  protected function getPreservedUsers() {
    $preserved_uids = parent::getPreservedUsers();

    // Remove the anonymous user from the list, since we do want to delete that
    // content.
    if (($key = array_search(0, $preserved_uids)) !== FALSE) {
      unset($preserved_uids[$key]);
    }
    return $preserved_uids;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcsfDuplicationScrubEntityHandler::$acsfVarStorage protected property The ACSF variable storage.
AcsfDuplicationScrubEntityHandler::$entityTypeId protected property The entity type to scrub.
AcsfDuplicationScrubEntityHandler::$entityTypeManager protected property The entity manager.
AcsfDuplicationScrubEntityHandler::$moduleHandler protected property The module handler.
AcsfDuplicationScrubEntityHandler::countRemaining public function Counts the entities that still need to be processed. 1
AcsfDuplicationScrubEntityHandler::deleteEntities protected function Deletes entities. 1
AcsfDuplicationScrubEntityHandler::getSiteAdmins public function Gets a list of site admins.
AcsfDuplicationScrubNodeHandler::getBaseQuery protected function Gets an initialized entity query instance. Overrides AcsfDuplicationScrubEntityHandler::getBaseQuery
AcsfDuplicationScrubNodeHandler::getPreservedUsers protected function Gets a list of user IDs which should not be scrubbed. Overrides AcsfDuplicationScrubEntityHandler::getPreservedUsers
AcsfDuplicationScrubNodeHandler::handle public function Implements AcsfEventHandler::handle(). Overrides AcsfDuplicationScrubEntityHandler::handle
AcsfDuplicationScrubNodeHandler::__construct public function Constructor. Overrides AcsfDuplicationScrubEntityHandler::__construct
AcsfEventHandler::$completed public property The time that the handler was completed.
AcsfEventHandler::$message public property Any messages triggered by the handler.
AcsfEventHandler::$started public property The time that the handler was started.
AcsfEventHandler::consoleLog public function Writes a log message to the console.