protected function parseCommonDirectives($dn)
{
$changeType = null;
$controls = [];
$this->nextLine();
while ($this->isCommonDirective()) {
if ($this->isComment()) {
$this->nextLine();
continue;
// We need to exit the loop completely in this case...
} elseif ($this->isEndOfLdif() || $this->isStartOfEntry()) {
break;
} elseif ($this->isCommonDirective()) {
list($key, $value) = $this->getKeyAndValue($this->currentLine());
if ($key == Ldif::DIRECTIVE_CHANGETYPE && is_null($changeType)) {
$changeType = $value;
} elseif ($key == Ldif::DIRECTIVE_CHANGETYPE && !is_null($changeType)) {
$this->throwException('The changetype directive has already been defined');
} else {
$controls[] = $this->getLdapControl($value);
}
}
$this->nextLine();
}
$changeType = $changeType ?: LdifEntryInterface::TYPE_ADD;
$entry = $this->getLdifEntryObject($dn, $changeType);
foreach ($controls as $control) {
$entry->addControl($control);
}
return $entry;
}