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


PHP node\NodeInterface类代码示例

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


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

示例1: access

 /**
  * {@inheritdoc}
  */
 public function access(Route $route, AccountInterface $account, NodeInterface $node = NULL)
 {
     if ($node->bundle() && \Drupal::config('webform.settings')->get('node_' . $node->bundle())) {
         return AccessResult::allowed();
     }
     return AccessResult::forbidden();
 }
开发者ID:Progressable,项目名称:openway8,代码行数:10,代码来源:WebformNodeAccessCheck.php

示例2: 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

示例3: 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

示例4: access

 /**
  * Checks access to the node preview page.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param \Drupal\node\NodeInterface $node_preview
  *   The node that is being previewed.
  *
  * @return string
  *   A \Drupal\Core\Access\AccessInterface constant value.
  */
 public function access(AccountInterface $account, NodeInterface $node_preview)
 {
     if ($node_preview->isNew()) {
         $access_controller = $this->entityManager->getAccessControlHandler('node');
         return $access_controller->createAccess($node_preview->bundle(), $account, [], TRUE);
     } else {
         return $node_preview->access('update', $account, TRUE);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:20,代码来源:NodePreviewAccessCheck.php

示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL)
 {
     $this->attributeTable = 'uc_product_attributes';
     $this->optionTable = 'uc_product_options';
     $this->idField = 'nid';
     $this->idValue = $node->id();
     $attributes = uc_product_get_attributes($node->id());
     return parent::buildForm($form, $form_state, $attributes);
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:12,代码来源:ProductAttributesAddForm.php

示例6: readNode

 /**
  * Marks a node as read by the current user right now.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request of the page.
  * @param \Drupal\node\NodeInterface $node
  *   The node whose "last read" timestamp should be updated.
  */
 public function readNode(Request $request, NodeInterface $node)
 {
     if ($this->currentUser()->isAnonymous()) {
         throw new AccessDeniedHttpException();
     }
     // Update the history table, stating that this user viewed this node.
     history_write($node->id());
     return new JsonResponse((int) history_read($node->id()));
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:17,代码来源:HistoryController.php

示例7: createNodeRevision

 /**
  * Creates a new revision for a given node.
  *
  * @param \Drupal\node\NodeInterface $node
  *   A node object.
  *
  * @return \Drupal\node\NodeInterface
  *   A node object with up to date revision information.
  */
 protected function createNodeRevision(NodeInterface $node)
 {
     // Create revision with a random title and body and update variables.
     $node->title = $this->randomMachineName();
     $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
     $node->setNewRevision();
     $node->save();
     return $node;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:NodeRevisionsAllTest.php

示例8: canViewRegistration

 /**
  * Determine if a user can view a given registration node.
  *
  * The user may view the node if they are the creator of it, or if they are
  * an admin.
  *
  * @param \Drupal\node\NodeInterface $node
  * @param \Drupal\Core\Session\AccountInterface $account
  * @return \Drupal\Core\Access\AccessResult
  */
 public function canViewRegistration(\Drupal\node\NodeInterface $node, \Drupal\Core\Session\AccountInterface $account)
 {
     if ($account->hasPermission('administer content')) {
         return \Drupal\Core\Access\AccessResult::allowed();
     }
     if ($node->getOwner()->getAccountName() === $account->getAccountName()) {
         return \Drupal\Core\Access\AccessResult::allowed();
     }
     return \Drupal\Core\Access\AccessResult::forbidden();
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:20,代码来源:RegistrationService.php

示例9: 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

示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL)
 {
     $query = \Drupal::request()->query->all();
     $form['#action'] = Url::fromRoute('<current>')->setOptions(['query' => $query])->toString();
     $form['nid'] = array('#type' => 'value', '#value' => $node->id());
     $form['qty'] = array('#type' => 'value', '#value' => 1);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Add to cart'), '#id' => 'edit-submit-' . $node->id());
     uc_form_alter($form, $form_state, $this->getFormId());
     return $form;
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:14,代码来源:BuyItNowForm.php

示例11: schedule

 /**
  * Simulates the scheduled (un)publication of a node.
  *
  * @param \Drupal\node\NodeInterface $node
  *   The node to schedule.
  * @param string $action
  *   The action to perform: either 'publish' or 'unpublish'. Defaults to
  *   'publish'.
  *
  * @return \Drupal\node\NodeInterface
  *   The updated node, after scheduled (un)publication via a cron run.
  */
 protected function schedule(NodeInterface $node, $action = 'publish')
 {
     $node_storage = $this->container->get('entity.manager')->getStorage('node');
     // Simulate scheduling by setting the (un)publication date in the past and
     // running cron.
     $node->{$action . '_on'} = strtotime('-1 day');
     $node->save();
     scheduler_cron();
     $node_storage->resetCache(array($node->id()));
     return $node_storage->load($node->id());
 }
开发者ID:blakefrederick,项目名称:sas-backend,代码行数:23,代码来源:SchedulerRevisioningTest.php

示例12: sorry

 /**
  * Text, if the user answered wrong.
  *
  * @param \Drupal\node\NodeInterface $node
  *   The node the client form belongs to.
  * @return array
  */
 public function sorry(NodeInterface $node)
 {
     $config = $this->config('field_quiz.settings');
     $text = $config->get('field_quiz.test_answer_wrong');
     $elements[] = array('#type' => 'html_tag', '#tag' => 'p', '#attributes' => array('style' => 'color: red'), '#value' => $this->t($text));
     $url = Url::fromRoute('entity.node.canonical', array('node' => $node->id()));
     $project_link = Link::fromTextAndUrl(t('Please try again.'), $url);
     $project_link = $project_link->toRenderable();
     // If you need some attributes.
     $project_link['#attributes'] = array('class' => array('button', 'button-action', 'button--primary', 'button--small'));
     $elements[] = array('#type' => 'html_tag', '#tag' => 'p', '#attributes' => array(), '#value' => render($project_link));
     return $elements;
 }
开发者ID:badelas,项目名称:afroweb,代码行数:20,代码来源:FieldQuizController.php

示例13: featuresOverview

 /**
  * Displays the product features tab on a product node edit form.
  */
 public function featuresOverview(NodeInterface $node)
 {
     $header = array($this->t('Type'), $this->t('Description'), $this->t('Operations'));
     $rows = [];
     $features = uc_product_feature_load_multiple($node->id());
     foreach ($features as $feature) {
         $operations = array('edit' => array('title' => $this->t('Edit'), 'url' => Url::fromRoute('uc_product.feature_edit', ['node' => $node->id(), 'fid' => $feature->fid, 'pfid' => $feature->pfid])), 'delete' => array('title' => $this->t('Delete'), 'url' => Url::fromRoute('uc_product.feature_delete', ['node' => $node->id(), 'fid' => $feature->fid, 'pfid' => $feature->pfid])));
         $rows[] = array(array('data' => uc_product_feature_data($feature->fid, 'title')), array('data' => array('#markup' => $feature->description)), array('data' => array('#type' => 'operations', '#links' => $operations)));
     }
     $build['features'] = array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('class' => array('uc-product-features')), '#empty' => $this->t('No features found for this product.'));
     $build['add_form'] = $this->formBuilder()->getForm('Drupal\\uc_product\\Form\\ProductFeatureAddForm', $node);
     return $build;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:16,代码来源:ProductFeaturesController.php

示例14: viewQuestion

 /**
  * Helper function to setup the faq question.
  *
  * @param array &$data
  *   Array reference to store display data in.
  * @param \Drupal\node\NodeInterface $node
  *   The node object.
  * @param string $path
  *   The path/url which the question should link to if links are disabled.
  * @param string $anchor
  *   Link anchor to use in question links.
  */
 public static function viewQuestion(&$data, \Drupal\node\NodeInterface $node, $path = NULL, $anchor = NULL)
 {
     $faq_settings = \Drupal::config('faq.settings');
     $disable_node_links = $faq_settings->get('disable_node_links');
     $question = '';
     // Don't link to faq node, instead provide no link, or link to current page.
     if ($disable_node_links) {
         if (empty($path) && empty($anchor)) {
             $question = $node->getTitle();
         } elseif (empty($path)) {
             // Can't seem to use l() function with empty string as screen-readers
             // don't like it, so create anchor name manually.
             $question = '<a id="' . $anchor . '"></a>' . $node->getTitle();
         } else {
             $options = array();
             if ($anchor) {
                 $options['attributes'] = array('id' => $anchor);
             }
             $question = l($node->getTitle(), $path, $options);
         }
     } else {
         $node_id = $node->id();
         if (empty($anchor)) {
             $question = l($node->getTitle(), "node/{$node_id})");
         } else {
             $question = l($node->getTitle(), "node/{$node_id}", array("attributes" => array("id" => "{$anchor}")));
         }
     }
     $question = '<span datatype="" property="dc:title">' . $question . '</span>';
     $detailed_question = $node->get('field_detailed_question')->value;
     if ($faq_settings->get('display') != 'hide_answer' && !empty($detailed_question) && $faq_settings->get('question_length') == 'both') {
         $question .= '<div class="faq-detailed-question">' . $detailed_question . '</div>';
     }
     $data['question'] = SafeMarkup::set($question);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:47,代码来源:FaqViewer.php

示例15: testBasicSettings

  /**
   * Test the basic settings.
   */
  public function testBasicSettings() {
    $manage_display = '/admin/structure/types/manage/article/display';
    $this->drupalGet($manage_display);
    $this->drupalPostAjaxForm(NULL, [], 'body_settings_edit');

    $this->drupalPostAjaxForm(NULL, [
      'fields[body][label]' => 'above',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_field_tag]' => 'article',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_field_classes]' => 'my-field-class',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_field_item_tag]' => 'code',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_field_item_classes]' => 'my-field-item-class',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_label_tag]' => 'h2',
      'fields[body][settings_edit_form][third_party_settings][fences][fences_label_classes]' => 'my-label-class',
    ], ['body_plugin_settings_update' => 'Update']);
    $this->drupalPostForm(NULL, [], 'Save');

    $expected_field_markup = <<<EOD
      <article class="my-field-class clearfix text-formatted field field--name-body field--type-text-with-summary field--label-above field__items">
        <h2 class="my-label-class field__label">Body</h2>
        <code class="my-field-item-class field__item">
          <p>Body field value.</p>
        </code>
      </article>
EOD;

    $page = $this->drupalGet('/node/' . $this->node->id());
    $this->assertTrue(strpos($this->stripWhitespace($page), $this->stripWhitespace($expected_field_markup)) !== FALSE, 'Found the correct field markup on the page.');
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:31,代码来源:IntegrationTest.php


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