Problem/Motivation

When trying to use VBO with a config entity, I ran into this error, since in at least one place VBO assumes it's dealing with translatable entitys that implement \Drupal\Core\TypedData\TranslatableInterface:

Error: Call to undefined method Drupal\my_module\Entity\RegistryFile::isTranslatable() in Drupal\views_bulk_operations\Service\ViewsBulkOperationsViewData->getEntityDefault() (line 196 of modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsViewData.php).
Drupal\views_bulk_operations\Service\ViewsBulkOperationsViewData->getEntityDefault(Object, 'none', Object)
call_user_func(Array, Object, 'none', Object) (Line: 143)
Drupal\views_bulk_operations\Service\ViewsBulkOperationsViewData->getEntity(Object) (Line: 308)
Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm->getEntity(Object) (Line: 557)
Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm->viewsForm(Array, Object) (Line: 60)
Drupal\views\Form\ViewsFormMainForm->buildForm(Array, Object, Object, Array) (Line: 169)
Drupal\views\Form\ViewsForm->buildForm(Array, Object, Object, Array)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('views_form_registry_files_page_1', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('views_form_registry_files_page_1', Object) (Line: 212)
Drupal\Core\Form\FormBuilder->getForm(Object, Object, Array) (Line: 2207)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

Avoid the assumption that we are dealing with a translatable entity, instead conditioning translation behaviour on implementation of the \Drupal\Core\TypedData\TranslatableInterface.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 non_translatable_support-2977601-2.patch1010 bytesm4olivei

Comments

m4olivei created an issue. See original summary.

m4olivei’s picture

Status: Active » Needs review
StatusFileSize
new1010 bytes

Here is a patch to fix this error.

  • Graber committed 78db508 on 8.x-2.x authored by m4olivei
    Issue #2977601 by m4olivei: Error: Call to undefined method Drupal\...
graber’s picture

Status: Needs review » Fixed

Nice one, thanks!

m4olivei’s picture

Title: Error: Call to undefined method Drupal\draco_dfp\Entity\RegistryFile::isTranslatable() for non-translatable entiies » Error: Call to undefined method Drupal\my_module\Entity\RegistryFile::isTranslatable() for non-translatable entiies
Issue summary: View changes
m4olivei’s picture

Title: Error: Call to undefined method Drupal\my_module\Entity\RegistryFile::isTranslatable() for non-translatable entiies » Error: Call to undefined method Drupal\my_module\Entity\RegistryFile::isTranslatable() for non-translatable entities

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.