2
以下のコードをテストした結果、同じ結果が得られます。私の質問は、両者の違いは何ですか?Silverstripeで作成されたレスポンスの差
public function someaction1(SS_HTTPRequest $request) {
$this->setResponse(new SS_HTTPResponse());
$this->getResponse()->setStatusCode(400);
$this->getResponse()->setBody('invalid');
return $this->getResponse();
}
public function someaction2(SS_HTTPRequest $request) {
$this->response = new SS_HTTPResponse();
$this->response->setStatusCode(400);
$this->response->setBody('invalid');
return $this->response;
}
追加するには、$ this-> responseが返されます。または$ this-> getResponse()を返します。必要なのか暗黙的なのか?違いはありません
getX()およびsetX()は[Mutator methods](https://en.wikipedia.org/wiki/Mutator_method)です。 http://stackoverflow.com/questions/1568091/wh y-use-getters-and-setters) –