Skip to main content
8 events
when toggle format what by license comment
Nov 25, 2020 at 13:08 vote accept Tobias Krause
Nov 25, 2020 at 10:43 answer added 4uk4 timeline score: 1
Nov 25, 2020 at 6:13 comment added Tobias Krause I already thought of creating a service for that but it seems to me sometimes that this is a little bit of overengineering. This is a very specific use case in my code. At the moment no other code depends on that "not so easy logic".It would be simpler to access the method on the controller already implementing it from within the block plugin to follow DRY and then refactor later in case this logic will be needed by some other code as well. A service for a logic just needed in two places deeply depending to each others seems too much for me.
Nov 24, 2020 at 14:31 comment added avpaderno @Hudri is correct. A plugin should not depend from a controller class, nor a controller class should assume a block is available on the page it renders.
Nov 24, 2020 at 14:22 history edited avpaderno CC BY-SA 4.0
edited tags
Nov 24, 2020 at 12:11 comment added Beebee You can also instantiate the block plugin from your controller and pass it settings. drupal.stackexchange.com/questions/171686/…
Nov 24, 2020 at 11:31 comment added Hudri Why don't you refactor your not so easy logic into a helper service class, and then call the helper service from controller and block instead? Sometimes refactoring is needed to prevent code smell. Define your own service and inject the route into the service
Nov 24, 2020 at 11:17 history asked Tobias Krause CC BY-SA 4.0