Skip to content

[HttpKernel] Added support for registering Bundle dependencies #5103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
22a87b5
Added depreciation note for the cascade_validation constraint and upd…
peterrehm Oct 20, 2014
06aed96
feature #4354 [WCM] Added depreciation note for the cascade_validatio…
weaverryan Jun 19, 2015
bfea184
Merge branch '2.7' into 2.8
weaverryan Jun 19, 2015
9538919
Merge branch '2.7' into 2.8
weaverryan Jun 19, 2015
0fe1050
Merge branch '2.7' into 2.8
wouterj Jun 20, 2015
485c8a0
document new Doctrine APC cache service
xabbuh Jun 16, 2015
c9e8634
[#3782] Deprecating the read_only option
snoob Jun 26, 2015
dd0e33f
minor #3782 [Form] Deprecate read_only option (snoob)
weaverryan Jun 26, 2015
9718c14
[Serializer] Array Denormalization
derrabus Jun 3, 2015
464b578
feature #5360 [Serializer] Array Denormalization (derrabus)
xabbuh Jun 28, 2015
d4d1f12
Starting with range documentation
harikt Jun 28, 2015
a45a393
Merge branch '2.7' into 2.8
xabbuh Jun 28, 2015
a2c3f21
Make the necessary changes mentioned by @xabbuh and add example for form
harikt Jun 28, 2015
acff5b0
Merge branch '2.7' into 2.8
weaverryan Jun 28, 2015
cbf8fd7
feature #5409 [Reference] document new Doctrine APC cache service (xa…
weaverryan Jun 28, 2015
9cbf3d4
Merge branch '2.7' into 2.8
weaverryan Jun 28, 2015
273cab9
Merge branch '2.7' into 2.8
weaverryan Jun 30, 2015
ceebee0
Merge branch '2.7' into 2.8
wouterj Jul 1, 2015
bef92ec
Added June changelog
wouterj Jul 1, 2015
0436ee7
Merge branch '2.7' into 2.8
weaverryan Jul 2, 2015
cb482dc
Merge branch '2.7' into 2.8
xabbuh Jul 2, 2015
3c6ff76
Fix issues reported by @snoek09 . Thank you.
harikt Jul 3, 2015
abf3e8e
Fix the rendering issue
harikt Jul 3, 2015
2863079
Fix moving the mapped down as per @xabbuh
harikt Jul 4, 2015
2c1328e
Merge branch '2.7' into 2.8
xabbuh Jul 6, 2015
99a996c
Added caution notes about the deprecation of container scopes
javiereguiluz Jul 7, 2015
2f65bf2
Merge branch '2.7' into 2.8
weaverryan Jul 7, 2015
654b36c
Merge branch '2.7' into 2.8
weaverryan Jul 8, 2015
8fadb17
Merge branch '2.7' into 2.8
weaverryan Jul 12, 2015
7c967ed
Merge branch '2.7' into 2.8
weaverryan Jul 15, 2015
b88a17e
[Cookbook][WebServer] #5504 add a tip for the --force option on serve…
vincentaubert Jul 14, 2015
dc173b6
Merge branch '2.7' into 2.8
weaverryan Jul 15, 2015
571ed5b
Merge branch '2.7' into 2.8
xabbuh Jul 15, 2015
79a1902
Merge branch '2.7' into 2.8
weaverryan Jul 16, 2015
f4b7d7f
feature #5458 HTML5 range documentation (harikt)
weaverryan Jul 16, 2015
befbf7b
Merge branch '2.7' into 2.8
weaverryan Jul 16, 2015
3b829c0
Merge branch '2.7' into 2.8
xabbuh Jul 17, 2015
2f98474
feature #5521 [Cookbook][WebServer] #5504 add a tip for the --force o…
wouterj Jul 23, 2015
1739549
[#5521] Added versionadded directive
wouterj Jul 23, 2015
343b349
Merge branch '2.7' into 2.8
wouterj Jul 23, 2015
74cd23b
Merge branch '2.7' into 2.8
xabbuh Jul 23, 2015
0281f61
Merge branch '2.7' into 2.8
wouterj Jul 28, 2015
a20ea5d
Merge branch '2.7' into 2.8
wouterj Jul 28, 2015
4ab47cc
Merge branch '2.7' into 2.8
wouterj Jul 28, 2015
43565d9
minor #5498 [WIP] Added caution notes about the deprecation of contai…
xabbuh Jul 28, 2015
eafdb8c
Merge branch '2.7' into 2.8
weaverryan Aug 8, 2015
09fe35f
[HttpKernel] Added support for registering Bundle dependencies
andrerom Mar 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ New Documentation
~~~~~~~~~~~~~~~~~

* `#5423 <https://github.com/symfony/symfony-docs/pull/5423>`_ [Security] add & update doc entries on AbstractVoter implementation (Inoryy, javiereguiluz)
* `#5409 <https://github.com/symfony/symfony-docs/pull/5409>`_ [Reference] document new Doctrine APC cache service (xabbuh)
* `#5401 <https://github.com/symfony/symfony-docs/pull/5401>`_ Added some more docs about the remember me feature (WouterJ)
* `#5384 <https://github.com/symfony/symfony-docs/pull/5384>`_ Added information about the new date handling in the comparison constraints and Range (webmozart, javiereguiluz)
* `#5382 <https://github.com/symfony/symfony-docs/pull/5382>`_ Added support for standard Forwarded header (tony-co, javiereguiluz)
* `#5361 <https://github.com/symfony/symfony-docs/pull/5361>`_ Document security.switch_user event (Rvanlaak)
* `#5332 <https://github.com/symfony/symfony-docs/pull/5332>`_ [Serializer] ObjectNormalizer, object_to_populate doc. Minor enhancements. (dunglas)
* `#5335 <https://github.com/symfony/symfony-docs/pull/5335>`_ [Serializer] Updated the cookbook. (dunglas)
* `#5313 <https://github.com/symfony/symfony-docs/pull/5313>`_ Documented the overridden form options (javiereguiluz)
* `#5360 <https://github.com/symfony/symfony-docs/pull/5360>`_ [Serializer] Array Denormalization (derrabus)
* `#5307 <https://github.com/symfony/symfony-docs/pull/5307>`_ Update data_transformers.rst (zebba)
* `#5186 <https://github.com/symfony/symfony-docs/pull/5186>`_ Added a new article about using/installing unstable Symfony versions (javiereguiluz)
* `#5166 <https://github.com/symfony/symfony-docs/pull/5166>`_ Proposed a new article about using pure PHP libraries with Assetic (javiereguiluz)
Expand All @@ -42,6 +44,7 @@ New Documentation
* `#5355 <https://github.com/symfony/symfony-docs/pull/5355>`_ Added a mention to the Symfony Demo application (javiereguiluz)
* `#5331 <https://github.com/symfony/symfony-docs/pull/5331>`_ [PSR-7] Bridge documentation (dunglas)
* `#5373 <https://github.com/symfony/symfony-docs/pull/5373>`_ Added mentions to some popular (and useful) Symfony bundles (javiereguiluz)
* `#4354 <https://github.com/symfony/symfony-docs/pull/4354>`_ [WCM] Added depreciation note for the cascade_validation constraint (peterrehm)

Fixed Documentation
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -88,6 +91,7 @@ Minor Documentation Changes
* `#5381 <https://github.com/symfony/symfony-docs/pull/5381>`_ remove Yoda condition (greg0ire)
* `#5452 <https://github.com/symfony/symfony-docs/pull/5452>`_ [#5388] change echo and print in examples (snoek09)
* `#5451 <https://github.com/symfony/symfony-docs/pull/5451>`_ [#5388] change echo and print in examples (snoek09)
* `#3782 <https://github.com/symfony/symfony-docs/pull/3782>`_ [Form] Deprecate read_only option (snoob)
* `#5432 <https://github.com/symfony/symfony-docs/pull/5432>`_ removed squashing stuff. fixes #5368 (OskarStark)
* `#5383 <https://github.com/symfony/symfony-docs/pull/5383>`_ Reword a paragraph about service configurations (richardudovich)
* `#5389 <https://github.com/symfony/symfony-docs/pull/5389>`_ Updates to security.rst (HexTitan)
Expand Down
49 changes: 49 additions & 0 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,55 @@ having unique identifiers::
var_dump($serializer->serialize($org, 'json'));
// {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]}

Handling Arrays
---------------

The Serializer component is capable of handling arrays of objects as well.
Serializing arrays works just like serializing a single object::

use Acme\Person;

$person1 = new Person();
$person1->setName('foo');
$person1->setAge(99);
$person1->setSportsman(false);

$person2 = new Person();
$person2->setName('bar');
$person2->setAge(33);
$person2->setSportsman(true);

$persons = array($person1, $person2);
$data = $serializer->serialize($persons, 'json');

// $data contains [{"name":"foo","age":99,"sportsman":false},{"name":"bar","age":33,"sportsman":true}]

.. versionadded:: 2.8
The :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer`
class was introduced in 2.8. Prior to Symfony 2.8, only the serialization of
arrays is supported.

If you want to deserialize such a structure, you need to add the
:class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer`
to the set of normalizers. By appending ``[]`` to the type parameter of the
:method:`Symfony\\Component\\Serializer\\Serializer::deserialize` method,
you indicate that you're expecting an array instead of a single object.

.. code-block:: php

use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;

$serializer = new Serializer(
array(new GetSetMethodNormalizer(), new ArrayDenormalizer()),
array(new JsonEncoder())
);

$data = ...; // The serialized data from the previous example
$persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');

.. seealso::

A popular alternative to the Symfony Serializer Component is the third-party
Expand Down
97 changes: 97 additions & 0 deletions cookbook/bundles/dependencies.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. index::
single: Bundle; Dependencies

How to Use Bundle Dependencies to Load other Bundles
====================================================

.. versionadded:: 2.8
Support for bundle dependencies was introduced in Symfony 2.8.

When working on your own bundle(s), you'll sometimes have the need to reuse
other bundles, either by just requiring, overriding or inheriting from them.

While Composer takes care about making sure these dependencies are loaded,
you'll also need to enable these bundles in the kernel.

If your bundle is meant to be reused, bundle dependencies will complicate
your installation documentation. This makes installation and upgrading your
bundle more tedious for your users.

You can avoid this by specifying your dependencies. This will make sure that
they are loaded in the kernel. It'll also make sure they are loaded *before*
your own bundle, to make sure you can extend them.

Additional use case for this is for distribution bundle use cases where one
bundle is in fact bundling several others.

Specifying dependencies
-----------------------

Dependencies are specified using a Fully Qualified Name for the bundle class in same
format as PHP uses for ``get_class`` and for ``class`` constant introduced in PHP 5.5.

This implies you can only specify bundles that does not take arguments in it's constructor.
This is in-line with Symfony best practice and furthermore avoids same bundle being loaded
several times.

Specifying dependencies is accomplished by implementing the
:class:`Symfony\\Component\\HttpKernel\\Bundle\\BundleDependenciesInterface`::

// src/CacheBundle/CacheBundle.php
namespace CacheBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\Bundle\BundleDependenciesInterface;

class CacheBundle extends Bundle implements BundleDependenciesInterface
{
public function getBundleDependencies($environment, $debug)
{
return array('FOS\HttpCacheBundle\FOSHttpCacheBundle' => self::DEP_REQUIRED);
}
}

.. tip::

If your bundle requires PHP 5.5 or higher, you can also take advantage of
the ``class`` constant::

use FOS\HttpCacheBundle\FOSHttpCacheBundle;

// ...
public function getBundleDependencies($environment, $debug)
{
return array(FOSHttpCacheBundle::class => self::DEP_REQUIRED);
}

.. tip::

If your dependency is only to be loaded in ``dev`` or when debugging use the provided arguments::

use Egulias\SecurityDebugCommandBundle\EguliasSecurityDebugCommandBundle;

// ...
public function getBundleDependencies($environment, $debug)
{
if ($environment !== 'dev')
return array();

return array('Egulias\SecurityDebugCommandBundle\EguliasSecurityDebugCommandBundle' => self::DEP_REQUIRED);
}


Specifying optional dependencies
--------------------------------

Specifying a optional dependency follows the same format but with a different constant::

// ...
public function getBundleDependencies($environment, $debug)
{
return array('Oneup\FlysystemBundle\OneupFlysystemBundle' => self::DEP_OPTIONAL);
}

.. tip::

Make sure to not use PHP's ``class`` constant in combination with optional dependencies as that effectively will
make PHP error when they are missing.
1 change: 1 addition & 0 deletions cookbook/bundles/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Bundles
installation
best_practices
inheritance
dependencies
override
remove
extension
Expand Down
5 changes: 5 additions & 0 deletions cookbook/console/console_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ for details.
Getting Services from the Service Container
-------------------------------------------

.. caution::

The "container scopes" concept explained in this section has been deprecated
in Symfony 2.8 and it will be removed in Symfony 3.0.

By using :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand`
as the base class for the command (instead of the more basic
:class:`Symfony\\Component\\Console\\Command\\Command`), you have access to the
Expand Down
1 change: 1 addition & 0 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* :doc:`/cookbook/bundles/installation`
* :doc:`/cookbook/bundles/best_practices`
* :doc:`/cookbook/bundles/inheritance`
* :doc:`/cookbook/bundles/dependencies`
* :doc:`/cookbook/bundles/override`
* :doc:`/cookbook/bundles/remove`
* :doc:`/cookbook/bundles/extension`
Expand Down
5 changes: 5 additions & 0 deletions cookbook/service_container/scopes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
How to Work with Scopes
=======================

.. caution::

The "container scopes" concept explained in this article has been deprecated
in Symfony 2.8 and it will be removed in Symfony 3.0.

This article is all about scopes, a somewhat advanced topic related to the
:doc:`/book/service_container`. If you've ever gotten an error mentioning
"scopes" when creating services, then this article is for you.
Expand Down
12 changes: 12 additions & 0 deletions cookbook/web_server/built_in.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ can change the socket passing an IP address and a port as a command-line argumen

$ php app/console server:run 192.168.0.1:8080

.. note::

You can use the ``--force`` option to force the web server start
if the process wasn't correctly stopped (without using the ``server:stop`` command).

.. code-block:: bash

$ php app/console server:start --force

.. versionadded:: 2.8
The ``--force`` option was introduced in Symfony 2.8.

.. note::

You can use the ``server:status`` command to check if a web server is
Expand Down
7 changes: 7 additions & 0 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,13 @@ cache
The service that is used to persist class metadata in a cache. The service
has to implement the :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`.

.. versionadded:: 2.8
The ``validator.mapping.cache.doctrine.apc`` service was introduced in
Symfony 2.8.

Set this option to ``validator.mapping.cache.doctrine.apc`` to use the APC
cache provide from the Doctrine project.

.. _reference-validation-enable_annotations:

enable_annotations
Expand Down
2 changes: 0 additions & 2 deletions reference/forms/twig_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ done by using a public ``vars`` property on the
+------------------------+-------------------------------------------------------------------------------------+
| ``value`` | The value that will be used when rendering (commonly the ``value`` HTML attribute). |
+------------------------+-------------------------------------------------------------------------------------+
| ``read_only`` | If ``true``, ``readonly="readonly"`` is added to the field. |
+------------------------+-------------------------------------------------------------------------------------+
| ``disabled`` | If ``true``, ``disabled="disabled"`` is added to the field. |
+------------------------+-------------------------------------------------------------------------------------+
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
Expand Down
1 change: 1 addition & 0 deletions reference/forms/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Form Types Reference
types/percent
types/search
types/url
types/range

types/choice
types/entity
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/birthday.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ option defaults to 120 years ago to the current year.
| | - `invalid_message`_ |
| | - `invalid_message_parameters`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
+----------------------+-------------------------------------------------------------------------------+
| Parent type | :doc:`date </reference/forms/types/date>` |
+----------------------+-------------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/checkbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ true, if the box is unchecked, the value will be set to false.
| | - `label`_ |
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ option.
| | - `label`_ |
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ you should just use the ``choice`` type directly.
| | - `label`_ |
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+-----------------------------------------------------------------------+
| Parent type | :doc:`choice </reference/forms/types/choice>` |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ you should just use the ``choice`` type directly.
| | - `label`_ |
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`choice </reference/forms/types/choice>` |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ day and year) or three select boxes (see the `widget`_ option).
| | - `invalid_message`_ |
| | - `invalid_message_parameters`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
+----------------------+-----------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
+----------------------+-----------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array.
| | - `invalid_message`_ |
| | - `invalid_message_parameters`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
+----------------------+-----------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
+----------------------+-----------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The ``email`` field is a text field that is rendered using the HTML5
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
| | - `trim`_ |
+-------------+---------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ objects from the database.
| | - `label`_ |
| | - `label_attr`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------+
| Parent type | :doc:`choice </reference/forms/types/choice>` |
Expand Down
Loading