当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::label方法代码示例

本文整理汇总了PHP中Drupal\node\NodeInterface::label方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::label方法的具体用法?PHP NodeInterface::label怎么用?PHP NodeInterface::label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\node\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = new Breadcrumb();
     $links[] = Link::createFromRoute(t('Home'), '<front>');
     // Articles page is a view.
     $links[] = Link::createFromRoute(t('Articles'), 'view.articles.page_1');
     $links[] = Link::createFromRoute($this->node->label(), '<none>');
     $breadcrumb->setLinks($links);
     return $breadcrumb;
 }
开发者ID:chi-teck,项目名称:drupal-code-generator,代码行数:13,代码来源:_breadcrumb_builder.php

示例2: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form['#title'] = $this->entity->label();
     if (!isset($this->entity->book)) {
         // The node is not part of any book yet - set default options.
         $this->entity->book = $this->bookManager->getLinkDefaults($this->entity->id());
     } else {
         $this->entity->book['original_bid'] = $this->entity->book['bid'];
     }
     // Find the depth limit for the parent select.
     if (!isset($this->entity->book['parent_depth_limit'])) {
         $this->entity->book['parent_depth_limit'] = $this->bookManager->getParentDepthLimit($this->entity->book);
     }
     $form = $this->bookManager->addFormElements($form, $form_state, $this->entity, $this->currentUser(), FALSE);
     return $form;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:19,代码来源:BookOutlineForm.php

示例3: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL)
 {
     $form['#title'] = $node->label();
     $form['#node'] = $node;
     $this->bookAdminTable($node, $form);
     $form['save'] = array('#type' => 'submit', '#value' => $this->t('Save book pages'));
     return $form;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:BookAdminEditForm.php

示例4: testSearchModuleDisabling

 /**
  * Verifies that you can disable individual search plugins.
  */
 function testSearchModuleDisabling()
 {
     // Array of search plugins to test: 'keys' are the keywords to search for,
     // and 'text' is the text to assert is on the results page.
     $plugin_info = array('node_search' => array('keys' => 'pizza', 'text' => $this->searchNode->label()), 'user_search' => array('keys' => $this->searchUser->getUsername(), 'text' => $this->searchUser->getEmail()), 'dummy_search_type' => array('keys' => 'foo', 'text' => 'Dummy search snippet to display'));
     $plugins = array_keys($plugin_info);
     /** @var $entities \Drupal\search\SearchPageInterface[] */
     $entities = entity_load_multiple('search_page');
     // Disable all of the search pages.
     foreach ($entities as $entity) {
         $entity->disable()->save();
     }
     // Test each plugin if it's enabled as the only search plugin.
     foreach ($entities as $entity_id => $entity) {
         // Set this as default.
         $this->drupalGet("admin/config/search/pages/manage/{$entity_id}/set-default");
         // Run a search from the correct search URL.
         $info = $plugin_info[$entity_id];
         $this->drupalGet('search/' . $entity->getPath(), array('query' => array('keys' => $info['keys'])));
         $this->assertResponse(200);
         $this->assertNoText('no results', $entity->label() . ' search found results');
         $this->assertText($info['text'], 'Correct search text found');
         // Verify that other plugin search tab labels are not visible.
         foreach ($plugins as $other) {
             if ($other != $entity_id) {
                 $label = $entities[$other]->label();
                 $this->assertNoText($label, $label . ' search tab is not shown');
             }
         }
         // Run a search from the search block on the node page. Verify you get
         // to this plugin's search results page.
         $terms = array('keys' => $info['keys']);
         $this->submitGetForm('node', $terms, t('Search'));
         $current = $this->getURL();
         $expected = \Drupal::url('search.view_' . $entity->id(), array(), array('query' => array('keys' => $info['keys']), 'absolute' => TRUE));
         $this->assertEqual($current, $expected, 'Block redirected to right search page');
         // Try an invalid search path, which should 404.
         $this->drupalGet('search/not_a_plugin_path');
         $this->assertResponse(404);
         $entity->disable()->save();
     }
     // Test with all search plugins enabled. When you go to the search
     // page or run search, all plugins should be shown.
     foreach ($entities as $entity) {
         $entity->enable()->save();
     }
     // Set the node search as default.
     $this->drupalGet('admin/config/search/pages/manage/node_search/set-default');
     $paths = array(array('path' => 'search/node', 'options' => array('query' => array('keys' => 'pizza'))), array('path' => 'search/node', 'options' => array()));
     foreach ($paths as $item) {
         $this->drupalGet($item['path'], $item['options']);
         foreach ($plugins as $entity_id) {
             $label = $entities[$entity_id]->label();
             $this->assertText($label, format_string('%label search tab is shown', array('%label' => $label)));
         }
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:60,代码来源:SearchConfigSettingsFormTest.php

示例5: bookExportHtml

 /**
  * Generates HTML for export when invoked by book_export().
  *
  * The given node is embedded to its absolute depth in a top level section. For
  * example, a child node with depth 2 in the hierarchy is contained in
  * (otherwise empty) <div> elements corresponding to depth 0 and depth 1.
  * This is intended to support WYSIWYG output - e.g., level 3 sections always
  * look like level 3 sections, no matter their depth relative to the node
  * selected to be exported as printer-friendly HTML.
  *
  * @param \Drupal\node\NodeInterface $node
  *   The node to export.
  *
  * @throws \Exception
  *   Thrown when the node was not attached to a book.
  *
  * @return array
  *   A render array representing the HTML for a node and its children in the
  *   book hierarchy.
  */
 public function bookExportHtml(NodeInterface $node)
 {
     if (!isset($node->book)) {
         throw new \Exception();
     }
     $tree = $this->bookManager->bookSubtreeData($node->book);
     $contents = $this->exportTraverse($tree, array($this, 'bookNodeExport'));
     return array('#theme' => 'book_export_html', '#title' => $node->label(), '#contents' => $contents, '#depth' => $node->book['depth'], '#cache' => ['tags' => $node->getEntityType()->getListCacheTags()]);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:BookExport.php

示例6: nodeGreeting

 public function nodeGreeting(NodeInterface $node)
 {
     if ($node->isPublished()) {
         $formatted = $node->body->processed;
         foreach ($node->field_tags as $tag) {
             $terms[] = $tag->entity->label();
         }
         return ['#theme' => 'greeting_node', '#title' => $node->label() . ' (' . $node->bundle() . ')', '#body' => $formatted, '#name' => $node->getOwner()->label(), '#terms' => $terms];
     }
     return ['#markup' => $this->t('Not published')];
 }
开发者ID:japo32,项目名称:greeting,代码行数:11,代码来源:GreetingController.php

示例7: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->nodeStorage->deleteRevision($this->revision->getRevisionId());
     $this->logger('content')->notice('@type: deleted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     $node_type = $this->nodeTypeStorage->load($this->revision->bundle())->label();
     drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '@type' => $node_type, '%title' => $this->revision->label())));
     $form_state->setRedirect('entity.node.canonical', array('node' => $this->revision->id()));
     if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $this->revision->id()))->fetchField() > 1) {
         $form_state->setRedirect('entity.node.version_history', array('node' => $this->revision->id()));
     }
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:14,代码来源:NodeRevisionDeleteForm.php

