You are here

public function DisablePathauto::onPreEntitySave in Acquia Content Hub 8.2

Turn off pathauto alias generation for entities being imported.

Parameters

\Drupal\acquia_contenthub\PreEntitySaveEvent $event: The pre entity save event.

File

src/EventSubscriber/PreEntitySave/DisablePathauto.php, line 49

Class

DisablePathauto
Disables path auto during pre-entity save.

Namespace

Drupal\acquia_contenthub\EventSubscriber\PreEntitySave

Code

public function onPreEntitySave(PreEntitySaveEvent $event) {
  $entity = $event
    ->getEntity();
  if ($this->handler
    ->moduleExists('pathauto') && $entity instanceof ContentEntityInterface && $entity
    ->hasField('path')) {
    $entity->path->pathauto = 0;
  }
}