<?php namespace common\models; use common\models\User; use yii\base\InvalidParamException; use yii\base\Model; use Yii; use Solarium\Exception\InvalidArgumentException; use Solarium\Exception\Solarium\Exception; class ValidationForm extends Model{ /** * @inheritdoc */ /** * * @var \common\models\User */ public $user; public $comment; /** * Creates a form model given a token. * * @param string $token * @param array $config * name-value pairs that will be used to initialize the object properties * @throws \yii\base\InvalidParamException if token is empty or not valid */ public function __construct($token, $config = []) { //throw new InvalidArgumentException('bla'); if (empty ( $token ) || ! is_string ( $token )) { throw new InvalidArgumentException('Activation key cannot be blank'); } $this->user = User::findByActivationKey( $token ); if (! $this->user) { throw new InvalidParamException ( 'Wrong activation Key.' ); } parent::__construct ( $config ); } public function rules() { return[ [ 'comment', 'safe' ] ]; } /** * */ }