Beispiel #1
0
<?php

use Phale\Module;
use Phale\Request;
use Phale\Response;
use PhaleDemo\Database;
use PhaleDemo\User\IUserService;
use PhaleDemo\User\UserService;
$users = new Module('users');
$users->factory('userService', ['database'], function (Database $database) {
    return new UserService($database);
});
/**
 * @api {get} /user List
 * @apiName ListUsers
 * @apiGroup User
 */
$users->get('', ['userService'], function (Request $request, Response $response, IUserService $userService) {
    $response->json($userService->findAll());
});
$users->post('', ['userService'], function (Request $request, Response $response, IUserService $userService) {
});
require_once 'user.api.php';
$users->module('/:id', $user);
Beispiel #2
0
 public function delete_ValidHandler_RegisterEndpoint()
 {
     // arrange
     $expectedEndpoint = new Endpoint(self::VALID_ENDPOINT_PATH, $this->VALID_ENDPOINT_DEPENDENCIES, $this->VALID_ENDPOINT_HANDLER);
     $module = new Module(self::VALID_MODULE_NAME);
     // act
     $module->delete(self::VALID_ENDPOINT_PATH, $this->VALID_ENDPOINT_DEPENDENCIES, $this->VALID_ENDPOINT_HANDLER);
     // assert
     Assert::areSame($module->endpoints, ['GET' => [], 'POST' => [], 'PUT' => [], 'DELETE' => [self::VALID_ENDPOINT_PATH => $expectedEndpoint]]);
 }
Beispiel #3
0
<?php

use Phale\Module;
use Phale\Request;
use Phale\Response;
use PhaleDemo\User\IUserService;
use PhaleDemo\User\UserNotFoundException;
$user = new Module('user');
/**
 * @api {get} /user/:id Get
 * @apiName GetUser
 * @apiGroup User
 * @apiVersion 1.0.0
 *
 * @apiParam (URL Parameters) {Integer} id The user id.
 *
 * @apiParamExample Request Example
 * GET /user/1
 *
 * @apiSuccess {Integer} id The user id.
 * @apiSuccess {String} username The login username.
 * @apiSuccess {String} password The login password.
 * @apiSuccess {String} email The user email address.
 * @apiSuccess {String} notes Notes about the user record.
 * @apiSuccess {Boolean} deleted Whether the user record is deleted.
 * @apiSuccess {Timestamp} created_at When the user was created.
 * @apiSuccess {Timestamp} updated_at When the user was last updated.
 *
 * @apiSuccessExample {json} Response Example
 * HTTP/1.1 200 OK
 * {