Class yii\debug\models\search\Mail
Inheritance | yii\debug\models\search\Mail » yii\debug\models\search\Base » yii\base\Model |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/models/search/Mail.php |
Mail represents the model behind the search form about current send emails.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$bcc | string | Bcc attribute input search value | yii\debug\models\search\Mail |
$body | string | Body attribute input search value | yii\debug\models\search\Mail |
$cc | string | Cc attribute input search value | yii\debug\models\search\Mail |
$charset | string | Charset attribute input search value | yii\debug\models\search\Mail |
$file | string | File attribute input search value | yii\debug\models\search\Mail |
$from | string | From attribute input search value | yii\debug\models\search\Mail |
$headers | string | Headers attribute input search value | yii\debug\models\search\Mail |
$reply | string | Reply attribute input search value | yii\debug\models\search\Mail |
$subject | string | Subject attribute input search value | yii\debug\models\search\Mail |
$to | string | To attribute input search value | yii\debug\models\search\Mail |
Public Methods
Method | Description | Defined By |
---|---|---|
addCondition() | Adds filtering condition for a given attribute | yii\debug\models\search\Base |
attributeLabels() | yii\debug\models\search\Mail | |
rules() | yii\debug\models\search\Mail | |
search() | Returns data provider with filled models. Filter applied if needed. | yii\debug\models\search\Mail |
Property Details
Method Details
Defined in: yii\debug\models\search\Base::addCondition()
Adds filtering condition for a given attribute
public void addCondition ( yii\debug\components\search\Filter $filter, $attribute, $partial = false ) | ||
$filter | yii\debug\components\search\Filter |
Filter instance |
$attribute | string |
Attribute to filter |
$partial | boolean |
If partial match should be used |
public function addCondition(Filter $filter, $attribute, $partial = false)
{
$value = $this->$attribute;
if (mb_strpos($value, '>') !== false) {
$value = (int) str_replace('>', '', $value);
$filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));
} elseif (mb_strpos($value, '<') !== false) {
$value = (int) str_replace('<', '', $value);
$filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
} else {
$filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
}
}
public void attributeLabels ( ) |
public function attributeLabels()
{
return [
'from' => 'From',
'to' => 'To',
'reply' => 'Reply',
'cc' => 'Copy receiver',
'bcc' => 'Hidden copy receiver',
'subject' => 'Subject',
'charset' => 'Charset'
];
}
public void rules ( ) |
public function rules()
{
return [
[['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'], 'safe'],
];
}
Returns data provider with filled models. Filter applied if needed.
public \yii\data\ArrayDataProvider search ( $params, $models ) | ||
$params | array | |
$models | array |
public function search($params, $models)
{
$dataProvider = new ArrayDataProvider([
'allModels' => $models,
'pagination' => [
'pageSize' => 20,
],
'sort' => [
'attributes' => ['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'],
],
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$filter = new Filter();
$this->addCondition($filter, 'from', true);
$this->addCondition($filter, 'to', true);
$this->addCondition($filter, 'reply', true);
$this->addCondition($filter, 'cc', true);
$this->addCondition($filter, 'bcc', true);
$this->addCondition($filter, 'subject', true);
$this->addCondition($filter, 'body', true);
$this->addCondition($filter, 'charset', true);
$dataProvider->allModels = $filter->filter($models);
return $dataProvider;
}