Create yufu_admin module and add view jsonapi output operation to nodes. #16
|
@ -16,8 +16,6 @@ Nato vzpostavimo / poženemo zabojnike z ukazom `ddev start`.
|
||||||
|
|
||||||
Namestimo odvisne PHP pakete z ukazom `ddev composer install`.
|
Namestimo odvisne PHP pakete z ukazom `ddev composer install`.
|
||||||
|
|
||||||
@TODO uvoz baze
|
|
||||||
|
|
||||||
Osnovne podatke pa vnesemo z ukazuma:
|
Osnovne podatke pa vnesemo z ukazuma:
|
||||||
|
|
||||||
`ddev drush site:install --account-name=root --account-pass=toor --existing-config minimal`
|
`ddev drush site:install --account-name=root --account-pass=toor --existing-config minimal`
|
||||||
|
|
|
@ -47,6 +47,7 @@ module:
|
||||||
update: 0
|
update: 0
|
||||||
user: 0
|
user: 0
|
||||||
views_ui: 0
|
views_ui: 0
|
||||||
|
yufu_admin: 0
|
||||||
content_translation: 10
|
content_translation: 10
|
||||||
views: 10
|
views: 10
|
||||||
minimal: 1000
|
minimal: 1000
|
||||||
|
|
|
@ -4,6 +4,7 @@ status: true
|
||||||
dependencies:
|
dependencies:
|
||||||
module:
|
module:
|
||||||
- system
|
- system
|
||||||
|
- yufu_admin
|
||||||
_core:
|
_core:
|
||||||
default_config_hash: dJ0L2DNSj5q6XVZAGsuVDpJTh5UeYkIPwKrUOOpr8YI
|
default_config_hash: dJ0L2DNSj5q6XVZAGsuVDpJTh5UeYkIPwKrUOOpr8YI
|
||||||
id: authenticated
|
id: authenticated
|
||||||
|
@ -12,3 +13,4 @@ weight: 1
|
||||||
is_admin: false
|
is_admin: false
|
||||||
permissions:
|
permissions:
|
||||||
- 'access content'
|
- 'access content'
|
||||||
|
- 'use jsonapi operation link'
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
name: Yufu Admin
|
||||||
|
type: module
|
||||||
|
description: Provides admin functionality.
|
||||||
|
package: Yufu
|
||||||
|
core_version_requirement: ^9 || ^10
|
||||||
|
dependencies:
|
||||||
|
- drupal:jsonapi
|
|
@ -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;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
'use jsonapi operation link':
|
||||||
|
title: 'Use jsonapi operation link'
|
||||||
|
description: 'Access jsonapi operation link.'
|
Loading…
Reference in New Issue