NodeMakePostPublic.php in Private 8
File
src/Plugin/Action/NodeMakePostPublic.php
View source
<?php
namespace Drupal\private_content\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class NodeMakePostPublic extends ActionBase {
public function execute($entity = NULL) {
$entity->private->value = 0;
$entity
->save();
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = $object
->access('update', $account, TRUE)
->andIf($object->status
->access('edit', $account, TRUE));
return $return_as_object ? $result : $result
->isAllowed();
}
}