class PublishAction in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Action/Plugin/Action/PublishAction.php \Drupal\Core\Action\Plugin\Action\PublishAction
- 9 core/lib/Drupal/Core/Action/Plugin/Action/PublishAction.php \Drupal\Core\Action\Plugin\Action\PublishAction
Publishes an entity.
Plugin annotation
@Action(
id = "entity:publish_action",
action_label = @Translation("Publish"),
deriver = "Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver",
)
Hierarchy
- class \Drupal\Core\Action\Plugin\Action\PublishAction extends \Drupal\Core\Action\Plugin\Action\EntityActionBase
Expanded class hierarchy of PublishAction
2 files declare their use of PublishAction
- content_moderation.module in core/
modules/ content_moderation/ content_moderation.module - Contains content_moderation.module.
- ModerationOptOutPublish.php in core/
modules/ content_moderation/ src/ Plugin/ Action/ ModerationOptOutPublish.php
File
- core/
lib/ Drupal/ Core/ Action/ Plugin/ Action/ PublishAction.php, line 16
Namespace
Drupal\Core\Action\Plugin\ActionView source
class PublishAction extends EntityActionBase {
/**
* {@inheritdoc}
*/
public function execute($entity = NULL) {
$entity
->setPublished()
->save();
}
/**
* {@inheritdoc}
*/
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$key = $object
->getEntityType()
->getKey('published');
/** @var \Drupal\Core\Entity\EntityInterface $object */
$result = $object
->access('update', $account, TRUE)
->andIf($object->{$key}
->access('edit', $account, TRUE));
return $return_as_object ? $result : $result
->isAllowed();
}
}