From a773ab666d2ab4df357fed1828e932583939b88d Mon Sep 17 00:00:00 2001 From: Petra Barus Date: Thu, 18 Jun 2015 16:02:11 +0700 Subject: [PATCH] HOTFIX add namespace to exception. --- src/Behaviors/ActiveRecordDeferredEventBehavior.php | 10 +++++----- src/Behaviors/ActiveRecordDeferredEventHandler.php | 2 +- src/Behaviors/DeferredEventBehavior.php | 10 +++++----- src/Behaviors/DeferredEventHandler.php | 3 +-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Behaviors/ActiveRecordDeferredEventBehavior.php b/src/Behaviors/ActiveRecordDeferredEventBehavior.php index c2040f6..2492e4f 100644 --- a/src/Behaviors/ActiveRecordDeferredEventBehavior.php +++ b/src/Behaviors/ActiveRecordDeferredEventBehavior.php @@ -77,7 +77,7 @@ public function postDeferredEvent($event) { try { $unserialized = $serializer->unserialize($handler); $unserialized($object); - } catch (Exception $exc) { + } catch (\Exception $exc) { return call_user_func([$object, $handler]); } } else { @@ -87,7 +87,7 @@ public function postDeferredEvent($event) { /* @var $object DeferredEventInterface */ return $object->handleDeferredEvent($eventName); } else { - throw new Exception("Model is not instance of DeferredEventInterface"); + throw new \Exception("Model is not instance of DeferredEventInterface"); } } ])); @@ -98,7 +98,7 @@ public function postDeferredEvent($event) { $object = $class::findOne($pk); $object->scenario = $scenario; if ($object === null) { - throw new Exception("Model is not found"); + throw new \Exception("Model is not found"); } if ($handlers) { $handler = $handlers[$eventName]; @@ -106,7 +106,7 @@ public function postDeferredEvent($event) { try { $unserialized = $serializer->unserialize($handler); $unserialized($object); - } catch (Exception $exc) { + } catch (\Exception $exc) { return call_user_func([$object, $handler]); } } else { @@ -116,7 +116,7 @@ public function postDeferredEvent($event) { /* @var $object DeferredEventInterface */ return $object->handleDeferredEvent($eventName); } else { - throw new Exception("Model is not instance of DeferredEventInterface"); + throw new \Exception("Model is not instance of DeferredEventInterface"); } } ])); diff --git a/src/Behaviors/ActiveRecordDeferredEventHandler.php b/src/Behaviors/ActiveRecordDeferredEventHandler.php index 41b1382..c41d6b5 100644 --- a/src/Behaviors/ActiveRecordDeferredEventHandler.php +++ b/src/Behaviors/ActiveRecordDeferredEventHandler.php @@ -50,7 +50,7 @@ public function deferEvent($event) { 'route' => function() use ($class, $pk, $attributes, $handler, $eventName, $scenario) { $object = $class::findOne($pk); if ($object === null) { - throw new Exception("Model is not found"); + throw new \Exception("Model is not found"); } $object->scenario = $scenario; /* @var $object ActiveRecord */ diff --git a/src/Behaviors/DeferredEventBehavior.php b/src/Behaviors/DeferredEventBehavior.php index 9b83f00..b4ad46a 100644 --- a/src/Behaviors/DeferredEventBehavior.php +++ b/src/Behaviors/DeferredEventBehavior.php @@ -100,14 +100,14 @@ public function events() { /** * Initialize the queue. - * @throws Exception + * @throws \Exception */ public function init() { parent::init(); $queueName = $this->queue; $this->queue = Yii::$app->get($queueName); if (!$this->queue instanceof \UrbanIndo\Yii2\Queue\Queue) { - throw new Exception("Can not found queue component named '{$queueName}'"); + throw new \Exception("Can not found queue component named '{$queueName}'"); } $this->_hasEventHandlers = !\yii\helpers\ArrayHelper::isIndexed($this->events, true); @@ -130,7 +130,7 @@ public function init() { public function postDeferredEvent($event) { $object = clone $this->owner; if (!$this->_hasEventHandlers && !$object instanceof DeferredEventInterface) { - throw new Exception("Model is not instance of DeferredEventInterface"); + throw new \Exception("Model is not instance of DeferredEventInterface"); } $handlers = ($this->_hasEventHandlers) ? $this->events : false; $eventName = $event->name; @@ -147,7 +147,7 @@ public function postDeferredEvent($event) { try { $unserialized = $serializer->unserialize($handler); $unserialized($object); - } catch (Exception $exc) { + } catch (\Exception $exc) { return call_user_func([$object, $handler]); } } else { @@ -157,7 +157,7 @@ public function postDeferredEvent($event) { /* @var $object DeferredEventInterface */ return $object->handleDeferredEvent($eventName); } else { - throw new Exception("Model doesn't have handlers for the event or is not instance of DeferredEventInterface"); + throw new \Exception("Model doesn't have handlers for the event or is not instance of DeferredEventInterface"); } } ])); diff --git a/src/Behaviors/DeferredEventHandler.php b/src/Behaviors/DeferredEventHandler.php index 08513e2..a0eacf9 100644 --- a/src/Behaviors/DeferredEventHandler.php +++ b/src/Behaviors/DeferredEventHandler.php @@ -8,7 +8,6 @@ namespace UrbanIndo\Yii2\Queue\Behaviors; use Yii; -use Exception; /** * DeferredEventHandler handles the event inside the behavior instance, instead @@ -35,7 +34,7 @@ public function init() { $queueName = $this->queue; $this->queue = Yii::$app->get($queueName); if (!$this->queue instanceof \UrbanIndo\Yii2\Queue\Queue) { - throw new Exception("Can not found queue component named '{$queueName}'"); + throw new \Exception("Can not found queue component named '{$queueName}'"); } }