Paperyard
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
Paperyard\Models\Rule\Rule Class Reference
Inheritance diagram for Paperyard\Models\Rule\Rule:
Paperyard\Models\Rule\Archive Paperyard\Models\Rule\Recipient Paperyard\Models\Rule\Senders Paperyard\Models\Rule\Subjects

Public Member Functions

 setIsActiveAttribute ($value)
 
 validateAndSave ()
 
 validateAndUpdate ()
 

Public Attributes

const TAG_REGEX = '/^([ÄäÜüÖöß\sa-zA-Z0-9]+,)*[ÄäÜüÖöß\sa-zA-Z0-9]+$/'
 
 $errors = []
 

Protected Attributes

 $attributes
 
 $rules
 
 $labels
 

Private Member Functions

 validate ()
 

Detailed Description

Definition at line 8 of file Rule.php.

Member Function Documentation

Paperyard\Models\Rule\Rule::setIsActiveAttribute (   $value)

Mutates post data reliable.

Parameters
$valuevalue from post

Definition at line 32 of file Rule.php.

33  {
34  $this->attributes['isActive'] = (int)($value == 'on');
35  }
Paperyard\Models\Rule\Rule::validate ( )
private

Checks if data matches rule set.

Definition at line 40 of file Rule.php.

41  {
42  // new validator object
43  $validator = new Validator($this->getAttributes());
44 
45  // pass rules
46  $validator->rules($this->rules);
47 
48  // add labels (we dont want to show internal names to the user)
49  $validator->labels($this->labels);
50 
51  // check rules
52  if(!$validator->validate()) {
53  $this->errors = $validator->errors();
54  }
55  }
Paperyard\Models\Rule\Rule::validateAndSave ( )

Saves data if it matches rule set.

Returns
bool

Definition at line 62 of file Rule.php.

63  {
64  // check rules
65  $this->validate();
66 
67  // return result
68  if(empty($this->errors)) {
69  return $this->save();
70  } else {
71  return false;
72  }
73  }
Paperyard\Models\Rule\Rule::validateAndUpdate ( )

Updates data if it matches rule set.

Returns
bool

Definition at line 80 of file Rule.php.

81  {
82  // check rules
83  $this->validate();
84 
85  // return result
86  if(empty($this->errors)) {
87  return $this->update();
88  } else {
89  return false;
90  }
91  }

Member Data Documentation

Paperyard\Models\Rule\Rule::$attributes
protected
Initial value:
= array(
'isActive' => 0
)

Definition at line 14 of file Rule.php.

Paperyard\Models\Rule\Rule::$errors = []

Definition at line 25 of file Rule.php.

Paperyard\Models\Rule\Rule::$labels
protected

Definition at line 22 of file Rule.php.

Paperyard\Models\Rule\Rule::$rules
protected

Definition at line 19 of file Rule.php.

const Paperyard\Models\Rule\Rule::TAG_REGEX = '/^([ÄäÜüÖöß\sa-zA-Z0-9]+,)*[ÄäÜüÖöß\sa-zA-Z0-9]+$/'

matches Alphanum, special german chars

Definition at line 11 of file Rule.php.


The documentation for this class was generated from the following file: