Commit Graph

96 Commits

Author SHA1 Message Date
Ray
e83629139c Added matching test to mirror the xml file loader test 2011-03-16 08:56:26 -05:00
Ray
c2908cdaa0 Allow collection's internal keys to be mixed case 2011-03-15 09:35:40 -05:00
Johannes M. Schmitt
98216a9af2 [DependencyInjection] refactored some more exceptions 2011-03-14 21:14:49 +01:00
Fabien Potencier
a1fcbf4d5f Merge remote branch 'kriswallsmith/dic/false-circular-ref-fix'
* kriswallsmith/dic/false-circular-ref-fix:
  [DependencyInjection] fixed false positive when detecting circular references if a service throws an exception during creation
2011-03-11 19:58:54 +01:00
Fabien Potencier
cedf588e98 Revert "Merge remote branch 'kriswallsmith/dic/lazy-replace-ext-params'"
This reverts commit 32ac2e8709, reversing
changes made to 6e81c28ca4.
2011-03-11 15:35:09 +01:00
Fabien Potencier
f321fadad6 [DependencyInjection] moved most protected things to private 2011-03-11 14:50:46 +01:00
Fabien Potencier
a8d05746ff Merge remote branch 'schmittjoh/propertyAnnotations'
* schmittjoh/propertyAnnotations:
  [DependencyInjection] added some tests
  [DependencyInjection] adds property injection
2011-03-11 13:12:12 +01:00
Fabien Potencier
32ac2e8709 Merge remote branch 'kriswallsmith/dic/lazy-replace-ext-params'
* kriswallsmith/dic/lazy-replace-ext-params:
  [DependencyInjection] added test for lazy param replacement
  Removed replacement of parameter placeholders at load time since they're now replaced at compile time. Extensions should be written to expect parameter placeholders.
2011-03-11 10:41:22 +01:00
Amal Raghav
2d1ef129b2 Updated tests for ResolveDefinitionTemplatesPass 2011-03-11 10:36:48 +01:00
Kris Wallsmith
6385431a2d [DependencyInjection] added test for lazy param replacement 2011-03-10 13:24:14 -08:00
Johannes M. Schmitt
d9848f38ac [DependencyInjection] added some tests 2011-03-10 15:31:00 +01:00
Kris Wallsmith
8c45a21637 [DependencyInjection] fixed false positive when detecting circular references if a service throws an exception during creation 2011-03-09 06:38:02 -08:00
Fabien Potencier
8716c2ad1e merged 2011-03-08 15:43:02 +01:00
Fabien Potencier
8c423edfef replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00
Fabien Potencier
44d069a3fb Merge remote branch 'kriswallsmith/dic/auto-ext-load'
* kriswallsmith/dic/auto-ext-load:
  [HttpKernel] added an subclass merge extension configuration compiler pass to ensure each bundle's "main" extension is loaded
  [DependencyInjection] extensions should only load if called during configuration
2011-03-05 12:18:18 +01:00
Fabien Potencier
4a8f10192f [DependencyInjection] fixed unit tests when using phar and suhosin 2011-03-05 11:43:11 +01:00
Kris Wallsmith
bf0553c23a [DependencyInjection] extensions should only load if called during configuration 2011-03-03 13:53:29 +01:00
Fabien Potencier
fd53035c8d Merge remote branch 'schmittjoh/inlinePassFix'
* schmittjoh/inlinePassFix:
  [DependencyInjection/Compiler] fixes a bug which silently changed the scope of services
2011-03-01 20:38:48 +01:00
Pascal Borreli
3a47fa6eed [Tests] Fixed Typo 2011-03-01 18:58:08 +01:00
Johannes M. Schmitt
67c886f3df [DependencyInjection/Compiler] fixes a bug which silently changed the scope of services 2011-03-01 13:47:34 +01:00
Martin Hason
3d94c6c4bd [DependencyInjection] added phar creator in test 2011-02-28 09:58:37 +01:00
Martin Hason
c75622cb4b [DependencyInjection] removed unused class Extension, fix tests 2011-02-28 09:57:18 +01:00
Martin Hason
d231a8a8d5 [Config] [DependencyInjection] removed DependencyInjection dependency in Config, fix tests 2011-02-28 09:19:13 +01:00
Fabien Potencier
2b4b3f83a5 fixed previous commit 2011-02-27 21:14:03 +01:00
Lukas Kahwe Smith
4b3c49550f issues found by static code analysis 2011-02-27 19:34:02 +01:00
yclian
092403909e [DependencyInjection] Test for Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass. 2011-02-20 20:23:40 +08:00
yclian
3275820a6f [DependencyInjection] Add Symfony\Tests\Component\DependencyInjection\ContainerBuilderTest::testAddGetCompilerPass(). 2011-02-20 20:23:32 +08:00
Yuen-Chi Lian
a0e00ff159 [DependencyInjection] Aesthetic changes on ContainerTest, consequence of not using a formatter. 2011-02-19 19:50:57 +01:00
Yuen-Chi Lian
c42f38523f [DependencyInjection] Test coverage improvements and corrections on Container. 2011-02-19 19:49:26 +01:00
Fabien Potencier
6b12c21261 moved DependencyInjection\Configuration to Config\Definition 2011-02-17 16:03:48 +01:00
Ryan Weaver
c5e4dfb5a6 [DependencyInjection] Adding to InvalidArgumentException messages to clarify when a service is given an invalid "tags" value. 2011-02-17 15:59:39 +01:00
Fabien Potencier
a29a413c48 made DIC extensions members of the Container instead of static members 2011-02-15 22:22:32 +01:00
Fabien Potencier
62e3053769 refactored previous commit, fixed tests
How to upgrade?

For XML configuration files:

 * All extensions should now use the config tag (this is just a convention as
   the YAML configurations files do not use it anymore):

 * The previous change means that the doctrine and security bundles now are
   wrapped under a main "config" tag:

        <doctrine:config>
            <doctrine:orm />
            <doctrine:dbal />
        </doctrine:config>

        <security:config>
            <security:acl />
            ...
        </security:config>

For YAML configuration files:

 * The main keys have been renamed as follows:

        * assetic:config -> assetic
        * app:config -> framework
        * webprofiler:config -> web_profiler
        * doctrine_odm.mongodb -> doctrine_mongo_db
        * doctrine:orm -> doctrine: { orm: ... }
        * doctrine:dbal -> doctrine: { dbal: ... }
        * security:config -> security
        * security:acl -> security: { acl: ... }
        * twig.config -> twig
        * zend.config -> zend
2011-02-15 22:22:28 +01:00
Fabien Potencier
5c905beb13 moved common configuration classes to a new Config component 2011-02-13 22:31:50 +01:00
Johannes M. Schmitt
d4d2d60f7b [DependencyInjection] minor interface change 2011-02-13 10:38:10 +01:00
Christophe Coevoet
cb0fa406aa Added unit tests 2011-02-12 21:56:22 +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
e58a84eb09 added a FileLocator to DIC so that we can load resources like @BundleName/Resources/... 2011-02-10 00:44:02 +01:00
Johannes M. Schmitt
2b256a0804 [DependencyInjection] allow null for scalar nodes 2011-02-06 20:50:03 +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
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
Fabien Potencier
b6f400a2bc [DependencyInjection] made an optimization on dumped DIC
When dumping a Container, and if it is frozen, we use a plain
PHP array for parameters instead of a ParameterBag.
2011-02-04 00:17:51 +01:00
Johannes Schmitt
b484763a7a [DependencyInjection] added first version of the config normalizer
This is mainly intended for complex configurations to ease the work you
have with normalizing different configuration formats (YAML, XML, and PHP).

First, you have to set-up a config tree:

    $treeBuilder = new TreeBuilder();
    $tree = $treeBuilder
        ->root('security_config', 'array')
            ->node('access_denied_url', 'scalar')->end()
            ->normalize('encoder')
            ->node('encoders', 'array')
                ->key('class')
                ->prototype('array')
                    ->before()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
                    ->node('algorithm', 'scalar')->end()
                    ->node('encode_as_base64', 'scalar')->end()
                    ->node('iterations', 'scalar')->end()
                ->end()
            ->end()
        ->end()
        ->buildTree()
    ;

This tree and the metadata attached to the different nodes is then used
to intelligently transform the passed config array:

    $normalizedConfig = $tree->normalize($config);
2011-02-01 16:07:04 +01:00
Johannes Schmitt
803dd58002 add definition inheritance support 2011-01-28 09:12:29 +01:00
Johannes Schmitt
40dec8831f adds helper method to normalize keys 2011-01-25 15:59:51 +01:00
Johannes Schmitt
f29a5f74a1 made the DI config validation more strict to catch errors early 2011-01-24 21:15:48 +01:00