PHP类链

时间:2016-08-16 20:53:14

标签: php class symfony

我正在使用Picoss的SMoney软件包,我的代码:

$http = new HttpClient("token","url");
$api = new SMoneyApi($http);

$profile = new \Picoss\SMoney\Entity\Profile();
$profile->setCivility(0);
$profile->setLastName("Doe");
$profile->setFirstName("John");
$profile->setEmail("johndoe@gmail.com");
$profile->setPhoneNumber("000000000");

$user = new \Picoss\SMoney\Entity\User();
$user->setAppUserId(time());
$user->setProfile($profile);
$user->setType(1);

$api->user()->save($user); // works

如何在我的元素上使用此代码来获取所有错误:

$api->user()->getErrors(); // works

我想做:

$api->user()->save($user)->getErrors(); // doesn't works

但我不能,你有解决方案吗?

信息:

  • SMoneyApi有方法user(),它扩展了ApiUser
  • APIUser扩展了ApiBase
  • ApiBase(抽象类)有方法: getErrors();
  • getErrors扩展了SMoneyError

https://github.com/picoss/SMoney/blob/master/src/SMoneyError.php

==

解决了:

$d = $api->user();
$apis = $d->save($user);
var_dump($d->getErrors());

由于

0 个答案:

没有答案