build() public method

Builds the type of modification automatically based on the current and original values.
public build ( ) : BatchModification
return BatchModification
Example #1
0
 /**
  * Sets and returns the models modifications.
  *
  * @return array
  */
 public function getModifications()
 {
     $dirty = $this->getDirty();
     foreach ($dirty as $attribute => $values) {
         if (!is_array($values)) {
             // Make sure values is always an array.
             $values = [$values];
         }
         $modification = new BatchModification();
         if (array_key_exists($attribute, $this->original)) {
             $modification->setOriginal($this->original[$attribute]);
         }
         $modification->setAttribute($attribute);
         $modification->setValues($values);
         $modification->build();
         $this->addModification($modification);
     }
     return $this->modifications;
 }
Example #2
0
 /**
  * Sets and returns the models modifications.
  *
  * @return array
  */
 public function getModifications()
 {
     foreach ($this->getDirty() as $attribute => $values) {
         // Make sure values is always an array.
         $values = is_array($values) ? $values : [$values];
         // Create a new modification.
         $modification = new BatchModification($attribute, null, $values);
         if (array_key_exists($attribute, $this->original)) {
             // If the attribute we're modifying has an original value, we'll give the
             // BatchModification object its values to automatically determine
             // which type of LDAP operation we need to perform.
             $modification->setOriginal($this->original[$attribute]);
         }
         // Finally, we'll add the modification to the model.
         $this->addModification($modification->build());
     }
     return $this->modifications;
 }