【发布时间】:2015-06-24 18:06:42
【问题描述】:
我已经为我正在使用的 API 制作了自己的 Wrapper,现在我有一个可以注册用户的类,我需要在整个类中获取该 API 调用的结果。
所以我想知道是否有可能让结果对象 API 作为对象返回以使用并传递给其他方法
这是我的代码,我添加了内联 cmets 以澄清问题
class RegisterController extends Controller {
private $company;
public function __construct()
{
// This is not the object I want, It's the class that communicates with the API
$this->company = new Teamleader\Company;
}
public function index($id = null)
{
// I'm trying to set the class to the result of the API call ( returns an StdObject )
$this->company = $this->company->get($id);
// Still returns the original object, not the result of the API call
var_dump($this->company);
}
public function register()
{
// Also returns the original object
dd($this->company);
}
}
非常感谢你,一个困惑的开发者。
【问题讨论】: