Commit Graph

2470 Commits

Author SHA1 Message Date
Fabien Potencier
7cb42d2a68 Revert "[TwigBundle] fixed error messages when an error occurs during template compilation"
This reverts commit c68b326665.
2011-02-06 21:05:37 +01:00
Jeremy Mikola
099b9dee1f [FrameworkBundle] Integrate Configuration\Builder class for config merging and normalization
This fixes some BC problems introduced in f9138d313b. Some top-level can now be simply enabled by providing true/null in PHP/YAML. Additionally, the Configuration\Builder allows options to be unset by providing "false" (helpful for overriding activation in a previous config file). All options supporting these behaviors can be found in the Configuration.php file (look for canBeUnset() and treatNull/TrueLike()).

Major changes:

 * Removed "enabled" option for profiler config. Profiler is now enabled if its config is true, null or a map.
 * Restore original config structure for validation namespaces. In PHP/YAML, namespaces are defined under annotations as an alternative to false (disabled) and true/null (enabled). For XML, annotation remains a boolean attribute for validation and a one or more optional namespace tags may appear within <app:validation />. During config normalization, namespace tags under validation will be moved to annotations to conform to the PHP/YAML structure (this occurs transparently to the user).
 * Restore behavior for router/templating config sections being optional (as shown in changes to session/validation test fixtures). If either top-level section is unset in the configuration, neither feature will be enabled and the user will no longer receive exceptions due to missing a resource option (router) or engines (templating). Resource/engines will still be properly required if the respective feature is enabled.
 * Remove unused router type option from XML config XSD. Type is only relevant for import statements, so this option is likely useless.

Additional small changes:

 * Added isset()'s, since config options may be unset
 * Wrap registerXxxConfiguration() calls in isset() checks
 * Load translation.xml in configLoad(), since it's always required
 * Default cache_warmer value (!kernel.debug) is determined via Configuration class

Things to be fixed:

 * Configuration\Builder doesn't seem to respect isRequired() and requiresAtLeastOneElement() (or I haven't set it properly); this should replace the need for FrameworkExtension to throw exceptions for bad router/templating configs
 * The config nodes for session options don't have the "pdo." prefix, as dots are not allowed in node names. To preserve BC for now, the "pdo." prefix is still allowed (and mandated by XSD) in configuration files. In the future, we may just want to do away with the "pdo." prefix.
 * Translator has an "enabled" option. If there's no use case for setting "fallback" independently (when "enabled" is false), perhaps "enabled" should be removed entirely and translator should function like profiler currently does.
 * Profiler matcher merging might need to be adjusted so multiple configs simply overwrite matcher instead of merging its array keys.
2011-02-06 20:50:12 +01:00
Johannes M. Schmitt
2b256a0804 [DependencyInjection] allow null for scalar nodes 2011-02-06 20:50:03 +01:00
Fabien Potencier
cdff8b2bf8 [FrameworkBundle] fixed error message for template as an array 2011-02-06 20:22:57 +01:00
Johannes Schmitt
2316c90ec2 [Security] fixes a regression 2011-02-06 20:11:08 +01:00
Johannes M. Schmitt
c7ef8d98d6 [DependencyInjection] append new elements for prototype nodes without a key attribute 2011-02-06 20:11:08 +01:00
Johannes Schmitt
0b8fef2347 [Security/DependencyInjection] adds support for merging security configurations
The merging is done in three steps:

    1. Normalization:
    =================
    All passed config arrays will be transformed into the same structure
    regardless of what format they come from.

    2. Merging:
    ===========
    This is the step when the actual merging is performed. Starting at the root
    the configs will be passed along the tree until a node has no children, or
    the merging of sub-paths of the current node has been specifically disabled.

       Left-Side       Right-Side      Merge Result
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       -nothing-       array           Right-Side will be taken.
       scalar          scalar          Right-Side will be taken.
       array           false           Right-Side will be taken if ->canBeUnset()
                                       was called on the array node.
       false           array           Right-Side will be taken.
       array           array           Each value in the array will be passed to
                                       the specific child node, or the prototype
                                       node (whatever is present).

    3. Finalization:
    ================
    The normalized, and merged config will be passed through the config tree to
    perform final validation on the submitted values, and set default values
    where this has been requested.

You can influence this process in various ways, here is a list with some examples.
All of these methods must be called on the node on which they should be applied.

  * isRequired(): Node must be present in at least one config file.
  * requiresAtLeastOneElement(): PrototypeNode must have at least one element.
  * treatNullLike($value): Replaces null with $value during normalization.
  * treatTrueLike($value): Same as above just for true
  * treatFalseLike($value): Same as above just for false
  * defaultValue($value): Sets a default value for this node (only for scalars)
  * addDefaultsIfNotSet(): Whether to add default values of an array which has not
                           been defined in any configuration file.
  * disallowNewKeysInSubsequentConfigs(): All keys for this array must be defined
                                          in one configuration file, subsequent
                                          configurations may only overwrite these.
  * fixXmlConfig($key, $plural = null): Transforms XML config into same structure
                                        as YAML, and PHP configurations.
  * useAttributeAsKey($name): Defines which XML attribute to use as array key.
  * cannotBeOverwritten(): Declares a certain sub-path as non-overwritable. All
                           configuration for this path must be defined in the same
                           configuration file.
  * cannotBeEmpty(): If value is set, it must be non-empty.
  * canBeUnset(): If array values should be unset if false is specified.

Architecture:
=============
The configuration consists basically out of two different sets of classes.

  1. Builder classes: These classes provide the fluent interface and
                      are used to construct the config tree.

  2. Node classes: These classes contain the actual logic for normalization,
                   merging, and finalizing configurations.

After you have added all the metadata to your builders, the call to
->buildTree() will convert this metadata to actual node classes. Most of the
time, you will not have to interact with the config nodes directly, but will
delegate this to the Processor class which will call the respective methods
on the config node classes.
2011-02-06 20:11:08 +01:00
ornicar
c5fb96b86b [HttpKernel] Add more unit tests for Kernel 2011-02-06 20:05:49 +01:00
Bernhard Schussek
74d0ac82f7 [Form] Cleaned up ValueTransformerInterface
This commit removes CollectionToStringTransformer. Transformers should never change the state of the outside world, otherwise hard-to-track bugs might creap in.

This functionality needs to be implemented as a custom FieldType (see EntityChoiceField).
2011-02-06 19:46:29 +01:00
Bernhard Schussek
bd3e6c6b49 [Form] Fixed: Form::bind() throws an exception if form is anonymous 2011-02-06 19:46:28 +01:00
Bernhard Schussek
6ff4120784 [Form] Added Form option "by_reference" so that objects received from parent forms are modified by reference when this option is true (the default)
The implication is that set<Reference>() in the object of the parent form will not be called (and thus not has to be implemented/public).

If you want to suppress this behaviour, manually set "by_reference" to false.
2011-02-06 19:46:28 +01:00
Javier Eguíluz
42a3e404b2 translated validators resources into Spanish 2011-02-06 19:40:21 +01:00
hidenorigoto
39ed62de46 translated validators resources into Japanese 2011-02-06 17:11:14 +01:00
José Nahuel Cuesta Luengo
f08c9480ee [CssSelector] Fixed PHPDoc blocks. 2011-02-06 16:18:25 +01:00
ornicar
9ba2943aff [HttpKernel] Add unit tests for Kernel. Also slightly modify Kernel to make it more testable. 2011-02-06 16:17:35 +01:00
John Kary
c251a36935 [HttpFoundation] Add tests for Cookie 2011-02-06 16:16:05 +01:00
Kris Wallsmith
4f6256b713 [FrameworkBundle] fixed invalid template filename 2011-02-06 16:14:37 +01:00
ornicar
bd97471954 [HttpKernel] Add test coverage for cache warming 2011-02-05 23:54:09 +01:00
José Nahuel Cuesta Luengo
562ebd5608 [CssSelector] Added PHPDoc blocks to first-level classes. 2011-02-05 23:28:22 +01:00
pborreli
f56a6efbf5 [HttpFoundation] File/File full coverage 2011-02-05 23:24:00 +01:00
Fabien Potencier
e5403490e7 removed the need to define getNamespace() and getPath() in bundles 2011-02-05 22:40:30 +01:00
Fabien Potencier
523e652d9d [FrameworkBundle] fixed the way profiler configuration works 2011-02-05 22:19:14 +01:00
Fabien Potencier
bfe701a2da fixed code coverage 2011-02-05 21:36:20 +01:00
ornicar
80b03f92b3 [HttpKernel] Throw exception when SQLite statement execution failed
This fixes SQLiteProfilerStorageTest, that was failing using PDO.
2011-02-05 20:44:51 +01:00
Jeremy Mikola
743f25a287 [DependencyInjection] Create explicit factoryClass property for Definitions
Previously, the Definition class was used both for type inference and factory construction (if factoryService was absent). This is fine for cases where classes create instances of themselves (e.g. getInstance() or create()), but leads to ambiguity when we have a separate factory class.
2011-02-05 20:39:42 +01:00
ornicar
575b75a9df [DependencyInjection] Fix fixture class loaded twice during dumper tests 2011-02-05 20:27:47 +01:00
Jeremy Mikola
f9138d313b [FrameworkBundle] Implemented single-pass config loading with intelligent option merging for FrameworkExtension
Restructured config format to make processing more straightforward. Important changes that might break existing configs:

 * Added "enabled" option for translator (improves multi-format compat)
 * Removed hash variation of validation annotations option (only boolean)
 * Moved namespace option directly under validation (improves multi-format compat)

