Commit Graph

167 Commits

Author SHA1 Message Date
Fabien Potencier
3859589daa [Yaml] renamed load() to parse() 2011-06-14 16:25:25 +02:00
Fabien Potencier
72483f946b [Routing] tagged the public @api 2011-06-14 15:35:32 +02:00
Ryan Weaver
4f0214eff4 [Routing] Fixing a bug where the current directory was set too late in the PhpFileLoader 2011-05-29 11:26:36 -05:00
Fabien Potencier
9aa8083cb4 [Routing] fixed previous merge 2011-05-26 18:28:42 +02:00
Fabien Potencier
5911fb946d [Routing] fixed CS 2011-05-26 18:27:18 +02:00
Fabien Potencier
1c0dfad979 Merge remote branch 'Chekote/xmlfileloader_overload_refactor'
* Chekote/xmlfileloader_overload_refactor:
  Refactored the processing of each individual node into it's own method, enabling easier overloading of behavior for Bundles such as FriendsOfSymfony/RestBundle
2011-05-26 18:25:53 +02:00
Fabien Potencier
a2a1a88291 Merge remote branch 'schmittjoh/annotations'
* schmittjoh/annotations:
  removed obsolete compiler pass
  fixed some more tests
  fixed tests
  removed unused vendor
  some cleanups
  updated to latest changes
  [WebProfilerBundle] removed @ignorePhpDoc annotations
  [FrameworkBundle] fixed default
  [FrameworkBundle] updated configuration
  [Validator] updated fixtures
  updated UPDATE file
  updated Annotations integration
  [Routing] updated to changes
  [FrameworkBundle] added framework-wide annotation reader, updated validator tests
  [WebProfilerBundle] fixed controllers
  fixed unit tests
  added Annotations library
2011-05-22 08:45:24 +02:00
Johannes Schmitt
42fb34b647 fixed tests 2011-05-19 22:46:34 +02:00
Benjamin Eberlei
ec22b03b1d [Routing] Remove exception condition in YamlFileLoader::load() as its duplicating a check that is done in parseRoute() anyways. This changes allows to extend the YamlFileLoader without having to duplicate the whole method. 2011-05-19 20:26:26 +02:00
Johannes Schmitt
796d9af0c4 some updates 2011-05-16 22:26:24 +02:00
Chekote
ebab0a3ac2 Refactored the processing of each individual node into it's own method, enabling easier overloading of behavior for Bundles such as FriendsOfSymfony/RestBundle 2011-05-12 10:55:14 -05:00
Johannes Schmitt
73b92db612 [Routing] updated to changes 2011-04-29 17:44:56 +02:00
Johannes Schmitt
7e26575bbd [FrameworkBundle] added framework-wide annotation reader, updated validator tests 2011-04-29 15:54:44 +02:00
Artur Kotyrba
713e8c26a6 [Routing] removed redundant parameter in addRoute method 2011-04-25 22:58:23 +02:00
Pascal Borreli
8c0beea677 [Phpdoc] Cleaning/fixing 2011-04-23 15:18:47 +00:00
Brikou CARRE
e898445b94 removed empty lines/trailing spaces 2011-04-15 21:12:02 +02:00
Ryan Weaver
b9883a3bad [Config] Improving the exception when a resource cannot be imported
This improves, for example, the exception one would receive if they tried to import a resource from a bundle that doesn't exist.
Previously, the deep "bundle is not activated" exception would be thrown. That has value, however there is no indication of where
the exception is actually occurring.

In this new implementation, we throw an exception that explains exactly which resource, and from which source resource, cannot be
loaded. The deeper exception is still thrown as a nested exception.

Two caveats:

  * The `HttpKernel::varToString` method was replicated
  * This introduces a new `Exception` class, which allows us to prevent lot's of exceptions from nesting into each other in the case
    that some deeply imported resource cannot be imported (each upstream import that fails doesn't add its own exception).
2011-04-01 18:59:54 -05:00
Kris Wallsmith
daccbf45bf [Routing] updated for DirectoryResource changes 2011-04-01 04:57:10 -07:00
Fabien Potencier
1fb08b6445 [Routing] fixed private method 2011-03-23 21:40:54 +01:00
Fabien Potencier
e4a3e0c2c7 [Config] moved from protected to private (WIP) 2011-03-23 19:34:00 +01:00
Fabien Potencier
b5857528e0 [Routing] moved protected to private 2011-03-23 19:25:56 +01:00
Sven Paulus
eb8491f754 re-add filename based directory filter to the AnnotationDirectoryLoader,
now restricting to *.php files and therefore disregarding e.g. SVN metadata
files
2011-03-22 18:23:54 +01:00
Sven Paulus
61974adb4f revert adding filename based filter to the directory resource 2011-03-22 12:14:12 +01:00
Sven Paulus
f93e4b2d73 Eleminate the need to manually clear the cache if a new controller file containing routing annotations is added - part II
* add unit tests
* introduce filename filter to DirectoryResource (to restrict change monitoring to a subset of files)
* modify AnnotationDirectoryLoader.php to use filename filter set on Controller\.php$
2011-03-22 09:03:45 +01:00
Fabien Potencier
a505ff43b5 [Routing] added supported for multiple route annotations for a single controller 2011-03-19 17:40:24 +01:00
everzet
e4eee05b06 [Routing] tuned exception message 2011-03-19 12:58:31 +02:00
everzet
3fd50ea4e6 [Routing] throw an exception if route config has unsupported keys 2011-03-19 12:54:29 +02:00
Victor Berchet
61be2b7986 [Routing] XMLFileLoader small optimization 2011-03-11 09:47:46 +01:00
develop
1daedcc6fc fix whitespace problem 2011-03-08 09:49:52 +01:00
develop
a93aa55199 If you use an annotation resource pointing to a controller directory
in your routing configuration, only existing files in this directory
get tracked for changes in this directory. So if you add a new
controller file in this directory you'd have to manually clear the
cache since the new file gets ignored.
This patch adds a DirectoryResource for this case which tracks all
changes in the given directory (and files and directories contained
within).
2011-03-08 09:49:45 +01:00
Fabien Potencier
8c423edfef replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00
Fabien Potencier
2bb2388c3f fixed typo 2011-02-28 12:12:49 +01:00
Fabien Potencier
3948c2d8a2 [Routing] fixed annotation dir loader auto-reload when a controller class changes 2011-02-27 22:39:54 +01:00
Christophe Coevoet
92bfbf575c Fixed CS 2011-02-27 20:56:29 +01:00
Fabien Potencier
5c905beb13 moved common configuration classes to a new Config component 2011-02-13 22:31:50 +01:00
Jeremy Mikola
8525ff83cd [Routing] XmlFileLoader should treat a missing "type" attribute as null when calling FileLoader::import() 2011-02-12 21:52:16 +01:00
Fabien Potencier
5ee8eca0ee [Routing] fixed previous commit 2011-02-11 01:54:25 +01:00
Jeremy Mikola
d85a839997 [Routing] Avoid locating imported resources as files unless they resolve to a FileLoader
XML/YAML loaders assume imported resources are files before attempting to resolve their loader. This is problematic for loaders such as Assetic, which does not use a file as its resource. Furthermore, the previous consecutive calls to both locate() and getAbsolutePath() were redundant. File location can safely be delayed until FileLoader::import(), and we can let that throw an exception if the file is not found.
2011-02-11 00:08:43 +01:00
Fabien Potencier
b91f082be5 Revert "moved Resource to the Config component"
This reverts commit f53080860a.

Revert "[Router] config fixes"

This reverts commit 51beecc6f2.

Revert "moved duplicated files to a new Config component"

This reverts commit a8ec9b27f0.
2011-02-10 16:14:12 +01:00
Fabien Potencier
f53080860a moved Resource to the Config component 2011-02-10 16:07:42 +01:00
Fabien Potencier
a8ec9b27f0 moved duplicated files to a new Config component 2011-02-10 03:43:36 +01:00
Fabien Potencier
37537e3e8c fixed previous commit 2011-02-04 19:38:42 +01:00
Lukas Kahwe Smith
dd71501f54 some fixes by just "blindly" trying to make phpStorm code analysis happier 2011-02-04 19:30:28 +01:00
Fabien Potencier
8649debb06 [Routing] fixed imports from the current directory 2011-01-21 12:06:06 +01:00
Ryan Weaver
17f9162b89 [Standards] Changing many instances of "boolean" to "Boolean". 2011-01-21 09:53:24 +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
Dominique Bongiraud
64fb94c725 normalized license messages in PHP files 2011-01-18 08:07:46 +01:00
Fabien Potencier
6dd1d6172f fixed some routing patterns 2011-01-12 07:10:57 +01:00
Kris Wallsmith
763ef35d0e [Routing] added creation of a file resource in annotations loader 2010-12-22 11:19:05 +01:00
Kris Wallsmith
32aef96441 [Routing] removed call to setDefaultAnnotationNamespace() so this can be configure on the injected reader 2010-12-22 11:18:44 +01:00
Fabien Potencier
48e30537c4 added exception when a loaded YAML resource is not an array 2010-12-12 08:39:37 +01:00
Jeremy Mikola
c8c9fba7d9 [Routing] Add optional "type" param for loader hinting when resource strings are ambiguous
Currently, ambiguities only arise for PHP files, as PhpFileLoader and AnnotationFileLoader would both claim support.  Future conflicts may occur if the XML, YAML, or PHP loaders were to receive Directory and Glob loaders (as annotations have).

Since the "type" parameter is optional, loader resolution will default to awarding resolution to the first loader to claim support.  A previous hack in PhpFileLoader to avoid an AnnotationFileLoader conflict was removed, so that should be the only lost backwards compatibility with this patch.  Unit tests were also created for the various loader classes, although only the supports() method is being tested.

This implementation was proposed on the symfony-dev mailing list in response to Fabien's RFC for custom loader notation: http://groups.google.com/group/symfony-devs/browse_thread/thread/3104c1a9e45799d2/20fbe393c1afe088
2010-12-10 09:48:10 +01:00
Fabien Potencier
dca8a79bf5 [Routing] made annotation class loader more flexible 2010-11-30 14:00:48 +01:00
Ryan Weaver
f0ee10112e [Routing] Updating changed method name after method name refactoring. 2010-11-26 14:43:07 +01:00
Fabien Potencier
944d91c1df made some method name changes to have a better coherence throughout the framework
When an object has a "main" many relation with related "things" (objects,
parameters, ...), the method names are normalized:

 * get()
 * set()
 * all()
 * replace()
 * remove()
 * clear()
 * isEmpty()
 * add()
 * register()
 * count()
 * keys()

The classes below follow this method naming convention:

 * BrowserKit\CookieJar -> Cookie
 * BrowserKit\History -> Request
 * Console\Application -> Command
 * Console\Application\Helper\HelperSet -> HelperInterface
 * DependencyInjection\Container -> services
 * DependencyInjection\ContainerBuilder -> services
 * DependencyInjection\ParameterBag\ParameterBag -> parameters
 * DependencyInjection\ParameterBag\FrozenParameterBag -> parameters
 * DomCrawler\Form -> FormField
 * EventDispatcher\Event -> parameters
 * Form\FieldGroup -> Field
 * HttpFoundation\HeaderBag -> headers
 * HttpFoundation\ParameterBag -> parameters
 * HttpFoundation\Session -> attributes
 * HttpKernel\Profiler\Profiler -> DataCollectorInterface
 * Routing\RouteCollection -> Route
 * Security\Authentication\AuthenticationProviderManager -> AuthenticationProviderInterface
 * Templating\Engine -> HelperInterface
 * Translation\MessageCatalogue -> messages

The usage of these methods are only allowed when it is clear that there is a
main relation:

 * a CookieJar has many Cookies;

 * a Container has many services and many parameters (as services is the main
   relation, we use the naming convention for this relation);

 * a Console Input has many arguments and many options. There is no "main"
   relation, and so the naming convention does not apply.

For many relations where the convention does not apply, the following methods
must be used instead (where XXX is the name of the related thing):

 * get()      -> getXXX()
 * set()      -> setXXX()
 * all()      -> getXXXs()
 * replace()  -> setXXXs()
 * remove()   -> removeXXX()
 * clear()    -> clearXXX()
 * isEmpty()  -> isEmptyXXX()
 * add()      -> addXXX()
 * register() -> registerXXX()
 * count()    -> countXXX()
 * keys()
2010-11-25 17:30:06 +01:00
Fabien Potencier
7f8c540a20 [Routing] fixed XML loader on Windows (there is no need to urlencode here as schemaValidate() takes a filename, not a URL) 2010-10-28 09:17:11 +02:00
Ryan Weaver
84a60d74d1 Allowing a routes node to be specified without any child import or route nodes.
This is not really a bug or a big issue, but if you need to temporarily empty a routes node, Symfony shouldn't care - it's not an actual validation failure (a routes node still makes sense without an route or import children).
2010-10-22 13:21:55 +02:00
Ryan Weaver
cc4f2bd955 Adding a type-hint to XmlFileLoader::validate(). 2010-10-22 08:22:08 +02:00
Fabien Potencier
92c56a5066 Revert "[Routing] allowed multiple routing requirement with xml loader, using comma separated values"
This reverts commit e8bcbcba57.
2010-10-21 08:13:10 +02:00
ornicar
e8bcbcba57 [Routing] allowed multiple routing requirement with xml loader, using comma separated values 2010-10-20 14:32:36 +02:00
Kris Wallsmith
f79e23ffb5 Removed all those spaces after @author that were bothering me so… 2010-10-18 16:55:41 +02:00
Ryan Weaver
c39635680f added PHPDoc 2010-10-13 07:29:41 +02:00
Ryan Weaver
8c70a2ee24 Adding basic PHPDoc to the Routing\DelegatingLoader class. 2010-10-12 06:58:51 +02:00
Fabien Potencier
c39534e258 [Routing] removed the autoloading trick, which is not needed anymore 2010-09-07 16:15:13 +02:00
Fabien Potencier
b753ea45b2 [Routing] added 'defaults' support in Annotation class loader 2010-09-07 13:55:45 +02:00
Fabien Potencier
130494066d [Routing] added an annotation loader 2010-09-07 09:44:08 +02:00
Fabien Potencier
bf82cf42dd renamed Symfony\Components to Symfony\Component 2010-08-20 23:09:55 +02:00