-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
namespace Snc\RedisBundle\Tests\Functional\App\Controller; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Snc\RedisBundle\Tests\Functional\App\Entity\User; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
@@ -25,6 +26,13 @@ | |
*/ | ||
class Controller extends AbstractController | ||
{ | ||
private $entityManager; | ||
|
||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
public function home(Request $request, \Redis $redis) | ||
{ | ||
$redis->set('foo', 'bar'); | ||
|
@@ -41,16 +49,15 @@ public function createUser() | |
->setEmail('[email protected]') | ||
; | ||
|
||
$em = $this->getDoctrine()->getManagerForClass(User::class); | ||
$em->persist($user); | ||
$em->flush(); | ||
$this->entityManager->persist($user); | ||
$this->entityManager->flush(); | ||
|
||
return new JsonResponse(['result' => 'ok']); | ||
} | ||
|
||
public function viewUser() | ||
{ | ||
$repository = $this->getDoctrine()->getRepository(User::class); | ||
$repository = $this->entityManager->getRepository(User::class); | ||
|
||
/** @var User $user */ | ||
$user = $repository->findOneBy(['username' => 'foo']); | ||
|
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
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