Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow AnalyticsFactory to be public/shared and injected in other services #16

Closed
wants to merge 2 commits into from

Conversation

emmanuelballery
Copy link

Hi!

I updated the AnalyticsFactory to be able to inject it in my services/create multiple analytics without requiring the entire container and calling $container->get('gamp.analytics') each time. This way, I can simply create multiple Analytics like this :

use FourLabs\GampBundle\Service\AnalyticsFactory;

class Stats
{
    /** @var AnalyticsFactory */
    private $analyticsFactory;

    public function __construct(AnalyticsFactory $analyticsFactory)
    {
        $this->analyticsFactory = $analyticsFactory;
    }

    public function doSomething()
    {
        $analytics1 = $this->analyticsFactory->createAnalytics();
        // ...
        $analytics2 = $this->analyticsFactory->createAnalytics();
        // ...
    }
}

Could you take a look and tell me what you think.

Thanks!

@n3r0-ch n3r0-ch mentioned this pull request Jul 1, 2018
@foaly-nr1
Copy link
Contributor

Merged via #18.

@foaly-nr1 foaly-nr1 closed this Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants