Class zhuravljov\yii\queue\Queue
| Inheritance | zhuravljov\yii\queue\Queue » yii\base\Component | 
|---|---|
| Implements | yii\base\BootstrapInterface | 
| Source Code | https://github.com/yiisoft/yii2-queue/blob/master/src/Queue.php | 
Class Queue
Public Properties
| Property | Type | Description | Defined By | 
|---|---|---|---|
| $driver | zhuravljov\yii\queue\Driver|array|string | zhuravljov\yii\queue\Queue | |
| $id | string | of component | zhuravljov\yii\queue\Queue | 
Public Methods
| Method | Description | Defined By | 
|---|---|---|
| bootstrap() | zhuravljov\yii\queue\Queue | |
| getId() | zhuravljov\yii\queue\Queue | |
| init() | zhuravljov\yii\queue\Queue | |
| purge() | Purges the queue | zhuravljov\yii\queue\Queue | 
| push() | zhuravljov\yii\queue\Queue | |
| work() | zhuravljov\yii\queue\Queue | 
Constants
| Constant | Value | Description | Defined By | 
|---|---|---|---|
| EVENT_ON_POP | 'onPop' | zhuravljov\yii\queue\Queue | |
| EVENT_ON_PUSH | 'onPush' | zhuravljov\yii\queue\Queue | |
| EVENT_ON_RELEASE | 'onRelease' | zhuravljov\yii\queue\Queue | 
Property Details
Method Details
| public void bootstrap ( $app ) | ||
| $app | ||
                public function bootstrap($app)
{
    if ($this->driver instanceof BootstrapInterface) {
        $this->driver->bootstrap($app);
    }
}
            
        
| public string getId ( ) | ||
| return | string | 
                                 Component id  | 
                        
|---|---|---|
                public function getId()
{
    foreach (Yii::$app->getComponents(false) as $id => $component) {
        if ($component === $this) {
            return $id;
        }
    }
    return null;
}
            
        
| public void init ( ) | 
                public function init()
{
    parent::init();
    $this->driver = Yii::createObject($this->driver, [$this]);
}
            
        
| public void push ( zhuravljov\yii\queue\Job $job ) | ||
| $job | zhuravljov\yii\queue\Job | |
                public function push(Job $job)
{
    $this->driver->push($job);
    $this->trigger(self::EVENT_ON_PUSH, new Event(['job' => $job]));
}
            
        
| public boolean work ( $throw = true ) | ||
| $throw | boolean | |
                public function work($throw = true)
{
    if ($this->driver->pop($message, $job)) {
        $this->trigger(self::EVENT_ON_POP, new Event(['job' => $job]));
        try {
            /** @var Job $job */
            $job->run($this);
        } catch (\Exception $e) {
            if ($throw) {
                throw $e;
            } else {
                Yii::error($e, __METHOD__);
            }
        } finally {
            $this->driver->release($message);
            $this->trigger(self::EVENT_ON_RELEASE, new Event(['job' => $job]));
        }
        return true;
    } else {
        return false;
    }
}