- Issue created by @司南
I have a dynamic_entity_reference field.
/**
* Implements hook_entity_base_field_info().
*/
function enhanced_flag_entity_base_field_info(EntityTypeInterface $entity_type): array {
$fields = [];
if ($entity_type->id() === 'flagging') {
$fields['flagged_entity_dynamic'] = BaseFieldDefinition::create('dynamic_entity_reference')
->setLabel(t('Flagged entity dynamic'))
->setDisplayOptions('view', [
'type' => 'dynamic_entity_reference_label',
]);
}
return $fields;
}
And I expose the flagging entities by jsonapi with a filter on flagged_entity_dynamic filed.
{
'filter[test][condition][path]': ['flagged_entity_dynamic.title'],
'filter[test][condition][value]': ['MB3U'],
}
Then error occurs:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /app/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
#0 /app/web/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php(239): Drupal\Core\Entity\EntityTypeManager->getDefinition(NULL)
#1 /app/web/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php(198): Drupal\jsonapi\Access\TemporaryQueryGuard::getAccessCondition(NULL, Object(Drupal\Core\Cache\CacheableMetadata))
#2 /app/web/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php(167): Drupal\jsonapi\Access\TemporaryQueryGuard::applyAccessConditions(Object(Drupal\Core\Entity\Query\Sql\Query), NULL, 'flagged_entity_...', Object(Drupal\Core\Cache\CacheableMetadata))
#3 /app/web/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php(139): Drupal\jsonapi\Access\TemporaryQueryGuard::secureQuery(Object(Drupal\Core\Entity\Query\Sql\Query), 'flagging', Array, Object(Drupal\Core\Cache\CacheableMetadata), 'flagged_entity_...', Object(Drupal\Core\Field\BaseFieldDefinition))
#4 /app/web/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php(95): Drupal\jsonapi\Access\TemporaryQueryGuard::secureQuery(Object(Drupal\Core\Entity\Query\Sql\Query), 'flagging', Array, Object(Drupal\Core\Cache\CacheableMetadata))
#5 /app/web/core/modules/jsonapi/src/Controller/EntityResource.php(897): Drupal\jsonapi\Access\TemporaryQueryGuard::applyAccessControls(Object(Drupal\jsonapi\Query\Filter), Object(Drupal\Core\Entity\Query\Sql\Query), Object(Drupal\Core\Cache\CacheableMetadata))
#6 /app/web/core/modules/jsonapi/src/Controller/EntityResource.php(414): Drupal\jsonapi\Controller\EntityResource->getCollectionQuery(Object(Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType), Array, Object(Drupal\Core\Cache\CacheableMetadata))
#7 [internal function]: Drupal\jsonapi\Controller\EntityResource->getCollection(Object(Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType), Object(Symfony\Component\HttpFoundation\Request))
#8 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#9 /app/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#12 /app/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /app/web/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(54): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#27 {main}
if I change the filter syntax to flagged_entity_dynamic.entity:commerce_product.title :
{
'filter[test][condition][path]': ['flagged_entity_dynamic.entity:commerce_product.title'],
'filter[test][condition][value]': ['MB3U'],
}
then another error occurs:
Drupal\Core\Entity\Query\QueryException: 'flagged_entity_dynamic' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 373 of /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).
#0 /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php(268): Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable('', 'flagged_entity_...', 'INNER', NULL, 'base_table', 'id', Array)
#1 /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(58): Drupal\Core\Entity\Query\Sql\Tables->addField('flagged_entity_...', 'INNER', NULL)
#2 /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(53): Drupal\Core\Entity\Query\Sql\Condition->compile(Object(Drupal\Core\Database\Query\Condition))
#3 /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile(Object(Drupal\Core\Database\Query\Select))
#4 /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(82): Drupal\Core\Entity\Query\Sql\Query->compile()
#5 /app/web/core/modules/jsonapi/src/Controller/EntityResource.php(508): Drupal\Core\Entity\Query\Sql\Query->execute()
#6 /app/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\jsonapi\Controller\EntityResource->Drupal\jsonapi\Controller\{closure}()
#7 /app/web/core/modules/jsonapi/src/Controller/EntityResource.php(507): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 /app/web/core/modules/jsonapi/src/Controller/EntityResource.php(422): Drupal\jsonapi\Controller\EntityResource->executeQueryInRenderContext(Object(Drupal\Core\Entity\Query\Sql\Query), Object(Drupal\Core\Cache\CacheableMetadata))
#9 [internal function]: Drupal\jsonapi\Controller\EntityResource->getCollection(Object(Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType), Object(Symfony\Component\HttpFoundation\Request))
#10 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#11 /app/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#14 /app/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /app/web/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(54): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}
Active
4.0
Code