I want to create a class with list of helper functions, so I created a module and placed the helper functions inside it. I created a service.yml inside that module folder.
services:
helpers.helpers:
class: Helpers
Helper class file:
class Helpers {
public function buildPage($page_template, $template_variables) {
echo "Dheivamey oru vazhiya"
}
}
I make it as a dependency inside another module.
dependencies:
- helpers:helpers
I tried using it inside a controller file like this
public function buildSomePage(Request $request) {
$helper = \Drupal::service('helpers.helpers');
}
But I am getting a Helpers class not found error. Someone help me before my head explode.