From 80c102761cf5f75678364e6bad12eae52d690617 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 26 Mar 2011 14:35:55 -0500 Subject: [PATCH 1/3] [HttpKernel] Making the "no response returned from controller" more explanatory when it's possible that the user forgot a return statement in his/her controller Also made "null" show up as null in the exception message, instead of as a blank string (slightly more expressive). --- src/Symfony/Component/HttpKernel/HttpKernel.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 49dbd9aad3..77afc471aa 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -120,7 +120,13 @@ class HttpKernel implements HttpKernelInterface } if (!$response instanceof Response) { - throw new \LogicException(sprintf('The controller must return a response (%s given).', $this->varToString($response))); + $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response)); + + // the user may have forgotten to return something + if (null === $response) { + $msg .= ' Did you forget to add a return statement somewhere in your controller?'; + } + throw new \LogicException($msg); } } @@ -187,6 +193,10 @@ class HttpKernel implements HttpKernelInterface return '[resource]'; } + if (null === $var) { + return 'null'; + } + return str_replace("\n", '', var_export((string) $var, true)); } } From c2579aa2000f19fc57f9a1f9d8ec4f334d86d818 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Sun, 27 Mar 2011 06:33:10 -0700 Subject: [PATCH 2/3] [AsseticBundle] removed the event again --- .../AsseticBundle/Command/DumpCommand.php | 6 ---- .../Bundle/AsseticBundle/Event/WriteEvent.php | 32 ------------------- src/Symfony/Bundle/AsseticBundle/Events.php | 20 ------------ 3 files changed, 58 deletions(-) delete mode 100644 src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php delete mode 100644 src/Symfony/Bundle/AsseticBundle/Events.php diff --git a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php index 5698bd1810..a2ae7ff759 100644 --- a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php +++ b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php @@ -14,8 +14,6 @@ namespace Symfony\Bundle\AsseticBundle\Command; use Assetic\Asset\AssetInterface; use Assetic\Factory\LazyAssetManager; use Symfony\Bundle\FrameworkBundle\Command\Command; -use Symfony\Bundle\AsseticBundle\Event\WriteEvent; -use Symfony\Bundle\AsseticBundle\Events; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -46,10 +44,6 @@ class DumpCommand extends Command $am = $this->container->get('assetic.asset_manager'); - // notify an event so custom stream wrappers can be registered lazily - $writeEvent = new WriteEvent($basePath); - $this->container->get('event_dispatcher')->dispatch(Events::onAsseticWrite, $writeEvent); - if ($input->getOption('watch')) { return $this->watch($am, $basePath, $output, $this->container->getParameter('kernel.debug')); } diff --git a/src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php b/src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php deleted file mode 100644 index 2d3ff8e35e..0000000000 --- a/src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Symfony\Bundle\AsseticBundle\Event; - -use Symfony\Component\EventDispatcher\Event; - -/** - * @author Bernhard Schussek - */ -class WriteEvent extends Event -{ - private $targetPath; - - public function __construct($targetPath = null) - { - $this->targetPath = $targetPath; - } - - public function getTargetPath() - { - return $this->targetPath; - } -} diff --git a/src/Symfony/Bundle/AsseticBundle/Events.php b/src/Symfony/Bundle/AsseticBundle/Events.php deleted file mode 100644 index 3fc8011973..0000000000 --- a/src/Symfony/Bundle/AsseticBundle/Events.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Symfony\Bundle\AsseticBundle; - -/** - * @author Bernhard Schussek - */ -final class Events -{ - const onAsseticWrite = 'onAsseticWrite'; -} From a294024184f1e62c2e699f78e829db2844d47f13 Mon Sep 17 00:00:00 2001 From: Matthieu Bontemps Date: Sun, 27 Mar 2011 19:17:13 +0200 Subject: [PATCH 3/3] Fix Filesystem->mkdir return value --- src/Symfony/Component/HttpKernel/Util/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Util/Filesystem.php b/src/Symfony/Component/HttpKernel/Util/Filesystem.php index 82491c7131..7273273487 100644 --- a/src/Symfony/Component/HttpKernel/Util/Filesystem.php +++ b/src/Symfony/Component/HttpKernel/Util/Filesystem.php @@ -55,7 +55,7 @@ class Filesystem */ public function mkdir($dirs, $mode = 0777) { - $ret = false; + $ret = true; foreach ($this->toIterator($dirs) as $dir) { if (is_dir($dir)) { continue;