How to register callback in service tag?

JuniorJR
Member | 181
+
0
-

I'm using nette master, is there a way for registering callbacks (particularly in service tag(s) and using generated factory)?

$containerBuilder->addDefinition($this->prefix('myFactory'))
    ->setImplement('App\IMyFactory')
    ->addTag('myTag', [
        'callback' => '@' . $this->prefix('myFactory') . '::create', // does not work as generated factory does not inherit from Nette\Object :(
    ]);

Thanks for advice.

Felix
Nette Core | 957
+
0
-

I'm not sure. But I think it's not possible.

What do you need it for?

Comments

JuniorJR:

I had a component container which should contain list of factory callbacks for nested components. I've solved it by registering interface not general callback. I've been thinking callback would suffice but due to this problem it doesn't.

4 years ago