public function vapnHandler::checkIfContentTypeEnabled in View access per node 8
File
- src/
vapnHandler.php, line 37
Class
- vapnHandler
- Class vapnHandler.
Namespace
Drupal\vapnCode
public function checkIfContentTypeEnabled() {
if (!\Drupal::currentUser()
->hasPermission('use vapn')) {
return FALSE;
}
/** @var \Drupal\node\Entity\NodeType $nodeType */
$routeName = \Drupal::routeMatch()
->getRouteName();
$config = \Drupal::config('vapn.vapnconfig')
->get('vapn_node_list');
$nodeType = '';
if ($routeName == 'node.add') {
$nodeType = \Drupal::routeMatch()
->getParameters()
->get('node_type');
$nodeType = $nodeType
->get('type');
}
elseif ($routeName == 'entity.node.edit_form') {
/** @var NodeInterface $nodeType */
$nodeType = \Drupal::routeMatch()
->getParameters()
->get('node');
$nodeType = $nodeType
->getType();
}
if (is_null($config)) {
return FALSE;
}
return in_array($nodeType, $config, TRUE);
}