Skip to content

Commit

Permalink
Merge branch '2.3' into 2.6
Browse files Browse the repository at this point in the history
Conflicts:
	components/event_dispatcher/introduction.rst
	cookbook/bundles/best_practices.rst
	reference/forms/types/choice.rst
  • Loading branch information
wouterj committed Jun 27, 2015
2 parents 8b8ba03 + 4f3ce84 commit 52bd0a9
Show file tree
Hide file tree
Showing 28 changed files with 253 additions and 188 deletions.
3 changes: 2 additions & 1 deletion book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,8 @@ to the given ``Category`` object via their ``category_id`` value.
$category = $product->getCategory();

// prints "Proxies\AppBundleEntityCategoryProxy"
echo get_class($category);
dump(get_class($category));
die();

This proxy object extends the true ``Category`` object, and looks and
acts exactly like it. The difference is that, by using a proxy object,
Expand Down
9 changes: 5 additions & 4 deletions book/service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ The service container is built using a single configuration resource
be imported from inside this file in one way or another. This gives you absolute
flexibility over the services in your application.

External service configuration can be imported in two different ways. The
first - and most common method - is via the ``imports`` directive. Later, you'll
learn about the second method, which is the flexible and preferred method
for importing service configuration from third-party bundles.
External service configuration can be imported in two different ways. The first
method, commonly used to import container configuration from the bundles you've
created - is via the ``imports`` directive. The second method, although slightly more
complex offers more flexibility and is commonly used to import third-party bundle
configuration. Read on to learn more about both methods.

.. index::
single: Service Container; Imports
Expand Down
6 changes: 4 additions & 2 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ wrapping each with a function capable of translating the text (or "message")
into the language of the user::

// text will *always* print out in English
echo 'Hello World';
dump('Hello World');
die();

// text can be translated into the end-user's language or
// default to English
echo $translator->trans('Hello World');
dump($translator->trans('Hello World'));
die();

.. note::

Expand Down
2 changes: 1 addition & 1 deletion components/class_loader/class_map_generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ method::

use Symfony\Component\ClassLoader\ClassMapGenerator;

print_r(ClassMapGenerator::createMap(__DIR__.'/library'));
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));

Given the files and class from the table above, you should see an output like
this:
Expand Down
1 change: 1 addition & 0 deletions components/console/console_arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Have a look at the following command that has three options::

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
2 changes: 1 addition & 1 deletion components/css_selector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ equivalents::

use Symfony\Component\CssSelector\CssSelector;

print CssSelector::toXPath('div.item > h4 > a');
var_dump(CssSelector::toXPath('div.item > h4 > a'));

This gives the following output:

Expand Down
2 changes: 2 additions & 0 deletions components/dependency_injection/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Advanced Container Configuration
================================

.. _container-private-services:

Marking Services as public / private
------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ traverse easily::
$crawler = new Crawler($html);

foreach ($crawler as $domElement) {
print $domElement->nodeName;
var_dump($domElement->nodeName);
}

Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and
Expand Down
5 changes: 3 additions & 2 deletions components/event_dispatcher/generic_event.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ the event arguments::
);
$dispatcher->dispatch('foo', $event);

echo $event['counter'];
var_dump($event['counter']);

class FooListener
{
Expand All @@ -96,7 +96,7 @@ Filtering data::
$event = new GenericEvent($subject, array('data' => 'Foo'));
$dispatcher->dispatch('foo', $event);

echo $event['data'];
var_dump($event['data']);

class FooListener
{
Expand All @@ -105,3 +105,4 @@ Filtering data::
$event['data'] = strtolower($event['data']);
}
}

2 changes: 1 addition & 1 deletion components/event_dispatcher/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ dispatched, are passed as arguments to the listener::
{
public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
echo $eventName;
// ... do something with the event name
}
}

Expand Down
16 changes: 7 additions & 9 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ directories::
$finder->files()->in(__DIR__);

foreach ($finder as $file) {
// Print the absolute path
print $file->getRealpath()."\n";
// Dump the absolute path
var_dump($file->getRealpath());

// Print the relative path to the file, omitting the filename
print $file->getRelativePath()."\n";
// Dump the relative path to the file, omitting the filename
var_dump($file->getRelativePath());

// Print the relative path to the file
print $file->getRelativePathname()."\n";
// Dump the relative path to the file
var_dump($file->getRelativePathname());
}

The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
Expand Down Expand Up @@ -118,9 +118,7 @@ And it also works with user-defined streams::
$finder = new Finder();
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
foreach ($finder->in('s3://bucket-name') as $file) {
// ... do something

print $file->getFilename()."\n";
// ... do something with the file
}

.. note::
Expand Down
4 changes: 2 additions & 2 deletions components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ is created from the form factory.
->add('dueDate', 'date')
->getForm();
echo $twig->render('new.html.twig', array(
var_dump($twig->render('new.html.twig', array(
'form' => $form->createView(),
));
)));
.. code-block:: php-symfony
Expand Down
4 changes: 2 additions & 2 deletions components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ represented by a PHP callable instead of a string::

$response = new StreamedResponse();
$response->setCallback(function () {
echo 'Hello World';
var_dump('Hello World');
flush();
sleep(2);
echo 'Hello World';
var_dump('Hello World');
flush();
});
$response->send();
Expand Down
10 changes: 5 additions & 5 deletions components/http_foundation/session_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,18 @@ further creates an extension point from where custom logic can be added that
works independently of which handler is being wrapped inside.

There are two kinds of save handler class proxies which inherit from
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\AbstractProxy`:
they are :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeProxy`
and :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\SessionHandlerProxy`.
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy`:
they are :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\NativeProxy`
and :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy`.

:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage`
automatically injects storage handlers into a save handler proxy unless already
wrapped by one.

:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeProxy`
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\NativeProxy`
is used automatically under PHP 5.3 when internal PHP save handlers are specified
using the ``Native*SessionHandler`` classes, while
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\SessionHandlerProxy`
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy`
will be used to wrap any custom save handlers, that implement :phpclass:`SessionHandlerInterface`.

From PHP 5.4 and above, all session handlers implement :phpclass:`SessionHandlerInterface`
Expand Down
12 changes: 6 additions & 6 deletions components/intl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This class currently only works with the `intl extension`_ installed::
$reader = new BinaryBundleReader();
$data = $reader->read('/path/to/bundle', 'en');

echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

PhpBundleReader
~~~~~~~~~~~~~~~
Expand All @@ -152,7 +152,7 @@ object::
$reader = new PhpBundleReader();
$data = $reader->read('/path/to/bundle', 'en');

echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

BufferedBundleReader
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -193,10 +193,10 @@ returned::
$data = $reader->read('/path/to/bundle', 'en');

// Produces an error if the key "Data" does not exist
echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

// Returns null if the key "Data" does not exist
echo $reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1'));
var_dump($reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1')));

Additionally, the
:method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry`
Expand All @@ -207,12 +207,12 @@ multi-valued entries (arrays), the values of the more specific and the fallback
locale will be merged. In order to suppress this behavior, the last parameter
``$fallback`` can be set to ``false``::

echo $reader->readEntry(
var_dump($reader->readEntry(
'/path/to/bundle',
'en',
array('Data', 'entry1'),
false
);
));

Accessing ICU Data
------------------
Expand Down
38 changes: 19 additions & 19 deletions components/property_access/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ method. This is done using the index notation that is used in PHP::
'first_name' => 'Wouter',
);

echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
echo $accessor->getValue($person, '[age]'); // null
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
var_dump($accessor->getValue($person, '[age]')); // null

As you can see, the method will return ``null`` if the index does not exists.

Expand All @@ -64,8 +64,8 @@ You can also use multi dimensional arrays::
)
);

echo $accessor->getValue($persons, '[0][first_name]'); // 'Wouter'
echo $accessor->getValue($persons, '[1][first_name]'); // 'Ryan'
var_dump($accessor->getValue($persons, '[0][first_name]')); // 'Wouter'
var_dump($accessor->getValue($persons, '[1][first_name]')); // 'Ryan'

Reading from Objects
--------------------
Expand All @@ -82,13 +82,13 @@ To read from properties, use the "dot" notation::
$person = new Person();
$person->firstName = 'Wouter';

echo $accessor->getValue($person, 'firstName'); // 'Wouter'
var_dump($accessor->getValue($person, 'firstName')); // 'Wouter'

