Commit Graph

437 Commits

Author SHA1 Message Date
Johannes M. Schmitt
cf64d2cfe7 namespace changes
Symfony\Component\Security -> Symfony\Component\Security\Core
Symfony\Component\Security\Acl remains unchanged
Symfony\Component\HttpKernel\Security -> Symfony\Component\Security\Http
2011-01-26 22:23:20 +01:00
Fabien Potencier
75404e6bd6 renamed HttpKernel/Cache/ namespace to HttpKernel/HttpCache/ 2011-01-26 21:44:54 +01:00
Fabien Potencier
e645090423 moved security related things to a new SecurityBundle (the Security component is left unchanged) 2011-01-26 19:10:54 +01:00
Johannes Schmitt
e0fe42d050 removed isAuthenticated() from SecurityContext 2011-01-26 16:38:54 +01:00
Johannes Schmitt
57ae50e894 [Security] many improvements, and fixes 2011-01-26 16:38:54 +01:00
Fabien Potencier
db2f2b1315 refactored template name parser to occur independently of the loaders 2011-01-26 14:53:12 +01:00
Fabien Pennequin
c392f2518d [Form][Validator] Fixed indentation 2011-01-26 10:36:10 +01:00
Fabien Potencier
8b62df7247 changed the EventDispatcher and Event interfaces
The three notification methods do not return the Event instance anymore.

notify() does not return anything
notifyUntil() returns the returned value of the event that has processed the event
filter() returns the filtered value

Upgrading your listeners:
Listeners for notify() and filter() events: nothing to change
Listeners for notifyUntil() events:

Before:

    $event->setReturnValue('foo');
    return true;

After:

    $event->setProcessed();
    return 'foo';

If you notify events, the processing also need to be changed:

For filter() notifications: the filtered value is now available as
the returned value of the filter() method.

For notifyUntil() notifications:

Before:

    $event = $dispatcher->notifyUntil($event);
    if ($event->isProcessed()) {
        $ret = $event->getReturnValue();

        // do something with $ret
    }

After:

    $ret = $dispatcher->notifyUntil($event);
    if ($event->isProcessed()) {
        // do something with $ret
    }
2011-01-26 08:41:59 +01:00
Fabien Potencier
fb4e7fb5c5 added KernelInterface 2011-01-25 17:10:47 +01:00
Johannes Schmitt
40dec8831f adds helper method to normalize keys 2011-01-25 15:59:51 +01:00
Bernhard Schussek
d017970867 [Form] Implemented FormFactory::buildDefault() to ease the use of the new CSRF implementation without the DIC 2011-01-25 11:31:04 +01:00
Bernhard Schussek
7848a7ca63 [Form] Refactored CSRF implementation to be reusable and to work correctly with the session service 2011-01-25 11:31:04 +01:00
Ryan Weaver
d341e8bccb [Form] Adding PHPDoc to many Field objects and making other small changes:
* Added empty_value option on CountryField, LanguageField, LocaleField, TimezoneField
 * Added missing date_pattern to DateTimeField
 * Made the currency option on MoneyField required.
2011-01-25 11:10:25 +01:00
Johannes Schmitt
f29a5f74a1 made the DI config validation more strict to catch errors early 2011-01-24 21:15:48 +01:00
Fabien Pennequin
242562a361 [HttpFoundation] added test for processed array in sub-requests 2011-01-24 18:22:48 +01:00
Johannes M. Schmitt
e55f150fb7 adds hasTag() to Definition 2011-01-24 17:46:22 +01:00
Johannes M. Schmitt
0144dd86da adds synthetic attribute to definitions
This attribute can be used to hint that the service is being injected
dynamically at runtime, and not constructed by the DIC.
2011-01-23 21:11:50 +01:00
Fabien Potencier
1c11d81611 made all event listeners lazy loaded
* The register() method on all listeners has been removed
 * Instead, the information is now put directly in the DIC tag

For instance, a listener on core.request had this method:

   public function register(EventDispatcher $dispatcher, $priority = 0)
   {
       $dispatcher->connect('core.response', array($this, 'filter'), $priority);
   }

And this tag in the DIC configuration:

  <tag name="kernel.listener" />

Now, it only has the following configuration:

  <tag name="kernel.listener" event="core.response" method="filter" priority="0" />

