Last active
August 29, 2015 14:17
-
-
Save manuakasam/70d99f0111b2edb5f787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FooController { | |
public function __construct(FooService $foo) { | |
$this->foo = $foo; | |
} | |
public function indexAction() { | |
return new ViewModel([ | |
'data' => $foo->listStuff(); | |
]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FooService { | |
__construct(ObjectRepository $er) { | |
$this->er = $er; | |
} | |
public function listStuff() { | |
return $this->er->findAll(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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