Drupal 8.7.8找不到自定义模块创建的休息资源(API)



目录结构:

module_name->config->install->rest.resource.location_api.yml

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

模块名称/src/plugin/rest/resource/LocationApi.php

<?php
namespace DrupallocationsPluginrestresource;
use DrupalrestPluginResourceBase;
use DrupalrestResourceResponse;
use DrupalCoreControllerControllerBase;
//use DrupalnodeEntityNode;
//use DrupaltaxonomyEntityTerm;
use DrupaluserEntityUser;
//use DrupalCoreDatabaseConnection;
use SymfonyComponentHttpFoundationJsonResponse;

/**
* 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 {

}

但当我安装模块时,它会返回一个错误,

消息

Drupal\Component\Plugin\Exception\PluginNotFoundException:"entity_bundle:node"插件不存在。Drupal\Core\Condition\ConditionManager的有效插件ID为:node_type、request_path、current_theme、user_role in Drupal\Core \plugin\DefaultPluginManager->doGetDefinition(((/home/linugdem/kdr.linumdemo.me/Core/lib/Drupal/Component/plugin/DiscoveryTrait.php的第53行(。

这是Drupal 8的缓存问题,我已经通过清除缓存并重新安装模块来解决。

最新更新