You are here

NodeAccessRecordFactory.php in Permissions by Term 8

Same filename and directory in other branches
  1. 8.2 src/Factory/NodeAccessRecordFactory.php

File

src/Factory/NodeAccessRecordFactory.php
View source
<?php

namespace Drupal\permissions_by_term\Factory;

use Drupal\permissions_by_term\Model\NodeAccessRecordModel;
class NodeAccessRecordFactory {
  public function create($realm, $gid, $nid, $langcode = '', $grantUpdate, $grantDelete) {
    $langcode = $langcode === '' ? \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId() : $langcode;
    $nodeAccessRecord = new NodeAccessRecordModel();
    $nodeAccessRecord
      ->setNid($nid);
    $nodeAccessRecord
      ->setFallback(1);
    $nodeAccessRecord
      ->setGid($gid);
    $nodeAccessRecord
      ->setGrantDelete($grantDelete);
    $nodeAccessRecord
      ->setGrantUpdate($grantUpdate);
    $nodeAccessRecord
      ->setGrantView(1);
    $nodeAccessRecord
      ->setLangcode($langcode);
    $nodeAccessRecord
      ->setRealm($realm);
    return $nodeAccessRecord;
  }

}

Classes