Skip to content

Commit

Permalink
Merge branch '2.3' into 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Mar 24, 2014
2 parents c75b1a7 + e15afe0 commit b0e07b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ python:
- "2.7"

install:
- "git submodule update --init"
- "bash install.sh"
- "pip install -q -r requirements.txt --use-mirrors"

Expand Down
4 changes: 2 additions & 2 deletions book/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ If there are any issues, correct them now before moving on.
$ rm -rf app/cache/*
$ rm -rf app/logs/*
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data' | grep -v root | head -1 | cut -d\ -f1`
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
$ sudo chmod +a "$APACHEUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
Expand All @@ -248,7 +248,7 @@ If there are any issues, correct them now before moving on.

.. code-block:: bash
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data' | grep -v root | head -1 | cut -d\ -f1`
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
$ sudo setfacl -Rn -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dRn -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs

Expand Down
20 changes: 10 additions & 10 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ creating that particular field is delegated to an event listener::
{
$builder->add('price');

$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
// ... adding the name field if needed
});
}
Expand All @@ -116,7 +116,7 @@ the event listener might look like the following::
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$product = $event->getData();
$form = $event->getForm();

Expand Down Expand Up @@ -254,7 +254,7 @@ Using an event listener, your form might look like this::
->add('subject', 'text')
->add('body', 'textarea')
;
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
// ... add a choice list of friends of the current application user
});
}
Expand Down Expand Up @@ -330,13 +330,13 @@ and fill in the listener logic::

$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) use ($user) {
function (FormEvent $event) use ($user) {
$form = $event->getForm();

$formOptions = array(
'class' => 'Acme\DemoBundle\Entity\User',
'property' => 'fullName',
'query_builder' => function(EntityRepository $er) use ($user) {
'query_builder' => function (EntityRepository $er) use ($user) {
// build a custom query
// return $er->createQueryBuilder('u')->addOrderBy('fullName', 'DESC');

Expand Down Expand Up @@ -496,7 +496,7 @@ sport like this::

$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) {
function (FormEvent $event) {
$form = $event->getForm();

// this would be your entity, i.e. SportMeetup
Expand Down Expand Up @@ -565,7 +565,7 @@ The type would now look like::
));
;

$formModifier = function(FormInterface $form, Sport $sport = null) {
$formModifier = function (FormInterface $form, Sport $sport = null) {
$positions = null === $sport ? array() : $sport->getAvailablePositions();

$form->add('position', 'entity', array(
Expand All @@ -577,7 +577,7 @@ The type would now look like::

$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) use ($formModifier) {
function (FormEvent $event) use ($formModifier) {
// this would be your entity, i.e. SportMeetup
$data = $event->getData();

Expand All @@ -587,7 +587,7 @@ The type would now look like::

$builder->get('sport')->addEventListener(
FormEvents::POST_SUBMIT,
function(FormEvent $event) use ($formModifier) {
function (FormEvent $event) use ($formModifier) {
// It's important here to fetch $event->getForm()->getData(), as
// $event->getData() will get you the client data (that is, the ID)
$sport = $event->getForm()->getData();
Expand Down Expand Up @@ -739,7 +739,7 @@ all of this, use a listener::

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::POST_SUBMIT, function($event) {
$builder->addEventListener(FormEvents::POST_SUBMIT, function ($event) {
$event->stopPropagation();
}, 900); // Always set a higher priority than ValidationListener

Expand Down
9 changes: 5 additions & 4 deletions cookbook/security/voters_data_permission.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ edit a particular object. Here's an example implementation::
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Acme\DemoBundle\Entity\Post;

class PostVoter implements VoterInterface
{
Expand All @@ -79,9 +78,11 @@ edit a particular object. Here's an example implementation::
));
}

public function supportsClass($obj)
public function supportsClass($class)
{
return $obj instanceof Post;
$supportedClass = 'Acme\DemoBundle\Entity\Post';

return $supportedClass === $class || is_subclass_of($class, $supportedClass);
}

/**
Expand All @@ -90,7 +91,7 @@ edit a particular object. Here's an example implementation::
public function vote(TokenInterface $token, $post, array $attributes)
{
// check if class of this object is supported by this voter
if (!$this->supportsClass($post)) {
if (!$this->supportsClass(get_class($post))) {
return VoterInterface::ACCESS_ABSTAIN;
}

Expand Down

0 comments on commit b0e07b4

Please sign in to comment.