Skip to content

Commit

Permalink
Merge pull request #1534 from brikou/fix_phpcode_20
Browse files Browse the repository at this point in the history
fixed php code against 2.0 branch
  • Loading branch information
weaverryan committed Jul 10, 2012
2 parents ba6e94e + 05cd9f5 commit 97294e0
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 59 deletions.
6 changes: 3 additions & 3 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ a controller object. Controllers are also called *actions*.
:linenos:
// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class HelloController
Expand Down Expand Up @@ -208,8 +208,8 @@ passed to that method:
<?php
// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HelloController extends Controller
Expand Down Expand Up @@ -349,8 +349,8 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the
.. code-block:: php
// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
Expand Down
8 changes: 4 additions & 4 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Without even thinking about Doctrine or databases, you already know that
you need a ``Product`` object to represent those products. Create this class
inside the ``Entity`` directory of your ``AcmeStoreBundle``::

// src/Acme/StoreBundle/Entity/Product.php
// src/Acme/StoreBundle/Entity/Product.php
namespace Acme\StoreBundle\Entity;

class Product
Expand Down Expand Up @@ -369,7 +369,7 @@ of the bundle:
use Acme\StoreBundle\Entity\Product;
use Symfony\Component\HttpFoundation\Response;
// ...
public function createAction()
{
$product = new Product();
Expand Down Expand Up @@ -1058,7 +1058,7 @@ can avoid the second query by issuing a join in the original query. Add the
following method to the ``ProductRepository`` class::

// src/Acme/StoreBundle/Repository/ProductRepository.php

public function findOneByIdJoinedToCategory($id)
{
$query = $this->getEntityManager()
Expand All @@ -1067,7 +1067,7 @@ following method to the ``ProductRepository`` class::
JOIN p.category c
WHERE p.id = :id'
)->setParameter('id', $id);

try {
return $query->getSingleResult();
} catch (\Doctrine\ORM\NoResultException $e) {
Expand Down
1 change: 0 additions & 1 deletion book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ that will house the logic for building the task form:
.. code-block:: php
// src/Acme/TaskBundle/Form/Type/TaskType.php
namespace Acme\TaskBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
Expand Down
2 changes: 1 addition & 1 deletion book/from_flat_php_to_symfony2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ them for you. Here's the same sample application, now built in Symfony2:

<?php
// src/Acme/BlogBundle/Controller/BlogController.php

namespace Acme\BlogBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class BlogController extends Controller
Expand Down
8 changes: 4 additions & 4 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ greeted. To create the page, follow the simple two-step process.
``web`` directory of your new Symfony2 project. For detailed information
on this process, see the documentation on the web server you are using.
Here's the relevant documentation page for some web server you might be using:

* For Apache HTTP Server, refer to `Apache's DirectoryIndex documentation`_.
* For Nginx, refer to `Nginx HttpCoreModule location documentation`_.

Expand Down Expand Up @@ -209,8 +209,6 @@ inside your ``AcmeHelloBundle``::
// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

class HelloController
{
}
Expand All @@ -225,8 +223,10 @@ Create the ``indexAction`` method that Symfony will execute when the ``hello``
route is matched::

// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

// ...
class HelloController
{
public function indexAction($name)
Expand Down
4 changes: 2 additions & 2 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pattern that points to a specific PHP class and method:
.. code-block:: php
// src/Acme/BlogBundle/Controller/BlogController.php
namespace Acme\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BlogController extends Controller
Expand Down Expand Up @@ -815,8 +815,8 @@ The controller might look like this:
.. code-block:: php
// src/Acme/BlogBundle/Controller/BlogController.php
namespace Acme\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BlogController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ called ``Calculator`` in the ``Utility/`` directory of your bundle::

// src/Acme/DemoBundle/Utility/Calculator.php
namespace Acme\DemoBundle\Utility;

class Calculator
{
public function add($a, $b)
Expand Down
4 changes: 2 additions & 2 deletions cookbook/bundles/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ original method, and change its functionality::
public function registerAction()
{
$response = parent::registerAction();

// do custom stuff

return $response;
}
}
Expand Down
6 changes: 3 additions & 3 deletions cookbook/doctrine/event_listeners_subscribers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ a ``postPersist`` method, which will be called when the event is thrown::

// src/Acme/SearchBundle/Listener/SearchIndexer.php
namespace Acme\SearchBundle\Listener;

use Doctrine\ORM\Event\LifecycleEventArgs;
use Acme\StoreBundle\Entity\Product;

class SearchIndexer
{
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$entityManager = $args->getEntityManager();

// perhaps you only want to act on some "Product" entity
if ($entity instanceof Product) {
// do something with the Product
Expand Down
6 changes: 3 additions & 3 deletions cookbook/form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ will be called `GenderType` and the file will be stored in the default location
for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extends
:class:`Symfony\\Component\\Form\\AbstractType`::

# src/Acme/DemoBundle/Form/Type/GenderType.php
// src/Acme/DemoBundle/Form/Type/GenderType.php
namespace Acme\DemoBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
Expand Down Expand Up @@ -153,7 +153,7 @@ new instance of the type in one of your forms::

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class AuthorType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
Expand Down Expand Up @@ -231,7 +231,7 @@ returned by the ``getName`` method defined earlier. We'll see the importance
of this in a moment when we use the custom field type. But first, add a ``__construct``
argument to ``GenderType``, which receives the gender configuration::

# src/Acme/DemoBundle/Form/Type/GenderType.php
// src/Acme/DemoBundle/Form/Type/GenderType.php
namespace Acme\DemoBundle\Form\Type;
// ...

Expand Down
1 change: 0 additions & 1 deletion cookbook/form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ manager can be automatically injected:
You can now add the type to your form by its alias as follows::

// src/Acme/TaskBundle/Form/Type/TaskType.php

namespace Acme\TaskBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
Expand Down
12 changes: 6 additions & 6 deletions cookbook/form/dynamic_form_generation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ might look like the following::
class AddNameFieldSubscriber implements EventSubscriberInterface
{
private $factory;

public function __construct(FormFactoryInterface $factory)
{
$this->factory = $factory;
}

public static function getSubscribedEvents()
{
// Tells the dispatcher that we want to listen on the form.pre_set_data
Expand All @@ -116,11 +116,11 @@ might look like the following::
{
$data = $event->getData();
$form = $event->getForm();
// During form creation setData() is called with null as an argument
// by the FormBuilder constructor. We're only concerned with when

// During form creation setData() is called with null as an argument
// by the FormBuilder constructor. We're only concerned with when
// setData is called with an actual Entity object in it (whether new,
// or fetched with Doctrine). This if statement let's us skip right
// or fetched with Doctrine). This if statement let's us skip right
// over the null condition.
if (null === $data) {
return;
Expand Down
18 changes: 9 additions & 9 deletions cookbook/form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ objects. Start by creating a simple ``Task`` class::

// src/Acme/TaskBundle/Entity/Task.php
namespace Acme\TaskBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;

class Task
Expand All @@ -37,7 +37,7 @@ objects. Start by creating a simple ``Task`` class::
{
$this->tags = new ArrayCollection();
}

public function getDescription()
{
return $this->description;
Expand Down Expand Up @@ -149,13 +149,13 @@ In your controller, you'll now initialize a new instance of ``TaskType``::

// src/Acme/TaskBundle/Controller/TaskController.php
namespace Acme\TaskBundle\Controller;

use Acme\TaskBundle\Entity\Task;
use Acme\TaskBundle\Entity\Tag;
use Acme\TaskBundle\Form\Type\TaskType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class TaskController extends Controller
{
public function newAction(Request $request)
Expand All @@ -171,17 +171,17 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
$tag2->name = 'tag2';
$task->getTags()->add($tag2);
// end dummy code

$form = $this->createForm(new TaskType(), $task);

// process the form on POST
if ('POST' === $request->getMethod()) {
$form->bindRequest($request);
if ($form->isValid()) {
// maybe do some form processing, like saving the Task and Tag objects
}
}

return $this->render('AcmeTaskBundle:Task:new.html.twig', array(
'form' => $form->createView(),
));
Expand Down Expand Up @@ -280,7 +280,7 @@ add the ``allow_add`` option to our collection field::

// src/Acme/TaskBundle/Form/Type/TaskType.php
// ...

public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('description');
Expand Down Expand Up @@ -491,7 +491,7 @@ Start by adding the ``allow_delete`` option in the form Type::
// src/Acme/TaskBundle/Form/Type/TaskType.php
// ...

public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('description');
Expand Down
2 changes: 1 addition & 1 deletion cookbook/form/use_virtuals_forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For example, imagine you have two entities, a ``Company`` and a ``Customer``::

.. code-block:: php
// src/Acme/HelloBundle/Entity/Company.php
// src/Acme/HelloBundle/Entity/Customer.php
namespace Acme\HelloBundle\Entity;
class Customer
Expand Down
8 changes: 4 additions & 4 deletions cookbook/security/custom_authentication_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ provider.
public $created;
public $digest;
public $nonce;
public function __construct(array $roles = array())
{
parent::__construct($roles);
// If the user has roles, consider it authenticated
$this->setAuthenticated(count($roles) > 0);
}
Expand Down Expand Up @@ -141,7 +141,7 @@ set an authenticated token in the security context if successful.
if ($returnValue instanceof TokenInterface) {
return $this->securityContext->setToken($returnValue);
} else if ($returnValue instanceof Response) {
} elseif ($returnValue instanceof Response) {
return $event->setResponse($returnValue);
}
} catch (AuthenticationException $e) {
Expand Down Expand Up @@ -208,7 +208,7 @@ the ``PasswordDigest`` header value matches with the user's password.
{
$user = $this->userProvider->loadUserByUsername($token->getUsername());
if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
$authenticatedToken = new WsseUserToken($user->getRoles());
$authenticatedToken->setUser($user);
Expand Down
4 changes: 2 additions & 2 deletions cookbook/security/custom_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class: ``getRoles()``, ``getPassword()``, ``getSalt()``, ``getUsername()``,

Let's see this in action::

// src/Acme/WebserviceUserBundle/Security/User.php
// src/Acme/WebserviceUserBundle/Security/User/WebserviceUser.php
namespace Acme\WebserviceUserBundle\Security\User;

use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -65,7 +65,7 @@ Let's see this in action::
public function getUsername()
{
return $this->username;
}
}

public function eraseCredentials()
{
Expand Down
Loading

0 comments on commit 97294e0

Please sign in to comment.