Changeset 28330
- Timestamp:
- 03/01/10 12:00:04 (3 years ago)
- Files:
-
- branches/2.0/src/Symfony/Components/Console/Input/Input.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Foundation/Bundle/KernelBundle.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Foundation/Bundle/KernelExtension.php (modified) (1 diff)
- branches/2.0/src/Symfony/Foundation/Kernel.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Foundation/Resources/config/debug.xml (copied) (copied from branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/debug.xml) (1 diff)
- branches/2.0/src/Symfony/Foundation/Resources/config/services.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Foundation/UniversalClassLoader.php (modified) (1 diff)
- branches/2.0/src/Symfony/Foundation/bootstrap.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/BuildDoctrineCommand.php (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/BuildEntitiesDoctrineCommand.php (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/DatabaseToolDoctrineCommand.php (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/InitEntityDoctrineCommand.php (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php (modified) (5 diffs)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/README (added)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/dbal.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/orm.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/schema/dic/doctrine/doctrine-1.0.xsd (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Bundle.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Console/Application.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Controller.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/debug.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/debug_exception_handler.xml (deleted)
- branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/schema/dic/symfony/symfony-1.0.xsd (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/web.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Framework/WebBundle/Templating/Engine.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/src/Symfony/Components/Console/Input/Input.php
r26615 r28330 131 131 132 132 /** 133 * Returns true if an InputArgument object exists by name or position. 134 * 135 * @param string|integer $name The InputArgument name or position 136 * 137 * @return Boolean true if the InputArgument object exists, false otherwise 138 */ 139 public function hasArgument($name) 140 { 141 return $this->definition->hasArgument($name); 142 } 143 144 /** 133 145 * Returns the options values. 134 146 * … … 172 184 $this->options[$name] = $value; 173 185 } 186 187 /** 188 * Returns true if an InputOption object exists by name. 189 * 190 * @param string $name The InputOption name 191 * 192 * @return Boolean true if the InputOption object exists, false otherwise 193 */ 194 public function hasOption($name) 195 { 196 return $this->definition->hasOption($name); 197 } 174 198 } branches/2.0/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php
r26560 r28330 66 66 { 67 67 $value = (string) $value; 68 $lowercaseValue = strtolower($value); 68 69 69 70 switch (true) 70 71 { 71 case 'null' == strtolower($value):72 case 'null' === $lowercaseValue: 72 73 return null; 73 74 case ctype_digit($value): 74 75 return '0' == $value[0] ? octdec($value) : intval($value); 75 case 'true' === strtolower($value):76 case 'true' === $lowercaseValue: 76 77 return true; 77 case 'false' === strtolower($value):78 case 'false' === $lowercaseValue: 78 79 return false; 79 80 case is_numeric($value): … … 82 83 return floatval(str_replace(',', '', $value)); 83 84 default: 84 return (string)$value;85 return $value; 85 86 } 86 87 } branches/2.0/src/Symfony/Foundation/Bundle/KernelBundle.php
r28142 r28330 7 7 use Symfony\Components\DependencyInjection\ContainerInterface; 8 8 use Symfony\Components\DependencyInjection\Loader\Loader; 9 use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; 10 use Symfony\Components\DependencyInjection\BuilderConfiguration; 9 11 10 12 /* … … 28 30 { 29 31 Loader::registerExtension(new KernelExtension()); 32 33 $configuration = new BuilderConfiguration(); 34 35 $loader = new XmlFileLoader(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')); 36 $configuration->merge($loader->load('services.xml')); 37 38 if ($container->getParameter('kernel.debug')) 39 { 40 $configuration->merge($loader->load('debug.xml')); 41 $configuration->setDefinition('event_dispatcher', $configuration->findDefinition('debug.event_dispatcher')); 42 } 43 44 return $configuration; 30 45 } 31 46 branches/2.0/src/Symfony/Foundation/Bundle/KernelExtension.php
r28096 r28330 26 26 { 27 27 $configuration = new BuilderConfiguration(); 28 29 $loader = new XmlFileLoader(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));30 $configuration->merge($loader->load('services.xml'));31 28 32 29 if (isset($config['charset'])) branches/2.0/src/Symfony/Foundation/Kernel.php
r28179 r28330 85 85 86 86 /** 87 * Checks whether the current kernel has been booted or not. 88 * 89 * @return boolean $booted 90 */ 91 public function isBooted() 92 { 93 return $this->booted; 94 } 95 96 /** 87 97 * Boots the current kernel. 88 98 * … … 226 236 foreach ($_SERVER as $key => $value) 227 237 { 228 if ('SYMFONY__' === $key =substr($key, 0, 9))229 { 230 $parameters[strtolower(str_replace('__', '.', $key))] = $value;238 if ('SYMFONY__' === substr($key, 0, 9)) 239 { 240 $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; 231 241 } 232 242 } … … 270 280 $this->optimizeContainer($container); 271 281 272 // cache dir 273 if (!is_dir($parameters['kernel.cache_dir'])) 274 { 275 if (false === @mkdir($parameters['kernel.cache_dir'], 0777, true)) 276 { 277 die(sprintf('Unable to create the cache directory (%s)', $parameters['kernel.cache_dir'])); 278 } 279 } 280 elseif (!is_writable($parameters['kernel.cache_dir'])) 281 { 282 die(sprintf('Unable to write in the cache directory (%s)', $parameters['kernel.cache_dir'])); 283 } 284 285 // logs dir 286 if (!is_dir($parameters['kernel.logs_dir'])) 287 { 288 if (false === @mkdir($parameters['kernel.logs_dir'], 0777, true)) 289 { 290 die(sprintf('Unable to create the logs directory (%s)', $parameters['kernel.logs_dir'])); 291 } 292 } 293 elseif (!is_writable($parameters['kernel.logs_dir'])) 294 { 295 die(sprintf('Unable to write in the logs directory (%s)', $parameters['kernel.logs_dir'])); 282 foreach (array('cache', 'logs') as $name) 283 { 284 $key = sprintf('kernel.%s_dir', $name); 285 if (!is_dir($parameters[$key])) 286 { 287 if (false === @mkdir($parameters[$key], 0777, true)) 288 { 289 die(sprintf('Unable to create the %s directory (%s)', $name, dirname($parameters['kernel.cache_dir']))); 290 } 291 } 292 elseif (!is_writable($parameters[$key])) 293 { 294 die(sprintf('Unable to write in the %s directory (%s)', $name, $parameters['kernel.cache_dir'])); 295 } 296 296 } 297 297 branches/2.0/src/Symfony/Foundation/Resources/config/debug.xml
r28096 r28330 6 6 7 7 <parameters> 8 <parameter key=" symfony.templating.debugger.class">Symfony\Framework\WebBundle\Templating\Debugger</parameter>8 <parameter key="debug.event_dispatcher.class">Symfony\Foundation\Debug\EventDispatcher</parameter> 9 9 </parameters> 10 10 11 11 <services> 12 <service id="symfony.templating.debugger" class="%symfony.templating.debugger.class%"> 12 <service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%"> 13 <argument type="service" id="service_container" /> 13 14 <argument type="service" id="logger" on-invalid="null" /> 14 15 </service> branches/2.0/src/Symfony/Foundation/Resources/config/services.xml
r28096 r28330 7 7 <parameters> 8 8 <parameter key="event_dispatcher.class">Symfony\Foundation\EventDispatcher</parameter> 9 <parameter key="debug.event_dispatcher.class">Symfony\Foundation\Debug\EventDispatcher</parameter>10 9 <parameter key="request_handler.class">Symfony\Components\RequestHandler\RequestHandler</parameter> 11 10 <parameter key="request.class">Symfony\Components\RequestHandler\Request</parameter> … … 18 17 <service id="event_dispatcher" class="%event_dispatcher.class%"> 19 18 <argument type="service" id="service_container" /> 20 </service>21 22 <service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%">23 <argument type="service" id="service_container" />24 <argument type="service" id="logger" on-invalid="null" />25 19 </service> 26 20 branches/2.0/src/Symfony/Foundation/UniversalClassLoader.php
r28071 r28330 13 13 14 14 /** 15 * UniversalClassLoader implements a "universal" autolo der for PHP 5.3.15 * UniversalClassLoader implements a "universal" autoloader for PHP 5.3. 16 16 * 17 17 * It is able to load classes that use either: branches/2.0/src/Symfony/Foundation/bootstrap.php
r28179 r28330 41 41 use Symfony\Components\DependencyInjection\ContainerInterface; 42 42 use Symfony\Components\DependencyInjection\Loader\Loader; 43 use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; 44 use Symfony\Components\DependencyInjection\BuilderConfiguration; 43 45 44 46 … … 50 52 { 51 53 Loader::registerExtension(new KernelExtension()); 54 55 $configuration = new BuilderConfiguration(); 56 57 $loader = new XmlFileLoader(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')); 58 $configuration->merge($loader->load('services.xml')); 59 60 if ($container->getParameter('kernel.debug')) 61 { 62 $configuration->merge($loader->load('debug.xml')); 63 $configuration->setDefinition('event_dispatcher', $configuration->findDefinition('debug.event_dispatcher')); 64 } 65 66 return $configuration; 52 67 } 53 68 … … 75 90 { 76 91 $configuration = new BuilderConfiguration(); 77 78 $loader = new XmlFileLoader(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));79 $configuration->merge($loader->load('services.xml'));80 92 81 93 if (isset($config['charset'])) … … 362 374 363 375 376 public function isBooted() 377 { 378 return $this->booted; 379 } 380 381 364 382 public function boot() 365 383 { … … 494 512 foreach ($_SERVER as $key => $value) 495 513 { 496 if ('SYMFONY__' === $key =substr($key, 0, 9))497 { 498 $parameters[strtolower(str_replace('__', '.', $key))] = $value;514 if ('SYMFONY__' === substr($key, 0, 9)) 515 { 516 $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; 499 517 } 500 518 } … … 538 556 $this->optimizeContainer($container); 539 557 540 if (!is_dir($parameters['kernel.cache_dir'])) 541 { 542 if (false === @mkdir($parameters['kernel.cache_dir'], 0777, true)) 543 { 544 die(sprintf('Unable to create the cache directory (%s)', $parameters['kernel.cache_dir'])); 545 } 546 } 547 elseif (!is_writable($parameters['kernel.cache_dir'])) 548 { 549 die(sprintf('Unable to write in the cache directory (%s)', $parameters['kernel.cache_dir'])); 550 } 551 552 if (!is_dir($parameters['kernel.logs_dir'])) 553 { 554 if (false === @mkdir($parameters['kernel.logs_dir'], 0777, true)) 555 { 556 die(sprintf('Unable to create the logs directory (%s)', $parameters['kernel.logs_dir'])); 557 } 558 } 559 elseif (!is_writable($parameters['kernel.logs_dir'])) 560 { 561 die(sprintf('Unable to write in the logs directory (%s)', $parameters['kernel.logs_dir'])); 558 foreach (array('cache', 'logs') as $name) 559 { 560 $key = sprintf('kernel.%s_dir', $name); 561 if (!is_dir($parameters[$key])) 562 { 563 if (false === @mkdir($parameters[$key], 0777, true)) 564 { 565 die(sprintf('Unable to create the %s directory (%s)', $name, dirname($parameters['kernel.cache_dir']))); 566 } 567 } 568 elseif (!is_writable($parameters[$key])) 569 { 570 die(sprintf('Unable to write in the %s directory (%s)', $name, $parameters['kernel.cache_dir'])); 571 } 562 572 } 563 573 branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php
r28207 r28330 29 29 public function buildContainer(ContainerInterface $container) 30 30 { 31 Loader::registerExtension(new DoctrineExtension( ));31 Loader::registerExtension(new DoctrineExtension($container)); 32 32 33 33 $metadataDirs = array(); … … 52 52 } 53 53 } 54 $container->setParameter('doctrine.orm.metadata_driver _impl.dirs', $metadataDirs);55 $container->setParameter('doctrine. entity_dirs', $entityDirs);54 $container->setParameter('doctrine.orm.metadata_driver.mapping_dirs', $metadataDirs); 55 $container->setParameter('doctrine.orm.entity_dirs', $entityDirs); 56 56 } 57 57 } branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php
r28179 r28330 4 4 5 5 use Symfony\Framework\WebBundle\Command\Command; 6 use Symfony\Components\Console\Input\ArrayInput; 6 7 use Symfony\Components\Console\Input\InputArgument; 7 8 use Symfony\Components\Console\Input\InputOption; … … 9 10 use Symfony\Components\Console\Output\OutputInterface; 10 11 use Symfony\Components\Console\Output\Output; 12 use Symfony\Framework\WebBundle\Console\Application; 11 13 use Symfony\Framework\WebBundle\Util\Filesystem; 12 14 use Doctrine\Common\Cli\Configuration; … … 31 33 abstract class DoctrineCommand extends Command 32 34 { 33 protected $cli; 35 protected 36 $application, 37 $cli, 38 $em; 34 39 35 40 protected function getDoctrineCli() … … 38 43 { 39 44 $configuration = new Configuration(); 40 $configuration->setAttribute('em', $this->container->getDoctrine_Orm_EntityManagerService());41 45 $this->cli = new DoctrineCliController($configuration); 42 46 } 47 $em = $this->em ? $this->em : $this->container->getDoctrine_Orm_EntityManagerService(); 48 $this->cli->getConfiguration()->setAttribute('em', $em); 43 49 return $this->cli; 44 50 } … … 61 67 } 62 68 63 p ublicfunction buildDoctrineCliTaskOptions(InputInterface $input, array $options)69 protected function buildDoctrineCliTaskOptions(InputInterface $input, array $options) 64 70 { 65 71 $taskOptions = array(); … … 73 79 return $options; 74 80 } 81 82 protected function runCommand($name, array $input = array()) 83 { 84 if ($this->application === null) 85 { 86 $this->application = new Application($this->container->getKernelService()); 87 } 88 89 $arguments = array(); 90 $arguments = array_merge(array($name), $input); 91 $input = new ArrayInput($arguments); 92 $this->application->setAutoExit(false); 93 $this->application->run($input); 94 } 95 96 /** 97 * TODO: Better way to do these functions? 98 */ 99 protected function getDoctrineConnections() 100 { 101 $connections = array(); 102 $ids = $this->container->getServiceIds(); 103 foreach ($ids as $id) 104 { 105 preg_match('/doctrine.dbal.(.*)_connection/', $id, $matches); 106 if ($matches) 107 { 108 $name = $matches[1]; 109 $connections[$name] = $this->container->getService($id); 110 } 111 } 112 return $connections; 113 } 114 115 protected function getDoctrineEntityManagers() 116 { 117 $entityManagers = array(); 118 $ids = $this->container->getServiceIds(); 119 foreach ($ids as $id) 120 { 121 preg_match('/doctrine.orm.(.*)_entity_manager/', $id, $matches); 122 if ($matches) 123 { 124 $name = $matches[1]; 125 $entityManagers[$name] = $this->container->getService($id); 126 } 127 } 128 return $entityManagers; 129 } 75 130 } branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
r28207 r28330 42 42 ->setName('doctrine:load-data-fixtures') 43 43 ->setDescription('Load data fixtures to your database.') 44 ->addOption('dir_or_file', null, null, 'The directory or file to load data fixtures from.')44 ->addOption('dir_or_file', null, InputOption::PARAMETER_OPTIONAL | InputOption::PARAMETER_IS_ARRAY, 'The directory or file to load data fixtures from.') 45 45 ->addOption('append', null, InputOption::PARAMETER_OPTIONAL, 'Whether or not to append the data fixtures.', false) 46 46 ; … … 52 52 protected function execute(InputInterface $input, OutputInterface $output) 53 53 { 54 $em = $this->container->getDoctrine_ORM_EntityManagerService(); 55 if (!$input->getOption('append')) 56 { 57 $classes = array(); 58 $metadatas = $em->getMetadataFactory()->getAllMetadata(); 59 60 foreach ($metadatas as $metadata) 61 { 62 if (!$metadata->isMappedSuperclass) 63 { 64 $classes[] = $metadata; 65 } 66 } 67 $cmf = $em->getMetadataFactory(); 68 $classes = $this->getCommitOrder($em, $classes); 69 for ($i = count($classes) - 1; $i >= 0; --$i) 70 { 71 $class = $classes[$i]; 72 if ($cmf->hasMetadataFor($class->name)) 73 { 74 try { 75 $em->createQuery('DELETE FROM '.$class->name.' a')->execute(); 76 } catch (Exception $e) {} 77 } 78 } 79 } 80 54 $defaultEm = $this->container->getDoctrine_ORM_EntityManagerService(); 81 55 $dirOrFile = $input->getOption('dir_or_file'); 82 56 if ($dirOrFile) 83 57 { 84 $paths = $dirOrFile;58 $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile); 85 59 } else { 86 60 $paths = array(); … … 113 87 } 114 88 89 $ems = array(); 90 $emEntities = array(); 115 91 $files = array_unique($files); 116 117 92 foreach ($files as $file) 118 93 { 94 $em = $defaultEm; 95 $output->writeln(sprintf('<info>Loading data fixtures from <comment>"%s"</comment></info>', $file)); 96 119 97 $before = array_keys(get_defined_vars()); 120 98 include($file); 121 99 $after = array_keys(get_defined_vars()); 122 100 $new = array_diff($after, $before); 123 $entities = array_values($new); 124 unset($entities[array_search('before', $entities)]); 125 foreach ($entities as $entity) { 126 $em->persist($$entity); 101 $params = $em->getConnection()->getParams(); 102 $emName = isset($params['path']) ? $params['path']:$params['dbname']; 103 104 $ems[$emName] = $em; 105 $emEntities[$emName] = array(); 106 $variables = array_values($new); 107 108 foreach ($variables as $variable) 109 { 110 $value = $$variable; 111 if (!is_object($value) || $value instanceof \Doctrine\ORM\EntityManager) 112 { 113 continue; 114 } 115 $emEntities[$emName][] = $value; 127 116 } 128 $em->flush(); 117 foreach ($ems as $emName => $em) 118 { 119 if (!$input->getOption('append')) 120 { 121 $output->writeln(sprintf('<info>Purging data from entity manager named <comment>"%s"</comment></info>', $emName)); 122 $this->purgeEntityManager($em); 123 } 124 125 $entities = $emEntities[$emName]; 126 $numEntities = count($entities); 127 $output->writeln(sprintf('<info>Persisting "%s" '.($numEntities > 1 ? 'entities' : 'entity').'</info>', count($entities))); 128 129 foreach ($entities as $entity) 130 { 131 $output->writeln(sprintf('<info>Persisting "%s" entity:</info>', get_class($entity))); 132 $output->writeln(''); 133 $output->writeln(var_dump($entity)); 134 135 $em->persist($entity); 136 } 137 $output->writeln('<info>Flushing entity manager</info>'); 138 $em->flush(); 139 } 129 140 } 130 141 } 131 142 143 protected function purgeEntityManager(EntityManager $em) 144 { 145 $classes = array(); 146 $metadatas = $em->getMetadataFactory()->getAllMetadata(); 147 148 foreach ($metadatas as $metadata) 149 { 150 if (!$metadata->isMappedSuperclass) 151 { 152 $classes[] = $metadata; 153 } 154 } 155 $cmf = $em->getMetadataFactory(); 156 $classes = $this->getCommitOrder($em, $classes); 157 for ($i = count($classes) - 1; $i >= 0; --$i) 158 { 159 $class = $classes[$i]; 160 if ($cmf->hasMetadataFor($class->name)) 161 { 162 try { 163 $em->createQuery('DELETE FROM '.$class->name.' a')->execute(); 164 } catch (Exception $e) {} 165 } 166 } 167 } 168 132 169 protected function getCommitOrder(EntityManager $em, array $classes) 133 170 { branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/RunDqlDoctrineCommand.php
r28179 r28330 41 41 ->addOption('dql', null, null, 'The DQL query to run.') 42 42 ->addOption('depth', null, null, 'The depth to output the data to.') 43 ->addOption('connection', null, null, 'The connection to use.') 43 44 ; 44 45 } branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/RunSqlDoctrineCommand.php
r28179 r28330 42 42 ->addOption('file', null, null, 'Path to a SQL file to run.') 43 43 ->addOption('depth', null, null, 'The depth to output the data to.') 44 ->addOption('connection', null, null, 'The connection to use.') 44 45 ; 45 46 } branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/SchemaToolDoctrineCommand.php
r28179 r28330 45 45 ->addOption('re-create', null, null, 'Drop and re-create your database schema.') 46 46 ->addOption('dump-sql', null, null, 'Dump the SQL instead of executing it.') 47 ->addOption('connection', null, null, 'The connection to use.') 47 48 ; 48 49 } … … 56 57 'create', 'drop', 'update', 'complete-update', 're-create', 'dump-sql' 57 58 )); 58 $entityDirs = $this->container->getParameter('doctrine.entity_dirs'); 59 60 $entityDirs = $this->container->getParameter('doctrine.orm.entity_dirs'); 59 61 $options['class-dir'] = implode(', ', $entityDirs); 60 $this->runDoctrineCliTask('orm:schema-tool', $options); 62 63 $found = false; 64 $ems = $this->getDoctrineEntityManagers(); 65 foreach ($ems as $name => $em) 66 { 67 if ($input->getOption('connection') && $name !== $input->getOption('connection')) 68 { 69 continue; 70 } 71 $this->em = $em; 72 $this->runDoctrineCliTask('orm:schema-tool', $options); 73 $found = true; 74 } 75 76 if ($found === false) 77 { 78 if ($input->getOption('connection')) 79 { 80 $output->writeln(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $input->getOption('connection'))); 81 } 82 else 83 { 84 $output->writeln(sprintf('<error>Could not find any configured connections</error>', $input->getOption('connection'))); 85 } 86 } 61 87 } 62 88 } branches/2.0/src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php
r28179 r28330 17 17 18 18 /** 19 * 19 * Doctrine ORM controller gives you access to entity managers and DQL queries. 20 20 * 21 21 * @package symfony 22 22 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 23 * @author Jonathan H. Wage <jonwage@gmail.com> 23 24 */ 24 25 class DoctrineController extends Controller 25 26 { 26 p rotected function getEntityManager()27 public function getDatabaseConnection($name = null) 27 28 { 28 return $this->container->getDoctrine_ORM_EntityManagerService(); 29 if ($name) 30 { 31 return $this->container->getService(sprintf('doctrine.dbal.%s_connection', $name)); 32 } 33 else 34 { 35 return $this->container->getDatabaseConnectionService(); 36 } 29 37 } 30 38 31 public function createQueryBuilder() 39 /** 40 * Get the default entity manager service or the entity manager 41 * with the given name. 42 * 43 * @param string $name Optional entity manager service name 44 * @return object $em 45 */ 46 protected function getEntityManager($name = null) 32 47 { 33 return $this->getEntityManager()->createQueryBuilder(); 48 if ($name) 49 { 50 return $this->container->getService(sprintf('doctrine.orm.%s_entity_manager', $name)); 51 } 52 else 53 { 54 return $this->container->getDoctrine_ORM_EntityManagerService(); 55 } 34 56 } 35 57 36 public function createQuery($dql = '') 58 /** 59 * Create a new QueryBuilder instance. 60 * 61 * @param string $name Optional entity manager service name 62 * @return object QueryBuilder 63 */ 64 public function createQueryBuilder($name = null) 37 65 { 38 return $this->getEntityManager()->createQuery($dql); 66 return $this->getEntityManager($name)->createQueryBuilder(); 67 } 68 69 /** 70 * Create a new Query instance. 71 * 72 * @param string $dql Optional Dql string to create the query from 73 * @param string $name Optional entity manager service name 74 * @return object QueryBuilder 75 */ 76 public function createQuery($dql = '', $name = null) 77 { 78 return $this->getEntityManager($name)->createQuery($dql); 39 79 } 40 80 } branches/2.0/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php
r28179 r28330 6 6 use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; 7 7 use Symfony\Components\DependencyInjection\BuilderConfiguration; 8 use Symfony\Components\DependencyInjection\Definition; 9 use Symfony\Components\DependencyInjection\Reference; 10 use Symfony\Components\DependencyInjection\Container; 8 11 9 12 /* … … 32 35 protected $alias; 33 36 37 public function __construct(Container $container) 38 { 39 $this->container = $container; 40 } 41 34 42 public function setAlias($alias) 35 43 { … … 55 63 $configuration->merge($loader->load($this->resources['dbal'])); 56 64 57 foreach (array('dbname', 'host', 'user', 'password', 'path', 'port') as $key) 58 { 59 if (isset($config[$key])) 60 { 61 $configuration->setParameter('doctrine.dbal.'.$key, $config[$key]); 62 } 63 } 64 65 if (isset($config['options'])) 66 { 67 $configuration->setParameter('doctrine.dbal.driver.options', $config['options']); 68 } 69 70 if (isset($config['driver'])) 71 { 72 $class = $config['driver']; 73 if (in_array($class, array('OCI8', 'PDOMsSql', 'PDOMySql', 'PDOOracle', 'PDOPgSql', 'PDOSqlite'))) 74 { 75 $class = 'Doctrine\\DBAL\\Driver\\'.$class.'\\Driver'; 76 } 77 78 $configuration->setParameter('doctrine.dbal.driver.class', $class); 79 } 80 81 $configuration->setAlias('database_connection', null !== $this->alias ? $this->alias : 'doctrine.dbal.connection'); 65 $defaultConnection = array( 66 'driver' => 'PDOMySQL', 67 'user' => 'root', 68 'password' => null, 69 'host' => 'localhost', 70 'port' => null, 71 'event_manager_class' => 'Doctrine\Common\EventManager', 72 'configuration_class' => 'Doctrine\DBAL\Configuration', 73 'wrapper_class' => null, 74 'options' => array() 75 ); 76 77 $config['default_connection'] = isset($config['default_connection']) ? $config['default_connection'] : 'default'; 78 79 $connections = array(); 80 if (isset($config['connections'])) 81 { 82 foreach ($config['connections'] as $name => $connection) 83 { 84 $connections[isset($connection['id']) ? $connection['id'] : $name] = $connection; 85 } 86 } 87 else 88 { 89 $connections = array($config['default_connection'] => $config); 90 } 91 92 foreach ($connections as $name => $connection) 93 { 94 $connection = array_merge($defaultConnection, $connection); 95 $configurationClass = isset($connection['configuration_class']) ? 96 $connection['configuration_class'] : 'Doctrine\DBAL\Configuration'; 97 98 $configurationDef = new Definition($configurationClass); 99 $configurationDef->addMethodCall('setSqlLogger', array( 100 new Reference('doctrine.dbal.logger') 101 )); 102 $configuration->setDefinition( 103 sprintf('doctrine.dbal.%s_connection.configuration', $name), 104 $configurationDef 105 ); 106 107 $eventManagerDef = new Definition($connection['event_manager_class']); 108 $configuration->setDefinition( 109 sprintf('doctrine.dbal.%s_connection.event_manager', $name), 110 $eventManagerDef 111 ); 112 113 $driverOptions = array(); 114 if (isset($connection['driver'])) 115 { 116 $driverOptions['driverClass'] = sprintf( 117 'Doctrine\\DBAL\\Driver\\%s\\Driver', 118 $connection['driver'] 119 ); 120 } 121 if (isset($connection['wrapper_class'])) 122 { 123 $driverOptions['wrapperClass'] = $connection['wrapper_class']; 124 } 125 if (isset($connection['options'])) 126 { 127 $driverOptions['driverOptions'] = $connection['options']; 128 } 129 foreach (array('dbname', 'host', 'user', 'password', 'path', 'port') as $key) 130 { 131 if (isset($connection[$key])) 132 { 133 $driverOptions[$key] = $connection[$key]; 134 } 135 } 136 $driverArgs = array( 137 $driverOptions, 138 new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)), 139 new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)) 140 ); 141 $driverDef = new Definition('Doctrine\DBAL\DriverManager', $driverArgs); 142 $driverDef->setConstructor('getConnection'); 143 $configuration->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), $driverDef); 144 } 145 146 $configuration->setAlias('database_connection', 147 null !== $this->alias ? $this->alias : sprintf( 148 'doctrine.dbal.%s_connection', $config['default_connection'] 149 ) 150 ); 82 151 83 152 return $configuration; … … 98 167 $configuration->merge($loader->load($this->resources['orm'])); 99 168 100 foreach (array('entity_manager.class', 'metadata_driver_impl.class', 'cache.class') as $key) 169 $config['default_entity_manager'] = isset($config['default_entity_manager']) ? $config['default_entity_manager'] : 'default'; 170 foreach (array('metadata_driver', 'cache_driver') as $key) 101 171 { 102 172 if (isset($config[$key])) … … 106 176 } 107 177 178 $config['entity_managers'] = isset($config['entity_managers']) ? 179 $config['entity_managers'] : array($config['default_entity_manager'] => array()) 180 ; 181 foreach ($config['entity_managers'] as $name => $connection) 182 { 183 $ormConfigDef = new Definition('Doctrine\ORM\Configuration'); 184 $configuration->setDefinition( 185 sprintf('doctrine.orm.%s_configuration', $name), $ormConfigDef 186 ); 187 188 $drivers = array('metadata', 'query', 'result'); 189 foreach ($drivers as $driver) 190 { 191 $definition = $configuration->getDefinition(sprintf('doctrine.orm.cache.%s', $configuration->getParameter('doctrine.orm.cache_driver'))); 192 $clone = clone $definition; 193 $clone->addMethodCall('setNamespace', array(sprintf('doctrine_%s_', $driver))); 194 $configuration->setDefinition(sprintf('doctrine.orm.%s_cache', $driver), $clone); 195 } 196 197 // configure metadata driver for each bundle based on the type of mapping files found 198 $mappingDriverDef = new Definition('Doctrine\ORM\Mapping\Driver\DriverChain'); 199 $bundleEntityMappings = array(); 200 $bundleDirs = $this->container->getParameter('kernel.bundle_dirs'); 201 foreach ($this->container->getParameter('kernel.bundles') as $className) 202 { 203 $tmp = dirname(str_replace('\\', '/', $className)); 204 $namespace = str_replace('/', '\\', dirname($tmp)); 205 $class = basename($tmp); 206 207 if (isset($bundleDirs[$namespace])) 208 { 209 if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata')) 210 { 211 $type = $this->detectMappingType($dir); 212 } 213 elseif (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) 214 { 215 $type = 'annotation'; 216 217 $reader = new \Doctrine\Common\Annotations\AnnotationReader(); 218 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); 219 $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $dir); 220 $classNames = $annotationDriver->getAllClassNames(); 221 foreach ($classNames as $className) 222 { 223 $alias = substr_replace($className, '', 0, strpos($className, '\\') + 1); 224 $alias = str_replace('\Entities\\', '\\', $alias); 225 $ormConfigDef->addMethodCall('addEntityAlias', array($className, $alias)); 226 } 227 } 228 else 229 { 230 $type = false; 231 } 232 233 if (false !== $type) 234 { 235 $mappingDriverDef->addMethodCall('addDriver', array( 236 new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)), 237 $namespace.'\\'.$class.'\\Entities' 238 ) 239 ); 240 } 241 } 242 } 243 244 $configuration->setDefinition('doctrine.orm.metadata_driver', $mappingDriverDef); 245 246 $methods = array( 247 'setMetadataCacheImpl' => new Reference('doctrine.orm.metadata_cache'), 248 'setQueryCacheImpl' => new Reference('doctrine.orm.query_cache'), 249 'setResultCacheImpl' => new Reference('doctrine.orm.result_cache'), 250 'setMetadataDriverImpl' => new Reference('doctrine.orm.metadata_driver'), 251 'setProxyDir' => '%kernel.cache_dir%/doctrine/Proxies', 252 'setProxyNamespace' => 'Proxies', 253 'setAutoGenerateProxyClasses' => true 254 ); 255 256 foreach ($methods as $method => $arg) 257 { 258 $ormConfigDef->addMethodCall($method, array($arg)); 259 } 260 261 $ormEmArgs = array( 262 new Reference( 263 sprintf('doctrine.dbal.%s_connection', 264 isset($connection['connection']) ? $connection['connection'] : $name) 265 ), 266 new Reference(sprintf('doctrine.orm.%s_configuration', $name)) 267 ); 268 $ormEmDef = new Definition('Doctrine\ORM\EntityManager', $ormEmArgs); 269 $ormEmDef->setConstructor('create'); 270 271 $configuration->setDefinition( 272 sprintf('doctrine.orm.%s_entity_manager', $name), 273 $ormEmDef 274 ); 275 276 if ($name == $config['default_entity_manager']) 277 { 278 $configuration->setAlias( 279 'doctrine.orm.entity_manager', 280 sprintf('doctrine.orm.%s_entity_manager', $name) 281 ); 282 } 283 } 284 285 $configuration->setAlias( 286 'doctrine.orm.cache', 287 sprintf( 288 'doctrine.orm.cache.%s', 289 $configuration->getParameter('doctrine.orm.cache_driver') 290 ) 291 ); 292 108 293 return $configuration; 109 294 } 110 295 111 296 /** 297 * Detect the type of Doctrine 2 mapping files located in a given directory. 298 * Simply finds the first file in a directory and returns the extension. If no 299 * mapping files are found then the annotation type is returned. 300 * 301 * @param string $dir 302 * @return string $type 303 */ 304 protected function detectMappingType($dir) 305 { 306 $files = glob($dir.'/*.*'); 307 if (!$files) 308 { 309 return 'annotation'; 310 } 311 $info = pathinfo($files[0]); 312 313 return $info['extension']; 314 } 315 316 /** 112 317 * Returns the base path for the XSD files. 113 318 * branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/dbal.xml
r28096 r28330 6 6 7 7 <parameters> 8 <parameter key="doctrine.dbal.dbname">null</parameter> 9 <parameter key="doctrine.dbal.user">root</parameter> 10 <parameter key="doctrine.dbal.password"></parameter> 11 <parameter key="doctrine.dbal.host">localhost</parameter> 12 <parameter key="doctrine.dbal.port">null</parameter> 13 <parameter key="doctrine.dbal.path">null</parameter> 14 <parameter key="doctrine.dbal.driver.class">Doctrine\DBAL\Driver\PDOMySql\Driver</parameter> 15 <parameter key="doctrine.dbal.driver.options" type="collection" /> 16 <parameter key="doctrine.dbal.wrapper.class">Doctrine\DBAL\Connection</parameter> 17 <parameter key="doctrine.dbal.configuration.class">Doctrine\DBAL\Configuration</parameter> 18 <parameter key="doctrine.dbal.event_manager.class">Doctrine\Common\EventManager</parameter> 19 <parameter key="doctrine.debug.collector.class">Symfony\Framework\DoctrineBundle\Debug\DoctrineDataCollector</parameter> 8 <parameter key="doctrine.debug.collector.class"> 9 Symfony\Framework\DoctrineBundle\Debug\DoctrineDataCollector 10 </parameter> 20 11 </parameters> 21 12 22 13 <services> 23 <service id="doctrine.dbal.connection" class="Doctrine\DBAL\DriverManager" constructor="getConnection">24 <argument type="collection">25 <argument key="dbname">%doctrine.dbal.dbname%</argument>26 <argument key="user">%doctrine.dbal.user%</argument>27 <argument key="password">%doctrine.dbal.password%</argument>28 <argument key="host">%doctrine.dbal.host%</argument>29 <argument key="port">%doctrine.dbal.port%</argument>30 <argument key="path">%doctrine.dbal.path%</argument>31 <argument key="driverClass">%doctrine.dbal.driver.class%</argument>32 <argument key="driverOptions">%doctrine.dbal.driver.options%</argument>33 <!--34 <argument key="wrapperClass">%doctrine.dbal.wrapper.class%</argument>35 //-->36 </argument>37 <argument type="service" id="doctrine.dbal.configuration" />38 <argument type="service" id="doctrine.dbal.event_manager" />39 </service>40 41 <service id="doctrine.dbal.configuration" class="%doctrine.dbal.configuration.class%">42 <call method="setSqlLogger"><argument type="service" id="doctrine.dbal.logger" on-invalid="ignore" /></call>43 </service>44 45 14 <service id="doctrine.dbal.logger.debug" class="Doctrine\DBAL\Logging\DebugStack" /> 46 47 <service id="doctrine.dbal.event_manager" class="%doctrine.dbal.event_manager.class%" />48 15 49 16 <service id="doctrine.dbal.logger" class="Symfony\Framework\DoctrineBundle\Logger\DbalLogger"> branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/orm.xml
r28179 r28330 6 6 7 7 <parameters> 8 <parameter key="doctrine.orm. entity_manager.class">Doctrine\ORM\EntityManager</parameter>9 <parameter key="doctrine.orm. metadata_driver_impl.class">Doctrine\ORM\Mapping\Driver\XmlDriver</parameter>10 <parameter key="doctrine.orm.cache. class">Doctrine\Common\Cache\ArrayCache</parameter>8 <parameter key="doctrine.orm.cache_driver">array</parameter> 9 <parameter key="doctrine.orm.cache.memcache.host">localhost</parameter> 10 <parameter key="doctrine.orm.cache.memcache.port">11211</parameter> 11 11 </parameters> 12 12 13 13 <services> 14 <service id="doctrine.orm.entity_manager" class="%doctrine.orm.entity_manager.class%" constructor="create"> 15 <argument type="service" id="doctrine.dbal.connection" /> 16 <argument type="service" id="doctrine.orm.configuration" /> 14 <!--- Should we just move all this to php code? is it best to go one way or the other? --> 15 16 <!--- Annotation Metadata Driver Service --> 17 <service id="doctrine.orm.metadata_driver.annotation" class="Doctrine\ORM\Mapping\Driver\AnnotationDriver"> 18 <argument type="service" id="doctrine.orm.metadata_driver.annotation.reader" /> 19 <argument>%doctrine.orm.entity_dirs%</argument> 17 20 </service> 18 21 19 <service id="doctrine.orm.metadata_driver_impl" class="%doctrine.orm.metadata_driver_impl.class%"> 20 <argument>%doctrine.orm.metadata_driver_impl.dirs%</argument> 22 <service id="doctrine.orm.metadata_driver.annotation.reader" class="Doctrine\Common\Annotations\AnnotationReader"> 23 <argument type="service" id="doctrine.orm.cache" /> 24 <call method="setDefaultAnnotationNamespace"><argument>Doctrine\ORM\Mapping\</argument></call> 21 25 </service> 22 26 23 <service id="doctrine.orm.cache" class="%doctrine.orm.cache.class%" /> 27 <!--- XML Metadata Driver Service --> 28 <service id="doctrine.orm.metadata_driver.xml" class="Doctrine\ORM\Mapping\Driver\XmlDriver"> 29 <argument>%doctrine.orm.metadata_driver.mapping_dirs%</argument> 30 </service> 24 31 25 <service id="doctrine.orm.configuration" class="Doctrine\ORM\Configuration"> 26 <call method="setMetadataCacheImpl"><argument type="service" id="doctrine.orm.cache" /></call> 27 <call method="setQueryCacheImpl"><argument type="service" id="doctrine.orm.cache" /></call> 28 <call method="setResultCacheImpl"><argument type="service" id="doctrine.orm.cache" /></call> 29 <call method="setMetadataDriverImpl"><argument type="service" id="doctrine.orm.metadata_driver_impl" /></call> 30 <call method="setProxyDir"><argument>%kernel.cache_dir%/doctrine/Proxies</argument></call> 31 <call method="setProxyNamespace"><argument>Proxies</argument></call> 32 <call method="setAutoGenerateProxyClasses"><argument>true</argument></call> 32 <!--- YAML Metadata Driver Service --> 33 <service id="doctrine.orm.metadata_driver.yml" class="Doctrine\ORM\Mapping\Driver\YamlDriver"> 34 <argument>%doctrine.orm.metadata_driver.mapping_dirs%</argument> 33 35 </service> 36 37 <!--- ORM Array Cache Driver Service --> 38 <service id="doctrine.orm.cache.array" class="Doctrine\Common\Cache\ArrayCache" /> 39 40 <!--- ORM APC Cache Driver Service --> 41 <service id="doctrine.orm.cache.apc" class="Doctrine\Common\Cache\ApcCache" /> 42 43 <!--- ORM Memcache Cache Driver Service --> 44 <service id="doctrine.orm.cache.memcache" class="Doctrine\Common\Cache\MemcacheCache"> 45 <call method="setMemcache"><argument type="service" id="doctrine.orm.cache.memcache.instance" /></call> 46 </service> 47 48 <!--- ORM Memcache Cache Driver Memcache instance. See doctrine.orm.cache.memcache --> 49 <service id="doctrine.orm.cache.memcache.instance" class="Memcache"> 50 <call method="connect"> 51 <argument>%doctrine.orm.cache.memcache.host%</argument> 52 <argument>%doctrine.orm.cache.memcache.port%</argument> 53 </call> 54 </service> 55 56 <!--- ORM Xcache Cache Driver Service --> 57 <service id="doctrine.orm.cache.xcache" class="Doctrine\Common\Cache\XcacheCache" /> 34 58 </services> 35 59 </container> branches/2.0/src/Symfony/Framework/DoctrineBundle/Resources/config/schema/dic/doctrine/doctrine-1.0.xsd
r28142 r28330 9 9 10 10 <xsd:complexType name="dbal"> 11 <xsd:sequence> 12 <xsd:element name="connections" type="connections" minOccurs="0" maxOccurs="1" /> 13 </xsd:sequence> 14 15 <xsd:attribute name="default_connection" type="xsd:string" /> 11 16 <xsd:attribute name="dbname" type="xsd:string" /> 12 17 <xsd:attribute name="host" type="xsd:string" /> … … 18 23 <xsd:attribute name="path" type="xsd:string" /> 19 24 </xsd:complexType> 25 26 <xsd:complexType name="connections"> 27 <xsd:sequence> 28 <xsd:element name="connection" type="connection" minOccurs="1" maxOccurs="unbounded" /> 29 </xsd:sequence> 30 </xsd:complexType> 31 32 <xsd:complexType name="connection"> 33 <xsd:attribute name="id" type="xsd:string" use="required" /> 34 <xsd:attribute name="dbname" type="xsd:string" use="required" /> 35 <xsd:attribute name="host" type="xsd:string" /> 36 <xsd:attribute name="port" type="xsd:integer" /> 37 <xsd:attribute name="user" type="xsd:string" /> 38 <xsd:attribute name="password" type="xsd:string" /> 39 <xsd:attribute name="driver" type="xsd:string" /> 40 <xsd:attribute name="options" type="xsd:string" /> 41 <xsd:attribute name="path" type="xsd:string" /> 42 </xsd:complexType> 20 43 </xsd:schema> branches/2.0/src/Symfony/Framework/WebBundle/Bundle.php
r28142 r28330 6 6 use Symfony\Components\DependencyInjection\ContainerInterface; 7 7 use Symfony\Components\DependencyInjection\Loader\Loader; 8 use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; 9 use Symfony\Components\DependencyInjection\BuilderConfiguration; 8 10 use Symfony\Framework\WebBundle\DependencyInjection\WebExtension; 9 11 … … 35 37 } 36 38 $container->setParameter('templating.loader.filesystem.path', $dirs); 39 40 $configuration = new BuilderConfiguration(); 41 if ($container->getParameter('kernel.debug')) 42 { 43 $loader = new XmlFileLoader(__DIR__.'/Resources/config'); 44 $configuration->merge($loader->load('debug.xml')); 45 } 46 47 return $configuration; 37 48 } 38 49 } branches/2.0/src/Symfony/Framework/WebBundle/Console/Application.php
r28096 r28330 39 39 $this->definition->addOption(new InputOption('--shell', '-s', InputOption::PARAMETER_NONE, 'Launch the shell.')); 40 40 41 $this->kernel->boot(); 41 if (!$this->kernel->isBooted()) 42 { 43 $this->kernel->boot(); 44 } 42 45 43 46 $this->registerCommands(); … … 93 96 foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($commandDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) 94 97 { 95 if ($file->isDir() )98 if ($file->isDir() || strpos($file, -4) !== '.php') 96 99 { 97 100 continue; branches/2.0/src/Symfony/Framework/WebBundle/Controller.php
r28096 r28330 15 15 16 16 /** 17 * 17 * WebBundle Controller gives you convenient access to all commonly needed services. 18 18 * 19 19 * @package symfony … … 37 37 { 38 38 return $this->container->getUserService(); 39 }40 41 public function getDatabaseConnection()42 {43 return $this->container->getDatabaseConnectionService();44 39 } 45 40 branches/2.0/src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php
r28096 r28330 169 169 } 170 170 171 $linkFormat = $this->container->hasParameter(' web_debug.file_link_format') ? $this->container->getParameter('web_debug.file_link_format') : ini_get('xdebug.file_link_format');171 $linkFormat = $this->container->hasParameter('debug.file_link_format') ? $this->container->getParameter('debug.file_link_format') : ini_get('xdebug.file_link_format'); 172 172 if ('html' === $format && $file && $line && $linkFormat) 173 173 { branches/2.0/src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php
r28096 r28330 5 5 use Symfony\Components\DependencyInjection\Loader\LoaderExtension; 6 6 use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; 7 use Symfony\Components\DependencyInjection\Builder;8 7 use Symfony\Components\DependencyInjection\BuilderConfiguration; 9 8 use Symfony\Components\DependencyInjection\Reference; … … 39 38 $loader = new XmlFileLoader(__DIR__.'/../Resources/config'); 40 39 $configuration->merge($loader->load($this->resources['web'])); 40 41 if (isset($config['ide']) && 'textmate' === $config['ide']) 42 { 43 $configuration->setParameter('debug.file_link_format', 'txmt://open?url=file://%%f&line=%%l'); 44 } 41 45 42 46 return $configuration; … … 148 152 $configuration = new BuilderConfiguration(); 149 153 150 $loader = new XmlFileLoader(__DIR__.'/../Resources/config');151 $configuration->merge($loader->load($this->resources['debug']));152 153 if (isset($config['exception']) && $config['exception'])154 {155 $configuration->merge($loader->load('debug_exception_handler.xml'));156 }157 158 154 if (isset($config['toolbar']) && $config['toolbar']) 159 155 { 156 $loader = new XmlFileLoader(__DIR__.'/../Resources/config'); 160 157 $configuration->merge($loader->load('debug_data_collector.xml')); 161 158 $configuration->merge($loader->load('debug_web_debug_toolbar.xml')); 162 159 } 163 164 if (isset($config['ide']) && 'textmate' === $config['ide'])165 {166 $configuration->setParameter('web_debug.file_link_format', 'txmt://open?url=file://%%f&line=%%l');167 }168 169 $configuration->setAlias('event_dispatcher', 'debug.event_dispatcher');170 160 171 161 return $configuration; branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/debug.xml
r28096 r28330 6 6 7 7 <parameters> 8 <parameter key=" symfony.templating.debugger.class">Symfony\Framework\WebBundle\Templating\Debugger</parameter>8 <parameter key="templating.debugger.class">Symfony\Framework\WebBundle\Templating\Debugger</parameter> 9 9 </parameters> 10 10 11 11 <services> 12 <service id=" symfony.templating.debugger" class="%symfony.templating.debugger.class%">12 <service id="templating.debugger" class="%templating.debugger.class%"> 13 13 <argument type="service" id="logger" on-invalid="null" /> 14 14 </service> branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/schema/dic/symfony/symfony-1.0.xsd
r28096 r28330 33 33 34 34 <xsd:complexType name="web"> 35 <xsd:attribute name="ide" type="xsd:string" /> 35 36 </xsd:complexType> 36 37 … … 47 48 48 49 <xsd:complexType name="debug"> 49 <xsd:attribute name="exception" type="xsd:string" />50 50 <xsd:attribute name="toolbar" type="xsd:string" /> 51 <xsd:attribute name="ide" type="xsd:string" />52 51 </xsd:complexType> 53 52 </xsd:schema> branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/web.xml
r28096 r28330 10 10 <parameter key="router.class">Symfony\Components\Routing\Router</parameter> 11 11 <parameter key="response_filter.class">Symfony\Framework\WebBundle\Listener\ResponseFilter</parameter> 12 13 <parameter key="exception_handler.class">Symfony\Framework\WebBundle\Listener\ExceptionHandler</parameter> 14 <parameter key="exception_handler.bundle">WebBundle</parameter> 15 <parameter key="exception_handler.controller">Exception</parameter> 16 <parameter key="exception_handler.action">exception</parameter> 12 17 </parameters> 13 18 … … 44 49 <argument type="service" id="request" /> 45 50 </service> 51 52 <service id="exception_handler" class="%exception_handler.class%"> 53 <annotation name="kernel.listener" event="core.exception" method="handle" /> 54 <argument type="service" id="service_container" /> 55 <argument type="service" id="logger" on-invalid="null" /> 56 <argument>%exception_handler.bundle%</argument> 57 <argument>%exception_handler.controller%</argument> 58 <argument>%exception_handler.action%</argument> 59 </service> 46 60 </services> 47 61 </container> branches/2.0/src/Symfony/Framework/WebBundle/Templating/Engine.php
r28096 r28330 117 117 protected function splitTemplateName($name) 118 118 { 119 $parts = explode(':', $name, 3);119 $parts = explode(':', $name, 4); 120 120 121 121 $options = array(