Skip to content

Commit 2139eb6

Browse files
committed
use container get shortcut
1 parent 55c2e34 commit 2139eb6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

book/service_container.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Symfony2 controller, we can easily access the new ``my_mailer`` service::
148148
public function sendEmailAction()
149149
{
150150
// ...
151-
$mailer = $this->container->get('my_mailer');
151+
$mailer = $this->get('my_mailer');
152152
$mailer->send('ryan@foobar.net', ... );
153153
}
154154
}
@@ -507,7 +507,7 @@ fairly easily from inside a controller::
507507

508508
public function sendNewsletterAction()
509509
{
510-
$mailer = $this->container->get('my_mailer');
510+
$mailer = $this->get('my_mailer');
511511
$newsletter = new Acme\HelloBundle\Newsletter\NewsletterManager($mailer);
512512
// ...
513513
}
@@ -739,7 +739,7 @@ which you can access inside a standard controller as follows::
739739

740740
public function indexAction($bar)
741741
{
742-
$session = $this->container->get('session');
742+
$session = $this->get('session');
743743
$session->set('foo', $bar);
744744

745745
// ...

book/validation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ simple example from inside a controller:
115115
$author = new Acme\BlogBundle\Author();
116116
// ... do something to the $author object
117117
118-
$validator = $this->container->get('validator');
118+
$validator = $this->get('validator');
119119
$errorList = $validator->validate($author);
120120
121121
if (count($errorList) > 0) {

cookbook/security/acl.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ Creating an ACL, and adding an ACE
9494
// ...
9595
9696
if ($form->isValid()) {
97-
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
97+
$entityManager = $this->get('doctrine.orm.default_entity_manager');
9898
$entityManager->persist($comment);
9999
$entityManager->flush();
100100
101101
// creating the ACL
102-
$aclProvider = $this->container->get('security.acl.provider');
102+
$aclProvider = $this->get('security.acl.provider');
103103
$objectIdentity = ObjectIdentity::fromDomainObject($comment);
104104
$acl = $aclProvider->createAcl($objectIdentity);
105105
106106
// retrieving the security identity of the currently logged-in user
107-
$securityContext = $this->container->get('security.context');
107+
$securityContext = $this->get('security.context');
108108
$user = $securityContext->getToken()->getUser();
109109
$securityIdentity = UserSecurityIdentity::fromAccount($user);
110110
@@ -144,7 +144,7 @@ Checking Access
144144
// BlogController.php
145145
public function editCommentAction(Comment $comment)
146146
{
147-
$securityContext = $this->container->get('security.context');
147+
$securityContext = $this->get('security.context');
148148
149149
// check for edit access
150150
if (false === $securityContext->isGranted('EDIT', $comment))

0 commit comments

Comments
 (0)