github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

symfony / symfony

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 899
    • 116
  • Source
  • Commits
  • Network (116)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Graph
  • Members
  • Pull Requests

jwage wants someone to pull 22 commits into symfony:master from jwage:f5e2254

  • Discussion
  • Commits 22
  • Files Changed 34
  • Reply

Showing 0 comments with 22 commits and 0 commit comments

Same change for mapping files

jwage — Fri Sep 03 12:12:18 -0700 2010

Closed

No description given.

blt04 and others added some commits

Thu Aug 12 08:25:53 -0700 2010

26e4b2e blt04 [Finder] Fixed randomly failing tests due to the order files a...
179fe8e Sébastien HOUZE Symfony\Component\Routing\Route::setRequirements() _method req...
2ccaafa avalanche123 [DpependencyInjection] added hasParameter()
e71eec3 kriswallsmith [DoctrineMongoDBBundle] removed some mostly unnecessary calls ...
4f33761 fabpot [HttpFoundation] added request matcher
3c695fd jwage [DoctrineMongoDBBundle] updated log format to look more like t...
2914c44 jwage Replacing "Entities" with "Entity"
9e4aebf fabpot [DoctrineBundle] removed README
7c1b42e fabpot [DependencyInjection] added a way to inject an anonymous servi...
af96c87 fabpot [DependencyInjection] added methods to remove an alias and a d...
0b378d1 fabpot added a way to conditionnaly enable the profiler based on the ...
1719bfb Seldaek [DomCrawler] Fixed URIs being incorrectly generated
a6da0fb Seldaek [DomCrawler] Added tests to verify previous fix
20ca97c Seldaek [DomCrawler] Fixing trailing space
2ab5979 Seldaek [DomCrawler] Fixing typo
c1d0262 jwage Fixing issue with FieldGroup and its __clone() method not prop...
436ca95 jwage Fixing coding standards.
f5e2254 ornicar [DoctrineMongoDBBundle] BC break - Load metadata files in Reso...
b16303e ornicar [DoctrineBundle] BC break - Load fixtures in Resources/data/fi...
81b73dc fabpot [Form] fixed problem with PHPUnit mocks (ugly hack but it work...
4c17ce8 fabpot changed calls to has() to use the new proxy method
7be00aa fabpot fixed previous commit

Comment on this pull request

You must be logged in to comment on pull requests.

Active Participants

  • jwage

Showing 22 unique commits by 8 authors.

2914c443 jwage Replacing "Entities" with "Entity" Wed Sep 01 11:23:46 -0700 2010
e71eec3f kriswallsmith [DoctrineMongoDBBundle] removed some mostly unnecessary calls to ... Tue Aug 31 22:43:12 -0700 2010
9e4aebf3 fabpot [DoctrineBundle] removed README Wed Sep 01 11:31:08 -0700 2010
7c1b42e8 fabpot [DependencyInjection] added a way to inject an anonymous service ... Thu Sep 02 03:16:20 -0700 2010
af96c871 fabpot [DependencyInjection] added methods to remove an alias and a defi... Thu Sep 02 03:20:20 -0700 2010
4f337615 fabpot [HttpFoundation] added request matcher Wed Sep 01 04:56:06 -0700 2010
0b378d1b fabpot added a way to conditionnaly enable the profiler based on the req... Thu Sep 02 04:54:32 -0700 2010
c1d0262c jwage Fixing issue with FieldGroup and its __clone() method not properl... Thu Sep 02 11:51:07 -0700 2010
436ca95f jwage Fixing coding standards. Thu Sep 02 12:22:00 -0700 2010
2ab59791 Seldaek [DomCrawler] Fixing typo Thu Sep 02 11:49:00 -0700 2010
20ca97c5 Seldaek [DomCrawler] Fixing trailing space Thu Sep 02 11:48:11 -0700 2010
a6da0fb0 Seldaek [DomCrawler] Added tests to verify previous fix Thu Sep 02 11:47:15 -0700 2010
1719bfb8 Seldaek [DomCrawler] Fixed URIs being incorrectly generated Thu Sep 02 09:56:55 -0700 2010
26e4b2e2 blt04 [Finder] Fixed randomly failing tests due to the order files are ... Thu Aug 12 08:25:53 -0700 2010
81b73dc9 fabpot [Form] fixed problem with PHPUnit mocks (ugly hack but it works f... Fri Sep 03 00:56:52 -0700 2010
2ccaafa5 avalanche123 [DpependencyInjection] added hasParameter() Wed Aug 25 15:30:10 -0700 2010
4c17ce8e fabpot changed calls to has() to use the new proxy method Fri Sep 03 02:38:21 -0700 2010
179fe8e6 Sébastien HOUZE Symfony\Component\Routing\Route::setRequirements() _method requir... Tue Aug 24 04:45:14 -0700 2010
7be00aa3 fabpot fixed previous commit Fri Sep 03 07:18:04 -0700 2010
b16303e8 ornicar [DoctrineBundle] BC break - Load fixtures in Resources/data/fixtu... Thu Sep 02 21:32:08 -0700 2010
3c695fdc jwage [DoctrineMongoDBBundle] updated log format to look more like the ... Wed Sep 01 11:19:10 -0700 2010
f5e22544 ornicar [DoctrineMongoDBBundle] BC break - Load metadata files in Resourc... Thu Sep 02 21:20:45 -0700 2010

Showing 34 changed files with 439 additions and 295 deletions.

M src/Symfony/Bundle/DoctrineBundle/Command/ConvertDoctrine1SchemaDoctrineCommand.php 4 ••••
M src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php 2 ••
M src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php 6 ••••
M src/Symfony/Bundle/DoctrineBundle/Command/ImportMappingDoctrineCommand.php 4 ••••
M src/Symfony/Bundle/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php 4 ••••
D src/Symfony/Bundle/DoctrineBundle/README 223 •••••
M src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php 6 ••••
M src/Symfony/Bundle/DoctrineMongoDBBundle/Logger/DoctrineMongoDBLogger.php 12 ••••
M src/Symfony/Bundle/FrameworkBundle/DependencyInjection/WebExtension.php 64 ••••
M src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml 1 •
M src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd 15 ••••
M src/Symfony/Bundle/PropelBundle/DependencyInjection/PropelExtension.php 2 ••
M src/Symfony/Component/DependencyInjection/Container.php 12 •••••
M src/Symfony/Component/DependencyInjection/ContainerBuilder.php 20 •••••
M src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php 4 ••••
M src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php 2 ••
M src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php 41 ••••
M src/Symfony/Component/DomCrawler/Crawler.php 4 ••••
M src/Symfony/Component/DomCrawler/Form.php 7 ••••
M src/Symfony/Component/DomCrawler/Link.php 7 ••••
M src/Symfony/Component/Form/FieldGroup.php 7 ••••
M src/Symfony/Component/Form/FieldInterface.php 7 •••••
M src/Symfony/Component/HttpFoundation/Request.php 2 ••
A src/Symfony/Component/HttpFoundation/RequestMatcher.php 105 •••••
A src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php 29 •••••
M src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php 2 ••
M src/Symfony/Component/HttpKernel/Profiler/ProfilerListener.php 14 ••••
M src/Symfony/Component/Routing/Route.php 14 ••••
M tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php 7 ••••
M tests/Symfony/Tests/Component/DomCrawler/FormTest.php 10 ••••
M tests/Symfony/Tests/Component/DomCrawler/LinkTest.php 10 •••••
M tests/Symfony/Tests/Component/Finder/FinderTest.php 11 ••••
A tests/Symfony/Tests/Component/HttpFoundation/RequestMatcherTest.php 72 •••••
M tests/Symfony/Tests/Component/HttpKernel/Profiler/ProfilerTest.php 4 ••••
Txt src/Symfony/Bundle/DoctrineBundle/Command/ConvertDoctrine1SchemaDoctrineCommand.php
  • View file @ f5e2254
... ...
@@ -73,7 +73,7 @@ EOT
73 73
 
74 74
         $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
75 75
         if ($type === 'annotation') {
76  
-            $destPath .= '/Entities';
  76
+            $destPath .= '/Entity';
77 77
         } else {
78 78
             $destPath .= '/Resources/config/doctrine/metadata';
79 79
         }
... ...
@@ -98,7 +98,7 @@ EOT
98 98
             $output->writeln(sprintf('Converting Doctrine 1 schema "<info>%s</info>"', $input->getArgument('d1-schema')));
99 99
             foreach ($metadata as $class) {
100 100
                 $className = $class->name;
101  
-                $class->name = $namespace.'\\'.$bundleClass.'\\Entities\\'.$className;
  101
+                $class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
102 102
                 if ($type === 'annotation') {
103 103
                     $path = $destPath.'/'.$className.'.php';
104 104
                 } else {
Txt src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php
  • View file @ f5e2254
... ...
@@ -55,7 +55,7 @@ EOT
55 55
     protected function execute(InputInterface $input, OutputInterface $output)
56 56
     {
57 57
         $filterBundle = $input->getOption('bundle') ? str_replace('/', '\\', $input->getOption('bundle')) : false;
58  
-        $filterEntity = $filterBundle ? $filterBundle . '\\Entities\\' . str_replace('/', '\\', $input->getOption('entity')) : false;
  58
+        $filterEntity = $filterBundle ? $filterBundle . '\\Entity\\' . str_replace('/', '\\', $input->getOption('entity')) : false;
59 59
 
60 60
         if (!isset($filterBundle) && isset($filterEntity)) {
61 61
             throw new \InvalidArgumentException(sprintf('Unable to specify an entity without also specifying a bundle.'));
Txt src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php
  • View file @ f5e2254
... ...
@@ -42,7 +42,7 @@ The <info>doctrine:generate:entity</info> task initializes a new Doctrine entity
42 42
 
43 43
   <info>./symfony doctrine:generate:entity "Bundle\MyCustomBundle" "User\Group"</info>
44 44
 
45  
-The above would initialize a new entity in the following entity namespace <info>Bundle\MyCustomBundle\Entities\User\Group</info>.
  45
+The above would initialize a new entity in the following entity namespace <info>Bundle\MyCustomBundle\Entity\User\Group</info>.
46 46
 
47 47
 You can also optionally specify the fields you want to generate in the new entity:
48 48
 
... ...
@@ -71,7 +71,7 @@ EOT
71 71
         }
72 72
 
73 73
         $entity = $input->getArgument('entity');
74  
-        $entityNamespace = $namespace.'\\'.$bundle.'\\Entities';
  74
+        $entityNamespace = $namespace.'\\'.$bundle.'\\Entity';
75 75
         $fullEntityClassName = $entityNamespace.'\\'.$entity;
76 76
         $tmp = str_replace('\\', '/', $fullEntityClassName);
77 77
         $tmp = str_replace('/', '\\', dirname($tmp));
... ...
@@ -108,7 +108,7 @@ EOT
108 108
         $exporter = $cme->getExporter($mappingType);
109 109
 
110 110
         if ($mappingType === 'annotation') {
111  
-            $path = $dirs[$namespace].'/'.$bundle.'/Entities/'.str_replace($entityNamespace.'\\', null, $fullEntityClassName).'.php';
  111
+            $path = $dirs[$namespace].'/'.$bundle.'/Entity/'.str_replace($entityNamespace.'\\', null, $fullEntityClassName).'.php';
112 112
 
113 113
             $exporter->setEntityGenerator($this->getEntityGenerator());
114 114
         } else {
Txt src/Symfony/Bundle/DoctrineBundle/Command/ImportMappingDoctrineCommand.php
  • View file @ f5e2254
... ...
@@ -71,7 +71,7 @@ EOT
71 71
 
72 72
         $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
73 73
         if ($type === 'annotation') {
74  
-            $destPath .= '/Entities';
  74
+            $destPath .= '/Entity';
75 75
         } else {
76 76
             $destPath .= '/Resources/config/doctrine/metadata';
77 77
         }
... ...
@@ -99,7 +99,7 @@ EOT
99 99
             $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
100 100
             foreach ($metadata as $class) {
101 101
                 $className = $class->name;
102  
-                $class->name = $namespace.'\\'.$bundleClass.'\\Entities\\'.$className;
  102
+                $class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
103 103
                 if ($type === 'annotation') {
104 104
                     $path = $destPath.'/'.$className.'.php';
105 105
                 } else {
Txt src/Symfony/Bundle/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
  • View file @ f5e2254
... ...
@@ -69,7 +69,7 @@ EOT
69 69
                 $namespace = str_replace('/', '\\', dirname($tmp));
70 70
                 $class = basename($tmp);
71 71
 
72  
-                if (isset($bundleDirs[$namespace]) && is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/data/fixtures/doctrine')) {
  72
+                if (isset($bundleDirs[$namespace]) && is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/data/fixtures/doctrine/orm')) {
73 73
                     $paths[] = $dir;
74 74
                 }
75 75
             }
... ...
@@ -204,4 +204,4 @@ EOT
204 204
 
205 205
         return $associationTables;
206 206
     }
207  
-}
208 207
\ No newline at end of file
  208
+}
Txt src/Symfony/Bundle/DoctrineBundle/README
  • View file @ f5e2254
... ...
@@ -1,223 +0,0 @@
1  
-DoctrineBundle
2  
---------------
3  
-
4  
-This document describes some of the functionality provided by the 
5  
-**DoctrineBundle**. Doctrine 2 is a first class citizen in Symfony 2 and is 
6  
-tightly integrated. Continue reading to learn how to use Doctrine 2 with the
7  
-latest Symfony 2!
8  
-
9  
-## Configuration
10  
-
11  
-This section will help you with configuring your Symfony 2 project to enable
12  
-the Doctrine DBAL and ORM services.
13  
-
14  
-### Database Abstraction Layer
15  
-
16  
-You can configure your database abstraction layer simply configuration a few 
17  
-pieces of information about your database. If you only have one database you can
18  
-do the following:
19  
-
20  
-    [yml]
21  
-    doctrine.dbal:
22  
-      dbname: symfony_guestbook
23  
-      user: root
24  
-      password: ~
25  
-
26  
-Or if you want to use XML instead of YAMl it would look like this:
27  
-
28  
-    <doctrine:dbal dbname="symfony_guestbook" user="root" password="" />
29  
-
30  
-Or if you have multiple connections and want to customize the configuration of the
31  
-connection further you can use the following:
32  
-
33  
-    [yml]
34  
-    doctrine.dbal:
35  
-      default_connection:       default
36  
-      connections:
37  
-        default:
38  
-          driver:               PDOSqlite     # PDOSqlite, PDOMySql, PDOMsSql, PDOOracle, PDOPgSql, OCI8
39  
-          dbname:               symfony_guestbook
40  
-          user:                 root
41  
-          password:             null
42  
-          host:                 localhost
43  
-          port:                 ~
44  
-          path:                 %kernel.data_dir%/symfony.sqlite
45  
-          event_manager_class:  Doctrine\Common\EventManager
46  
-          configuration_class:  Doctrine\DBAL\Configuration
47  
-          wrapper_class:        ~
48  
-          options:              []
49  
-
50  
-You can also specify multiple connections using the XML format:
51  
-
52  
-    <doctrine:dbal default_connection="default">
53  
-        <doctrine:connection id="default" dbname="symfony_guestbook" user="root" password="" />
54  
-    </doctrine:dbal>
55  
-
56  
-### Object Relational Mapper
57  
-
58  
-If you want to enable the Doctrine 2 ORM you can do so with the following:
59  
-
60  
-    doctrine.orm:
61  
-      default_entity_manager:   default
62  
-      cache_driver:             apc           # array, apc, memcache, xcache
63  
-      entity_managers:
64  
-        default:
65  
-          connection:           default
66  
-
67  
-It's pretty simple, you can specify which entity managers you want to instantiate
68  
-for which connections and also configure some other information about the ORM
69  
-like what type of mapping files to use or what cache driver to use.
70  
-
71  
-## Creating a Bundle
72  
-
73  
-To get started we need to create a new bundle:
74  
-
75  
-    $ php console init:bundle "Bundle\\GuestbookBundle"
76  
-    Initializing bundle "GuestbookBundle" in "/path/to/symfony-sandbox/src/Bundle"
77  
-
78  
-Now basically the most important thing to know about using Doctrine 2 with Symfony
79  
-is where to put your mapping information files, where your entity classes are and 
80  
-a few commands to help move things faster!
81  
-
82  
-## Mapping Information
83  
-
84  
-You can place all your mapping information inside a bundle. Below is an example
85  
-path for the **GuestbookBundle** we created above:
86  
-
87  
-    /path/to/symfony-sandbox/src/Bundle/GuestbookBundle/Resources/config/doctrine/metadata
88  
-
89  
-Any files found in here that have a suffix of **.dcm.xml** (or whatever
90  
-mapping_driver you picked) are used as your entities mapping information.
91  
-
92  
-In the **GuestbookBundle** we have a file named **Bundle.GuestbookBundle.Entities.Entry.dcm.xml**
93  
-which contains the following XML:
94  
-
95  
-    <?xml version="1.0" encoding="UTF-8"?>
96  
-
97  
-    <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
98  
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99  
-          xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
100  
-                              http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
101  
-
102  
-        <entity name="Bundle\GuestbookBundle\Entities\Entry" table="guestbook_entry">
103  
-
104  
-            <id name="id" type="integer" column="id">
105  
-                <generator strategy="AUTO"/>
106  
-            </id>
107  
-
108  
-            <field name="createdAt" column="created_at" type="datetime" />
109  
-            <field name="name" column="name" type="string" length="255" />
110  
-            <field name="emailAddress" column="email_address" type="string" length="255" />
111  
-            <field name="body" column="body" type="text" />
112  
-
113  
-        </entity>
114  
-
115  
-    </doctrine-mapping>
116  
-
117  
-## Generating Entities
118  
-
119  
-Doctrine can help you a little bit by generating the entity classes for your 
120  
-mapping information with the command:
121  
-
122  
-    $ php console doctrine:generate:entities
123  
-
124  
-Now if you have a look in the bundles **Entities** directory you will see a new
125  
-file named **Entry.php** with some code like the following:
126  
-
127  
-    [php]
128  
-    // Bundle/GuestbookBundle/Entities/Entry.php
129  
-
130  
-    namespace Bundle\GuestbookBundle\Entities;
131  
-
132  
-    /**
133  
-     * @Entity
134  
-     * @Table(name="guestbook_entry")
135  
-     */
136  
-    class Entry
137  
-    {
138  
-      /**
139  
-        * @Column(name="created_at", type="datetime")
140  
-        */
141  
-      private $createdAt;
142  
-
143  
-      /**
144  
-        * @Column(name="name", type="string", length=255)
145  
-        */
146  
-      private $name;
147  
-
148  
-    // ...
149  
-
150  
-> **NOTE**
151  
-> If you modify your mapping information and re-run the build entities command
152  
-> it will modify the classes and update them based on the mapping information.
153  
-
154  
-## Commands
155  
-
156  
-The Doctrine 2 CLI is integrated with the Symfony 2 CLI so we have all the common
157  
-commands we need to make working with Doctrine 2 just as easy and fast as before!
158  
-
159  
-### Listing Available Doctrine Commands
160  
-
161  
-    $ php console list doctrine
162  
-
163  
-    Available commands for the "doctrine" namespace:
164  
-      :cache:clear-metadata        Clear all metadata cache for a entity manager.
165  
-      :cache:clear-query           Clear all query cache for a entity manager.
166  
-      :cache:clear-result          Clear result cache for a entity manager.
167  
-      :data:load                   Load data fixtures to your database.
168  
-      :database:create             Create the configured databases.
169  
-      :database:drop               Drop the configured databases.
170  
-      :ensure-production-settings  Verify that Doctrine is properly configured for a production environment.
171  
-      :generate:entities           Generate entity classes and method stubs from your mapping information.
172  
-      :generate:entity             Generate a new Doctrine entity inside a bundle.
173  
-      :generate:proxies            Generates proxy classes for entity classes.
174  
-      :generate:repositories       Generate repository classes from your mapping information.
175  
-      :mapping:convert             Convert mapping information between supported formats.
176  
-      :mapping:convert-d1-schema   Convert a Doctrine 1 schema to Doctrine 2 mapping files.
177  
-      :mapping:import              Import mapping information from an existing database.
178  
-      :query:dql                   Executes arbitrary DQL directly from the command line.
179  
-      :query:sql                   Executes arbitrary SQL directly from the command line.
180  
-      :schema:create               Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.
181  
-      :schema:drop                 Processes the schema and either drop the database schema of EntityManager Storage Connection or generate the SQL output.
182  
-      :schema:update               Processes the schema and either update the database schema of EntityManager Storage Connection or generate the SQL output.
183  
-
184  
-### Schema Tool
185  
-
186  
-The schema tool in Doctrine 2 allows you to easily drop and create your 
187  
-database schemas for your mapping information.
188  
-
189  
-You can easily create your initial schema from mapping information:
190  
-
191  
-    php console doctrine:schema:create
192  
-
193  
-Or if you want to then drop your schema you can do:
194  
-
195  
-    php console doctrine:schema:drop
196  
-
197  
-Now the scenario arrises where you want to change your mapping information and
198  
-update your database without blowing away everything and losing your existing data.
199  
-You can do the following for that:
200  
-
201  
-    php console doctrine:schema:update
202  
-
203  
-> **TIP**
204  
-> The above will not drop anything from your database schema. To drop the remaining
205  
-> things from your schema you need to use the **--complete** option.
206  
->
207  
->     php console doctrine:schema:update --complete
208  
-
209  
-### Doctrine Generate Entity Command
210  
-
211  
-You can easily generate a new Doctrine entity for a bundle by using the 
212  
-**doctrine:generate-entity** command:
213  
-
214  
-    $ php console doctrine:generate:entity "Bundle\MySampleBundle" "User\Group"  --fields="name:string(255) description:text"
215  
-
216  
-Now if you have a look inside the bundle you will see that you have a **Group** class
217  
-located here **Bundle/MySampleBundle/Entities/User/Group.php**.
218  
-
219  
-Now you can customize the mapping information for the entity by editing the metadata
220  
-information inside **Bundle/MySampleBundle/Resources/config/doctrine/metadata** and
221  
-just update your database schema:
222  
-
223  
-    $ php console doctrine:schema:update
224 0
\ No newline at end of file
Txt src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php
  • View file @ f5e2254
... ...
@@ -85,7 +85,7 @@ class DoctrineMongoDBExtension extends Extension
85 85
                 $container->setParameter('doctrine.odm.mongodb.'.$key, $config[$key]);
86 86
             }
87 87
         }
88  
-        $container->setParameter('doctrine.odm.mongodb.mapping_dirs', $this->findBundleSubpaths('Resources/config/doctrine/metadata', $container));
  88
+        $container->setParameter('doctrine.odm.mongodb.mapping_dirs', $this->findBundleSubpaths('Resources/config/doctrine/metadata/mongodb', $container));
89 89
         $container->setParameter('doctrine.odm.mongodb.document_dirs', $this->findBundleSubpaths('Document', $container));
90 90
     }
91 91
 
... ...
@@ -338,9 +338,9 @@ class DoctrineMongoDBExtension extends Extension
338 338
         }
339 339
         $container->addResource(new FileResource($resource));
340 340
 
341  
-        if (count(glob($dir.'/Resources/config/doctrine/metadata/*.xml'))) {
  341
+        if (count(glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.xml'))) {
342 342
             return 'xml';
343  
-        } elseif (count(glob($dir.'/Resources/config/doctrine/metadata/*.yml'))) {
  343
+        } elseif (count(glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.yml'))) {
344 344
             return 'yml';
345 345
         }
346 346
 
Txt src/Symfony/Bundle/DoctrineMongoDBBundle/Logger/DoctrineMongoDBLogger.php
  • View file @ f5e2254
... ...
@@ -53,20 +53,20 @@ class DoctrineMongoDBLogger
53 53
             }
54 54
 
55 55
             if (is_scalar($value)) {
56  
-                $formatted = json_encode($value);
  56
+                $formatted = '"'.$value.'"';
57 57
             } elseif (is_array($value)) {
58 58
                 $formatted = static::formatQuery($value);
59 59
             } elseif ($value instanceof \MongoId) {
60  
-                $formatted = 'ObjectId('.json_encode((string) $value).')';
  60
+                $formatted = 'ObjectId("'.$value.'")';
61 61
             } elseif ($value instanceof \MongoDate) {
62  
-                $formatted = 'new Date('.date('r', $value->sec).')';
  62
+                $formatted = 'new Date("'.date('r', $value->sec).'")';
63 63
             } elseif ($value instanceof \MongoRegex) {
64  
-                $formatted = 'new RegExp('.json_encode($value->regex).', '.json_encode($value->flags).')';
  64
+                $formatted = 'new RegExp("'.$value->regex.'", "'.$value->flags.'")';
65 65
             } else {
66 66
                 $formatted = (string) $value;
67 67
             }
68 68
 
69  
-            $parts[json_encode($key)] = $formatted;
  69
+            $parts['"'.$key.'"'] = $formatted;
70 70
         }
71 71
 
72 72
         if (0 == count($parts)) {
... ...
@@ -84,4 +84,4 @@ class DoctrineMongoDBLogger
84 84
             return '{ '.implode(', ', array_map($mapper, array_keys($parts), array_values($parts))).' }';
85 85
         }
86 86
     }
87  
-}
  87
+}
88 88
\ No newline at end of file
Txt src/Symfony/Bundle/FrameworkBundle/DependencyInjection/WebExtension.php
  • View file @ f5e2254
... ...
@@ -75,21 +75,7 @@ class WebExtension extends Extension
75 75
         }
76 76
 
77 77
         if (isset($config['profiler'])) {
78  
-            if ($config['profiler']) {
79  
-                if (!$container->hasDefinition('profiler')) {
80  
-                    $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
81  
-                    $loader->load('profiling.xml');
82  
-                    $loader->load('collectors.xml');
83  
-                }
84  
-
85  
-                if (isset($config['profiler']['only-exceptions'])) {
86  
-                    $container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only-exceptions']);
87  
-                } elseif (isset($config['profiler']['only_exceptions'])) {
88  
-                    $container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only_exceptions']);
89  
-                }
90  
-            } elseif ($container->hasDefinition('profiler')) {
91  
-                $container->getDefinition('profiling')->clearTags();
92  
-            }
  78
+            $this->registerProfilerConfiguration($config, $container);
93 79
         }
94 80
 
95 81
         if (isset($config['validation']['enabled'])) {
... ...
@@ -204,6 +190,54 @@ class WebExtension extends Extension
204 190
         ));
205 191
     }
206 192
 
  193
+    /*
  194
+        <profiler only-exceptions="false">
  195
+            <matcher ip="192.168.0.0/24" path="#/admin/#i" />
  196
+            <matcher>
  197
+                <service class="MyMatcher" />
  198
+            </matcher>
  199
+            <matcher service="my_matcher" />
  200
+        </profiler>
  201
+    */
  202
+    protected function registerProfilerConfiguration($config, ContainerBuilder $container)
  203
+    {
  204
+        if ($config['profiler']) {
  205
+            if (!$container->hasDefinition('profiler')) {
  206
+                $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
  207
+                $loader->load('profiling.xml');
  208
+                $loader->load('collectors.xml');
  209
+            }
  210
+
  211
+            if (isset($config['profiler']['only-exceptions'])) {
  212
+                $container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only-exceptions']);
  213
+            } elseif (isset($config['profiler']['only_exceptions'])) {
  214
+                $container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only_exceptions']);
  215
+            }
  216
+
  217
+            if (isset($config['profiler']['matcher'])) {
  218
+                if (isset($config['profiler']['matcher']['service'])) {
  219
+                    $container->setAlias('profiler.request_matcher', $config['profiler']['matcher']['service']);
  220
+                } elseif (isset($config['profiler']['matcher']['_services'])) {
  221
+                    $container->setAlias('profiler.request_matcher', (string) $config['profiler']['matcher']['_services'][0]);
  222
+                } else {
  223
+                    $definition = $container->register('profiler.request_matcher', 'Symfony\\Component\\HttpFoundation\\RequestMatcher');
  224
+
  225
+                    if (isset($config['profiler']['matcher']['ip'])) {
  226
+                        $definition->addMethodCall('matchIp', array($config['profiler']['matcher']['ip']));
  227
+                    }
  228
+
  229
+                    if (isset($config['profiler']['matcher']['path'])) {
  230
+                        $definition->addMethodCall('matchPath', array($config['profiler']['matcher']['path']));
  231
+                    }
  232
+                }
  233
+            } else {
  234
+                $container->removeAlias('profiler.request_matcher');
  235
+            }
  236
+        } elseif ($container->hasDefinition('profiler')) {
  237
+            $container->getDefinition('profiling')->clearTags();
  238
+        }
  239
+    }
  240
+
207 241
     protected function registerValidationConfiguration($config, ContainerBuilder $container)
208 242
     {
209 243
         if ($config['validation']['enabled']) {
Txt src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml
  • View file @ f5e2254
... ...
@@ -28,6 +28,7 @@
28 28
         <service id="profiler_listener" class="%profiler_listener.class%">
29 29
             <tag name="kernel.listener" />
30 30
             <argument type="service" id="profiler" />
  31
+            <argument type="service" id="profiler.request_matcher" on-invalid="null" />
31 32
             <argument>%profiler_listener.only_exceptions%</argument>
32 33
         </service>
33 34
     </services>
Txt src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
  • View file @ f5e2254
... ...
@@ -13,11 +13,22 @@
13 13
         <xsd:sequence>
14 14
             <xsd:element name="router" type="router" minOccurs="0" maxOccurs="1" />
15 15
             <xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" />
  16
+            <xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
16 17
         </xsd:sequence>
17 18
 
18 19
         <xsd:attribute name="ide" type="xsd:string" />
19  
-        <xsd:attribute name="profiler" type="xsd:boolean" />
20  
-        <xsd:attribute name="toolbar" type="xsd:boolean" />
  20
+    </xsd:complexType>
  21
+
  22
+    <xsd:complexType name="profiler">
  23
+        <xsd:sequence>
  24
+            <xsd:element name="matcher" type="profiler_matcher" minOccurs="0" maxOccurs="1" />
  25
+        </xsd:sequence>
  26
+    </xsd:complexType>
  27
+
  28
+    <xsd:complexType name="profiler_matcher">
  29
+        <xsd:attribute name="ip" type="xsd:string" />
  30
+        <xsd:attribute name="path" type="xsd:string" />
  31
+        <xsd:attribute name="service" type="xsd:string" />
21 32
     </xsd:complexType>
22 33
 
23 34
     <xsd:complexType name="router">
Txt src/Symfony/Bundle/PropelBundle/DependencyInjection/PropelExtension.php
  • View file @ f5e2254
... ...
@@ -27,7 +27,7 @@ class PropelExtension extends Extension
27 27
             $loader->load($this->resources['propel']);
28 28
         }
29 29
 
30  
-        if (!$container->getParameterBag()->has('propel.path')) {
  30
+        if (!$container->hasParameter('propel.path')) {
31 31
             if (!isset($config['path'])) {
32 32
                 throw new \InvalidArgumentException('The "path" parameter is mandatory.');
33 33
             }
Txt src/Symfony/Component/DependencyInjection/Container.php
  • View file @ f5e2254
... ...
@@ -119,6 +119,18 @@ class Container implements ContainerInterface, \ArrayAccess
119 119
     }
120 120
 
121 121
     /**
  122
+     * Checks if a parameter exists.
  123
+     *
  124
+     * @param  string $name The parameter name
  125
+     *
  126
+     * @return boolean  The presense of parameter in container
  127
+     */
  128
+    public function hasParameter($name)
  129
+    {
  130
+        return $this->parameterBag->has($name);
  131
+    }
  132
+
  133
+    /**
122 134
      * Sets a parameter.
123 135
      *
124 136
      * @param string $name       The parameter name
Txt src/Symfony/Component/DependencyInjection/ContainerBuilder.php
  • View file @ f5e2254
... ...
@@ -140,6 +140,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
140 140
     }
141 141
 
142 142
     /**
  143
+     * Removes a service.
  144
+     *
  145
+     * @param string $id The service identifier
  146
+     */
  147
+    public function remove($id)
  148
+    {
  149
+        unset($this->definitions[$id]);
  150
+    }
  151
+
  152
+    /**
143 153
      * Returns true if the given service is defined.
144 154
      *
145 155
      * @param  string  $id      The service identifier
... ...
@@ -333,6 +343,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
333 343
     }
334 344
 
335 345
     /**
  346
+     * Removes an alias.
  347
+     *
  348
+     * @param string $alias The alias to remove
  349
+     */
  350
+    public function removeAlias($alias)
  351
+    {
  352
+        unset($this->aliases[$alias]);
  353
+    }
  354
+
  355
+    /**
336 356
      * Returns true if an alias exists under the given identifier.
337 357
      *
338 358
      * @param  string  $id The service identifier
Txt src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
  • View file @ f5e2254
... ...
@@ -109,9 +109,9 @@ class GraphvizDumper extends Dumper
109 109
         $edges = array();
110 110
         foreach ($arguments as $argument) {
111 111
             if (is_object($argument) && $argument instanceof Parameter) {
112  
-                $argument = $this->container->getParameterBag()->has($argument) ? $this->container->getParameter($argument) : null;
  112
+                $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null;
113 113
             } elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) {
114  
-                $argument = $this->container->getParameterBag()->has($match[1]) ? $this->container->getParameter($match[1]) : null;
  114
+                $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null;
115 115
             }
116 116
 
117 117
             if ($argument instanceof Reference) {
Txt src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
  • View file @ f5e2254
... ...
@@ -412,7 +412,7 @@ EOF;
412 412
 
413 413
     public function dumpParameter($name)
414 414
     {
415  
-        if ($this->container->isFrozen() && $this->container->getParameterBag()->has($name)) {
  415
+        if ($this->container->isFrozen() && $this->container->hasParameter($name)) {
416 416
             return $this->dumpValue($this->container->getParameter($name), false);
417 417
         }
418 418
 
Txt src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
  • View file @ f5e2254
... ...
@@ -179,12 +179,24 @@ class XmlFileLoader extends FileLoader
179 179
 
180 180
         // find anonymous service definitions
181 181
         $xml->registerXPathNamespace('container', 'http://www.symfony-project.org/schema/dic/services');
  182
+
  183
+        // anonymous services as arguments
182 184
         $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]');
183 185
         foreach ($nodes as $node) {
184  
-            // give it a unique names
  186
+            // give it a unique name
  187
+            $node['id'] = sprintf('_%s_%d', md5($file), ++$count);
  188
+
  189
+            $definitions[(string) $node['id']] = array($node->service, $file, false);
  190
+            $node->service['id'] = (string) $node['id'];
  191
+        }
  192
+
  193
+        // anonymous services "in the wild"
  194
+        $nodes = $xml->xpath('//container:service[not(@id)]');
  195
+        foreach ($nodes as $node) {
  196
+            // give it a unique name
185 197
             $node['id'] = sprintf('_%s_%d', md5($file), ++$count);
186 198
 
187  
-            $definitions[(string) $node['id']] = array($node->service, $file);
  199
+            $definitions[(string) $node['id']] = array($node, $file, true);
188 200
             $node->service['id'] = (string) $node['id'];
189 201
         }
190 202
 
... ...
@@ -194,7 +206,13 @@ class XmlFileLoader extends FileLoader
194 206
             $this->parseDefinition($id, $def[0], $def[1]);
195 207
 
196 208
             $oNode = dom_import_simplexml($def[0]);
197  
-            $oNode->parentNode->removeChild($oNode);
  209
+            if (true === $def[2]) {
  210
+                $nNode = new \DOMElement('_services');
  211
+                $oNode->parentNode->replaceChild($nNode, $oNode);
  212
+                $nNode->setAttribute('id', $id);
  213
+            } else {
  214
+                $oNode->parentNode->removeChild($oNode);
  215
+            }
198 216
         }
199 217
 
200 218
         return $xml;
... ...
@@ -350,13 +368,20 @@ EOF
350 368
                     $empty = false;
351 369
                 }
352 370
             } elseif (!$node instanceof \DOMComment) {
353  
-                if (isset($config[$node->localName])) {
354  
-                    if (!is_array($config[$node->localName]) || !is_int(key($config[$node->localName]))) {
355  
-                        $config[$node->localName] = array($config[$node->localName]);
  371
+                if ($node instanceof \DOMElement && '_services' === $node->nodeName) {
  372
+                    $value = new Reference($node->getAttribute('id'));
  373
+                } else {
  374
+                    $value = static::convertDomElementToArray($node);
  375
+                }
  376
+
  377
+                $key = $node->localName;
  378
+                if (isset($config[$key])) {
  379
+                    if (!is_array($config[$key]) || !is_int(key($config[$key]))) {
  380
+                        $config[$key] = array($config[$key]);
356 381
                     }
357  
-                    $config[$node->localName][] = static::convertDomElementToArray($node);
  382
+                    $config[$key][] = $value;
358 383
                 } else {
359  
-                    $config[$node->localName] = static::convertDomElementToArray($node);
  384
+                    $config[$key] = $value;
360 385
                 }
361 386
 
362 387
                 $empty = false;
Txt src/Symfony/Component/DomCrawler/Crawler.php
  • View file @ f5e2254
... ...
@@ -567,10 +567,6 @@ class Crawler extends \SplObjectStorage
567 567
 
568 568
         $path = parse_url($uri, PHP_URL_PATH);
569 569
 
570  
-        if ('/' !== substr($path, -1)) {
571  
-            $path = substr($path, 0, strrpos($path, '/') + 1);
572  
-        }
573  
-
574 570
         return array(preg_replace('#^(.*?//[^/]+)\/.*$#', '$1', $uri), $path);
575 571
     }
576 572
 
Txt src/Symfony/Component/DomCrawler/Form.php
  • View file @ f5e2254
... ...
@@ -176,8 +176,13 @@ class Form implements \ArrayAccess
176 176
             $uri .= $sep.$queryString;
177 177
         }
178 178
 
  179
+        $path = $this->path;
  180
+        if ('?' !== substr($uri, 0, 1) && '/' !== substr($path, -1)) {
  181
+            $path = substr($path, 0, strrpos($path, '/') + 1);
  182
+        }
  183
+
179 184
         if ($uri && '/' !== $uri[0] && !$urlHaveScheme) {
180  
-            $uri = $this->path.$uri;
  185
+            $uri = $path.$uri;
181 186
         }
182 187
 
183 188
         if ($absolute && null !== $this->host && !$urlHaveScheme) {
Txt src/Symfony/Component/DomCrawler/Link.php
  • View file @ f5e2254
... ...
@@ -67,8 +67,13 @@ class Link
67 67
         $uri = $this->node->getAttribute('href');
68 68
         $urlHaveScheme = 'http' === substr($uri, 0, 4);
69 69
 
  70
+        $path = $this->path;
  71
+        if ('?' !== substr($uri, 0, 1) && '/' !== substr($path, -1)) {
  72
+            $path = substr($path, 0, strrpos($path, '/') + 1);
  73
+        }
  74
+
70 75
         if ($uri && '/' !== $uri[0] && !$urlHaveScheme) {
71  
-            $uri = $this->path.$uri;
  76
+            $uri = $path.$uri;
72 77
         }
73 78
 
74 79
         if ($absolute && null !== $this->host && !$urlHaveScheme) {
Txt src/Symfony/Component/Form/FieldGroup.php
  • View file @ f5e2254
... ...
@@ -58,7 +58,12 @@ class FieldGroup extends Field implements \IteratorAggregate, FieldGroupInterfac
58 58
     public function __clone()
59 59
     {
60 60
         foreach ($this->fields as $name => $field) {
61  
-            $this->fields[$name] = clone $field;
  61
+            $field = clone $field;
  62
+            // this condition is only to "bypass" a PHPUnit bug with mocks
  63
+            if (null !== $field->getParent()) {
  64
+                $field->setParent($this);
  65
+            }
  66
+            $this->fields[$name] = $field;
62 67
         }
63 68
     }
64 69
 
Txt src/Symfony/Component/Form/FieldInterface.php
  • View file @ f5e2254
... ...
@@ -37,6 +37,13 @@ interface FieldInterface extends Localizable, Translatable
37 37
     public function setParent(FieldInterface $parent = null);
38 38
 
39 39
     /**
  40
+     * Returns the parent field.
  41
+     *
  42
+     * @return FieldInterface  The parent field
  43
+     */
  44
+    public function getParent();
  45
+
  46
+    /**
40 47
      * Sets the key by which the field is identified in field groups.
41 48
      *
42 49
      * Once this field is nested in a field group, i.e. after setParent() was
Txt src/Symfony/Component/HttpFoundation/Request.php
  • View file @ f5e2254
... ...
@@ -134,7 +134,7 @@ class Request
134 134
             'SERVER_NAME'          => 'localhost',
135 135
             'SERVER_PORT'          => 80,
136 136
             'HTTP_HOST'            => 'localhost',
137  
-            'HTTP_USER_AGENT'      => 'Symfony/X.X',
  137
+            'HTTP_USER_AGENT'      => 'Symfony/2.X',
138 138
             'HTTP_ACCEPT'          => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
139 139
             'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
140 140
             'HTTP_ACCEPT_CHARSET'  => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
Txt src/Symfony/Component/HttpFoundation/RequestMatcher.php
  • View file @ f5e2254
... ...
@@ -0,0 +1,105 @@
  1
+<?php
  2
+
  3
+namespace Symfony\Component\HttpFoundation;
  4
+
  5
+/*
  6
+ * This file is part of the Symfony package.
  7
+ *
  8
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  9
+ *
  10
+ * For the full copyright and license information, please view the LICENSE
  11
+ * file that was distributed with this source code.
  12
+ */
  13
+
  14
+/**
  15
+ * RequestMatcher compares a pre-defined set of checks against a Request instance.
  16
+ *
  17
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  18
+ */
  19
+class RequestMatcher implements RequestMatcherInterface
  20
+{
  21
+    protected $path;
  22
+    protected $host;
  23
+    protected $methods;
  24
+    protected $ip;
  25
+
  26
+    /**
  27
+     * Adds a check for the URL host name.
  28
+     *
  29
+     * @param string $regexp A Regexp
  30
+     */
  31
+    public function matchHost($regexp)
  32
+    {
  33
+        $this->host = $regexp;
  34
+    }
  35
+
  36
+    /**
  37
+     * Adds a check for the URL path info.
  38
+     *
  39
+     * @param string $regexp A Regexp
  40
+     */
  41
+    public function matchPath($regexp)
  42
+    {
  43
+        $this->path = $regexp;
  44
+    }
  45
+
  46
+    /**
  47
+     * Adds a check for the client IP.
  48
+     *
  49
+     * @param string $ip A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
  50
+     */
  51
+    public function matchIp($ip)
  52
+    {
  53
+        $this->ip = $ip;
  54
+    }
  55
+
  56
+    /**
  57
+     * Adds a check for the HTTP method.
  58
+     *
  59
+     * @param string|array An HTTP method or an array of HTTP methods
  60
+     */
  61
+    public function matchMethod($method)
  62
+    {
  63
+        $this->methods = array_map(function ($m) { return strtolower($m); }, is_array($method) ? $method : array($method));
  64
+    }
  65
+
  66
+    /**
  67
+     * {@inheritdoc}
  68
+     */
  69
+    public function matches(Request $request)
  70
+    {
  71
+        if (null !== $this->methods && !in_array(strtolower($request->getMethod()), $this->methods)) {
  72
+            return false;
  73
+        }
  74
+
  75
+        if (null !== $this->path && !preg_match($this->path, $request->getPathInfo())) {
  76
+            return false;
  77
+        }
  78
+
  79
+        if (null !== $this->host && !preg_match($this->host, $request->getHost())) {
  80
+            return false;
  81
+        }
  82
+
  83
+        if (null !== $this->ip && !$this->checkIp($this->host, $request->getClientIp())) {
  84
+            return false;
  85
+        }
  86
+
  87
+        return true;
  88
+    }
  89
+
  90
+    protected function checkIp($ip)
  91
+    {
  92
+        if (false !== strpos($this->ip, '/')) {
  93
+            list($address, $netmask) = $this->ip;
  94
+
  95
+            if ($netmask <= 0) {
  96
+                return false;
  97
+            }
  98
+        } else {
  99
+            $address = $this->ip;
  100
+            $netmask = 1;
  101
+        }
  102
+
  103
+        return 0 === substr_compare(sprintf('%032b', ip2long($ip)), sprintf('%032b', ip2long($address)), 0, $netmask);
  104
+    }
  105
+}
Txt src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php
  • View file @ f5e2254
... ...
@@ -0,0 +1,29 @@
  1
+<?php
  2
+
  3
+namespace Symfony\Component\HttpFoundation;
  4
+
  5
+/*
  6
+ * This file is part of the Symfony package.
  7
+ *
  8
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  9
+ *
  10
+ * For the full copyright and license information, please view the LICENSE
  11
+ * file that was distributed with this source code.
  12
+ */
  13
+
  14
+/**
  15
+ * RequestMatcherInterface is an interface for strategies to match a Request.
  16
+ *
  17
+ * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  18
+ */
  19
+interface RequestMatcherInterface
  20
+{
  21
+    /**
  22
+     * Decides whether the rule(s) implemented by the strategy matches the supplied request.
  23
+     *
  24
+     * @param  Request $request The request to check for a match
  25
+     *
  26
+     * @return Boolean true if the request matches, false otherwise
  27
+     */
  28
+    function matches(Request $request);
  29
+}
Txt src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
  • View file @ f5e2254
... ...
@@ -38,7 +38,7 @@ class RequestDataCollector extends DataCollector
38 38
             'request_server'     => $request->server->all(),
39 39
             'request_cookies'    => $request->cookies->all(),
40 40
             'response_headers'   => $response->headers->all(),
41  
-            'session_attributes' => $request->getSession()->getAttributes(),
  41
+            'session_attributes' => $request->hasSession() ? $request->getSession()->getAttributes() : array(),
42 42
         );
43 43
     }
