You are here

class LingotekFieldDeletedConfigSubscriber in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  2. 4.0.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  3. 3.0.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  4. 3.1.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  5. 3.2.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  6. 3.3.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  7. 3.5.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  8. 3.6.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  9. 3.7.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber
  10. 3.8.x src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php \Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber

Updates Lingotek config if a field is deleted.

Hierarchy

Expanded class hierarchy of LingotekFieldDeletedConfigSubscriber

1 string reference to 'LingotekFieldDeletedConfigSubscriber'
lingotek.services.yml in ./lingotek.services.yml
lingotek.services.yml
1 service uses LingotekFieldDeletedConfigSubscriber
lingotek.field_deleted_subscriber in ./lingotek.services.yml
Drupal\lingotek\EventSubscriber\LingotekFieldDeletedConfigSubscriber

File

src/EventSubscriber/LingotekFieldDeletedConfigSubscriber.php, line 15

Namespace

Drupal\lingotek\EventSubscriber
View source
class LingotekFieldDeletedConfigSubscriber implements EventSubscriberInterface {

  /**
   * The Lingotek configuration service.
   *
   * @var \Drupal\lingotek\LingotekConfigurationServiceInterface
   */
  protected $lingotekConfiguration;

  /**
   * Constructs a LingotekFieldDeletedConfigSubscriber.
   *
   * @param \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_configuration
   *   The Lingotek configuration service.
   */
  public function __construct(LingotekConfigurationServiceInterface $lingotek_configuration) {
    $this->lingotekConfiguration = $lingotek_configuration;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      ConfigEvents::DELETE => 'onConfigDelete',
    ];
  }

  /**
   * Updates the Lingotek configuration when a field is deleted.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   The configuration event.
   */
  public function onConfigDelete(ConfigCrudEvent $event) {
    if (!InstallerKernel::installationAttempted()) {
      $config = $event
        ->getConfig();
      if ($config instanceof FieldConfigInterface) {
        $field_name = $config
          ->getName();
        $entity_type_id = $config
          ->getTargetEntityTypeId();
        $bundle = $config
          ->getTargetBundle();
        $this->lingotekConfiguration
          ->setFieldLingotekEnabled($entity_type_id, $bundle, $field_name, FALSE);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LingotekFieldDeletedConfigSubscriber::$lingotekConfiguration protected property The Lingotek configuration service.
LingotekFieldDeletedConfigSubscriber::getSubscribedEvents public static function
LingotekFieldDeletedConfigSubscriber::onConfigDelete public function Updates the Lingotek configuration when a field is deleted.
LingotekFieldDeletedConfigSubscriber::__construct public function Constructs a LingotekFieldDeletedConfigSubscriber.