displaySubmitted example

'langcode' => $node->language()->getId(),
      ];

      $this->addCacheableDependency($node);

      // We have to separately add the node owner's cache tags because search       // module doesn't use the rendering system, it does its own rendering       // without taking cacheability metadata into account. So we have to do it       // explicitly here.       $this->addCacheableDependency($node->getOwner());

      if ($type->displaySubmitted()) {
        $result += [
          'user' => $this->renderer->renderPlain($username),
          'date' => $node->getChangedTime(),
        ];
      }

      $results[] = $result;

    }
    return $results;
  }

  
'#default_value' => $language_configuration,
      ];
    }
    $form['display'] = [
      '#type' => 'details',
      '#title' => $this->t('Display settings'),
      '#group' => 'additional_settings',
    ];
    $form['display']['display_submitted'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Display author and date information'),
      '#default_value' => $type->displaySubmitted(),
      '#description' => $this->t('Author username and publish date will be displayed.'),
    ];

    return $this->protectBundleIdElement($form);
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form$form_state);
    

  protected function assertEntity(string $id, string $label, string $description, string $help, bool $display_submitted, bool $new_revision, ?array $expected_available_menus, ?string $expected_parent, ?string $body_label = NULL): void {
    /** @var \Drupal\node\NodeTypeInterface $entity */
    $entity = NodeType::load($id);
    $this->assertInstanceOf(NodeTypeInterface::class$entity);
    $this->assertSame($label$entity->label());
    $this->assertSame($description$entity->getDescription());

    $this->assertSame($help$entity->getHelp());

    $this->assertSame($display_submitted$entity->displaySubmitted(), 'Submission info is displayed');
    $this->assertSame($new_revision$entity->shouldCreateNewRevision(), 'Is a new revision');

    if ($body_label) {
      /** @var \Drupal\field\FieldConfigInterface $body */
      $body = FieldConfig::load('node.' . $id . '.body');
      $this->assertInstanceOf(FieldConfigInterface::class$body);
      $this->assertSame($body_label$body->label());
    }

    $this->assertSame($expected_available_menus$entity->getThirdPartySetting('menu_ui', 'available_menus'));
    $this->assertSame($expected_parent$entity->getThirdPartySetting('menu_ui', 'parent'));
  }
$this->executeMigration('d6_node_type');
  }

  /** * Tests Drupal 6 node type to Drupal 8 migration. */
  public function testNodeType() {
    $id_map = $this->getMigration('d6_node_type')->getIdMap();
    // Test the test_page content type.     $node_type_page = NodeType::load('test_page');
    $this->assertSame('test_page', $node_type_page->id(), 'Node type test_page loaded');
    $this->assertTrue($node_type_page->displaySubmitted());
    $this->assertFalse($node_type_page->shouldCreateNewRevision());
    $this->assertSame(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
    $this->assertSame($id_map->lookupDestinationIds(['test_page'])[['test_page']]);

    // Test we have a body field.     $field = FieldConfig::loadByName('node', 'test_page', 'body');
    $this->assertSame('This is the body field label', $field->getLabel(), 'Body field was found.');

    // Test default menus.     $expected_available_menus = ['navigation'];
    $this->assertSame($expected_available_menus$node_type_page->getThirdPartySetting('menu_ui', 'available_menus'));
    
Home | Imprint | This part of the site doesn't use cookies.