Commit Graph

1971 Commits

Author SHA1 Message Date
Fabien Potencier
59a974e8f6 added TemplateLocatorInterface 2011-01-22 08:31:08 +01:00
Antoine Hérault
47421dbc25 [DoctrineBundle] Fix load data fixtures command 2011-01-22 07:26:54 +01:00
Bulat Shakirzyanov
5ff0dedebb [FrameworkBundle] fixed template names 2011-01-22 07:23:55 +01:00
Hugo Hamon
c13b0db4c8 [HttpFoundation] fixed outdated documentation for the Controller class, which does not implement ArrayAccess anymore. 2011-01-22 07:19:11 +01:00
Fabien Potencier
72b7876c80 [TwigBundle] fiwed phpdoc 2011-01-21 18:04:56 +01:00
Fabien Potencier
db2f8ea6cb made a small refactoring of some DIC extensions 2011-01-21 17:48:35 +01:00
Fabien Potencier
fedb4b4f0d [TwigBundle] started to refactor TwigExtension 2011-01-21 17:45:04 +01:00
Fabien Potencier
69f0ec3b1a added a method to normalize config entries coming from YAML and XML 2011-01-21 17:44:30 +01:00
Bulat Shakirzyanov
acb19bc43f [FrameworkBundle] added 'document_root' option for File objects 2011-01-21 17:13:05 +01:00
Johannes M. Schmitt
bdc7ae8c52 show cookies in response headers 2011-01-21 17:06:04 +01:00
Johannes M. Schmitt
8d19136a55 refactors extensions to call XXXLoad only once with all config sections 2011-01-21 17:04:18 +01:00
Fabien Potencier
bd6bc4db62 [HttpKernel] changed Kernel::locateResource() to also work with directories 2011-01-21 16:42:57 +01:00
Fabien Potencier
645528c9c6 fixed typo 2011-01-21 16:28:24 +01:00
Fabien Potencier
d2e24a9cae added a missing file for unit tests 2011-01-21 15:06:38 +01:00
Henrik Bjørnskov
5e9c9f4174 Template rename fix files 2011-01-21 15:06:10 +01:00
Henrik Bjørnskov
a5007febdd [FrameworkBundle] Renderer is once more the last of the templates 2011-01-21 15:06:10 +01:00
Christophe Coevoet
1e793a2500 Fixed init:bundle 2011-01-21 14:19:51 +01:00
Fabien Potencier
4e0ecfdf81 [FrameworkBundle] fixed init:bundle 2011-01-21 12:58:46 +01:00
Fabien Potencier
a8e0a22011 [FrameworkBundle] fixed SecurityContext when security is disabled 2011-01-21 12:32:21 +01:00
Fabien Potencier
8649debb06 [Routing] fixed imports from the current directory 2011-01-21 12:06:06 +01:00
Johannes M. Schmitt
507da2a1ab some performance tweaks
This adds lazy loading for firewall configurations. This is useful when you have multiple firewalls, only the firewalls which are actually needed to process the Request are initialized. So, your event dispatcher is not as costly to initialize anymore.

It also implements re-using of RequestMatchers if all matching rules are the same, and exposes the remaining rules which are already implemented by the request matcher (host, ip, methods) in the access-control section
2011-01-21 11:57:43 +01:00
Fabien Potencier
82d29d2a76 [HttpKernel] added a unit tests for previous commit 2011-01-21 11:54:34 +01:00
Thomas
dd20434227 fix kernel:locateResource to loop accross the bundle tree to find the first match 2011-01-21 11:52:51 +01:00
Fabien Potencier
0b0c15b7b6 made XSD less strict when possible 2011-01-21 10:53:13 +01:00
Fabien Potencier
1583c8b9ef updated bootstrap file 2011-01-21 10:51:51 +01:00
Daniel Holmes
e135c14538 Allow arbitrary ordering of config elements in symfony xml config 2011-01-21 09:55:55 +01:00
Ryan Weaver
17f9162b89 [Standards] Changing many instances of "boolean" to "Boolean". 2011-01-21 09:53:24 +01:00
Fabien Potencier
e6f1248151 [HttpKernel] added back Bundle::getName() as it is quite useful 2011-01-21 09:45:37 +01:00
Fabien Potencier
6d1e91a1fa refactored bundle management
Before I explain the changes, let's talk about the current state.

Before this patch, the registerBundleDirs() method returned an ordered (for
resource overloading) list of namespace prefixes and the path to their
location. Here are some problems with this approach:

 * The paths set by this method and the paths configured for the autoloader
   can be disconnected (leading to unexpected behaviors);

 * A bundle outside these paths worked, but unexpected behavior can occur;

 * Choosing a bundle namespace was limited to the registered namespace
   prefixes, and their number should stay low enough (for performance reasons)
   -- moreover the current Bundle\ and Application\ top namespaces does not
   respect the standard rules for namespaces (first segment should be the
   vendor name);

 * Developers must understand the concept of "namespace prefixes" to
   understand the overloading mechanism, which is one more thing to learn,
   which is Symfony specific;

 * Each time you want to get a resource that can be overloaded (a template for
   instance), Symfony would have tried all namespace prefixes one after the
   other until if finds a matching file. But that can be computed in advance
   to reduce the overhead.

Another topic which was not really well addressed is how you can reference a
file/resource from a bundle (and take into account the possibility of
overloading). For instance, in the routing, you can import a file from a
bundle like this:

  <import resource="FrameworkBundle/Resources/config/internal.xml" />

Again, this works only because we have a limited number of possible namespace
prefixes.

This patch addresses these problems and some more.

First, the registerBundleDirs() method has been removed. It means that you are
now free to use any namespace for your bundles. No need to have specific
prefixes anymore. You are also free to store them anywhere, in as many
directories as you want. You just need to be sure that they are autoloaded
correctly.

The bundle "name" is now always the short name of the bundle class (like
FrameworkBundle or SensioCasBundle). As the best practice is to prefix the
bundle name with the vendor name, it's up to the vendor to ensure that each
bundle name is unique. I insist that a bundle name must be unique. This was
the opposite before as two bundles with the same name was how Symfony2 found
inheritance.

A new getParent() method has been added to BundleInterface. It returns the
bundle name that the bundle overrides (this is optional of course). That way,
there is no ordering problem anymore as the inheritance tree is explicitely
defined by the bundle themselves.

So, with this system, we can easily have an inheritance tree like the
following:

FooBundle < MyFooBundle < MyCustomFooBundle

MyCustomFooBundle returns MyFooBundle for the getParent() method, and
MyFooBundle returns FooBundle.

If two bundles override the same bundle, an exception is thrown.

Based on the bundle name, you can now reference any resource with this
notation:

    @FooBundle/Resources/config/routing.xml
    @FooBundle/Controller/FooController.php

This notation is the input of the Kernel::locateResource() method, which
returns the location of the file (and of course it takes into account
overloading).

So, in the routing, you can now use the following:

    <import resource="@FrameworkBundle/Resources/config/internal.xml" />

The template loading mechanism also use this method under the hood.

As a bonus, all the code that converts from internal notations to file names
(controller names: ControllerNameParser, template names: TemplateNameParser,
resource paths, ...) is now contained in several well-defined classes. The
same goes for the code that look for templates (TemplateLocator), routing
files (FileLocator), ...

As a side note, it is really easy to also support multiple-inheritance for a
bundle (for instance if a bundle returns an array of bundle names it extends).
However, this is not implemented in this patch as I'm not sure we want to
support that.

How to upgrade:

 * Each bundle must now implement two new mandatory methods: getPath() and
   getNamespace(), and optionally the getParent() method if the bundle extends
   another one. Here is a common implementation for these methods:

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'MyFrameworkBundle';
    }

    /**
     * {@inheritdoc}
     */
    public function getNamespace()
    {
        return __NAMESPACE__;
    }

    /**
     * {@inheritdoc}
     */
    public function getPath()
    {
        return strtr(__DIR__, '\\', '/');
    }

 * The registerBundleDirs() can be removed from your Kernel class;

 * If your code relies on getBundleDirs() or the kernel.bundle_dirs parameter,
   it should be upgraded to use the new interface (see Doctrine commands for
   many example of such a change);

 * When referencing a bundle, you must now always use its name (no more \ or /
   in bundle names) -- this transition was already done for most things
   before, and now applies to the routing as well;

 * Imports in routing files must be changed:
    Before: <import resource="Sensio/CasBundle/Resources/config/internal.xml" />
    After:  <import resource="@SensioCasBundle/Resources/config/internal.xml" />
2011-01-20 18:42:47 +01:00
Jordi Boggiano
252918beb2 [TwigBundle] Fixed RenderTokenParser when with isn't used and options are provided 2011-01-20 16:47:54 +01:00
Ryan Weaver
ea2cb49696 [TwigBundle] Improving the PHPDoc on the FormExtension inside the TwigBundle. 2011-01-20 16:37:36 +01:00
Ryan Weaver
cf1512dce8 [Form] Fixing the object versus normalized data PHPDoc on Field, which I believe was backwards. 2011-01-20 16:37:33 +01:00
Ryan Weaver
d41b4ec109 [Form] adding PHPDoc and some small PHPDoc changes. 2011-01-20 16:37:31 +01:00
Ryan Weaver
82283db789 [Form] Making the constructor inherit docs. 2011-01-20 16:37:27 +01:00
Fabien Potencier
67f13fee9e [HttpKernel] made a small tweak 2011-01-20 11:38:17 +01:00
Fabien Potencier
24ff22af07 [HttpFoundation] added a directory fallback for when the class is not found in registered namespaces and class prefixes 2011-01-20 10:20:14 +01:00
Jeremy Mikola
e414e06327 [HttpKernel] Fix AccessDecisionManagerInterface::decide() invocation in SwitchUserListener 2011-01-20 07:14:46 +01:00
Bulat Shakirzyanov
04fd4194b5 [DoctrineMongoDBBundle] fixed typo, updated extension test to reflection validation addon 2011-01-20 07:13:37 +01:00
Victor Berchet
b75840c6fc DI Extension: use the base class from the HttpKernel Component 2011-01-19 22:08:41 +01:00
Bulat Shakirzyanov
6d52645861 [DoctrineMongoDBBundle] registered new validation namespace for annotations 2011-01-19 21:50:51 +01:00
Bulat Shakirzyanov
1cbd0caa89 [DoctrineMongoDBBundle] added unique constraint, validator and test, registered validator in DIC 2011-01-19 21:50:47 +01:00
Johannes M. Schmitt
84fa4b50db adds setArgument to Definition 2011-01-19 21:48:56 +01:00
Bernhard Schussek
bdd2c91abd [Form] Fixed failing test 2011-01-19 17:51:07 +01:00
Bernhard Schussek
d143eaad72 [Validator] Fixed XML schema 2011-01-19 16:50:45 +01:00
Jordi Boggiano
8800452b1c [Form] Fixed some documentation 2011-01-19 16:37:02 +01:00
Jordi Boggiano
d928632583 [Form] Made RepeatedField sub-field names configurable 2011-01-19 16:36:57 +01:00
Bernhard Schussek
d327a90ff2 [Validator] Added namespace prefix support for XML and YAML loaders 2011-01-19 16:25:50 +01:00
Bernhard Schussek
2d7c47e488 [Validator] Each object is now only validated once for a given group 2011-01-19 16:25:50 +01:00
Bernhard Schussek
d52ae8e103 [Validator] Removed unused class GroupChain 2011-01-19 16:25:50 +01:00
Bernhard Schussek
eed3c9a48c [Validator] Added abstract method Constraint::targets() to define whether constraints can be put onto properties, classes or both 2011-01-19 16:25:50 +01:00