File tree Expand file tree Collapse file tree 25 files changed +689
-769
lines changed
Filter options
Expand file tree Collapse file tree 25 files changed +689
-769
lines changed
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -553,7 +553,8 @@ them for you. Here's the same sample application, now built in Symfony2::
553
553
{
554
554
public function listAction()
555
555
{
556
- $posts = $this->get('doctrine')->getManager()
556
+ $posts = $this->get('doctrine')
557
+ ->getManager()
557
558
->createQuery('SELECT p FROM AcmeBlogBundle:Post p')
558
559
->execute();
559
560
@@ -568,8 +569,7 @@ them for you. Here's the same sample application, now built in Symfony2::
568
569
$post = $this->get('doctrine')
569
570
->getManager()
570
571
->getRepository('AcmeBlogBundle:Post')
571
- ->find($id)
572
- ;
572
+ ->find($id);
573
573
574
574
if (!$post) {
575
575
// cause the 404 page not found to be displayed
Original file line number Diff line number Diff line change @@ -542,7 +542,7 @@ regardless of how your project is developed. To name a few:
542
542
* `Security `_ - A powerful library for handling all types of security inside
543
543
an application;
544
544
545
- * `Translation `_ A framework for translating strings in your application.
545
+ * `Translation `_ - A framework for translating strings in your application.
546
546
547
547
Each and every one of these components is decoupled and can be used in *any *
548
548
PHP project, regardless of whether or not you use the Symfony2 framework.
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Doctrine; ORM console commands
3
+ single: CLI; Doctrine ORM
4
+
5
+ Console Commands
6
+ ----------------
7
+
8
+ The Doctrine2 ORM integration offers several console commands under the
9
+ ``doctrine `` namespace. To view the command list you can use the ``list ``
10
+ command:
11
+
12
+ .. code-block :: bash
13
+
14
+ $ php app/console list doctrine
15
+
16
+ A list of available commands will print out. You can find out more information
17
+ about any of these commands (or any Symfony command) by running the ``help ``
18
+ command. For example, to get details about the ``doctrine:database:create ``
19
+ task, run:
20
+
21
+ .. code-block :: bash
22
+
23
+ $ php app/console help doctrine:database:create
24
+
25
+ Some notable or interesting tasks include:
26
+
27
+ * ``doctrine:ensure-production-settings `` - checks to see if the current
28
+ environment is configured efficiently for production. This should always
29
+ be run in the ``prod `` environment:
30
+
31
+ .. code-block :: bash
32
+
33
+ $ php app/console doctrine:ensure-production-settings --env=prod
34
+
35
+ * ``doctrine:mapping:import `` - allows Doctrine to introspect an existing
36
+ database and create mapping information. For more information, see
37
+ :doc: `/cookbook/doctrine/reverse_engineering `.
38
+
39
+ * ``doctrine:mapping:info `` - tells you all of the entities that Doctrine
40
+ is aware of and whether or not there are any basic errors with the mapping.
41
+
42
+ * ``doctrine:query:dql `` and ``doctrine:query:sql `` - allow you to execute
43
+ DQL or SQL queries directly from the command line.
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ Doctrine
14
14
resolve_target_entity
15
15
mapping_model_classes
16
16
registration_form
17
+ console
Original file line number Diff line number Diff line change @@ -216,6 +216,7 @@ Next, create the form for this ``Registration`` model::
216
216
'checkbox',
217
217
array('property_path' => 'termsAccepted')
218
218
);
219
+ $builder->add('Register', 'submit');
219
220
}
220
221
221
222
public function getName()
@@ -239,7 +240,6 @@ controller for displaying the registration form::
239
240
namespace Acme\AccountBundle\Controller;
240
241
241
242
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
242
- use Symfony\Component\HttpFoundation\Response;
243
243
244
244
use Acme\AccountBundle\Form\Type\RegistrationType;
245
245
use Acme\AccountBundle\Form\Model\Registration;
@@ -270,6 +270,9 @@ And its template:
270
270
Next, create the controller which handles the form submission. This performs
271
271
the validation and saves the data into the database::
272
272
273
+ use Symfony\Component\HttpFoundation\Request;
274
+ // ...
275
+
273
276
public function createAction(Request $request)
274
277
{
275
278
$em = $this->getDoctrine()->getManager();
Original file line number Diff line number Diff line change 62
62
* :doc:` /cookbook/doctrine/resolve_target_entity`
63
63
* :doc:` /cookbook/doctrine/mapping_model_classes`
64
64
* :doc:` /cookbook/doctrine/registration_form`
65
+ * :doc:` /cookbook/doctrine/console`
65
66
66
67
* :doc:` /cookbook/email/index`
67
68
132
133
* :doc:` /cookbook/security/remember_me`
133
134
* :doc:` /cookbook/security/impersonating_user`
134
135
* :doc:` /cookbook/security/voters`
136
+ * :doc:` /cookbook/security/voters_data_permission`
135
137
* :doc:` /cookbook/security/acl`
136
138
* :doc:` /cookbook/security/acl_advanced`
137
139
* :doc:` /cookbook/security/force_https`
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ the ACL system comes in.
14
14
Using ACL's isn't trivial, and for simpler use cases, it may be overkill.
15
15
If your permission logic could be described by just writing some code (e.g.
16
16
to check if a Blog is owned by the current User), then consider using
17
- :doc: `voters </cookbook/security/voters >`. A voter is passed the object
17
+ :doc: `voters </cookbook/security/voters_data_permission >`. A voter is passed the object
18
18
being voted on, which you can use to make complex decisions and effectively
19
19
implement your own ACL. Enforcing authorization (e.g. the ``isGranted ``
20
20
part) will look similar to what you see in this entry, but your voter
Original file line number Diff line number Diff line change 8
8
remember_me
9
9
impersonating_user
10
10
voters
11
+ voters_data_permission
11
12
acl
12
13
acl_advanced
13
14
force_https
Original file line number Diff line number Diff line change
1
+ .. code-block:: php
2
+
3
+ interface VoterInterface
4
+ {
5
+ public function supportsAttribute($attribute);
6
+ public function supportsClass($class);
7
+ public function vote(TokenInterface $token, $post, array $attributes);
8
+ }
9
+
10
+ The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsAttribute`
11
+ method is used to check if the voter supports the given user attribute (i.e:
12
+ a role like ``ROLE_USER``, an ACL ``EDIT``, etc.).
13
+
14
+ The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsClass`
15
+ method is used to check if the voter supports the class of the object whose
16
+ access is being checked.
17
+
18
+ The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::vote`
19
+ method must implement the business logic that verifies whether or not the
20
+ user has access. This method must return one of the following values:
21
+
22
+ * ``VoterInterface::ACCESS_GRANTED``: The authorization will be granted by this voter;
23
+ * ``VoterInterface::ACCESS_ABSTAIN``: The voter cannot decide if authorization should be granted;
24
+ * ``VoterInterface::ACCESS_DENIED``: The authorization will be denied by this voter.
Original file line number Diff line number Diff line change @@ -21,28 +21,7 @@ A custom voter must implement
21
21
:class: `Symfony\\ Component\\ Security\\ Core\\ Authorization\\ Voter\\ VoterInterface `,
22
22
which requires the following three methods:
23
23
24
- .. code-block :: php
25
-
26
- interface VoterInterface
27
- {
28
- public function supportsAttribute($attribute);
29
- public function supportsClass($class);
30
- public function vote(TokenInterface $token, $object, array $attributes);
31
- }
32
-
33
- The ``supportsAttribute() `` method is used to check if the voter supports
34
- the given user attribute (i.e: a role, an ACL, etc.).
35
-
36
- The ``supportsClass() `` method is used to check if the voter supports the
37
- class of the object whose access is being checked (doesn't apply to this entry).
38
-
39
- The ``vote() `` method must implement the business logic that verifies whether
40
- or not the user is granted access. This method must return one of the following
41
- values:
42
-
43
- * ``VoterInterface::ACCESS_GRANTED ``: The authorization will be granted by this voter;
44
- * ``VoterInterface::ACCESS_ABSTAIN ``: The voter cannot decide if authorization should be granted;
45
- * ``VoterInterface::ACCESS_DENIED ``: The authorization will be denied by this voter.
24
+ .. include :: /cookbook/security/voter_interface.rst.inc
46
25
47
26
In this example, you'll check if the user's IP address matches against a list of
48
27
blacklisted addresses and "something" will be the application. If the user's IP is blacklisted, you'll return
You can’t perform that action at this time.
0 commit comments