/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aAction) { $this->aAction->removeApi($this); } $this->id = null; $this->route = null; $this->method = null; $this->action_id = null; $this->required_params = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Interal mechanism to remove Apis from Action * * @param Action $model * @param mixed $data */ protected function doRemoveApis(Action $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Api'; } else { $related = ApiQuery::create()->findOneById($entry['id']); $model->removeApi($related); } } if (count($errors) > 0) { return new ErrorsException($errors); } }