You are here

public function NodeEntityBundleInfo::renderNodeDetails in Permissions by Term 8

Same name and namespace in other branches
  1. 8.2 src/Service/NodeEntityBundleInfo.php \Drupal\permissions_by_term\Service\NodeEntityBundleInfo::renderNodeDetails()

Parameters

$viewFilePath:

null $nid:

string $langcode:

Return value

string

Throws

\Twig_Error_Loader

\Twig_Error_Runtime

\Twig_Error_Syntax

File

src/Service/NodeEntityBundleInfo.php, line 67

Class

NodeEntityBundleInfo
Class Info

Namespace

Drupal\permissions_by_term\Service

Code

public function renderNodeDetails($viewFilePath, $langcode, $nid = null) {
  $roles = null;
  $users = null;
  if (!empty($nid)) {
    $tids = $this->term
      ->getTidsByNid($nid);
    if (!empty($tids)) {
      $uids = $this->accessStorage
        ->getUserTermPermissionsByTids($tids, $langcode);
      $rids = $this->accessStorage
        ->getRoleTermPermissionsByTids($tids, $langcode);
    }
  }
  if (!empty($rids)) {
    $roles = Role::loadMultiple($rids);
  }
  if (!empty($uids)) {
    $users = User::loadMultiple($uids);
  }
  $template = $this->twig
    ->loadTemplate($viewFilePath);
  return $template
    ->render([
    'roles' => $roles,
    'users' => $users,
  ]);
}