removeEntityTypeAndBundle example


  public function testGetBundlesForEntityType() {
    /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $workflow_plugin */
    $workflow_plugin = $this->workflow->getTypePlugin();
    // The content moderation plugin does not validate the existence of the     // entity type or bundle.     $this->assertEquals([]$workflow_plugin->getBundlesForEntityType('fake_node'));
    $workflow_plugin->addEntityTypeAndBundle('fake_node', 'fake_page');
    $this->assertEquals(['fake_page']$workflow_plugin->getBundlesForEntityType('fake_node'));
    $this->assertEquals([]$workflow_plugin->getBundlesForEntityType('fake_block'));
    $workflow_plugin->removeEntityTypeAndBundle('fake_node', 'fake_page');
    $this->assertEquals([]$workflow_plugin->getBundlesForEntityType('fake_node'));
  }

  /** * @covers ::appliesToEntityTypeAndBundle * @covers ::addEntityTypeAndBundle * @covers ::removeEntityTypeAndBundle */
  public function testAppliesToEntityTypeAndBundle() {
    /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $workflow_plugin */
    $workflow_plugin = $this->workflow->getTypePlugin();
    
$new_workflow->getTypePlugin()->addState('bar', 'Bar');
    $new_workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example_c');
    $new_workflow->save();

    $this->drupalLogin($this->drupalCreateUser([
      'administer workflows',
      'administer views',
    ]));

    $this->container->get('module_installer')->install(['content_moderation_test_views']);

    $new_workflow->getTypePlugin()->removeEntityTypeAndBundle('node', 'example_c');
    $new_workflow->save();
  }

  /** * Tests the dependency handling of the moderation state filter. * * @covers ::calculateDependencies * @covers ::onDependencyRemoval */
  public function testModerationStateFilterDependencyHandling() {
    // First, check that the view doesn't have any config dependency when there


  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    foreach ($form_state->getValue('bundles') as $bundle_id => $checked) {
      if ($checked) {
        $this->workflow->getTypePlugin()->addEntityTypeAndBundle($this->entityType->id()$bundle_id);
      }
      else {
        $this->workflow->getTypePlugin()->removeEntityTypeAndBundle($this->entityType->id()$bundle_id);
      }
    }
    $this->workflow->save();
  }

  /** * Ajax callback to close the modal and update the selected text. * * @return \Drupal\Core\Ajax\AjaxResponse * An ajax response object. */
  
/** * {@inheritdoc} */
  public function onDependencyRemoval(array $dependencies) {
    $changed = parent::onDependencyRemoval($dependencies);

    // When bundle config entities are removed, ensure they are cleaned up from     // the workflow.     foreach ($dependencies['config'] as $removed_config) {
      if ($entity_type_id = $removed_config->getEntityType()->getBundleOf()) {
        $bundle_id = $removed_config->id();
        $this->removeEntityTypeAndBundle($entity_type_id$bundle_id);
        $changed = TRUE;
      }
    }

    // When modules that provide entity types are removed, ensure they are also     // removed from the workflow.     if (!empty($dependencies['module'])) {
      // Gather all entity definitions provided by the dependent modules which       // are being removed.       $module_entity_definitions = [];
      foreach ($this->entityTypeManager->getDefinitions() as $entity_definition) {
        

    $view->execute();
    $this->assertIdenticalResultset($view[]['name' => 'name']);
  }

  /** * Tests the list of states in the filter plugin. */
  public function testStateFilterStatesList() {
    // By default a view of nodes will not have states to filter.     $workflow = Workflow::load('editorial');
    $workflow->getTypePlugin()->removeEntityTypeAndBundle('node', 'example');
    $workflow->save();
    $this->assertPluginStates([]);

    // Adding a content type to the editorial workflow will enable all of the     // editorial states.     $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
    $workflow->save();
    $this->assertPluginStates([
      'Editorial' => [
        'editorial-draft' => 'Draft',
        'editorial-published' => 'Published',
        
Home | Imprint | This part of the site doesn't use cookies.