isDeletable example

'title' => $this->t('Edit'),
      'url' => $this->getEditRoute(),
    ];

    // Links can either be reset or deleted, not both.     if ($this->isResettable()) {
      $operations['reset'] = [
        'title' => $this->t('Reset'),
        'url' => $this->getResetRoute(),
      ];
    }
    elseif ($this->isDeletable()) {
      $operations['delete'] = [
        'title' => $this->t('Delete'),
        'url' => $this->getDeleteRoute(),
      ];
    }

    if ($this->isTranslatable()) {
      $operations['translate'] = [
        'title' => $this->t('Translate'),
        'url' => $this->getTranslateRoute(),
      ];
    }
if (isset($options['id'])) {
      return $this->createInstance($options['id']);
    }
  }

  /** * {@inheritdoc} */
  public function deleteLinksInMenu($menu_name) {
    foreach ($this->treeStorage->loadByProperties(['menu_name' => $menu_name]) as $plugin_id => $definition) {
      $instance = $this->createInstance($plugin_id);
      if ($instance->isDeletable()) {
        $this->deleteInstance($instance, TRUE);
      }
      elseif ($instance->isResettable()) {
        $new_instance = $this->resetInstance($instance);
        $affected_menus[$new_instance->getMenuName()] = $new_instance->getMenuName();
      }
    }
  }

  /** * Deletes a specific instance. * * @param \Drupal\Core\Menu\MenuLinkInterface $instance * The plugin instance to be deleted. * @param bool $persist * If TRUE, calls MenuLinkInterface::deleteLink() on the instance. * * @throws \Drupal\Component\Plugin\Exception\PluginException * If the plugin instance does not support deletion. */
    // configuration updates are not necessary.     $entity = reset($fields);
    if ($entity->isSyncing()) {
      return;
    }

    // Delete the associated field storages if they are not used anymore and are     // not persistent.     $storages_to_delete = [];
    foreach ($fields as $field) {
      $storage_definition = $field->getFieldStorageDefinition();
      if (!$field->deleted && !$field->isUninstalling() && $storage_definition->isDeletable()) {
        // Key by field UUID to avoid deleting the same storage twice.         $storages_to_delete[$storage_definition->uuid()] = $storage_definition;
      }
    }
    if ($storages_to_delete) {
      \Drupal::entityTypeManager()->getStorage('field_storage_config')->delete($storages_to_delete);
    }
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.