Merge pull request 'Create yufu_admin module and add view jsonapi output operation to nodes.' (#16) from jsonapi-operations into master

Reviewed-on: #16
pull/17/head
Jurij Podgoršek 2023-04-11 01:48:36 +02:00
commit 1f765f2e99
6 changed files with 43 additions and 2 deletions

View File

@ -16,8 +16,6 @@ Nato vzpostavimo / poženemo zabojnike z ukazom `ddev start`.
Namestimo odvisne PHP pakete z ukazom `ddev composer install`.
@TODO uvoz baze
Osnovne podatke pa vnesemo z ukazuma:
`ddev drush site:install --account-name=root --account-pass=toor --existing-config minimal`

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.'