After generating the code via Drupalconsole when I click on Extend or People it crashes with this message

Error: Class 'Drupal\bolt\Entity\EquipmentType' not found in Drupal\bolt\EquipmentPermissions->generatePermissions() (line 29 of /workspace/base/mysite/web/modules/custom/bolt/src/EquipmentPermissions.php) #0 [internal function]: Drupal\bolt\EquipmentPermissions->generatePermissions() #1 /workspace/base/mysite/web/core/modules/user/src/PermissionHandler.php(149): call_user_func(Array) #2 /workspace/base/mysite/web/core/modules/user/src/PermissionHandler.php(108): Drupal\user\PermissionHandler->buildPermissionsYaml() #3 /workspace/base/mysite/web/core/modules/user/src/PermissionHandler.php(119): Drupal\user\PermissionHandler->getPermissions() #4 /workspace/base/mysite/web/core/modules/system/src/Form/ModulesListForm.php(235): Drupal\user\PermissionHandler->moduleProvidesPermissions('automated_cron') #5 /workspace/base/mysite/web/core/modules/system/src/Form/ModulesListForm.php(161): Drupal\system\Form\ModulesListForm->buildRow(Array, Object(Drupal\Core\Extension\Extension), 'Drupal') #6 [internal function]: Drupal\system\Form\ModulesListForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #7 /workspace/base/mysite/web/core/lib/Drupal/Core/Form/FormBuilder.php(519): call_user_func_array(Array, Array) #8 /workspace/base/mysite/web/core/lib/Drupal/Core/Form/FormBuilder.php(276): Drupal\Core\Form\FormBuilder->retrieveForm('system_modules', Object(Drupal\Core\Form\FormState)) #9 /workspace/base/mysite/web/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\system\Form\ModulesListForm), Object(Drupal\Core\Form\FormState)) #10 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #11 /workspace/base/mysite/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #12 /workspace/base/mysite/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #13 /workspace/base/mysite/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #14 /workspace/base/mysite/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #15 /workspace/base/mysite/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #16 /workspace/base/mysite/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #17 /workspace/base/mysite/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /workspace/base/mysite/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /workspace/base/mysite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /workspace/base/mysite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /workspace/base/mysite/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /workspace/base/mysite/web/modules/contrib/devel/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /workspace/base/mysite/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /workspace/base/mysite/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /workspace/base/mysite/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /workspace/base/mysite/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #27 {main}.
Error

I learned from core that the Node entity has a NodeType.php do I need this because I have used Drupalconsole before and have not had this problem in the past. 

Comments

John_B’s picture

Hard to say from just the error. Sometimes the 'class not found' error happens when there is an interface used in the class which is not defined in a 'use' statement at the top of the file.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

otcassetmgmt’s picture

So I used Drupal console to generate (my custom entity) I named it Equipment when I compare my code to Drupal's example using the Node.php there it has NodeType.php so I tried to make EquipmentType.php and it did not work.

John_B’s picture

You don't need an entity type unless you want your entity to have more than one bundle (collection of fields), as node has. The best place to start is to download 'examples' module and use content_entity_example module as a guide. In case you still want to create multiple bundles on your entity, there is a tutorial in the docs: https://www.drupal.org/docs/8/api/entity-api/create-a-custom-content-ent...

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

otcassetmgmt’s picture

I used gitpod.io to quickly launch a test workspace where I built a Drupal script. https://github.com/HalftimeHarry/base try it if you want? I like to code on the cloud. Thank you for the tip regarding the examples module. I have not built it out yet, but it looks like if I duplicate the structure from the example it's going to work.

It's been a wile since I used Drupalconsole to generate custom entities I assume it was updated to add in the extra functionality or when I gave it instructions I choose to add in those classes. I notice in my custom entity from DC it calls the permission_callbacks key from the premissions.yml and this adds complexity that I do not need. Thank you for helping me hopefully you like the gitpod.io just learned about it again thank you!

otcassetmgmt’s picture

During the generation process when I answered now to that question it worked!