【发布时间】:2019-12-16 05:43:22
【问题描述】:
我在前端有一个使用 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,但它的解释似乎有限。
【问题讨论】:
-
这是我感兴趣的特定记录的链接。请注意,只有“标签”属性可以作为匿名用户查看。 ihmm-drupal.reginault.com/jsonapi/commerce_product_type/…
标签: drupal json-api drupal-commerce drupal-content-types drupal-entities