digitalist.global // March 21 2016

Create own service for your module in Drupal 8

It is always good to know how to use core services and as well how to create your own service. This is how you can do that.

It is always good to know how to use core services and as well how to create your own service. Following code snippet can help you to do that.

Create custom service into modulename.service.yml

services:
  content_connected.manager:
    class: Drupal\content_connected\ContentConnectedManager
    arguments: ["@entity.manager", "@config.factory","@entity.query", "@module_handler","@renderer","@string_translation"]

 

You can see the details code in (http://cgit.drupalcode.org/content_connected?h=8.x-1.x)

Module link :- https://www.drupal.org/project/content_connected

Helpful link :- https://www.drupal.org/node/2133171

More from digitalist.global