I have a view that looks like in the following screenshot.
I am creating a custom action to publish selected comments and create a node for each comment. The custom action code is the following.
class publishtraction extends ViewsBulkOperationsActionBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function execute($entity = NULL, $view = NULL) {
// Publish the selected comment.
$entity->setPublished(TRUE)->save();
// Create a node for the selected comment.
// Don't return anything for a default completion message; otherwise return translatable markup.
return $this->t('Some result');
}
/**
* {@inheritdoc}
*/
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
if ($object->getEntityType() === 'node') {
$access = $object->access('update', $account, TRUE)
->andIf($object->status->access('edit', $account, TRUE));
return $return_as_object ? $access : $access->isAllowed();
}
// Other entity types may have different access methods and properties.
return TRUE;
}
}
My custom action is publishing/unpublishing the comments correctly. However, as next step, I want to read the multiselect field and the selected view row entities values to show them with var_dump()
.
How can I achieve that?