protected function startup() { parent::startup(); if (!($row = $this->addons->find($this->id, $this->auth->isAllowed('addon', 'delete')))) { $this->error('Addon not found!'); } $this->addon = Addon::fromActiveRow($row, $this->addonVotes); $this->addonVersions->rsort($this->addon->versions); }
protected function startup() { parent::startup(); if ($this->token && $this->addonId) { $this->error('Parameters token and addonId must not be present at the same time.', 409); } if ($this->token) { $this->addon = $this->manager->restoreAddon($this->token); } elseif ($this->addonId) { $deleted = $this->auth->isAllowed('addon', 'delete'); $row = $this->addons->find($this->addonId, $deleted); if (!$row) { $this->error('Addon not found.'); } $this->addon = Addon::fromActiveRow($row); } if ($this->addon && !$this->auth->isAllowed($this->addon, 'manage')) { $this->error('You are not allowed to manage this addon.', 403); } }