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.
		
		
		
		
			
				
					35 lines
				
				731 B
			
		
		
			
		
	
	
					35 lines
				
				731 B
			| 
								 
											8 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace core\entities\User;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use Webmozart\Assert\Assert;
							 | 
						||
| 
								 | 
							
								use yii\db\ActiveRecord;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @property integer $user_id
							 | 
						||
| 
								 | 
							
								 * @property string $identity
							 | 
						||
| 
								 | 
							
								 * @property string $network
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Network extends ActiveRecord
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    public static function create($network, $identity): self
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        Assert::notEmpty($network);
							 | 
						||
| 
								 | 
							
								        Assert::notEmpty($identity);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $item = new static();
							 | 
						||
| 
								 | 
							
								        $item->network = $network;
							 | 
						||
| 
								 | 
							
								        $item->identity = $identity;
							 | 
						||
| 
								 | 
							
								        return $item;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function isFor($network, $identity): bool
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return $this->network === $network && $this->identity === $identity;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static function tableName()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return '{{%user_networks}}';
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |