本文整理汇总了PHP中Coupon::createFromStdClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Coupon::createFromStdClass方法的具体用法?PHP Coupon::createFromStdClass怎么用?PHP Coupon::createFromStdClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coupon
的用法示例。
在下文中一共展示了Coupon::createFromStdClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromStdClass
/**
* @param \stdClass $data
*
* @return Promotion
*/
public static function createFromStdClass(\stdClass $data)
{
$promotion = new self();
$promotion->setId($data->id)->setAlias($data->alias)->setName($data->name)->setType($data->type)->setDescription($data->description)->setNeedProof($data->need_proof)->setOrganizationOwnerId($data->organization_owner_id);
if ($data->coupon !== null) {
$promotion->setCoupon(Coupon::createFromStdClass($data->coupon));
}
if ($data->bonus_program !== null) {
$promotion->setBonusProgram(Bonus::createFromStdClass($data->bonus_program));
}
if ($data->discount !== null) {
$promotion->setDiscount(Discount::createFromStdClass($data->discount));
}
if ($data->currency !== null) {
$promotion->setCurrency(Currency::createFromStdClass($data->currency));
}
if ($data->expires_at !== null) {
$promotion->setExpiresAt((new \DateTime(null, new \DateTimeZone('UTC')))->setTimestamp($data->expires_at));
}
foreach ($data->organizations as $organizationData) {
$promotion->addOrganization(Organization::createFromStdClass($organizationData));
}
return $promotion;
}