Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object argument of action bind with request parameters #101

Merged
merged 8 commits into from
Jun 27, 2018
Merged

Object argument of action bind with request parameters #101

merged 8 commits into from
Jun 27, 2018

Conversation

HZMarico
Copy link
Contributor

now

/**
 * Class DemoController
 * @package App\Controllers
 * @Controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param Request $request
     * @param Response $response
     * @return array
     */
    public function list(Request $request, Response $response)
    {
        return [];
    }
}

feature

/**
 * Class DemoController
 * @package App\Controllers
 * @Controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param EntityObject $model
     * @param OtherObject $object
     * @return array
     */
    public function list(EntityObject $model, OtherObject $object)
    {
        return [];
    }
}

now
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param Request $request
     * @param Response $response
     * @return array
     */
    public function list(Request $request, Response $response)
    {
        return [];
    }
}
```
feature
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param EntityObject $model
     * @param OtherObject $object
     * @return array
     */
    public function list(EntityObject $model, OtherObject $object)
    {
        return [];
    }
}
```
@wujunze wujunze requested review from huangzhhui and inhere June 19, 2018 07:23
Copy link
Member

@inhere inhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 创建反射类之前最好先判断下是否是个 class

另外建议 可以先检查是否是个bean, 是的话直接从容器里拿对象,返回

@HZMarico
Copy link
Contributor Author

好的,我再细化一下

Marico added 2 commits June 20, 2018 09:16
1. Bean Object Supported
2. Add class_exists($type)
fixed error
huangzhhui and others added 4 commits June 22, 2018 16:02
when  function __construct is private 
```
$object = $reflectClass->newInstance(); 
```
will error
@huangzhhui huangzhhui changed the title [feature]more controller method param supported Object argument of action bind with request parameters Jun 27, 2018
Copy link
Contributor

@huangzhhui huangzhhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应当完善 bindRequestParamsToClass 方法的单测

@huangzhhui huangzhhui merged commit 2425d46 into swoft-cloud:master Jun 27, 2018
@huangzhhui
Copy link
Contributor

@HZMarico 后续完善一下 bindRequestParamsToClass 方法的单测 及 相关调整的文档

huangzhhui pushed a commit to swoft-cloud/swoft-http-server that referenced this pull request Jul 10, 2018
…woft-component#101)

* [feature]more controller method param supported

now
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param Request $request
     * @param Response $response
     * @return array
     */
    public function list(Request $request, Response $response)
    {
        return [];
    }
}
```
feature
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param EntityObject $model
     * @param OtherObject $object
     * @return array
     */
    public function list(EntityObject $model, OtherObject $object)
    {
        return [];
    }
}
```
huangzhhui added a commit that referenced this pull request Jul 10, 2018
f54584ce Object argument of action bind with request parameters (#101)
e484ebe7  add coWrite(); use swoft/swoole-ide-helper (#83)

git-subtree-dir: src/http-server
git-subtree-split: f54584ce3ffa07def55570d88e4f10e4f1c3deb5
swoft-bot pushed a commit to swoft-cloud/swoft-view that referenced this pull request Jan 25, 2019
…woft-component#101)

* [feature]more controller method param supported

now
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param Request $request
     * @param Response $response
     * @return array
     */
    public function list(Request $request, Response $response)
    {
        return [];
    }
}
```
feature
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param EntityObject $model
     * @param OtherObject $object
     * @return array
     */
    public function list(EntityObject $model, OtherObject $object)
    {
        return [];
    }
}
```
stelin pushed a commit to swoft-cloud/swoft-http-server that referenced this pull request May 28, 2019
…woft-component#101)

* [feature]more controller method param supported

now
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param Request $request
     * @param Response $response
     * @return array
     */
    public function list(Request $request, Response $response)
    {
        return [];
    }
}
```
feature
```
/**
 * Class DemoController
 * @Package App\Controllers
 * @controller(prefix="/demo")
 */
class DemoController
{
    /**
     * @RequestMapping(route="/demo", method={RequestMethod::GET})
     * @param EntityObject $model
     * @param OtherObject $object
     * @return array
     */
    public function list(EntityObject $model, OtherObject $object)
    {
        return [];
    }
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants