SaveEntity.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php
  2. 8.9.x core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php
  3. 10 core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php

Namespace

Drupal\action_test\Plugin\Action

File

core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php

View source
<?php

declare (strict_types=1);
namespace Drupal\action_test\Plugin\Action;

use Drupal\Core\Action\ActionBase;
use Drupal\Core\Action\Attribute\Action;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides an operation to save user entities.
 */
class SaveEntity extends ActionBase {
    
    /**
     * {@inheritdoc}
     */
    public function execute($entity = NULL) {
        $entity->save();
    }
    
    /**
     * {@inheritdoc}
     */
    public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
        
        /** @var \Drupal\Core\Entity\EntityInterface $object */
        return $object->access('update', $account, $return_as_object);
    }

}

Classes

Title Deprecated Summary
SaveEntity Provides an operation to save user entities.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.