canModerateEntitiesOfEntityType example

    if ($this->router->getRouteCollection()->get('content_moderation.admin_moderated_content') !== NULL) {
      $this->derivatives['content_moderation.moderated_content'] = [
        'route_name' => 'content_moderation.admin_moderated_content',
        'title' => $this->t('Moderated content'),
        'parent_id' => 'system.admin_content',
        'weight' => 1,
      ];
    }

    // Add the latest version tab to entities.     $latest_version_entities = array_filter($this->entityTypeManager->getDefinitions()function DEntityTypeInterface $type) {
      return $this->moderationInfo->canModerateEntitiesOfEntityType($type) && $type->hasLinkTemplate('latest-version');
    });

    foreach ($latest_version_entities as $entity_type_id => $entity_type) {
      $this->derivatives["$entity_type_id.latest_version_tab"] = [
        'route_name' => "entity.$entity_type_id.latest_version",
        'title' => $this->t('Latest version'),
        'base_route' => "entity.$entity_type_id.canonical",
        'weight' => 1,
      ] + $base_plugin_definition;
    }

    
$this->assertSame($published$entity->isPublished());
    }
  }

  /** * Tests that the 'taxonomy_term' entity type cannot be moderated. */
  public function testTaxonomyTermEntityTypeModeration() {
    /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */
    $moderation_info = \Drupal::service('content_moderation.moderation_information');
    $entity_type = \Drupal::entityTypeManager()->getDefinition('taxonomy_term');
    $this->assertFalse($moderation_info->canModerateEntitiesOfEntityType($entity_type));
  }

}


  /** * Tests that the 'workspace' entity type can not be moderated. * * @see \Drupal\workspaces\EntityTypeInfo::entityTypeAlter() */
  public function testWorkspaceEntityTypeModeration() {
    /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */
    $moderation_info = \Drupal::service('content_moderation.moderation_information');
    $entity_type = \Drupal::entityTypeManager()->getDefinition('workspace');
    $this->assertFalse($moderation_info->canModerateEntitiesOfEntityType($entity_type));
  }

  /** * Tests the integration between Content Moderation and Workspaces. * * @see content_moderation_workspace_access() */
  public function testContentModerationIntegrationWithWorkspaces() {
    $editorial = $this->createEditorialWorkflow();
    $access_handler = \Drupal::entityTypeManager()->getAccessControlHandler('workspace');

    
// Finally, assert that when Content Moderation is installed, a new revision     // is automatically created when PATCHing for entity types that have a     // moderation handler.     // @see \Drupal\content_moderation\Entity\Handler\ModerationHandler::onPresave()     // @see \Drupal\content_moderation\EntityTypeInfo::$moderationHandlers     if ($updated_entity instanceof EntityPublishedInterface) {
      $updated_entity->setPublished()->save();
    }
    $this->assertTrue($this->container->get('module_installer')->install(['content_moderation'], TRUE), 'Installed modules.');

    if (!\Drupal::service('content_moderation.moderation_information')->canModerateEntitiesOfEntityType($this->entity->getEntityType())) {
      return;
    }

    $workflow = $this->createEditorialWorkflow();
    $workflow->getTypePlugin()->addEntityTypeAndBundle(static::$entityTypeId$this->entity->bundle());
    $workflow->save();
    $this->grantPermissionsToTestedRole(['use editorial transition publish']);
    $doc_add_items['data']['attributes']['field_rest_test_multivalue'][2] = ['value' => '3'];
    $request_options[RequestOptions::BODY] = Json::encode($doc_add_items);
    $response = $this->request('PATCH', $url$request_options);
    $this->assertResourceResponse(200, FALSE, $response);
    
'#title' => $this->t('This workflow applies to:'),
      '#open' => TRUE,
    ];
    $form['entity_types_container']['entity_types'] = [
      '#type' => 'table',
      '#header' => $header,
      '#empty' => $this->t('There are no entity types.'),
    ];

    $entity_types = $this->entityTypeManager->getDefinitions();
    foreach ($entity_types as $entity_type) {
      if (!$this->moderationInfo->canModerateEntitiesOfEntityType($entity_type)) {
        continue;
      }

      $selected_bundles = [];
      foreach ($this->entityTypeBundleInfo->getBundleInfo($entity_type->id()) as $bundle_id => $bundle) {
        if ($this->workflowType->appliesToEntityTypeAndBundle($entity_type->id()$bundle_id)) {
          $selected_bundles[$bundle_id] = $bundle['label'];
        }
      }

      $selected_bundles_list = [
        
/** * {@inheritdoc} */
  public function canModerateEntitiesOfEntityType(EntityTypeInterface $entity_type) {
    return $entity_type->hasHandlerClass('moderation');
  }

  /** * {@inheritdoc} */
  public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type$bundle) {
    if ($this->canModerateEntitiesOfEntityType($entity_type)) {
      $bundles = $this->bundleInfo->getBundleInfo($entity_type->id());
      return isset($bundles[$bundle]['workflow']);
    }
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function getDefaultRevisionId($entity_type_id$entity_id) {
    if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) {
      
Home | Imprint | This part of the site doesn't use cookies.