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
Update override.rst #4831
Update override.rst #4831
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ the routes from any bundle, then they must be manually imported from somewhere | |
in your application (e.g. ``app/config/routing.yml``). | ||
|
||
The easiest way to "override" a bundle's routing is to never import it at | ||
all. Instead of importing a third-party bundle's routing, simply copying | ||
all. Instead of importing a third-party bundle's routing, simply copy | ||
that routing file into your application, modify it, and import it instead. | ||
|
||
Controllers | ||
|
@@ -68,7 +68,7 @@ in the core FrameworkBundle: | |
$container->setParameter('translator.class', 'Acme\HelloBundle\Translation\Translator'); | ||
|
||
Secondly, if the class is not available as a parameter, you want to make sure the | ||
class is always overridden when your bundle is used, or you need to modify | ||
class is always overridden when your bundle is used or if you need to modify | ||
something beyond just the class name, you should use a compiler pass:: | ||
|
||
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php | ||
|
@@ -106,7 +106,7 @@ Forms | |
----- | ||
|
||
In order to override a form type, it has to be registered as a service (meaning | ||
it is tagged as "form.type"). You can then override it as you would override any | ||
it is tagged as ``form.type``). You can then override it as you would override any | ||
service as explained in `Services & Configuration`_. This, of course, will only | ||
work if the type is referred to by its alias rather than being instantiated, | ||
e.g.:: | ||
|
@@ -136,7 +136,7 @@ the constraints to a new validation group: | |
.. code-block:: yaml | ||
|
||
# src/Acme/UserBundle/Resources/config/validation.yml | ||
Fos\UserBundle\Model\User: | ||
FOS\UserBundle\Model\User: | ||
properties: | ||
plainPassword: | ||
- NotBlank: | ||
|
@@ -152,10 +152,17 @@ the constraints to a new validation group: | |
<?xml version="1.0" encoding="UTF-8" ?> | ||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> | ||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping | ||
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> | ||
|
||
<class name="FOS\UserBundle\Model\User"> | ||
<property name="plainPassword"> | ||
<constraint name="NotBlank"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why changing it? I think the length is a great example, as NotBlank is already part of the FOS User afaik There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency because the YAML has two rules, the XML only one. |
||
<option name="groups"> | ||
<value>AcmeValidation</value> | ||
</option> | ||
</constraint> | ||
|
||
<class name="Fos\UserBundle\Model\User"> | ||
<property name="password"> | ||
<constraint name="Length"> | ||
<option name="min">6</option> | ||
<option name="minMessage">fos_user.password.short</option> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should better reword this sentence completely. It reads really weird. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it wouldn't hurt to reword it, at least it should be split into two sentences to make it easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge it this way. I'll create a new PR for 2.5, as this way of overriding services is deprecated anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wouterj Actually, I think we can remove this from 2.3. This approach was considered "bad", but since there was no code change (e.g. in 2.5) that actually made it deprecated, I think we should show the "right" way in all versions. What do you think?