8000 Merge branch '2.4' · symfony/symfony-docs@8903e23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8903e23

Browse files
committed
Merge branch '2.4'
2 parents cadca3b + 1065855 commit 8903e23

25 files changed

+689
-769
lines changed

book/doctrine.rst

Lines changed: 71 additions & 278 deletions
Large diffs are not rendered by default.

book/from_flat_php_to_symfony2.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ them for you. Here's the same sample application, now built in Symfony2::
553553
{
554554
public function listAction()
555555
{
556-
$posts = $this->get('doctrine')->getManager()
556+
$posts = $this->get('doctrine')
557+
->getManager()
557558
->createQuery('SELECT p FROM AcmeBlogBundle:Post p')
558559
->execute();
559560

@@ -568,8 +569,7 @@ them for you. Here's the same sample application, now built in Symfony2::
568569
$post = $this->get('doctrine')
569570
->getManager()
570571
->getRepository('AcmeBlogBundle:Post')
571-
->find($id)
572-
;
572+
->find($id);
573573

574574
if (!$post) {
575575
// cause the 404 page not found to be displayed

book/http_fundamentals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ regardless of how your project is developed. To name a few:
542542
* `Security`_ - A powerful library for handling all types of security inside
543543
an application;
544544

545-
* `Translation`_ A framework for translating strings in your application.
545+
* `Translation`_ - A framework for translating strings in your application.
546546

547547
Each and every one of these components is decoupled and can be used in *any*
548548
PHP project, regardless of whether or not you use the Symfony2 framework.

cookbook/doctrine/console.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.

cookbook/doctrine/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Doctrine
1414
resolve_target_entity
1515
mapping_model_classes
1616
registration_form
17+
console

cookbook/doctrine/registration_form.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ Next, create the form for this ``Registration`` model::
216216
'checkbox',
217217
array('property_path' => 'termsAccepted')
218218
);
219+
$builder->add('Register', 'submit');
219220
}
220221

221222
public function getName()
@@ -239,7 +240,6 @@ controller for displaying the registration form::
239240
namespace Acme\AccountBundle\Controller;
240241

241242
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
242-
use Symfony\Component\HttpFoundation\Response;
243243

244244
use Acme\AccountBundle\Form\Type\RegistrationType;
245245
use Acme\AccountBundle\Form\Model\Registration;
@@ -270,6 +270,9 @@ And its template:
270270
Next, create the controller which handles the form submission. This performs
271271
the validation and saves the data into the database::
272272

273+
use Symfony\Component\HttpFoundation\Request;
274+
// ...
275+
273276
public function createAction(Request $request)
274277
{
275278
$em = $this->getDoctrine()->getManager();

cookbook/map.rst.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
* :doc:`/cookbook/doctrine/resolve_target_entity`
6363
* :doc:`/cookbook/doctrine/mapping_model_classes`
6464
* :doc:`/cookbook/doctrine/registration_form`
65+
* :doc:`/cookbook/doctrine/console`
6566

6667
* :doc:`/cookbook/email/index`
6768

@@ -132,6 +133,7 @@
132133
* :doc:`/cookbook/security/remember_me`
133134
* :doc:`/cookbook/security/impersonating_user`
134135
* :doc:`/cookbook/security/voters`
136+
* :doc:`/cookbook/security/voters_data_permission`
135137
* :doc:`/cookbook/security/acl`
136138
* :doc:`/cookbook/security/acl_advanced`
137139
* :doc:`/cookbook/security/force_https`

cookbook/security/acl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ the ACL system comes in.
1414
Using ACL's isn't trivial, and for simpler use cases, it may be overkill.
1515
If your permission logic could be described by just writing some code (e.g.
1616
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
1818
being voted on, which you can use to make complex decisions and effectively
1919
implement your own ACL. Enforcing authorization (e.g. the ``isGranted``
2020
part) will look similar to what you see in this entry, but your voter

cookbook/security/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Security
88
remember_me
99
impersonating_user
1010
voters
11+
voters_data_permission
1112
acl
1213
acl_advanced
1314
force_https
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.

cookbook/security/voters.rst

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,7 @@ A custom voter must implement
2121
:class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface`,
2222
which requires the following three methods:
2323

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
4625

4726
In this example, you'll check if the user's IP address matches against a list of
4827
blacklisted addresses and "something" will be the application. If the user's IP is blacklisted, you'll return

0 commit comments

Comments
 (0)
0