function delete() { if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { throw new Forbidden(); } if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { $principal = 'principal:' . parent::getOwner(); $shares = $this->getShares(); $shares = array_filter($shares, function ($share) use($principal) { return $share['href'] === $principal; }); if (empty($shares)) { throw new Forbidden(); } /** @var CalDavBackend $calDavBackend */ $calDavBackend = $this->caldavBackend; $calDavBackend->updateShares($this, [], ['href' => $principal]); return; } parent::delete(); }