$child = new Person();
$child->firstName = 'Bar';
$person->children = array($child);

echo $accessor->getValue($person, 'children[0].firstName'); // 'Bar'
var_dump($accessor->getValue($person, 'children[0].firstName')); // 'Bar'

.. caution::

Expand Down Expand Up @@ -118,7 +118,7 @@ property name (``first_name`` becomes ``FirstName``) and prefixes it with

$person = new Person();

echo $accessor->getValue($person, 'first_name'); // 'Wouter'
var_dump($accessor->getValue($person, 'first_name')); // 'Wouter'

Using Hassers/Issers
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -147,10 +147,10 @@ getters, this means that you can do something like this::
$person = new Person();

if ($accessor->getValue($person, 'author')) {
echo 'He is an author';
var_dump('He is an author');
}
if ($accessor->getValue($person, 'children')) {
echo 'He has children';
var_dump('He has children');
}

This will produce: ``He is an author``
Expand All @@ -175,7 +175,7 @@ The ``getValue`` method can also use the magic ``__get`` method::

$person = new Person();

echo $accessor->getValue($person, 'Wouter'); // array(...)
var_dump($accessor->getValue($person, 'Wouter')); // array(...)

.. _components-property-access-magic-call:

Expand Down Expand Up @@ -213,15 +213,15 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert
->enableMagicCall()
->getPropertyAccessor();

echo $accessor->getValue($person, 'wouter'); // array(...)
var_dump($accessor->getValue($person, 'wouter')); // array(...)

.. versionadded:: 2.3
The use of magic ``__call()`` method was introduced in Symfony 2.3.

.. caution::

The ``__call`` feature is disabled by default, you can enable it by calling
:method:`PropertyAccessorBuilder::enableMagicCallEnabled<Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::enableMagicCallEnabled>`
:method:`PropertyAccessorBuilder::enableMagicCall<Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::enableMagicCall>`
see `Enable other Features`_.

Writing to Arrays
Expand All @@ -237,9 +237,9 @@ method::

$accessor->setValue($person, '[first_name]', 'Wouter');

echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
// or
// echo $person['first_name']; // 'Wouter'
// var_dump($person['first_name']); // 'Wouter'

Writing to Objects
------------------
Expand Down Expand Up @@ -273,9 +273,9 @@ can use setters, the magic ``__set`` method or properties to set values::
$accessor->setValue($person, 'lastName', 'de Jong');
$accessor->setValue($person, 'children', array(new Person()));

echo $person->firstName; // 'Wouter'
echo $person->getLastName(); // 'de Jong'
echo $person->children; // array(Person());
var_dump($person->firstName); // 'Wouter'
var_dump($person->getLastName()); // 'de Jong'
var_dump($person->children); // array(Person());

You can also use ``__call`` to set values but you need to enable the feature,
see `Enable other Features`_.
Expand Down Expand Up @@ -311,7 +311,7 @@ see `Enable other Features`_.
$accessor->setValue($person, 'wouter', array(...));
echo $person->getWouter(); // array(...)
var_dump($person->getWouter()); // array(...)
Checking Property Paths
-----------------------
Expand Down Expand Up @@ -376,7 +376,7 @@ You can also mix objects and arrays::
$accessor->setValue($person, 'children[0].firstName', 'Wouter');
// equal to $person->getChildren()[0]->firstName = 'Wouter'

echo 'Hello '.$accessor->getValue($person, 'children[0].firstName'); // 'Wouter'
var_dump('Hello '.$accessor->getValue($person, 'children[0].firstName')); // 'Wouter'
// equal to $person->getChildren()[0]->firstName

Enable other Features
Expand Down
5 changes: 3 additions & 2 deletions components/security/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ first constructor argument::

$role = new Role('ROLE_ADMIN');

// will echo 'ROLE_ADMIN'
echo $role->getRole();
// will show 'ROLE_ADMIN'
var_dump($role->getRole());

.. note::

Expand Down Expand Up @@ -253,3 +253,4 @@ decision manager::
if (!$authorizationChecker->isGranted('ROLE_ADMIN')) {
throw new AccessDeniedException();
}

Loading

0 comments on commit 52bd0a9

Please sign in to comment.