示例8: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->nodeStorage->deleteRevision($this->revision->getRevisionId());
     watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     $node_type = $this->nodeTypeStorage->load($this->revision->bundle())->label();
     drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '@type' => $node_type, '%title' => $this->revision->label())));
     $form_state['redirect_route'] = array('route_name' => 'node.view', 'route_parameters' => array('node' => $this->revision->id()));
     if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $this->revision->id()))->fetchField() > 1) {
         $form_state['redirect_route']['route_name'] = 'node.revision_overview';
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:14,代码来源:NodeRevisionDeleteForm.php

示例9: testAdminBookNodeListing

 /**
  * Tests the administrative listing of all book pages in a book.
  */
 public function testAdminBookNodeListing()
 {
     // Create a new book.
     $this->createBook();
     $this->drupalLogin($this->adminUser);
     // Load the book page list and assert the created book title is displayed
     // and action links are shown on list items.
     $this->drupalGet('admin/structure/book/' . $this->book->id());
     $this->assertText($this->book->label(), 'The book title is displayed on the administrative book listing page.');
     $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a');
     $this->assertEqual((string) $elements[0], 'View', 'View link is found from the list.');
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:15,代码来源:BookTest.php

示例10: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // The revision timestamp will be updated when the revision is saved. Keep
     // the original one for the confirmation message.
     $original_revision_timestamp = $this->revision->getRevisionCreationTime();
     $this->revision = $this->prepareRevertedRevision($this->revision, $form_state);
     $this->revision->revision_log = t('Copy of the revision from %date.', ['%date' => $this->dateFormatter->format($original_revision_timestamp)]);
     $this->revision->save();
     $this->logger('content')->notice('@type: reverted %title revision %revision.', ['@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
     drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', ['@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
     $form_state->setRedirect('entity.node.version_history', array('node' => $this->revision->id()));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:NodeRevisionRevertForm.php

示例11: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->revision->setNewRevision();
     // Make this the new default revision for the node.
     $this->revision->isDefaultRevision(TRUE);
     // The revision timestamp will be updated when the revision is saved. Keep the
     // original one for the confirmation message.
     $original_revision_timestamp = $this->revision->getRevisionCreationTime();
     $this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
     $this->revision->save();
     watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
     $form_state['redirect_route'] = array('route_name' => 'node.revision_overview', 'route_parameters' => array('node' => $this->revision->id()));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:NodeRevisionRevertForm.php

示例12: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->revision->setNewRevision();
     // Make this the new default revision for the node.
     $this->revision->isDefaultRevision(TRUE);
     // The revision timestamp will be updated when the revision is saved. Keep the
     // original one for the confirmation message.
     $original_revision_timestamp = $this->revision->getRevisionCreationTime();
     $this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
     $this->revision->save();
     $this->logger('content')->notice('@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
     $form_state->setRedirect('entity.node.version_history', array('node' => $this->revision->id()));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:17,代码来源:NodeRevisionRevertForm.php

示例13: testEmbeddedForm

 /**
  * Tests that the embedded form appears and can be submitted.
  */
 function testEmbeddedForm()
 {
     // First verify we can submit the form from the module's page.
     $this->drupalPostForm('search_embedded_form', array('name' => 'John'), t('Send away'));
     $this->assertText(t('Test form was submitted'), 'Form message appears');
     $count = \Drupal::state()->get('search_embedded_form.submit_count');
     $this->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
     $this->submitCount = $count;
     // Now verify that we can see and submit the form from the search results.
     $this->drupalGet('search/node', array('query' => array('keys' => $this->node->label())));
     $this->assertText(t('Your name'), 'Form is visible');
     $this->drupalPostForm(NULL, array('name' => 'John'), t('Send away'));
     $this->assertText(t('Test form was submitted'), 'Form message appears');
     $count = \Drupal::state()->get('search_embedded_form.submit_count');
     $this->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
     $this->submitCount = $count;
     // Now verify that if we submit the search form, it doesn't count as
     // our form being submitted.
     $this->drupalPostForm('search', array('keys' => 'foo'), t('Search'));
     $this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
     $count = \Drupal::state()->get('search_embedded_form.submit_count');
     $this->assertEqual($this->submitCount, $count, 'Form submission count is correct');
     $this->submitCount = $count;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:27,代码来源:SearchEmbedFormTest.php

示例14: doContentView

  /**
   * Test the flag relationship on another relationship.
   */
  public function doContentView() {
    $this->drupalLogin($this->userA);
    $this->drupalGet('flag-followers/content');
    $this->assertText($this->nodeB->label());
    $this->assertNoText($this->nodeC->label());

    $this->drupalLogin($this->userB);
    $this->drupalGet('flag-followers/content');
    $this->assertText($this->nodeA->label());
    $this->assertText($this->nodeC->label());

    $this->drupalLogin($this->userC);
    $this->drupalGet('flag-followers/content');
    $this->assertNoText($this->nodeA->label());
    $this->assertNoText($this->nodeB->label());
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:19,代码来源:FlagFollowerUITest.php

示例15: testBookNavigationBlockOnUnpublishedBook

 /**
  * Tests the book navigation block when book is unpublished.
  *
  * There was a fatal error with "Show block only on book pages" block mode.
  */
 public function testBookNavigationBlockOnUnpublishedBook()
 {
     // Create a new book.
     $this->createBook();
     // Create administrator user.
     $administratorUser = $this->drupalCreateUser(['administer blocks', 'administer nodes', 'bypass node access']);
     $this->drupalLogin($administratorUser);
     // Enable the block with "Show block only on book pages" mode.
     $this->drupalPlaceBlock('book_navigation', ['block_mode' => 'book pages']);
     // Unpublish book node.
     $edit = [];
     $this->drupalPostForm('node/' . $this->book->id() . '/edit', $edit, t('Save and unpublish'));
     // Test node page.
     $this->drupalGet('node/' . $this->book->id());
     $this->assertText($this->book->label(), 'Unpublished book with "Show block only on book pages" book navigation settings.');
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:21,代码来源:BookTest.php


注:本文中的Drupal\node\NodeInterface::label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。