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


PHP NodeInterface::getOwner方法代码示例

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


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

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

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

示例3: nodeHug

 public function nodeHug(NodeInterface $node)
 {
     if ($node->isPublished()) {
         // These are the same!
         $body = $node->body->value;
         $body = $node->body[0]->value;
         // But we really want...
         $formatted = $node->body->processed;
         $terms = [];
         foreach ($node->field_tags as $tag) {
             $terms[] = $tag->entity->label();
         }
         $message = $this->t('Everyone hug @name because @reasons!', ['@name' => $node->getOwner()->label(), '@reasons' => implode(', ', $terms)]);
         return ['#title' => $node->label() . ' (' . $node->bundle() . ')', '#markup' => $message . $formatted];
     }
     return $this->t('Not published');
 }
开发者ID:sriharisahu,项目名称:hugs,代码行数:17,代码来源:HugsController.php

示例4: nodeMyHug

 /**
  * Discussed at 47:00 in https://www.youtube.com/watch?v=8vwC_01KFLo
  * @param NodeInterface $node
  * @return type
  */
 public function nodeMyHug(NodeInterface $node)
 {
     if ($node->isPublished()) {
         // These are the same!  BUT DO NOT USE! (See below)
         $body = $node->body->value;
         // works even when body is multi-valued (gets the first one)
         $body = $node->body[0]->value;
         // works even when body is single-valued (gets the only one)
         // But we really want the processed value, which has been run through drupal's filters
         $formatted = $node->body->processed;
         $terms = [];
         foreach ($node->field_tags as $tag) {
             $terms[] = $tag->entity->label();
         }
         $message = $this->t('Everyone give @name a my_hug because @reasons!', ['@name' => $node->getOwner()->label(), '@reasons' => implode(', ', $terms)]);
         return ['#title' => $node->label() . ' (' . $node->bundle() . ')', '#markup' => $message . $formatted];
     }
     return $this->t('Not published');
 }
开发者ID:tomwhartung,项目名称:jmws_drupal_hello_world-my_hugs-d8,代码行数:24,代码来源:MyHugsController.php


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