You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					42 lines
				
				1.0 KiB
			
		
		
			
		
	
	
					42 lines
				
				1.0 KiB
			| 
								 
											13 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @link http://www.yiiframework.com/
							 | 
						||
| 
								 | 
							
								 * @copyright Copyright (c) 2008 Yii Software LLC
							 | 
						||
| 
								 | 
							
								 * @license http://www.yiiframework.com/license/
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								namespace yii\mutex;
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								use Yii;
							 | 
						||
| 
								 | 
							
								use yii\db\Connection;
							 | 
						||
| 
								 | 
							
								use yii\base\InvalidConfigException;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @author resurtm <resurtm@gmail.com>
							 | 
						||
| 
								 | 
							
								 * @since 2.0
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								abstract class DbMutex extends Mutex
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
								{
							 | 
						||
| 
								 | 
							
									/**
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
									 * @var Connection|string the DB connection object or the application component ID of the DB connection.
							 | 
						||
| 
								 | 
							
									 * After the Mutex object is created, if you want to change this property, you should only assign
							 | 
						||
| 
								 | 
							
									 * it with a DB connection object.
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
									 */
							 | 
						||
| 
								 | 
							
									public $db = 'db';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
									/**
							 | 
						||
| 
								 | 
							
									 * Initializes generic database table based mutex implementation.
							 | 
						||
| 
								 | 
							
									 * @throws InvalidConfigException if [[db]] is invalid.
							 | 
						||
| 
								 | 
							
									 */
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
									public function init()
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										parent::init();
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
										if (is_string($this->db)) {
							 | 
						||
| 
								 | 
							
											$this->db = Yii::$app->getComponent($this->db);
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
										if (!$this->db instanceof Connection) {
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
											throw new InvalidConfigException('Mutex::db must be either a DB connection instance or the application component ID of a DB connection.');
							 | 
						||
| 
								 
											13 years ago
										 
									 | 
							
										}
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |