For a custom entity I have created several dynamic blocks. But the blocks are not displayed. They are placed in admin/structure/block. Below is an example of block 1.
myentity.routing.yml:
myentity.blocks: path: '/collection/{myentity}' defaults: _title: 'Stuff collection' requirements: _permission: 'access content' myentity: d+ options: parameters: myentity: type: entity:myentity bundle: - a
Part of src/Plugin/Block:
namespace DrupalCorePluginBlock; use DrupalCoreBlockBase; /** * Provides a 'Collection' block. * * @Block( * id = "collection_block 1", * admin_label = @Translation("Collection: Stuff"), * category = @Translation("My Collection"), * context_definitions = { * "myentity" = @ContextDefinition("entity:myentity", label = @Translation("Myentity ID")) * } * ) */ class MyentityBlock1 extends BlockBase { /** * {@inheritdoc} */ public function build() { $myentity = $this->getContextValue('myentity'); return [...]; }
If I replace myentity with node, it works, but for a custom entity I probably need to define something more. But what?