Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295107

Batch operation fails upon the unserialization of the service class

$
0
0

Problem/Motivation

Once I created a service class that had methods for running batch operations.

My service class had some protected fields.

To maintain Dependency Injection I initialized values of the fields in the constructor method, but types of protected fields didn't necessarily match the params of the constructor.

For example, the service class had a protected field to save the logger. But inasmuch as there isn't a logger service in Drupal, but there is the logger factory service, I passed the logger factory service as a param in the constructor, and in the code of the constructor the logger variable initialized as

$logger = $loggerFactory->get('myChannelName');

Here I noticed that the method that should execute the batch operation fails upon the unserialization of the service class. Even using the DependencySerializationTrait in the service class couldn't help.

I hope I managed to describe the problem clearly.


Viewing all articles
Browse latest Browse all 295107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>