drupal - 如何使 Drupal Commerce 配置实体可修改
问题描述
我在前端有一个使用 Drupal 的 JSONAPI 的 Ember 应用程序。
Drupal 安装了商务模块。
ember 应用程序正在请求所有 product_types,并且需要显示有关产品类型的信息。
产品类型上有描述变量类型和标签等字段,但作为匿名用户,我看不到所有这些属性,只有标签。
这似乎是商务模块检查权限的方式的问题。
if (!$access->isAllowed()) {
// If this is the default revision or the entity is not revisionable, then
// check access to the entity label. Revision support is all or nothing.
if (!$entity->getEntityType()->isRevisionable() || $entity->isDefaultRevision()) {
$label_access = $entity->access('view label', NULL, TRUE);
$entity->addCacheableDependency($label_access);
if ($label_access->isAllowed()) {
return LabelOnlyResourceObject::createFromEntity($resource_type, $entity);
这里 jsonapi 决定渲染实体的有限版本。
似乎需要使该实体可修改才能通过上述检查并完全呈现。
https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/product/src/Entity/ProductType.php
如何使 ProductType 实体可修改?
我发现了这个https://www.drupal.org/docs/8/api/entity-api/making-an-entity-revisionable但它的解释似乎有限。
解决方案
Drupal 的JSON:API 模块没有自带授权逻辑。它尊重并使用 Drupal 针对该数据采取的所有安全措施。您可以在模块文档的安全注意事项章节中找到有关该内容的更多详细信息。
Drupal Commerce 也不提供它自己的访问管理。至少这是我从他们的文档中得到的。
您应该检查您的字段权限。也许它们是使用字段权限模块定制的?您可能希望按照JSON:API 模块文档中的建议审核实体访问和字段访问。
推荐阅读
- ios - 节拍器。定时器、音乐和动画
- reactjs - 与 TypeScript 反应 - 类型 {...} 不可分配给类型“只读
” - javascript - Javascript:IE 的等效解构赋值
- reactjs - Safari & event.target.select()
- php - @php artisan package:discover 处理返回的自动加载转储后事件,错误代码为 255
- laravel - 在 laravel 中显示数据库中的多个图像
- xml - how to group XML without attributes
- javascript - 将 CSS 值存储在 JavaScript 变量中
- node.js - NodeJS + CloudSQL Postgres - 连接随机终止
- reactjs - 将 typeahead bootstrap 与 Elasticsearch 一起使用