protected function update()
{
$disallowedKeysInFirstLevel = ["install", "admin", "webservice", "plugin"];
if ($this->getParentId() == 1 && in_array($this->getKey(), $disallowedKeysInFirstLevel)) {
throw new \Exception("Key: " . $this->getKey() . " is not allowed in first level (root-level)");
}
// set index if null
if ($this->getIndex() === null) {
$this->setIndex($this->getDao()->getNextIndex());
}
// save properties
$this->getProperties();
$this->getDao()->deleteAllProperties();
if (is_array($this->getProperties()) and count($this->getProperties()) > 0) {
foreach ($this->getProperties() as $property) {
if (!$property->getInherited()) {
$property->setDao(null);
$property->setCid($this->getId());
$property->setCtype("document");
$property->setCpath($this->getRealFullPath());
$property->save();
}
}
}
// save dependencies
$d = $this->getDependencies();
$d->clean();
foreach ($this->resolveDependencies() as $requirement) {
if ($requirement["id"] == $this->getId() && $requirement["type"] == "document") {
// dont't add a reference to yourself
continue;
} else {
$d->addRequirement($requirement["id"], $requirement["type"]);
}
}
$d->save();
$this->getDao()->update();
//set object to registry
\Zend_Registry::set("document_" . $this->getId(), $this);
}