diff --git a/tests/webfiori/framework/test/writers/WebServiceWritterTest.php b/tests/webfiori/framework/test/writers/WebServiceWritterTest.php index a2f0d18f..9128fe80 100644 --- a/tests/webfiori/framework/test/writers/WebServiceWritterTest.php +++ b/tests/webfiori/framework/test/writers/WebServiceWritterTest.php @@ -17,7 +17,7 @@ public function test00() { $this->assertEquals('app\\apis', $writter->getNamespace()); $this->assertEquals('Service', $writter->getSuffix()); $this->assertEquals([ - "webfiori\\framework\\EAbstractWebService", + "webfiori\http\AbstractWebService", "webfiori\http\ParamType", "webfiori\http\ParamOption", "webfiori\\http\\RequestMethod" @@ -33,7 +33,7 @@ public function test01() { $this->assertEquals('app\\apis', $writter->getNamespace()); $this->assertEquals('Service', $writter->getSuffix()); $this->assertEquals([ - "webfiori\\framework\\EAbstractWebService", + "webfiori\http\AbstractWebService", "webfiori\http\ParamType", "webfiori\http\ParamOption", "webfiori\\http\\RequestMethod" @@ -61,7 +61,7 @@ public function test02() { $this->assertEquals('app\\apis', $writter->getNamespace()); $this->assertEquals('Service', $writter->getSuffix()); $this->assertEquals([ - "webfiori\\framework\\EAbstractWebService", + "webfiori\http\AbstractWebService", "webfiori\http\ParamType", "webfiori\http\ParamOption", "webfiori\\http\\RequestMethod" diff --git a/webfiori/framework/EAbstractWebService.php b/webfiori/framework/EAbstractWebService.php deleted file mode 100644 index 93766386..00000000 --- a/webfiori/framework/EAbstractWebService.php +++ /dev/null @@ -1,44 +0,0 @@ - - * {
- *   "message":"Action not implemented.",
- *   "type":"error",
- * } - *

- * In addition to the message, The response will sent HTTP code 404 - Not Found. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.0 - */ - public function actionNotImpl() { - $message = $this->get('general/action-not-impl'); - $this->sendResponse($message, self::$E, 404); - } - /** - * Sends a response message to indicate that an action is not supported by the API. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"Action not supported",
- *   "type":"error"
- * } - *

- * In addition to the message, The response will sent HTTP code 404 - Not Found. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.0 - */ - public function actionNotSupported() { - $message = $this->get('general/action-not-supported'); - $this->sendResponse($message, self::$E, 404); - } - /** - * Sends a response message to indicate that request content type is - * not supported by the API. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"Content type not supported.",
- *   "type":"error",
- *   "request-content-type":"content_type"
- * } - *

- * In addition to the message, The response will sent HTTP code 404 - Not Found. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.1 - */ - public function contentTypeNotSupported(string $cType = '') { - $message = $this->get('general/content-not-supported'); - $this->sendResponse($message, self::$E, 404,'"request-content-type":"'.$cType.'"'); - } /** * Creates a sub array to define language variables. * @@ -191,9 +115,9 @@ public function databaseErr($info = '') { if (defined('WF_VERBOSE') && WF_VERBOSE === true) { $json->add('query', $info->getLastQuery()); } - $this->sendResponse($message, self::$E, 404, $json); + $this->sendResponse($message, self::E, 404, $json); } else { - $this->sendResponse($message, self::$E, 404, $info); + $this->sendResponse($message, self::E, 404, $info); } } /** @@ -255,112 +179,10 @@ public function getAuthorizationHeader() { public function getTranslation() { return $this->translation; } - /** - * Sends a response message to indicate that a request parameter(s) have invalid values. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"The following parameter(s) has invalid values: 'param_1', 'param_2', 'param_n'",
- *   "type":"error"
- * } - *

- * In addition to the message, The response will sent HTTP code 404 - Not Found. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.3 - */ - public function invParams() { - $val = ''; - $paramsNamesArr = $this->getInvalidParameters(); - - if (gettype($paramsNamesArr) == 'array') { - $i = 0; - $count = count($paramsNamesArr); - - foreach ($paramsNamesArr as $paramName) { - if ($i + 1 == $count) { - $val .= '\''.$paramName.'\''; - } else { - $val .= '\''.$paramName.'\', '; - } - $i++; - } - } - $message = $this->get('general/inv-params'); - $this->sendResponse($message.$val.'.', self::$E, 404); - } - /** - * Sends a response message to indicate that a request parameter or parameters are missing. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"The following required parameter(s) where missing from the request body: 'param_1', 'param_2', 'param_n'",
- *   "type":"error",
- * } - *

- * In addition to the message, The response will sent HTTP code 404 - Not Found. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.3 - */ - public function missingParams() { - $val = ''; - $paramsNamesArr = $this->getMissingParameters(); - - if (gettype($paramsNamesArr) == 'array') { - $i = 0; - $count = count($paramsNamesArr); - - foreach ($paramsNamesArr as $paramName) { - if ($i + 1 == $count) { - $val .= '\''.$paramName.'\''; - } else { - $val .= '\''.$paramName.'\', '; - } - $i++; - } - } - $message = $this->get('general/missing-params'); - $this->sendResponse($message.$val.'.', self::$E, 404); - } - /** - * Sends a response message to indicate that a user is not authorized to - * do an API call. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"Not authorized",
- *   "type":"error"
- * } - *

- * In addition to the message, The response will sent HTTP code 401 - Not Authorized. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.0 - */ - public function notAuth() { - $message = $this->get('general/http-codes/401/message'); - $this->sendResponse($message, self::$E, 401); - } /** * Auto-register services tables which exist on a specific directory. * - * Note that the statement 'return __NAMESPACE__' should be included at the - * end of service class for auto-register to work. If the statement - * does not exist, the method will assume that the path is the namespace of - * each class. Also, the classes which represents web services must be suffixed + * The classes which represents web services must be suffixed * with the word 'Service' in order to register them (e.g. RegisterUserService). * * @param string $pathToScan A path which is relative to application source @@ -376,28 +198,6 @@ public function registerServices($pathToScan) { $m->addService($ws); }, 'Service', [$this], [$this]); } - /** - * Sends a response message to indicate that request method is not supported. - * - * This method will send back a JSON string in the following format: - *

- * {
- *   "message":"Method Not Allowed.",
- *   "type":"error",
- * } - *

- * In addition to the message, The response will sent HTTP code 405 - Method Not Allowed. - * Note that the content of the field "message" might differ. It depends on - * the language. If no language is selected or language is not supported, - * The language that will be used is the language that was set as default - * language in the class 'SiteConfig'. - * - * @since 1.0 - */ - public function requestMethodNotAllowed() { - $message = $this->get('general/http-codes/405/message'); - $this->sendResponse($message, self::$E, 405); - } /** * Sets multiple language variables. * diff --git a/webfiori/framework/writers/WebServiceWriter.php b/webfiori/framework/writers/WebServiceWriter.php index d322499c..5537d217 100644 --- a/webfiori/framework/writers/WebServiceWriter.php +++ b/webfiori/framework/writers/WebServiceWriter.php @@ -10,7 +10,6 @@ */ namespace webfiori\framework\writers; -use webfiori\framework\EAbstractWebService; use webfiori\http\AbstractWebService; use webfiori\http\ParamOption; use webfiori\http\ParamType; @@ -51,7 +50,7 @@ public function __construct($webServicesObj = null) { parent::__construct('NewWebService', APP_PATH.'apis', APP_DIR.'\\apis'); $this->setSuffix('Service'); - $this->addUseStatement(EAbstractWebService::class); + $this->addUseStatement(AbstractWebService::class); $this->addUseStatement(ParamType::class); $this->addUseStatement(ParamOption::class); $this->addUseStatement(RequestMethod::class); @@ -146,7 +145,7 @@ public function writeClassComment() { } public function writeClassDeclaration() { - $this->append('class '.$this->getName().' extends EAbstractWebService {'); + $this->append('class '.$this->getName().' extends AbstractWebService {'); } /** *