Skip to content
Snippets Groups Projects

Draft: Migrate from annotations to attributes

Open Patrick Kenny requested to merge issue/jsonrpc-3471347:attributes into 3.x
Compare and
15 files
+ 351
45
Compare changes
  • Side-by-side
  • Inline
Files
15
@@ -5,9 +5,13 @@ declare(strict_types=1);
namespace Drupal\jsonrpc_core\Plugin\jsonrpc\Method;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\jsonrpc\Attribute\JsonRpcMethod;
use Drupal\jsonrpc\Attribute\JsonRpcParameterDefinition;
use Drupal\jsonrpc\Exception\JsonRpcException;
use Drupal\jsonrpc\JsonRpcObject\Error;
use Drupal\jsonrpc\JsonRpcObject\ParameterBag;
use Drupal\jsonrpc\ParameterFactory\EntityParameterFactory;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
@@ -23,6 +27,22 @@ use Symfony\Component\Validator\ConstraintViolationInterface;
* }
* )
*/
#[JsonRpcMethod(
id: "user_permissions.add_permission_to_role",
usage: new TranslatableMarkup("Add the given permission to the specified role."),
access: ["administer permissions"],
params: [
'permission' => new JsonRpcParameterDefinition(
'permission',
["type" => "string"],
),
'role' => new JsonRpcParameterDefinition(
'role',
NULL,
EntityParameterFactory::class,
),
]
)]
class AddPermissionToRole extends UserPermissionsBase {
/**
Loading