44 44
 
Txt src/Symfony/Component/HttpKernel/Profiler/ProfilerListener.php
  • View file @ f5e2254
... ...
@@ -6,6 +6,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
6 6
 use Symfony\Component\EventDispatcher\Event;
7 7
 use Symfony\Component\HttpFoundation\Response;
8 8
 use Symfony\Component\HttpKernel\HttpKernelInterface;
  9
+use Symfony\Component\HttpFoundation\RequestMatcherInterface;
9 10
 
10 11
 /*
11 12
  * This file is part of the Symfony framework.
... ...
@@ -26,16 +27,19 @@ class ProfilerListener
26 27
     protected $profiler;
27 28
     protected $exception;
28 29
     protected $onlyException;
  30
+    protected $matcher;
29 31
 
30 32
     /**
31 33
      * Constructor.
32 34
      *
33  
-     * @param Profiler $profiler      A Profiler instance
34  
-     * @param Boolean  $onlyException true if the profiler only collects data when an exception occurs, false otherwise
  35
+     * @param Profiler                $profiler      A Profiler instance
  36
+     * @param RequestMatcherInterface $matcher       A RequestMatcher instance
  37
+     * @param Boolean                 $onlyException true if the profiler only collects data when an exception occurs, false otherwise
35 38
      */
36  
-    public function __construct(Profiler $profiler, $onlyException = false)
  39
+    public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false)
37 40
     {
38 41
         $this->profiler = $profiler;
  42
+        $this->matcher = $matcher;
39 43
         $this->onlyException = $onlyException;
40 44
     }
41 45
 
... ...
@@ -80,6 +84,10 @@ class ProfilerListener
80 84
             return $response;
81 85
         }
82 86
 
  87
+        if (null !== $this->matcher && !$this->matcher->matches($event->getParameter('request'))) {
  88
+            return $response;
  89
+        }
  90
+
83 91
         if ($this->onlyException && null === $this->exception) {
84 92
             return $response;
85 93
         }
Txt src/Symfony/Component/Routing/Route.php
  • View file @ f5e2254
... ...
@@ -197,12 +197,14 @@ class Route
197 197
     {
198 198
         $this->requirements = array();
199 199
         foreach ($requirements as $key => $regex) {
200  
-            if ('^' == $regex[0]) {
201  
-                $regex = substr($regex, 1);
202  
-            }
203  
-
204  
-            if ('$' == substr($regex, -1)) {
205  
-                $regex = substr($regex, 0, -1);
  200
+            if (!is_array($regex)) {
  201
+                if ('^' == $regex[0]) {
  202
+                    $regex = substr($regex, 1);
  203
+                }
  204
+
  205
+                if ('$' == substr($regex, -1)) {
  206
+                    $regex = substr($regex, 0, -1);
  207
+                }
206 208
             }
207 209
 
208 210
             $this->requirements[$key] = $regex;
Txt tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php
  • View file @ f5e2254
... ...
@@ -297,7 +297,10 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
297 297
         $this->assertEquals('http://example.com/bar/foo', $crawler->link()->getUri(), '->link() returns a Link instance');
298 298
 
299 299
         $crawler = $this->createTestCrawler('http://example.com/bar')->selectLink('Foo');
300  
-        $this->assertEquals('http://example.com/foo', $crawler->link()->getUri(), '->form() linketurns a Link instance');
  300
+        $this->assertEquals('http://example.com/foo', $crawler->link()->getUri(), '->link() returns a Link instance');
  301
+
  302
+        $crawler = $this->createTestCrawler('http://example.com/bar')->selectLink('GetLink');
  303
+        $this->assertEquals('http://example.com/bar?get=param', $crawler->link()->getUri(), '->link() returns a Link instance');
301 304
 
302 305
         try {
303 306
             $this->createTestCrawler()->filter('ol')->link();
... ...
@@ -475,6 +478,8 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
475 478
                     <a href="/bar"><img alt="Fabien&quot;s Bar"/></a>
476 479
                     <a href="/bar"><img alt="\' Fabien&quot;s Bar"/></a>
477 480
 
  481
+                    <a href="?get=param">GetLink</a>
  482
+
478 483
                     <form action="foo">
479 484
                         <input type="submit" value="FooValue" name="FooName" id="FooId" />
480 485
                         <input type="button" value="BarValue" name="BarName" id="BarId" />
Txt tests/Symfony/Tests/Component/DomCrawler/FormTest.php
  • View file @ f5e2254
... ...
@@ -280,6 +280,14 @@ class FormTest extends \PHPUnit_Framework_TestCase
280 280
         $this->assertEquals('/foo', $form->getUri(true), '->getUri() returns absolute URIs only if the host has been defined in the constructor');
281 281
     }
282 282
 
  283
+    public function testGetUriWithOnlyQueryString()
  284
+    {
  285
+        $form = $this->createForm('<form action="?get=param"><input type="submit" /></form>', null, 'http://localhost', '/foo/bar');
  286
+        $this->assertEquals('http://localhost/foo/bar?get=param', $form->getUri(true), '->getUri() returns absolute URIs only if the host has been defined in the constructor');
  287
+
  288
+        $this->assertEquals('/foo/bar?get=param', $form->getUri(false), '->getUri() returns absolute URIs only if the host has been defined in the constructor');
  289
+    }
  290
+
283 291
     public function provideGetUriValues()
284 292
     {
285 293
         return array(
... ...
@@ -317,7 +325,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
317 325
                 'returns an empty URI if the action is empty',
318 326
                 '<form><input type="submit" /></form>',
319 327
                 array(),
320  
-                '', 
  328
+                '',
321 329
             ),
322 330
             array(
323 331
                 'appends the form values even if the action is empty',
Txt tests/Symfony/Tests/Component/DomCrawler/LinkTest.php
  • View file @ f5e2254
... ...
@@ -72,5 +72,15 @@ class LinkTest extends \PHPUnit_Framework_TestCase
72 72
 
73 73
         $link = new Link($node, 'get','http://www.foo.com','/bar/');
74 74
         $this->assertEquals('http://login.foo.com/foo', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
  75
+
  76
+        $dom = new \DOMDocument();
  77
+        $dom->loadHTML('<html><a href="?get=param">foo</a></html>');
  78
+        $node = $dom->getElementsByTagName('a')->item(0);
  79
+
  80
+        $link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar');
  81
+        $this->assertEquals('http://www.foo.com/foo/bar?get=param', $link->getUri(), '->getUri() returns the absolute URI of the link, regardless of the context of the object');
  82
+
  83
+        $link = new Link($node, 'get', 'http://www.foo.com', '/foo/bar');
  84
+        $this->assertEquals('/foo/bar?get=param', $link->getUri(false), '->getUri() returns the relative URI of the link if false is the first argument');
75 85
     }
76 86
 }
Txt tests/Symfony/Tests/Component/Finder/FinderTest.php
  • View file @ f5e2254
... ...
@@ -205,14 +205,21 @@ class FinderTest extends Iterator\RealIteratorTestCase
205 205
             $dirs[] = (string) $dir;
206 206
         }
207 207
 
208  
-        $this->assertEquals($this->toAbsolute(array('foo', 'toto')), $dirs, 'implements the \IteratorAggregate interface');
  208
+        $expected = $this->toAbsolute(array('foo', 'toto'));
  209
+
  210
+        sort($dirs);
  211
+        sort($expected);
  212
+
  213
+        $this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
209 214
 
210 215
         $finder = new Finder();
211 216
         $this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
212 217
 
213 218
         $finder = new Finder();
214 219
         $a = iterator_to_array($finder->directories()->in(self::$tmpDir));
215  
-        $this->assertEquals($this->toAbsolute(array('foo', 'toto')), array_values(array_map(function ($a) { return (string) $a; }, $a)), 'implements the \IteratorAggregate interface');
  220
+        $a = array_values(array_map(function ($a) { return (string) $a; }, $a));
  221
+        sort($a);
  222
+        $this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
216 223
     }
217 224
 
218 225
     protected function toAbsolute($files)
Txt tests/Symfony/Tests/Component/HttpFoundation/RequestMatcherTest.php
  • View file @ f5e2254
... ...
@@ -0,0 +1,72 @@
  1
+<?php
  2
+
  3
+/*
  4
+ * This file is part of the Symfony package.
  5
+ *
  6
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  7
+ *
  8
+ * For the full copyright and license information, please view the LICENSE
  9
+ * file that was distributed with this source code.
  10
+ */
  11
+
  12
+namespace Symfony\Tests\Component\HttpFoundation;
  13
+
  14
+use Symfony\Component\HttpFoundation\RequestMatcher;
  15
+use Symfony\Component\HttpFoundation\Request;
  16
+
  17
+class RequestMatcherTest extends \PHPUnit_Framework_TestCase
  18
+{
  19
+    public function testIp()
  20
+    {
  21
+        $matcher = new RequestMatcher();
  22
+
  23
+        $matcher->matchIp('192.168.1.1/1');
  24
+        $request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => '192.168.1.1'));
  25
+        $this->assertTrue($matcher->matches($request));
  26
+
  27
+        $matcher->matchIp('192.168.1.0/24');
  28
+        $this->assertTrue($matcher->matches($request));
  29
+
  30
+        $matcher->matchIp('1.2.3.4/1');
  31
+        $this->assertFalse($matcher->matches($request));
  32
+    }
  33
+
  34
+    public function testMethod()
  35
+    {
  36
+        $matcher = new RequestMatcher();
  37
+
  38
+        $matcher->matchMethod('get');
  39
+        $request = Request::create('', 'get');
  40
+        $this->assertTrue($matcher->matches($request));
  41
+
  42
+        $matcher->matchMethod('post');
  43
+        $this->assertFalse($matcher->matches($request));
  44
+
  45
+        $matcher->matchMethod(array('get', 'post'));
  46
+        $this->assertTrue($matcher->matches($request));
  47
+    }
  48
+
  49
+    public function testHost()
  50
+    {
  51
+        $matcher = new RequestMatcher();
  52
+
  53
+        $matcher->matchHost('#.*\.example\.com#i');
  54
+        $request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com'));
  55
+        $this->assertTrue($matcher->matches($request));
  56
+
  57
+        $matcher->matchMethod('#sensio\.com#i');
  58
+        $this->assertFalse($matcher->matches($request));
  59
+    }
  60
+
  61
+    public function testPath()
  62
+    {
  63
+        $matcher = new RequestMatcher();
  64
+
  65
+        $matcher->matchPath('#^/admin#');
  66
+        $request = Request::create('/admin/foo');
  67
+        $this->assertTrue($matcher->matches($request));
  68
+
  69
+        $matcher->matchMethod('#^/blog#i');
  70
+        $this->assertFalse($matcher->matches($request));
  71
+    }
  72
+}
Txt tests/Symfony/Tests/Component/HttpKernel/Profiler/ProfilerTest.php
  • View file @ f5e2254
... ...
@@ -30,12 +30,12 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase
30 30
         $storage->purge(true);
31 31
 
32 32
         $profiler = new Profiler($storage);
33  
-        $profiler->addCollector($collector);
  33
+        $profiler->add($collector);
34 34
         $profiler->setToken('foobar');
35 35
         $profiler->collect($request, $response);
36 36
 
37 37
         $profiler = new Profiler($storage);
38 38
         $profiler->setToken('foobar');
39  
-        $this->assertEquals(array('foo' => 'bar'), $profiler->getCollector('request')->getRequestQuery()->all());
  39
+        $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
40 40
     }
41 41
 }
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Српски
  • Svenska
  • 中文