コード例 #1
0
 /**
  * Get a resource by `id`
  * @param  array  $params  Request parameters
  * @param  string $method  Request method
  * @param  array $headers  Request headers
  * @throws \Phramework\Exceptions\NotFoundException If resource doesn't exist or is
  * inaccessible
  */
 public static function GETById($params, $method, $headers, $id)
 {
     $id = \Phramework\Validate\UnsignedIntegerValidator::parseStatic($id);
     return self::handleGETById($params, $id, static::$systemLogModel, [], []);
 }
コード例 #2
0
ファイル: Request.php プロジェクト: phramework/phramework
 /**
  * Require id parameter if it's set else return NULL, it uses `resource_id` or `id` parameter if available
  * @param  array|object $parameters  The request parameters
  * @param  boolean      $UINTEGER  *[Optional]*, Check id's type to be unsigned integer
  * @throws \Phramework\Exceptions\IncorrectParameters When value is not correct
  * @return string|integer Returns the id or NULL if not set,
  * if $UINTEGER the returned value will be converted to unsigned integer
  */
 public static function resourceId($parameters, $UINTEGER = true)
 {
     //Work with arrays
     if (is_object($parameters)) {
         $parameters = (array) $parameters;
     }
     //Check if is set AND validate
     if (isset($parameters['resource_id']) && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['resource_id']) !== false) {
         if ($UINTEGER) {
             return UnsignedIntegerValidator::parseStatic($parameters['resource_id']);
         }
         return $parameters['resource_id'];
     }
     if (isset($parameters['id']) && preg_match(Validate::REGEXP_RESOURCE_ID, $parameters['id']) !== false) {
         if ($UINTEGER) {
             return UnsignedIntegerValidator::parseStatic($parameters['id']);
         }
         return $parameters['id'];
     }
     return false;
 }