Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

How to inject dependency in BaseSocketListener subclass? #21

Open
gianlucapisati opened this issue Apr 18, 2018 · 2 comments
Open

How to inject dependency in BaseSocketListener subclass? #21

gianlucapisati opened this issue Apr 18, 2018 · 2 comments

Comments

@gianlucapisati
Copy link

gianlucapisati commented Apr 18, 2018

if I inject the dependency that I need inside the constructor it doesn't work

/**
     * MyClass constructor.
     */
    public function __construct(MessageService $messageService)
    {
        $this->clients = new \SplObjectStorage();
        $this->messageService = $messageService;
    }
@tabuna
Copy link
Owner

tabuna commented Apr 18, 2018

This can only be done explicitly:

 App::getInstance()->make...

@bryce13950
Copy link

You can actually do this pretty easily in the router by doing this

/** @var $this \Orchid\Socket\Console\Server */
/** @var $socket \Ratchet\App */
$articleIterationSocket = $this->getLaravel()->make('\App\Http\Sockets\ArticleIterations');
$socket->route('/', $articleIterationSocket, ['*']);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants