Kaynağa Gözat

Merge branch 'master' into experimental

Bernhard Schussek 14 yıl önce
ebeveyn
işleme
eca2b87313
18 değiştirilmiş dosya ile 296 ekleme ve 102 silme
  1. 8 4
      src/Symfony/Bundle/AsseticBundle/Resources/config/assetic.xml
  2. 0 4
      src/Symfony/Bundle/AsseticBundle/Tests/DependencyInjection/AsseticExtensionTest.php
  3. 4 2
      src/Symfony/Bundle/DoctrineBundle/Resources/views/Collector/db.html.twig
  4. 132 0
      src/Symfony/Bundle/DoctrineMigrationsBundle/Command/MigrationsGenerateFromDataFixturesCommand.php
  5. 22 0
      src/Symfony/Bundle/DoctrineMigrationsBundle/SQLLogger/FixturesToMigrationSQLLogger.php
  6. 4 2
      src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/views/Collector/mongodb.html.twig
  7. 25 26
      src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php
  8. 0 1
      src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml
  9. 10 8
      src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig
  10. 1 2
      src/Symfony/Bundle/TwigBundle/TwigEngine.php
  11. 12 6
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig
  12. 4 2
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig
  13. 4 2
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig
  14. 4 2
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
  15. 4 2
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/timer.html.twig
  16. 48 0
      src/Symfony/Bundle/ZendBundle/DependencyInjection/Configuration.php
  17. 14 38
      src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php
  18. 0 1
      src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml

+ 8 - 4
src/Symfony/Bundle/AsseticBundle/Resources/config/assetic.xml

@@ -21,6 +21,7 @@
         <parameter key="assetic.filter.sass.class">Assetic\Filter\Sass\SassFilter</parameter>
         <parameter key="assetic.filter.scss.class">Assetic\Filter\Sass\ScssFilter</parameter>
         <parameter key="assetic.filter.sprockets.class">Assetic\Filter\SprocketsFilter</parameter>
+        <parameter key="assetic.filter.stylus.class">Assetic\Filter\StylusFilter</parameter>
 
         <parameter key="assetic.java_bin">/usr/bin/java</parameter>
         <parameter key="assetic.sass_bin">/usr/bin/sass</parameter>
@@ -52,7 +53,6 @@
         <!-- filters -->
         <service id="assetic.filter.cssrewrite" class="%assetic.filter.cssrewrite.class%">
             <tag name="assetic.filter" alias="cssrewrite" />
-            <argument type="service" id="assetic.css_tokenizer" />
         </service>
         <service id="assetic.filter.less" class="%assetic.filter.less.class%">
             <tag name="assetic.filter" alias="less" />
@@ -81,16 +81,20 @@
             <argument>%assetic.coffee_bin%</argument>
             <argument>%assetic.node_bin%</argument>
         </service>
+        <service id="assetic.filter.stylus" class="%assetic.filter.stylus.class%">
+            <tag name="assetic.filter" alias="stylus" />
+            <argument>%assetic.document_root%</argument>
+            <argument>%assetic.node_bin%</argument>
+            <argument>%assetic.node_paths%</argument>
+        </service>
 
         <!-- other -->
-        <service id="assetic.css_tokenizer" class="PHP_CodeSniffer_Tokenizers_CSS" public="false">
-            <file>PHP/CodeSniffer.php</file>
-        </service>
         <service id="assetic.config_cache" class="%assetic.config_cache.class%" public="false">
             <argument>%assetic.cache_dir%/config</argument>
         </service>
         <service id="assetic.asset_manager_cache_warmer" class="%assetic.asset_manager_cache_warmer.class%" public="false">
             <tag name="kernel.cache_warmer" priority="10" />
+            <argument type="service" id="assetic.asset_manager" />
         </service>
     </services>
 </container>

+ 0 - 4
src/Symfony/Bundle/AsseticBundle/Tests/DependencyInjection/AsseticExtensionTest.php

@@ -43,10 +43,6 @@ class AsseticExtensionTest extends \PHPUnit_Framework_TestCase
             $this->markTestSkipped('Assetic is not available.');
         }
 
-        if (false === @include_once 'PHP/CodeSniffer.php') {
-            $this->markTestSkipped('PHP_CodeSniffer is not installed.');
-        }
-
         $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel')
             ->disableOriginalConstructor()
             ->getMock();

Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/DoctrineBundle/Resources/views/Collector/db.html.twig


+ 132 - 0
src/Symfony/Bundle/DoctrineMigrationsBundle/Command/MigrationsGenerateFromDataFixturesCommand.php

@@ -0,0 +1,132 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\DoctrineMigrationsBundle\Command;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
+use Symfony\Bundle\FrameworkBundle\Command\Command;
+use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
+use Doctrine\Common\DataFixtures\Purger\ORMPurger;
+use Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader as DataFixturesLoader;
+use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
+use Doctrine\DBAL\Migrations\Configuration\Configuration;
+use Symfony\Bundle\DoctrineMigrationsBundle\SQLLogger\FixturesToMigrationSQLLogger;
+use Symfony\Bundle\DoctrineMigrationsBundle\Command\DoctrineCommand;
+
+/**
+ * Command for generating a Doctrine database migration class from a set of fixtures.
+ *
+ * @author Jonathan H. Wage <jonwage@gmail.com>
+ */
+class MigrationsGenerateFromDataFixturesCommand extends GenerateCommand
+{
+    protected function configure()
+    {
+        parent::configure();
+
+        $this
+            ->setName('doctrine:migrations:generate:from-data-fixtures')
+            ->addOption('fixtures', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The directory or file to load data fixtures from.')
+            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command.')
+        ;
+    }
+
+    public function execute(InputInterface $input, OutputInterface $output)
+    {
+        if ( ! class_exists('Doctrine\Common\DataFixtures\Loader')) {
+            throw new \Exception('You must have the Doctrine data fixtures extension installed in order to use this command.');
+        }
+
+        $sqlLogger = new FixturesToMigrationSQLLogger();
+
+        $container = $this->application->getKernel()->getContainer();
+
+        $emName = $input->getOption('em');
+        $emName = $emName ? $emName : 'default';
+
+        DoctrineCommand::setApplicationEntityManager($this->application, $emName);
+
+        $configuration = $this->getMigrationConfiguration($input, $output);
+        DoctrineCommand::configureMigrations($this->application->getKernel()->getContainer(), $configuration);
+
+        $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
+        $em = $container->get($emServiceName);
+
+        $em->getConnection()->getConfiguration()->setSQLLogger($sqlLogger);
+
+        $dirOrFile = $input->getOption('fixtures');
+        if ($dirOrFile) {
+            $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
+        } else {
+            $paths = array();
+            foreach ($this->application->getKernel()->getBundles() as $bundle) {
+                $paths[] = $bundle->getPath().'/DataFixtures/ORM';
+            }
+        }
+
+        $loader = new DataFixturesLoader($container);
+        foreach ($paths as $path) {
+            if (is_dir($path)) {
+                $loader->loadFromDirectory($path);
+            }
+        }
+        $fixtures = $loader->getFixtures();
+        $purger = new ORMPurger($em);
+        $executor = new ORMExecutor($em, $purger);
+        $executor->setLogger(function($message) use ($output) {
+            $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
+        });
+        $executor->execute($fixtures);
+
+        $queries = $sqlLogger->getQueries();
+        foreach ($queries as $key => $query) {
+            foreach ($query[1] as $key2 => $param) {
+                if (is_object($param)) {
+                    if ($param instanceOf \DateTime) {
+                        $queries[$key][1][$key2] = $param->format('Y-m-d\TH:i:s\Z');
+                    } else if (method_exists($param, '__toString')) {
+                        $queries[$key][1][$key2] = (string)$param;
+                    } else {
+                        $output->writeln(sprintf('  <comment>></comment> <info>cannot convert object of type %s to a string</info>', get_class($param)));
+                    }
+                }
+            }
+        }
+
+        $output->writeln(sprintf('  <comment>></comment> <info>%s queries logged</info>', count($queries)));
+        foreach ($queries as $query) {
+            $output->writeln(sprintf('    <comment>-</comment> <info>%s (parameters? %s)</info>', $query[0], is_array($query[1]) ? 'yes' : 'no'));
+        }
+
+        $version = date('YmdHis');
+
+        $up = $this->buildCodeFromSql($configuration, $queries);
+        $down = 'throw new \Doctrine\DBAL\Migrations\IrreversibleMigrationException();';
+        $path = $this->generateMigration($configuration, $input, $version, $up, $down);
+
+        $output->writeln(sprintf('  <comment>></comment> <info>Generated new migration class to %s</info>', $path));
+    }
+
+    private function buildCodeFromSql(Configuration $configuration, array $queries)
+    {
+        $code = array();
+        foreach ($queries as $query) {
+            if (strpos($query[0], $configuration->getMigrationsTableName()) !== false) {
+                continue;
+            }
+            $code[] = sprintf("\$this->addSql(\"%s\", %s);", $query[0], var_export($query[1], true));
+        }
+        return implode("\n", $code);
+    }
+}

+ 22 - 0
src/Symfony/Bundle/DoctrineMigrationsBundle/SQLLogger/FixturesToMigrationSQLLogger.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace Symfony\Bundle\DoctrineMigrationsBundle\SQLLogger;
+
+class FixturesToMigrationSQLLogger implements \Doctrine\DBAL\Logging\SQLLogger
+{
+    private $queries = array();
+
+    public function startQuery($sql, array $params = null, array $types = null)
+    {
+        $this->queries[] = array($sql, $params, $types);
+    }
+
+    public function getQueries()
+    {
+        return $this->queries;
+    }
+
+    public function stopQuery()
+    {
+    }
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/views/Collector/mongodb.html.twig


+ 25 - 26
src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php

@@ -14,8 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
 use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
 use Symfony\Component\HttpKernel\KernelInterface;
 use Symfony\Component\Finder\Finder;
-use Symfony\Component\Config\FileLocatorInterface;
-use Symfony\Bundle\FrameworkBundle\Templating\Template;
 use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
 
 /**
@@ -25,7 +23,8 @@ use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
  */
 class TemplatePathsCacheWarmer extends CacheWarmer
 {
-    protected $locator;
+    const TEMPLATES_PATH_IN_BUNDLE = '/Resources/views';
+
     protected $kernel;
     protected $rootDir;
     protected $parser;
@@ -34,14 +33,12 @@ class TemplatePathsCacheWarmer extends CacheWarmer
      * Constructor.
      *
      * @param KernelInterface      $kernel  A KernelInterface instance
-     * @param FileLocatorInterface $locator A FileLocatorInterface instance
      * @param TemplateNameParser   $parser  A TemplateNameParser instance
      * @param string               $rootDir The directory where global templates can be stored
      */
-    public function __construct(KernelInterface $kernel, FileLocatorInterface $locator, TemplateNameParser $parser, $rootDir)
+    public function __construct(KernelInterface $kernel, TemplateNameParser $parser, $rootDir)
     {
         $this->kernel = $kernel;
-        $this->locator = $locator;
         $this->parser = $parser;
         $this->rootDir = $rootDir;
     }
@@ -52,8 +49,14 @@ class TemplatePathsCacheWarmer extends CacheWarmer
      * @param string $cacheDir The cache directory
      */
     public function warmUp($cacheDir)
-    {
-        $templates = $this->computeTemplatePaths();
+    {       
+        $templates = array();
+
+        foreach ($this->kernel->getBundles() as $name => $bundle) {
+            $templates += $this->findTemplatesIn($bundle->getPath().self::TEMPLATES_PATH_IN_BUNDLE, $name);
+        }
+
+        $templates += $this->findTemplatesIn($this->rootDir);
 
         $this->writeCacheFile($cacheDir.'/templates.php', sprintf('<?php return %s;', var_export($templates, true)));
     }
@@ -68,35 +71,31 @@ class TemplatePathsCacheWarmer extends CacheWarmer
         return false;
     }
 
-    protected function computeTemplatePaths()
+    /**
+     * Find templates in the given directory
+     *
+     * @param string $dir       The folder where to look for templates
+     * @param string $bundle    The name of the bundle (null when out of a bundle)
+     *
+     * @return array An array of template paths
+     */
+    protected function findTemplatesIn($dir, $bundle = null)
     {
-        $prefix = '/Resources/views';
         $templates = array();
-        foreach ($this->kernel->getBundles() as $name => $bundle) {
-            if (!is_dir($dir = $bundle->getPath().$prefix)) {
-                continue;
-            }
 
+        if (is_dir($dir)) {
             $finder = new Finder();
             foreach ($finder->files()->followLinks()->in($dir) as $file) {
                 $template = $this->parser->parseFromFilename($file->getRelativePathname());
                 if (false !== $template) {
-                    $template->set('bundle', $name);
-                    $templates[$template->getSignature()] = $this->locator->locate($template->getPath(), $this->rootDir);
-                }
-            }
-        }
-
-        if (is_dir($this->rootDir)) {
-            $finder = new Finder();
-            foreach ($finder->files()->followLinks()->in($this->rootDir) as $file) {
-                $template = $this->parser->parseFromFilename($file->getRelativePathname());
-                if (false !== $template) {
+                    if (null !== $bundle) {
+                      $template->set('bundle', $bundle);
+                    }
                     $templates[$template->getSignature()] = $file->getRealPath();
                 }
             }
         }
 
-        return  $templates;
+        return $templates;
     }
 }

+ 0 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml

@@ -41,7 +41,6 @@
 
         <service id="templating.cache_warmer.template_paths" class="%templating.cache_warmer.template_paths.class%" public="false">
             <argument type="service" id="kernel" />
-            <argument type="service" id="file_locator" />
             <argument type="service" id="templating.name_parser" />
             <argument>%kernel.root_dir%/views</argument>
         </service>

Dosya farkı çok büyük olduğundan ihmal edildi
+ 10 - 8
src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig


+ 1 - 2
src/Symfony/Bundle/TwigBundle/TwigEngine.php

@@ -68,7 +68,7 @@ class TwigEngine implements EngineInterface
     {
         try {
             $this->load($name);
-        } catch (\Twig_Error_Loader $e) {
+        } catch (\InvalidArgumentException $e) {
             return false;
         }
 
@@ -133,6 +133,5 @@ class TwigEngine implements EngineInterface
         } catch (\Twig_Error_Loader $e) {
             throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
         }
-        
     }
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 12 - 6
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig


Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig


Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig


Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig


Dosya farkı çok büyük olduğundan ihmal edildi
+ 4 - 2
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/timer.html.twig


+ 48 - 0
src/Symfony/Bundle/ZendBundle/DependencyInjection/Configuration.php

@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\ZendBundle\DependencyInjection;
+
+use Symfony\Component\Config\Definition\Builder\NodeBuilder;
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+
+/**
+ * This class contains the configuration information for the bundle
+ *
+ * This information is solely responsible for how the different configuration
+ * sections are normalized, and merged.
+ *
+ * @author Christophe Coevoet <stof@notk.org>
+ */
+class Configuration
+{
+    /**
+     * Generates the configuration tree.
+     *
+     * @return \Symfony\Component\Config\Definition\NodeInterface
+     */
+    public function getConfigTree()
+    {
+        $treeBuilder = new TreeBuilder();
+        $rootNode = $treeBuilder->root('zend', 'array');
+
+        $rootNode
+            ->arrayNode('logger')
+                ->canBeUnset()
+                ->scalarNode('priority')->defaultValue('INFO')->end()
+                ->scalarNode('path')->defaultValue('%kernel.logs_dir%/%kernel.environment%.log')->end()
+                ->booleanNode('log_errors')->defaultFalse()->end()
+            ->end()
+        ;
+
+        return $treeBuilder->buildTree();
+    }
+}

+ 14 - 38
src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php

@@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\Config\FileLocator;
+use Symfony\Component\Config\Definition\Processor;
 
 /**
  * ZendExtension is an extension for the Zend Framework libraries.
@@ -37,52 +38,27 @@ class ZendExtension extends Extension
      */
     public function load(array $configs, ContainerBuilder $container)
     {
-        $first = true;
-        foreach ($configs as $config) {
-            if (!isset($config['logger'])) {
-                continue;
-            }
-
-            if ($first) {
-                $first = false;
+        $configuration = new Configuration();
+        $processor = new Processor();
+        $config = $processor->process($configuration->getConfigTree(), $configs);
 
-                $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
-                $loader->load('logger.xml');
-                $container->setAlias('logger', 'zend.logger');
-            }
-
-            $this->registerLoggerConfiguration($config, $container);
-        }
-    }
+        if (isset($config['logger'])) {
+            $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+            $loader->load('logger.xml');
+            $container->setAlias('logger', 'zend.logger');
 
-    /**
-     * Loads the logger configuration.
-     *
-     * Usage example:
-     *
-     *      <zend:logger priority="info" path="/path/to/some.log" />
-     *
-     * @param array            $config    An array of configuration settings
-     * @param ContainerBuilder $container A ContainerBuilder instance
-     */
-    protected function registerLoggerConfiguration($config, ContainerBuilder $container)
-    {
-        $config = $config['logger'];
+            $config = $config['logger'];
 
-        if (isset($config['priority'])) {
             $container->setParameter('zend.logger.priority', is_int($config['priority']) ? $config['priority'] : constant('\\Zend\\Log\\Logger::'.strtoupper($config['priority'])));
-        }
-
-        if (isset($config['path'])) {
             $container->setParameter('zend.logger.path', $config['path']);
-        }
 
-        if (isset($config['log_errors'])) {
             $definition = $container->findDefinition('zend.logger');
-            if (false === $config['log_errors'] && $definition->hasMethodCall('registerErrorHandler')) {
-                $container->findDefinition('zend.logger')->removeMethodCall('registerErrorHandler');
-            } else {
+            if ($config['log_errors']) {
                 $container->findDefinition('zend.logger')->addMethodCall('registerErrorHandler');
+            } else {
+                if ($definition->hasMethodCall('registerErrorHandler')) {
+                    $container->findDefinition('zend.logger')->removeMethodCall('registerErrorHandler');
+                }
             }
         }
     }

+ 0 - 1
src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml

@@ -6,7 +6,6 @@
 
     <parameters>
         <parameter key="zend.logger.class">Symfony\Bundle\ZendBundle\Logger\Logger</parameter>
-        <parameter key="zend.logger.priority" type="constant">Zend\Log\Logger::CRIT</parameter>
         <parameter key="zend.logger.log_errors">true</parameter>
         <parameter key="zend.logger.writer.debug.class">Symfony\Bundle\ZendBundle\Logger\DebugLogger</parameter>
         <parameter key="zend.logger.writer.filesystem.class">Zend\Log\Writer\Stream</parameter>