facilitatech/service-locator-factory

Get the service locator in Laminas

Installs: 1 235

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 4

pkg:composer/facilitatech/service-locator-factory

dev-master 2020-07-24 20:34 UTC

This package is not auto-updated.

Last update: 2025-09-28 16:01:13 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);
    }
}