简体   繁体   中英

Can i define parameters with Classes in Restler?

I want to declare params with differenc classes when i have a GET endpoint.

Example:

/**
* @param ClassA a
* @param ClassB b
...
public function getSomething() {}

public ClassA {
    /**
    * @param int
    */
    public $i;
}

public ClassB {
    ...
}

Yes, using the class as a parameter works fine. See https://restler5.luracast.com/examples/_016_forms/readme.html Users class makes use of Address class

/**
 * @param string  $firstName
 * @param string  $lastName
 * @param string  $email
 * @param string  $password
 * @param Address $address
 *
 * @return array
 *
 * @view users
 */
function postSignUp($firstName, $lastName, $email, $password, $address)
{
    return func_get_args();
}

Address class is as follows

<?PHP
class Address
{
    public $blockNumber;
    public $streetName;
    public $floor;
    public $unitNumber;
    public $country;
    public $postalCode;
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM