Compare commits

...

2 Commits

Author SHA1 Message Date
Lio Novelli 857208f3b5 Add missing dependency. 2023-04-06 10:41:59 +02:00
Lio Novelli 8796997a37 Create yufu_admin module and add view jsonapi output operation to nodes. 2023-04-06 10:28:26 +02:00
5 changed files with 43 additions and 0 deletions

View File

@ -47,6 +47,7 @@ module:
update: 0
user: 0
views_ui: 0
yufu_admin: 0
content_translation: 10
views: 10
minimal: 1000

View File

@ -4,6 +4,7 @@ status: true
dependencies:
module:
- system
- yufu_admin
_core:
default_config_hash: dJ0L2DNSj5q6XVZAGsuVDpJTh5UeYkIPwKrUOOpr8YI
id: authenticated
@ -12,3 +13,4 @@ weight: 1
is_admin: false
permissions:
- 'access content'
- 'use jsonapi operation link'

View File

@ -0,0 +1,7 @@
name: Yufu Admin
type: module
description: Provides admin functionality.
package: Yufu
core_version_requirement: ^9 || ^10
dependencies:
- drupal:jsonapi

View File

@ -0,0 +1,30 @@
<?php
/**
* @file
* Primary module hooks for Yufu Admin module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Implements hook_entity_operation().
*/
function yufu_admin_entity_operation(EntityInterface $entity) {
$operations = [];
$entityType = $entity->getEntityType();
// @todo Only for entity node - should we add other entities as well?
if ($entityType->id() === 'node' && \Drupal::currentUser()->hasPermission('use jsonapi operation link')) {
// Build the url.
$url = Url::fromRoute(sprintf('jsonapi.%s--%s.individual', $entityType->id(), $entity->bundle()),
['entity' => $entity->uuid()]
);
$operations['view-jsonapi-output'] = [
'title' => t('jsonapi Output'),
'weight' => 50,
'url' => $url,
];
}
return $operations;
}

View File

@ -0,0 +1,3 @@
'use jsonapi operation link':
title: 'Use jsonapi operation link'
description: 'Access jsonapi operation link.'