The event and method attributes are now mandatory.
2011-01-23 18:07:05 +01:00
Jordi Boggiano
005c1d9df8 [Serializer] Added initial version of the Serializer component 2011-01-23 12:34:47 +01:00
Bulat Shakirzyanov
271e757f27 [HttFoundation] extracted FileBag, ServerBag, fixed HeaderBag::add(), updated Request test 2011-01-23 07:40:31 +01:00
Johannes M. Schmitt
1d5b6ed908 adds scope to the DI container 2011-01-22 15:20:50 +01:00
Fabien Potencier
bd6bc4db62 [HttpKernel] changed Kernel::locateResource() to also work with directories 2011-01-21 16:42:57 +01:00
Fabien Potencier
d2e24a9cae added a missing file for unit tests 2011-01-21 15:06:38 +01:00
Fabien Potencier
82d29d2a76 [HttpKernel] added a unit tests for previous commit 2011-01-21 11:54:34 +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
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
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
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
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
Bernhard Schussek
6ad22fd702 [Validator] Added ValidatorFactory for programmatically creating validators 2011-01-19 16:25:50 +01:00
Bernhard Schussek
8f8f53d631 [Form][FrameworkBundle] Implemented FormFactory and added it to the DI container 2011-01-19 16:25:50 +01:00
Bernhard Schussek
fea37a3e95 [Validator] Added tests for AssertTypeValidator 2011-01-19 16:25:50 +01:00
Victor Berchet
3e8f8ea6af [ProfilerStorage] Make write() returns a status (Boolean) 2011-01-19 07:38:46 +01:00
Victor Berchet
5030255021 [SQLiteProfilerStorage] Add a unit test 2011-01-19 07:36:27 +01:00
Victor Berchet
2740e105e1 [Profiler] Fix a typo 2011-01-19 07:33:36 +01:00
Bulat Shakirzyanov
267a7e6956 [HttpKernel] fixed Cache, to respect the variable and trigger error handling 2011-01-19 07:31:27 +01:00
Kris Wallsmith
8d6da86016 [DependencyInjection] moved loading stack from static to object scope 2011-01-19 07:28:42 +01:00
Lukas Kahwe Smith
ddea635a51 fixes else -> } else 2011-01-19 07:20:23 +01:00
Dominique Bongiraud
64fb94c725 normalized license messages in PHP files 2011-01-18 08:07:46 +01:00
Fabien Potencier
c5f2ec8d2d made DIC tags only available during "compilation"
Now that we have a compilation phase for the DIC, using tags after compilation
is not needed anymore.

Tags were introduced to allow several independant bundles to be able to
interact which each others (remember that each extension knows nothing about
the others).

But during the compilation phase, the container has been merged ans so, all
the information from all bundles are available. This is then the right place
to deal with tags. That way, less work is needed at runtime and the DIC class
in the cache is also much smaller.

For simple cases, it means that you need to process the tag in a compiler pass
and store the information you need in a DIC parameter (have a look at the
TranslatorPass for a very simple example).

So, the PHP dumper does not add tags to the dumped PHP class anymore (it does
not implements TaggedContainerInterface anymore). But tags are still available
on ContainerBuilder instances.
2011-01-17 11:40:04 +01:00
Fabien Potencier
be35aa1d6a [HttpKernel] added the possibility to add non-namespaced classes to the compiled class cache 2011-01-16 11:32:14 +01:00
Fabien Potencier
d5c9f37982 [DependencyInjection] added compiler passes as resources 2011-01-16 10:20:10 +01:00
Fabien Potencier
5c64ca8a30 renamed Container::freeze() to Container::compile() 2011-01-16 08:12:36 +01:00
Johannes M. Schmitt
98b52b607c better support for cookie handling, use native PHP function to set cookies 2011-01-15 20:47:29 +01:00
hhamon
e2dc7f47cb [HttpFoundation] use pathinfo() native function to determine file extension. Change File::move() and UploadedFile::move() methods to accept a second argument allowing to move the file with a new name instead of moving it with its original name. 2011-01-15 15:44:50 +01:00
Fabien Potencier
055b6e4d6e made a big refactoring of the templating sub-framework
* better separation of concerns
 * made TwigBundle independant of the PHP Engine from FrameworkBundle (WIP)
 * removed one layer of abstraction in the Templating component (renderers)
 * made it easier to create a new Engine for any templating library
 * made engines lazy-loaded (PHP engine for instance is not started if you only use Twig)
 * reduces memory footprint (if you only use one engine)
 * reduces size of compiled classes.php cache file
2011-01-15 07:43:05 +01:00