Lemon\RestBundle\Object\ManagerFactory::create PHP Method

create() public method

public create ( string $resource ) : Manager
$resource string
return Manager
    public function create($resource)
    {
        $definition = $this->registry->get($resource);
        return new Manager($this->doctrine, $this->eventDispatcher, $definition);
    }

Usage Example

 public function testCreatesManagerWithCorrectClass()
 {
     $eventDispatcher = $this->mock('Symfony\\Component\\EventDispatcher\\EventDispatcher')->new();
     $doctrine = $this->mock('Doctrine\\Bundle\\DoctrineBundle\\Registry')->new();
     $registry = new Registry();
     $registry->add(new Definition('person', 'Lemon\\RestBundle\\Tests\\Fixtures\\Person'));
     $managerFactory = new ManagerFactory($registry, $doctrine, $eventDispatcher);
     $manager = $managerFactory->create("person");
     $this->assertEquals('Lemon\\RestBundle\\Tests\\Fixtures\\Person', $manager->getClass());
 }
ManagerFactory