Esempio n. 1
0
 /**
  * Deletes values of current attribute given in arguments.
  *
  * This method takes a variable number of arguments each representing
  * existing value of current attribute to be deleted/removed. Since empty
  * strings are ignored, there may be no value to delete. In that case
  * no values are deleted at all.
  *
  * @throws protocol_exception
  * @param string $firstValueToDelete first value of attribute to delete
  * @return attribute current instance
  */
 public function delete($firstValueToDelete)
 {
     if (!$this->faking) {
         $values = array_filter(array_map(function ($a) {
             return trim($a);
         }, func_get_args()), function ($a) {
             return $a !== '';
         });
         if (count($values)) {
             if ($this->node->isAdjusting()) {
                 $this->node->adjust($this, array_diff($this->read(), $values));
             } else {
                 if (!@ldap_mod_del($this->node->getLink(), $this->node->getDN(), array($this->name => $values))) {
                     throw new protocol_exception(sprintf('failed to delete values of attribute %s', $this->name), $this->node->getLink(), $this->node->getDN());
                 }
             }
         }
     }
     return $this;
 }