You are here

RealnameUpdateRealname.php in Real Name 8

Same filename and directory in other branches
  1. 2.x src/Plugin/Action/RealnameUpdateRealname.php

File

src/Plugin/Action/RealnameUpdateRealname.php
View source
<?php

namespace Drupal\realname\Plugin\Action;

use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;

/**
 * Update user real name.
 *
 * @Action(
 *   id = "realname_update_realname_action",
 *   label = @Translation("Update real name"),
 *   type = "user"
 * )
 */
class RealnameUpdateRealname extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($account = NULL) {
    realname_update($account);
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {

    /** @var \Drupal\user\UserInterface $object */
    $access = $object->status
      ->access('edit', $account, TRUE)
      ->andIf($object
      ->access('update', $account, TRUE));
    return $return_as_object ? $access : $access
      ->isAllowed();
  }

}

Classes

Namesort descending Description
RealnameUpdateRealname Update user real name.