/** * Check if the given object is a valid ApiObject for this collection, * taking into account the model of the repository attached. * Returns the actual given object * * @throws InvalidRepositoryException * @param ApiObject $object * @return ApiObject $object */ protected function validateObject(ApiObject $object) { if ($object->getModel() != $this->_repository->getModel()) { throw new InvalidRepositoryException(); } return $object; }
/** * Deletes given model object. * * @param $object Mr\Api\Model\ApiObject * @return void */ public function delete(ApiObject $object) { $object->beforeDelete(); $path = sprintf("%s/%s/%d", self::API_URL_PREFIX, strtolower($this->getModel()), $object->getRemoteId()); $this->_client->delete($path); $object->deleted(); $object->afterDelete(); }