Skip to content

Commit

Permalink
Merge branch '2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Mar 4, 2014
2 parents cadca3b + 1065855 commit 8903e23
Show file tree
Hide file tree
Showing 25 changed files with 689 additions and 769 deletions.
349 changes: 71 additions & 278 deletions book/doctrine.rst

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions book/from_flat_php_to_symfony2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ them for you. Here's the same sample application, now built in Symfony2::
{
public function listAction()
{
$posts = $this->get('doctrine')->getManager()
$posts = $this->get('doctrine')
->getManager()
->createQuery('SELECT p FROM AcmeBlogBundle:Post p')
->execute();

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

if (!$post) {
// cause the 404 page not found to be displayed
Expand Down
2 changes: 1 addition & 1 deletion book/http_fundamentals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ regardless of how your project is developed. To name a few:
* `Security`_ - A powerful library for handling all types of security inside
an application;

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

Each and every one of these components is decoupled and can be used in *any*
PHP project, regardless of whether or not you use the Symfony2 framework.
Expand Down
43 changes: 43 additions & 0 deletions cookbook/doctrine/console.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. index::
single: Doctrine; ORM console commands
single: CLI; Doctrine ORM

Console Commands
----------------

The Doctrine2 ORM integration offers several console commands under the
``doctrine`` namespace. To view the command list you can use the ``list``
command:

.. code-block:: bash
$ php app/console list doctrine
A list of available commands will print out. You can find out more information
about any of these commands (or any Symfony command) by running the ``help``
command. For example, to get details about the ``doctrine:database:create``
task, run:

.. code-block:: bash
$ php app/console help doctrine:database:create
Some notable or interesting tasks include:

* ``doctrine:ensure-production-settings`` - checks to see if the current
environment is configured efficiently for production. This should always
be run in the ``prod`` environment:

.. code-block:: bash
$ php app/console doctrine:ensure-production-settings --env=prod
* ``doctrine:mapping:import`` - allows Doctrine to introspect an existing
database and create mapping information. For more information, see
:doc:`/cookbook/doctrine/reverse_engineering`.

* ``doctrine:mapping:info`` - tells you all of the entities that Doctrine
is aware of and whether or not there are any basic errors with the mapping.

* ``doctrine:query:dql`` and ``doctrine:query:sql`` - allow you to execute
DQL or SQL queries directly from the command line.
1 change: 1 addition & 0 deletions cookbook/doctrine/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Doctrine
resolve_target_entity
mapping_model_classes
registration_form
console
5 changes: 4 additions & 1 deletion cookbook/doctrine/registration_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Next, create the form for this ``Registration`` model::
'checkbox',
array('property_path' => 'termsAccepted')
);
$builder->add('Register', 'submit');
}

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

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

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

use Symfony\Component\HttpFoundation\Request;
// ...

public function createAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
Expand Down
2 changes: 2 additions & 0 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* :doc:`/cookbook/doctrine/resolve_target_entity`
* :doc:`/cookbook/doctrine/mapping_model_classes`
* :doc:`/cookbook/doctrine/registration_form`
* :doc:`/cookbook/doctrine/console`

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

Expand Down Expand Up @@ -132,6 +133,7 @@
* :doc:`/cookbook/security/remember_me`
* :doc:`/cookbook/security/impersonating_user`
* :doc:`/cookbook/security/voters`
* :doc:`/cookbook/security/voters_data_permission`
* :doc:`/cookbook/security/acl`
* :doc:`/cookbook/security/acl_advanced`
* :doc:`/cookbook/security/force_https`
Expand Down
2 changes: 1 addition & 1 deletion cookbook/security/acl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ the ACL system comes in.
Using ACL's isn't trivial, and for simpler use cases, it may be overkill.
If your permission logic could be described by just writing some code (e.g.
to check if a Blog is owned by the current User), then consider using
:doc:`voters </cookbook/security/voters>`. A voter is passed the object
:doc:`voters </cookbook/security/voters_data_permission>`. A voter is passed the object
being voted on, which you can use to make complex decisions and effectively
implement your own ACL. Enforcing authorization (e.g. the ``isGranted``
part) will look similar to what you see in this entry, but your voter
Expand Down
1 change: 1 addition & 0 deletions cookbook/security/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Security
remember_me
impersonating_user
voters
voters_data_permission
acl
acl_advanced
force_https
Expand Down
24 changes: 24 additions & 0 deletions cookbook/security/voter_interface.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. code-block:: php

interface VoterInterface
{
public function supportsAttribute($attribute);
public function supportsClass($class);
public function vote(TokenInterface $token, $post, array $attributes);
}

The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsAttribute`
method is used to check if the voter supports the given user attribute (i.e:
a role like ``ROLE_USER``, an ACL ``EDIT``, etc.).

The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsClass`
method is used to check if the voter supports the class of the object whose
access is being checked.

The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::vote`
method must implement the business logic that verifies whether or not the
user has access. This method must return one of the following values:

* ``VoterInterface::ACCESS_GRANTED``: The authorization will be granted by this voter;
* ``VoterInterface::ACCESS_ABSTAIN``: The voter cannot decide if authorization should be granted;
* ``VoterInterface::ACCESS_DENIED``: The authorization will be denied by this voter.
23 changes: 1 addition & 22 deletions cookbook/security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,7 @@ A custom voter must implement
:class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface`,
which requires the following three methods:

.. code-block:: php
interface VoterInterface
{
public function supportsAttribute($attribute);
public function supportsClass($class);
public function vote(TokenInterface $token, $object, array $attributes);
}
The ``supportsAttribute()`` method is used to check if the voter supports
the given user attribute (i.e: a role, an ACL, etc.).

The ``supportsClass()`` method is used to check if the voter supports the
class of the object whose access is being checked (doesn't apply to this entry).

The ``vote()`` method must implement the business logic that verifies whether
or not the user is granted access. This method must return one of the following
values:

* ``VoterInterface::ACCESS_GRANTED``: The authorization will be granted by this voter;
* ``VoterInterface::ACCESS_ABSTAIN``: The voter cannot decide if authorization should be granted;
* ``VoterInterface::ACCESS_DENIED``: The authorization will be denied by this voter.
.. include:: /cookbook/security/voter_interface.rst.inc

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

0 comments on commit 8903e23

Please sign in to comment.