/** * @param array $data * @param int $id * @return bool * @throws \Exception */ protected function save(array $data, $id = null) { $this->form->setData($data); if (!$this->form->isValid()) { throw new \Exception('Form failed to validate. Unable to save album'); } /** * @var Album $album */ $album = $this->form->getData(); $this->repository->save($album, $id); return true; }