/** * @param Widget $widget * * @return bool * @throws ValidationException */ public function update(Widget $widget) { if (!$widget->isExists()) { return false; } $data = ['name' => $widget->getName(), 'description' => $widget->getDescription(), 'settings' => $widget->getSettings()]; $updater = new WidgetUpdator(); $validator = $updater->validator($data); if ($validator->fails()) { throw (new ValidationException())->setValidator($validator); } $updater->update($widget->getId(), $data); return true; }