Skip to content

Commit 92a8708

Browse files
committed
merged symfony master
2 parents bc26538 + 4e0204d commit 92a8708

25 files changed

+732
-43
lines changed

README

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ flexibility in mind. It allows developers to built better and easy to maintain
99
websites with PHP.
1010

1111
Symfony can be used to develop all kind of websites, from your personal blog
12-
to hight traffic ones like Dailymotion or Yahoo! Answers.
12+
to high traffic ones like Dailymotion or Yahoo! Answers.
1313

1414
High Performance
1515
----------------
1616

17-
Built with performance in mind, Symfony 2 is one of the fastest PHP framework.
18-
It is up to 3 times faster than symfony 1.4 or Zend Framework 1.10 and
19-
consumes half the memory.
17+
Built with performance in mind, Symfony 2 is one of the fastest PHP
18+
frameworks. It is up to 3 times faster than symfony 1.4 or Zend Framework 1.10
19+
and consumes half the memory.
2020

2121
Requirements
2222
------------
@@ -26,14 +26,14 @@ Symfony is only supported on PHP 5.3.0 and up.
2626
Documentation
2727
-------------
2828

29-
Symfony 2.0 is still in the early stages of development, but the "[Quick Tour][1]"
30-
tutorial can get you started fast.
29+
Symfony 2.0 is still in the early stages of development, but the
30+
"[Quick Tour][1]" tutorial can get you started fast.
3131

3232
The "Quick Tour" tutorial barely scratches the surface of Symfony 2.0 but it
33-
gives you a first feeling of the framework. If like us you think that Symfony
34-
2.0 can be of great help to speed up your development and take the quality of
35-
your work to the next level, visit the official [Symfony 2 website][2] to
36-
learn about it.
33+
gives you a first feeling of the framework. If, like us, you think that
34+
Symfony 2.0 can help speed up your development and take the quality of your
35+
work to the next level, visit the official [Symfony 2 website][2] to learn
36+
more.
3737

3838
[1]: http://symfony-reloaded.org/learn
3939
[2]: http://symfony-reloaded.org/

src/Symfony/Components/Templating/Helper/JavascriptsHelper.php

+21-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function get()
5151
}
5252

5353
/**
54-
* Returns a string representation of this helper as HTML.
54+
* Returns HTML representation of the links to JavaScripts.
5555
*
5656
* @return string The HTML representation of the JavaScripts
5757
*/
58-
public function __toString()
58+
public function render()
5959
{
6060
$html = '';
6161
foreach ($this->javascripts as $path => $attributes)
@@ -72,6 +72,25 @@ public function __toString()
7272
return $html;
7373
}
7474

75+
/**
76+
* Outputs HTML representation of the links to JavaScripts.
77+
*
78+
*/
79+
public function output()
80+
{
81+
echo $this->render();
82+
}
83+
84+
/**
85+
* Returns a string representation of this helper as HTML.
86+
*
87+
* @return string The HTML representation of the JavaScripts
88+
*/
89+
public function __toString()
90+
{
91+
return $this->render();
92+
}
93+
7594
/**
7695
* Returns the canonical name of this helper.
7796
*

src/Symfony/Components/Templating/Helper/StylesheetsHelper.php

+21-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function get()
5151
}
5252

5353
/**
54-
* Returns a string representation of this helper as HTML.
54+
* Returns HTML representation of the links to stylesheets.
5555
*
5656
* @return string The HTML representation of the stylesheets
5757
*/
58-
public function __toString()
58+
public function render()
5959
{
6060
$html = '';
6161
foreach ($this->stylesheets as $path => $attributes)
@@ -72,6 +72,25 @@ public function __toString()
7272
return $html;
7373
}
7474

75+
/**
76+
* Outputs HTML representation of the links to stylesheets.
77+
*
78+
*/
79+
public function output()
80+
{
81+
echo $this->render();
82+
}
83+
84+
/**
85+
* Returns a string representation of this helper as HTML.
86+
*
87+
* @return string The HTML representation of the stylesheets
88+
*/
89+
public function __toString()
90+
{
91+
return $this->render();
92+
}
93+
7594
/**
7695
* Returns the canonical name of this helper.
7796
*

src/Symfony/Foundation/Kernel.php

+7
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ public function getParameters()
180180

181181
public function getDefaultParameters()
182182
{
183+
$bundles = array();
184+
foreach ($this->bundles as $bundle)
185+
{
186+
$bundles[] = get_class($bundle);
187+
}
188+
183189
return array_merge(
184190
array(
185191
'kernel.root_dir' => $this->rootDir,
@@ -189,6 +195,7 @@ public function getDefaultParameters()
189195
'kernel.cache_dir' => $this->rootDir.'/cache/'.$this->environment,
190196
'kernel.logs_dir' => $this->rootDir.'/logs',
191197
'kernel.bundle_dirs' => $this->bundleDirs,
198+
'kernel.bundles' => $bundles,
192199
'kernel.charset' => 'UTF-8',
193200
),
194201
$this->getEnvParameters(),

src/Symfony/Foundation/bootstrap.php

+7
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ public function getParameters()
448448

449449
public function getDefaultParameters()
450450
{
451+
$bundles = array();
452+
foreach ($this->bundles as $bundle)
453+
{
454+
$bundles[] = get_class($bundle);
455+
}
456+
451457
return array_merge(
452458
array(
453459
'kernel.root_dir' => $this->rootDir,
@@ -457,6 +463,7 @@ public function getDefaultParameters()
457463
'kernel.cache_dir' => $this->rootDir.'/cache/'.$this->environment,
458464
'kernel.logs_dir' => $this->rootDir.'/logs',
459465
'kernel.bundle_dirs' => $this->bundleDirs,
466+
'kernel.bundles' => $bundles,
460467
'kernel.charset' => 'UTF-8',
461468
),
462469
$this->getEnvParameters(),

src/Symfony/Framework/DoctrineBundle/Bundle.php

+26-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,36 @@
2222
*
2323
* @package symfony
2424
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
25+
* @author Jonathan H. Wage <jonwage@gmail.com>
2526
*/
2627
class Bundle extends BaseBundle
2728
{
2829
public function buildContainer(ContainerInterface $container)
2930
{
3031
Loader::registerExtension(new DoctrineExtension());
32+
33+
$metadataDirs = array();
34+
$entityDirs = array();
35+
$bundleDirs = $container->getParameter('kernel.bundle_dirs');
36+
foreach ($container->getParameter('kernel.bundles') as $className)
37+
{
38+
$tmp = dirname(str_replace('\\', '/', $className));
39+
$namespace = dirname($tmp);
40+
$class = basename($tmp);
41+
42+
if (isset($bundleDirs[$namespace]))
43+
{
44+
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata'))
45+
{
46+
$metadataDirs[] = $dir;
47+
}
48+
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
49+
{
50+
$entityDirs[] = $dir;
51+
}
52+
}
53+
}
54+
$container->setParameter('doctrine.orm.metadata_driver_impl.dirs', $metadataDirs);
55+
$container->setParameter('doctrine.entity_dirs', $entityDirs);
3156
}
32-
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Symfony\Framework\DoctrineBundle\Command;
4+
5+
use Symfony\Components\Console\Input\InputArgument;
6+
use Symfony\Components\Console\Input\InputOption;
7+
use Symfony\Components\Console\Input\InputInterface;
8+
use Symfony\Components\Console\Output\OutputInterface;
9+
use Symfony\Components\Console\Output\Output;
10+
use Symfony\Framework\WebBundle\Util\Filesystem;
11+
use Doctrine\Common\Cli\Configuration;
12+
use Doctrine\Common\Cli\CliController as DoctrineCliController;
13+
14+
/*
15+
* This file is part of the symfony framework.
16+
*
17+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
18+
*
19+
* This source file is subject to the MIT license that is bundled
20+
* with this source code in the file LICENSE.
21+
*/
22+
23+
/**
24+
* Manage the cache clearing of the Doctrine ORM.
25+
*
26+
* @package symfony
27+
* @subpackage console
28+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
29+
* @author Jonathan H. Wage <jonwage@gmail.com>
30+
*/
31+
class ClearCacheDoctrineCommand extends DoctrineCommand
32+
{
33+
/**
34+
* @see Command
35+
*/
36+
protected function configure()
37+
{
38+
$this
39+
->setName('doctrine:clear-cache')
40+
->setDescription('Clear cache from configured query, result and metadata drivers.')
41+
->setAliases(array('doctrine:cc'))
42+
->addOption('query', null, null, 'Clear the query cache.')
43+
->addOption('metadata', null, null, 'Clear the metadata cache.')
44+
->addOption('result', null, null, 'Clear the result cache.')
45+
->addOption('id', null, null, 'Clear a cache entry by its id.')
46+
->addOption('regex', null, null, 'Clear cache entries that match a regular expression.')
47+
->addOption('prefix', null, null, 'Clear cache entries that match a prefix.')
48+
->addOption('suffix', null, null, 'Clear cache entries that match a suffix.')
49+
;
50+
}
51+
52+
/**
53+
* @see Command
54+
*/
55+
protected function execute(InputInterface $input, OutputInterface $output)
56+
{
57+
$options = $this->buildDoctrineCliTaskOptions($input, array(
58+
'query', 'metadata', 'result', 'id', 'regex', 'prefix', 'suffix'
59+
));
60+
$this->runDoctrineCliTask('orm:clear-cache', $options);
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Symfony\Framework\DoctrineBundle\Command;
4+
5+
use Symfony\Components\Console\Input\InputArgument;
6+
use Symfony\Components\Console\Input\InputOption;
7+
use Symfony\Components\Console\Input\InputInterface;
8+
use Symfony\Components\Console\Output\OutputInterface;
9+
use Symfony\Components\Console\Output\Output;
10+
use Symfony\Framework\WebBundle\Util\Filesystem;
11+
use Doctrine\Common\Cli\Configuration;
12+
use Doctrine\Common\Cli\CliController as DoctrineCliController;
13+
14+
/*
15+
* This file is part of the symfony framework.
16+
*
17+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
18+
*
19+
* This source file is subject to the MIT license that is bundled
20+
* with this source code in the file LICENSE.
21+
*/
22+
23+
/**
24+
* Convert Doctrine ORM metadata mapping information between the various supported
25+
* formats.
26+
*
27+
* @package symfony
28+
* @subpackage console
29+
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
30+
* @author Jonathan H. Wage <jonwage@gmail.com>
31+
*/
32+
class ConvertMappingDoctrineCommand extends DoctrineCommand
33+
{
34+
/**
35+
* @see Command
36+
*/
37+
protected function configure()
38+
{
39+
$this
40+
->setName('doctrine:convert-mapping')
41+
->setDescription('Convert mapping information between supported formats.')
42+
->addOption('from', null, null, 'The source to convert from.')
43+
->addOption('to', null, null, 'The type of mapping to convert to.')
44+
->addOption('dest', null, null, 'Where to output the converted source.')
45+
;
46+
}
47+
48+
/**
49+
* @see Command
50+
*/
51+
protected function execute(InputInterface $input, OutputInterface $output)
52+
{
53+
$options = $this->buildDoctrineCliTaskOptions($input, array(
54+
'from', 'to', 'dest'
55+
));
56+
$this->runDoctrineCliTask('orm:convert-mapping', $options);
57+
}
58+
}

src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php

+45-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Symfony\Components\Console\Output\Output;
1111
use Symfony\Framework\WebBundle\Util\Filesystem;
1212
use Doctrine\Common\Cli\Configuration;
13+
use Doctrine\Common\Cli\CliController as DoctrineCliController;
1314

1415
/*
1516
* This file is part of the symfony framework.
@@ -21,12 +22,54 @@
2122
*/
2223

2324
/**
24-
*
25+
* Base class for Doctrine consol commands to extend from.
2526
*
2627
* @package symfony
2728
* @subpackage console
2829
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
2930
*/
3031
abstract class DoctrineCommand extends Command
3132
{
32-
}
33+
protected $cli;
34+
35+
protected function getDoctrineCli()
36+
{
37+
if ($this->cli === null)
38+
{
39+
$configuration = new Configuration();
40+
$configuration->setAttribute('em', $this->container->getDoctrine_Orm_EntityManagerService());
41+
$this->cli = new DoctrineCliController($configuration);
42+
}
43+
return $this->cli;
44+
}
45+
46+
protected function runDoctrineCliTask($name, $options = array())
47+
{
48+
$builtOptions = array();
49+
foreach ($options as $key => $value)
50+
{
51+
if ($value === null)
52+
{
53+
$builtOptions[] = sprintf('--%s', $key);
54+
}
55+
else
56+
{
57+
$builtOptions[] = sprintf('--%s=%s', $key, $value);
58+
}
59+
}
60+
return $this->getDoctrineCli()->run(array_merge(array('doctrine', $name), $builtOptions));
61+
}
62+
63+
public function buildDoctrineCliTaskOptions(InputInterface $input, array $options)
64+
{
65+
$taskOptions = array();
66+
foreach ($options as $option)
67+
{
68+
if ($value = $input->getOption($option))
69+
{
70+
$options[$option] = $value;
71+
}
72+
}
73+
return $options;
74+
}
75+
}

0 commit comments

Comments
 (0)