The new merge process depends on an internal array of all supported options and their default values, which is used for both validating the config schema and inferring how to merge options (as an added benefit, it helps make the extension self-documenting). Exceptions will now be thrown for merge errors resulting from unrecognized options or invalid types. Since incoming configurations are all merged atop the defaults, many isset() checks were removed. As a rule of thumb, we probably only want to ignore null values when an option would be used to set a parameter.

Also:

 * Added missing attributes to symfony-1.0.xsd
   * profiler: added only-exceptions attribute
   * session: fix types and add pdo attributes
 * Create FrameworkExtension tests with PHP/XML/YAML fixtures
 * Use "%" syntax instead of calling getParameter() within FrameworkExtension
 * Normalize config keys and arrays with helper methods for PHP/XML/YAML compatibility

Earlier changes:

 * Remove nonexistent "DependencyInjection/Resources/" path from XmlFileLoaders
 * Remove hasDefinition() checks, as register methods should only execute once
 * Remove first-run logic from registerTranslatorConfiguration(), as it is only run once
 * Removed apparently obsolete clearTags() calls on definitions for non-enabled features
2011-02-05 20:01:15 +01:00
Fabien Potencier
199e6bf893 [BrowserKit] removed annotation in a unit test to fix coverage 2011-02-05 16:02:59 +01:00
Fabien Potencier
2ae542748a [TwigBundle] made error message more explicit 2011-02-05 01:17:59 +01:00
Fabien Potencier
e2ea634df4 [TwigBundle] fixed inheritance problem 2011-02-04 22:14:25 +01:00
Fabien Potencier
67c9fdf412 [TwigBundle] fixed theme for forms 2011-02-04 21:19:38 +01:00
Fabien Potencier
7f6fc6f0fb [TwigBundle] fixed form template inheritance 2011-02-04 20:41:31 +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
195c971da6 removed load() from EngineInterface 2011-02-04 19:28:14 +01:00
Martijn Evers
1e3dc1479c [Testing][HttpKernel] Added possibility to functional test raw body data 2011-02-04 13:07:13 +01:00
Fabien Potencier
710a1e56b0 [TwigBundle] added support for template as Twig_Template instances 2011-02-04 13:04:02 +01:00
Fabien Potencier
c68b326665 [TwigBundle] fixed error messages when an error occurs during template compilation 2011-02-04 12:54:53 +01:00
Fabien Potencier
2dfac2a881 fixed typo 2011-02-04 12:20:47 +01:00
Fabien Potencier
f455700b88 fixed previous commit 2011-02-04 12:18:26 +01:00
Victor Berchet
3ed47114d6 [Bundle] Make getPath() less error prone by allowing both backward and forward slashes 2011-02-04 12:12:19 +01:00
Victor Berchet
2a97f89897 [Bundle] Small optimization 2011-02-04 12:10:16 +01:00
Victor Berchet
84bbb945d7 [UniversalClassLoader] Small optimization 2011-02-04 12:10:16 +01:00
marc.weistroff
1316fb547e Reverted e557500c97 and edf57fc392 which deleted the getRequest() method in HttpCache as this methods is needed in the Esi class. 2011-02-04 11:37:09 +01:00
Bernhard Schussek
2276b98fc1 [Form] Fixed: ChoiceFields never validated 2011-02-04 11:30:49 +01:00
Fabien Potencier
6ed7dc1e5a made a small optimization 2011-02-04 05:45:07 +01:00
Kris Wallsmith
ea536b0d9e [FrameworkBundle] added cache warmer priority 2011-02-04 00:59:44 +01:00
Fabien Potencier
6b7e4ad2f9 [TwigBundle] fixed typo 2011-02-04 00:54:09 +01:00
Justin Hileman
5516ac21a2 Fix Doctrine Migrations commands to work with new bundles. 2011-02-04 00:37:02 +01:00
Lukas Kahwe Smith
661d5d236c fixed method call, cosmetic variable rename 2011-02-04 00:32:15 +01:00