public function DefaultController::ccl_actions_trigger in Custom Contextual Links 8
1 string reference to 'DefaultController::ccl_actions_trigger'
- ccl_actions.routing.yml in ccl_actions/
ccl_actions.routing.yml - ccl_actions/ccl_actions.routing.yml
File
- ccl_actions/
src/ Controller/ DefaultController.php, line 15 - Contains \Drupal\ccl_actions\Controller\DefaultController.
Class
- DefaultController
- Default controller for the ccl_actions module.
Namespace
Drupal\ccl_actions\ControllerCode
public function ccl_actions_trigger(\Drupal\node\NodeInterface $node, $action, $state) {
if (!node_access('update', $node)) {
drupal_set_message(t('You have no permission to update %node_title.', [
'%node_title' => $node
->getTitle(),
]), 'error');
drupal_goto();
}
switch ($action) {
case 'status':
if ($state) {
actions_do('node_publish_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been published.', [
'%node_title' => $node
->getTitle(),
]));
}
else {
$res = actions_do('node_unpublish_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been unpublished.', [
'%node_title' => $node
->getTitle(),
]));
}
break;
case 'sticky':
if ($state) {
actions_do('node_make_sticky_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been made sticky.', [
'%node_title' => $node
->getTitle(),
]));
}
else {
$res = actions_do('node_make_unsticky_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been made unsticky.', [
'%node_title' => $node
->getTitle(),
]));
}
break;
case 'promote':
if ($state) {
actions_do('node_promote_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been promoted to front page.', [
'%node_title' => $node
->getTitle(),
]));
}
else {
$res = actions_do('node_unpromote_action', $node);
$node
->save();
drupal_set_message(t('%node_title has been removed from front page.', [
'%node_title' => $node
->getTitle(),
]));
}
break;
}
// Return to set destination parameter.
drupal_goto();
}