當前位置: 首頁>>代碼示例>>PHP>>正文


PHP NodeInterface::getEntityType方法代碼示例

本文整理匯總了PHP中Drupal\node\NodeInterface::getEntityType方法的典型用法代碼示例。如果您正苦於以下問題:PHP NodeInterface::getEntityType方法的具體用法?PHP NodeInterface::getEntityType怎麽用?PHP NodeInterface::getEntityType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\node\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::getEntityType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: _getRevisionIds

 /**
  * Gets a list of node revision IDs for a specific node.
  *
  * @param \Drupal\node\NodeInterface
  *   The node entity.
  * @param \Drupal\node\NodeStorageInterface $node_storage
  *   The node storage handler.
  *
  * @return int[]
  *   Node revision IDs (in descending order).
  */
 protected function _getRevisionIds(NodeInterface $node, NodeStorageInterface $node_storage)
 {
     $result = $node_storage->getQuery()->allRevisions()->condition($node->getEntityType()->getKey('id'), $node->id())->sort($node->getEntityType()->getKey('revision'), 'DESC')->pager(50)->execute();
     return array_keys($result);
 }
開發者ID:DrupalCamp-NYC,項目名稱:dcnyc16,代碼行數:16,代碼來源:NodeController.php


注:本文中的Drupal\node\NodeInterface::getEntityType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。