You are here

class PathAutoAliasSubscriber in Multiversion 8

Creating a flag to skip generating new alias.

Hierarchy

  • class \Drupal\multiversion\EventSubscriber\PathAutoAliasSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of PathAutoAliasSubscriber

1 string reference to 'PathAutoAliasSubscriber'
multiversion.services.yml in ./multiversion.services.yml
multiversion.services.yml
1 service uses PathAutoAliasSubscriber
multiversion.pathauto_alias_subscriber in ./multiversion.services.yml
Drupal\multiversion\EventSubscriber\PathAutoAliasSubscriber

File

src/EventSubscriber/PathAutoAliasSubscriber.php, line 14

Namespace

Drupal\multiversion\EventSubscriber
View source
class PathAutoAliasSubscriber implements EventSubscriberInterface {

  /**
   * @var \Drupal\Core\State\StateInterface
   */
  protected $state;

  /**
   * Class constructor.
   *
   * @param \Drupal\Core\State\StateInterface $state
   */
  public function __construct(StateInterface $state) {
    $this->state = $state;
  }

  /**
   * Set flag for disabling alias generate.
   *
   * @param \Drupal\multiversion\Event\MultiversionManagerEvent $event
   */
  public function onPreMigrate(MultiversionManagerEvent $event) {
    $this->state
      ->set('skip_alias_save', TRUE);
  }

  /**
   * Remove flag "skip_pathauto_generator".
   *
   * @param \Drupal\multiversion\Event\MultiversionManagerEvent $event
   */
  public function onPostMigrate(MultiversionManagerEvent $event) {
    $this->state
      ->delete('skip_alias_save');
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      MultiversionManagerEvents::PRE_MIGRATE => [
        'onPreMigrate',
      ],
      MultiversionManagerEvents::POST_MIGRATE => [
        'onPostMigrate',
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PathAutoAliasSubscriber::$state protected property
PathAutoAliasSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
PathAutoAliasSubscriber::onPostMigrate public function Remove flag "skip_pathauto_generator".
PathAutoAliasSubscriber::onPreMigrate public function Set flag for disabling alias generate.
PathAutoAliasSubscriber::__construct public function Class constructor.