fezfez/service-locator-factory

This package is abandoned and no longer maintained. No replacement package was suggested.

Get the service locator in zf2

dev-master 2014-09-30 07:55 UTC

This package is auto-updated.

Last update: 2020-06-22 09:43:32 UTC


README

Project Status

Allow you to get ServiceManager from everywhere in your application by calling this static factory.

<?php

namespace Corp\News;

use Corp\News\NewsDAO;
use Zend\ServiceManager\ServiceManager;
use Corp\ServiceLocator\ServiceLocator;

class NewsDAOFactory
{
    private function __construct()
    {
        
    }

    /**
     * @return \Corp\News\NewsDAO
     */
    public static function getInstance()
    {
        $sm = ServiceLocatorFactory::getInstance();
        $em = $sm->get('doctrine.entitymanager.orm_default');

        return new NewsDAO($em);
    }
}