class AssignToMeTask

Redirects to a task assign form.

Plugin annotation


@Action(
  id = "tmgmt_local_task_assign_to_me",
  label = @Translation("Assign to me"),
  type = "tmgmt_local_task",
)

Hierarchy

  • class \Drupal\tmgmt_local\Plugin\Action\AssignToMeTask extends \Drupal\Core\Action\ActionBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface

Expanded class hierarchy of AssignToMeTask

File

translators/tmgmt_local/src/Plugin/Action/AssignToMeTask.php, line 20

Namespace

Drupal\tmgmt_local\Plugin\Action
View source
class AssignToMeTask extends ActionBase implements ContainerFactoryPluginInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public function executeMultiple(array $entities) {

    /** @var \Drupal\tmgmt_local\LocalTaskInterface $task */
    foreach ($entities as $task) {
      $task
        ->assign(\Drupal::currentUser());
      $task
        ->save();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function execute($object = NULL) {
    $this
      ->executeMultiple(array(
      $object,
    ));
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    $result = AccessResult::allowedIfHasPermission($account, 'provide translation services');
    return $return_as_object ? $result : $result
      ->isAllowed();
  }

}

Members