简体   繁体   English

Drupal 8.7.8 客户模块已创建 Rest 资源 (API) 未找到

[英]Drupal 8.7.8 Custome Module Created Rest Resource (API) not found

Directory structure:目录结构:

module_name -> config -> install -> rest.resource.location_api.yml模块名称 -> 配置 -> 安装 -> rest.resource.location_api.yml

id: location_api
plugin_id: location_api
granularity: resource
configuration:
  methods:
    - GET
    - POST 
    - PATCH
    - DELETE
  formats:
    - json
  authentication:
    - cookie     

module_name/src/plugin/rest/resource/LocationApi.php module_name/src/plugin/rest/resource/LocationApi.php

<?php

namespace Drupal\locations\Plugin\rest\resource;

use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;

use Drupal\Core\Controller\ControllerBase;
//use Drupal\node\Entity\Node;
//use Drupal\taxonomy\Entity\Term;
use Drupal\user\Entity\User;

//use Drupal\Core\Database\Connection;

use Symfony\Component\HttpFoundation\JsonResponse;


/**
 * Provides a KDR's Rest Custom Resource For Locations
 *
 * @RestResource(
 *   id = "location_api",
 *   label = @Translation("KDR's Rest Custom Resource For Location"),
 *   uri_paths = {
 *     "canonical" = "/kdr-apis/v1.0/location/{sl_id}",
 *     "https://www.drupal.org/link-relations/create" = "/kdr-apis/v1.0/location"
 *   }
 * )
 */ 

class LocationApi extends ResourceBase {



}

but when I install the module, then it returns an error,但是当我安装模块时,它会返回一个错误,

Message信息

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity_bundle:node" plugin does not exist. Drupal\Component\Plugin\Exception\PluginNotFoundException:“entity_bundle:node”插件不存在。 Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: node_type, request_path, current_theme, user_role in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /home/linuxdem/kdr.linuxdemos.me/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php). Drupal\Core\Condition\ConditionManager 的有效插件 ID 为:Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() 中的 node_type、request_path、current_theme、user_role(/home/linuxdem/kdr.linuxdemos.me/core/ 的第 53 行) lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)。

This was the Drupal 8 cache issue, I have resolved by clearing cache and re-installing module.这是 Drupal 8 缓存问题,我已通过清除缓存并重新安装模块解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM