Skip to content

Instantly share code, notes, and snippets.

@manuakasam
Last active August 29, 2015 14:17
Show Gist options
  • Save manuakasam/70d99f0111b2edb5f787 to your computer and use it in GitHub Desktop.
Save manuakasam/70d99f0111b2edb5f787 to your computer and use it in GitHub Desktop.
<?php
class FooController {
public function __construct(FooService $foo) {
$this->foo = $foo;
}
public function indexAction() {
return new ViewModel([
'data' => $foo->listStuff();
]);
}
}
<?php
class FooService {
__construct(ObjectRepository $er) {
$this->er = $er;
}
public function listStuff() {
return $this->er->findAll();
}
}
class FooServiceFactory {
public function createService($sl) {
return new FooService(
$sl->get('Doctrine\ORM\EntityManager')->getRepository('My\Entity\Foo')
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment