Skip to content

Commit

Permalink
Merge pull request #7 from urbanindo/hotfix-add-namespace-to-exception
Browse files Browse the repository at this point in the history
HOTFIX add namespace to exception.
  • Loading branch information
petrabarus committed Jun 18, 2015
2 parents 0c74a64 + a773ab6 commit f0b323f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/Behaviors/ActiveRecordDeferredEventBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
}
}
]));
Expand All @@ -98,15 +98,15 @@ 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];
if ($serializer !== null) {
try {
$unserialized = $serializer->unserialize($handler);
$unserialized($object);
} catch (Exception $exc) {
} catch (\Exception $exc) {
return call_user_func([$object, $handler]);
}
} else {
Expand All @@ -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");
}
}
]));
Expand Down
2 changes: 1 addition & 1 deletion src/Behaviors/ActiveRecordDeferredEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 5 additions & 5 deletions src/Behaviors/DeferredEventBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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");
}
}
]));
Expand Down
3 changes: 1 addition & 2 deletions src/Behaviors/DeferredEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace UrbanIndo\Yii2\Queue\Behaviors;

use Yii;
use Exception;

/**
* DeferredEventHandler handles the event inside the behavior instance, instead
Expand All @@ -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}'");
}
}

Expand Down

0 comments on commit f0b323f

Please sign in to comment.