Jelajahi Sumber

Merge remote-tracking branch 'upstream/master' into windows-process-fix

Pascal Borreli 14 tahun lalu
induk
melakukan
3e8874df75

+ 18 - 4
src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

@@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Output\Output;
 
 /**
- * AssetsInstallCommand.
+ * Command that places bundle web assets into a given directory.
  *
  * @author Fabien Potencier <fabien@symfony.com>
  */
@@ -31,9 +31,23 @@ class AssetsInstallCommand extends Command
     {
         $this
             ->setDefinition(array(
-                new InputArgument('target', InputArgument::REQUIRED, 'The target directory'),
+                new InputArgument('target', InputArgument::REQUIRED, 'The target directory (usually "web")'),
             ))
             ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
+            ->setHelp(<<<EOT
+The <info>assets:install</info> command installs bundle assets into a given
+directory (e.g. the web directory).
+
+<info>./app/console assets:install web [--symlink]</info>
+
+A "bundles" directory will be created inside the target directory, and the
+"Resources/public" directory of each bundle will be copied into it.
+
+To create a symlink to each bundle instead of copying its assets, use the
+<info>--symlink</info> option.
+
+EOT
+            )
             ->setName('assets:install')
         ;
     }
@@ -56,10 +70,10 @@ class AssetsInstallCommand extends Command
 
         foreach ($this->container->get('kernel')->getBundles() as $bundle) {
             if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
-                $output->writeln(sprintf('Installing assets for <comment>%s</comment>', $bundle->getNamespace()));
-
                 $targetDir = $input->getArgument('target').'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
 
+                $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
+
                 $filesystem->remove($targetDir);
 
                 if ($input->getOption('symlink')) {

+ 1 - 2
src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php

@@ -66,6 +66,7 @@ EOT
         }
 
         // validate namespace
+        $namespace = strtr($namespace, '/', '\\');
         if (preg_match('/[^A-Za-z0-9_\\\-]/', $namespace)) {
             throw new \InvalidArgumentException('The namespace contains invalid characters.');
         }
@@ -96,8 +97,6 @@ EOT
 
         $targetDir = $dir.strtr($namespace, '\\', '/');
 
-
-
         if (file_exists($targetDir)) {
             throw new \RuntimeException(sprintf('Bundle "%s" already exists.', $bundle));
         }

+ 4 - 0
src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

@@ -161,6 +161,10 @@ EOF
             return sprintf('object(%s)', get_class($value));
         }
 
+        if (is_string($value)) {
+            return $value;
+        }
+
         return preg_replace("/\n\s*/s", '', var_export($value, true));
     }
 }

+ 11 - 1
src/Symfony/Bundle/FrameworkBundle/RequestListener.php

@@ -91,7 +91,7 @@ class RequestListener
             $parameters = $this->router->match($request->getPathInfo());
 
             if (null !== $this->logger) {
-                $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], json_encode($parameters)));
+                $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters)));
             }
 
             $request->attributes->add($parameters);
@@ -113,4 +113,14 @@ class RequestListener
             throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e);
         }
     }
+
+    private function parametersToString(array $parameters)
+    {
+        $pieces = array();
+        foreach ($parameters as $key => $val) {
+            $pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val)));
+        }
+
+        return implode(', ', $pieces);
+    }
 }

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php

@@ -69,7 +69,7 @@ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
             }
         }
 
-        throw new \RuntimeException(sprintf('No engine is able to work with the %s template.', json_encode($name)));
+        throw new \RuntimeException(sprintf('No engine is able to work with the template "%s".', $name));
     }
 
     /**

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php

@@ -60,7 +60,7 @@ class TemplateLocator implements FileLocatorInterface
         try {
             return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path);
         } catch (\InvalidArgumentException $e) {
-            throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template->getLogicalName(), $this->path), 0, $e);
+            throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template, $this->path), 0, $e);
         }
     }
 }

+ 1 - 1
src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

@@ -94,7 +94,7 @@ class FilesystemLoader implements \Twig_LoaderInterface
         }
 
         if (false === $file || null === $file) {
-            throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $tpl->getLogicalName()), -1, null, $previous);
+            throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $tpl), -1, null, $previous);
         }
 
         return $this->cache[$key] = $file;

+ 1 - 1
src/Symfony/Component/Templating/DelegatingEngine.php

@@ -106,6 +106,6 @@ class DelegatingEngine implements EngineInterface
             }
         }
 
-        throw new \RuntimeException(sprintf('No engine is able to work with the %s template.', json_encode($name)));
+        throw new \RuntimeException(sprintf('No engine is able to work with the template "%s".', $name));
     }
 }

+ 4 - 4
src/Symfony/Component/Templating/PhpEngine.php

@@ -82,7 +82,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
         $parameters = array_replace($this->getGlobals(), $parameters);
         // render
         if (false === $content = $this->evaluate($storage, $parameters)) {
-            throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)->getLogicalName()));
+            throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)));
         }
 
         // decorator
@@ -172,7 +172,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
      */
     public function offsetGet($name)
     {
-        return $this->$name = $this->get($name);
+        return $this->get($name);
     }
 
     /**
@@ -211,7 +211,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
     /**
      * @param Helper[] $helpers An array of helper
      */
-    public function addHelpers(array $helpers = array())
+    public function addHelpers(array $helpers)
     {
         foreach ($helpers as $alias => $helper) {
             $this->set($helper, is_int($alias) ? null : $alias);
@@ -496,7 +496,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
         $storage = $this->loader->load($template);
 
         if (false === $storage) {
-            throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', is_string($name) ? $name : json_encode($name)));
+            throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $template));
         }
 
         return $this->cache[$key] = $storage;