Commit Graph

50 Commits

Author SHA1 Message Date
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
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
Johannes M. Schmitt
1d5b6ed908 adds scope to the DI container 2011-01-22 15:20:50 +01:00
Johannes M. Schmitt
84fa4b50db adds setArgument to Definition 2011-01-19 21:48:56 +01:00
Kris Wallsmith
8d6da86016 [DependencyInjection] moved loading stack from static to object scope 2011-01-19 07:28:42 +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
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
Martin Hason
6011073e7c [DependencyInjection] fixed XmlDumper (corrected validity) 2011-01-14 18:16:11 +01:00
Martin Hason
5ee48c4963 [DependencyInjection] fix XML entities in XmlDumper 2011-01-14 16:56:44 +01:00
Martin Hason
2a3d94a6d0 [DependencyInjection] added support for anonymous services in XmlDumper 2011-01-14 08:25:18 +01:00
Victor Berchet
1537c1f2d1 [InterfaceInjector] Fix a typo in the tests 2011-01-11 20:29:17 +01:00
Johannes Schmitt
f1e41a9671 [DependencyInjection] made some improvments to the container compiler
- inline private services which are references multiple times, but where all references originate from the same definition
- bug fix for non-shared services which were considered shared within the scope in which they were inlined
2011-01-09 19:58:51 +01:00
Johannes Schmitt
d1a2a65d19 [DependencyInjection] performance improvement, better analysis tools 2011-01-09 19:58:42 +01:00
Johannes Schmitt
e85546ef7d [DependencyInjection] made some improvments to the container compiler
- added generic repeated pass
- better optimization of services
- started adding some integration tests
2011-01-09 19:58:39 +01:00
Martin Hason
a11619973b [DependencyInjection] fix xml validation for extension in phar archive 2011-01-07 16:00:28 +01:00
Johannes Schmitt
3785a99b94 adds visibility to aliases 2011-01-07 15:58:48 +01:00
Jeremy Mikola
554c86c589 [DependencyInjection] Add hasInterfaceInjectorForClass(), which is helpful for extension loader methods
Additionally, doc blocks were added for the Container's InterfaceInjector methods, and the test case was modified to cover both add() methods
2011-01-07 14:33:06 +01:00
Johannes M. Schmitt
c5ef113b18 DI container optimization 2011-01-05 15:41:11 +01:00
Fabien Potencier
eb4788e98e [DependencyInjection] made service keys and aliases case insensitive (as method names are case insensitive in PHP) 2011-01-03 09:07:06 +01:00
Igor Wiedler
1577110c35 fix PHPUnit assertType deprecation warnings
PHPUnit 3.5.6 deprecates assertType in favor of assertInternalType and
assertInstanceOf. It will be completely removed in 3.6.
2011-01-03 07:44:30 +01:00
Johannes Schmitt
db5e180d37 tweaked DI container 2010-12-30 15:59:52 +01:00
Fabien Potencier
9f5253e460 fixed typo 2010-12-14 07:49:55 +01:00
Bulat Shakirzyanov
ff9e9ac315 [DependencyInjection] fixed a typo in PhpDumper 2010-12-13 18:55:37 +01:00
Jordi Boggiano
ac7e0bc35f [DependencyInjection] Fixes a loading order issue
ab7ad4808b introduced a regression when using a parameter in an extension config that is defined in the same file, the ParameterBag can not resolve it
2010-12-13 07:52:09 +01:00
Johannes Schmitt
763bba9b89 bug fix 2010-12-12 10:27:15 +01:00
Fabien Potencier
7c653305a3 [DependencyInjection] fixed typo 2010-12-08 14:33:58 +01:00
Kris Wallsmith
3e02eafc70 Fixed visibility of PHPUnit setUp and tearDown methods. 2010-12-06 15:52:23 +01:00
Bulat Shakirzyanov
73331cf1c1 [DependencyInjection] Interface Injection implementation 2010-11-30 20:36:56 +01:00
pablodip
314d3d06ae [DependencyInjection] format the tags in the findTaggedServiceIds method of the PhpDumper 2010-11-30 07:56:51 +01:00
Bulat Shakirzyanov
d171df0c3b [DependencyInjection] fixed tests to catch exception classes instead of asserting them 2010-11-26 22:39:51 +01:00
Fabien Potencier
341178e869 [DependencyInjection] made some cosmetic changes to the PHP dumper output 2010-11-24 15:55:25 +01:00
Fabien Potencier
60bbb8f380 [DependencyInjection] optimized compiled containers
* removed the __call() method in Container: it means that now, there is only
   one way to get a service: via the get() method;

 * removed the $shared variable in the dumped Container classes (we now use
   the $services variable from the parent class directly -- this is where we
   have a performance improvement);

 * optimized the PHP Dumper output.
2010-11-23 22:43:09 +01:00
Bulat Shakirzyanov
21f088d86a [DependencyInjection] replaced assertEquals(spl_object_hash()) with assertSame 2010-11-21 15:26:25 +01:00
Fabien Potencier
f6cc63c99c removed ArrayAccess interface for Container and Controller 2010-11-15 10:05:28 +01:00
Fabien Potencier
53dd4e39c7 [DependencyInjection] changed the YAML notation for optional services from @@ to @? 2010-11-15 10:00:59 +01:00
Fabien Potencier
efed6005cb [DependencyInjection] fixed PHP dumper
In the dumped PHP class, we must use get() and not get*Service() methods to get services.
That's because all calls must be managed by get(). From the outside, you can call
get*Service() because as they are protected, they are caught by the __call() method;
which is not the case obviously when it is used internally.

If not, if you override a service with set(), this won't work when a service
depends on this one (the default one will still be used).
2010-11-12 17:38:32 +01:00
Jeremy Mikola
0aba8ef720 [DependencyInjection] XmlFileLoader should allow "factory-service" attribute without "class" for <service> 2010-10-19 21:10:07 +02:00
Fabien Pennequin
c543692891 [DependencyInjection] Added tests for ContainerBuilder class 2010-10-18 16:51:04 +02:00
Fabien Pennequin
7225cf64b1 [DependencyInjection] Added tests for methods hasMethodCall and removeMethodCall of Definition class 2010-10-18 16:51:00 +02:00
Artur Kotyrba
308e85a5a7 Removed methods which implemented interfaces by throwing \LogicException('You must override...'). 2010-10-17 07:54:18 +02:00
Kris Wallsmith
ef4f61bb9f [DependencyInjection] Added TaggedContainerInterface to signature of generated container classes 2010-10-16 08:32:07 +02:00
Fabien Potencier
a432417ab9 [DependencyInjection] added a way to ignore errors when importing a non-existent file (useful when you want to include an optional service file) 2010-08-24 16:37:41 +02:00
Fabien Potencier
b1e79963b1 [DependencyInjection] moved extension loading in the freezing process (opens more possibilities in the loading order of configs) 2010-08-24 16:25:08 +02:00
Fabien Potencier
bf82cf42dd renamed Symfony\Components to Symfony\Component 2010-08-20 23:09:55 +02:00