本文整理汇总了PHP中Label::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::import方法的具体用法?PHP Label::import怎么用?PHP Label::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Label
的用法示例。
在下文中一共展示了Label::import方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($data = [], $connection = null)
{
$this->connection = $connection;
foreach (['id', 'shipment_reference', 'tracking_url'] as $prop) {
if (isset($data[$prop])) {
$this->{$prop} = $data[$prop];
}
}
foreach (['sender', 'recipient'] as $prop) {
$this->{$prop} = isset($data[$prop]) ? Address::import($data[$prop]) : null;
}
$this->product = isset($data['product']) ? Product::import($data['product']) : null;
if (isset($data['parcels'])) {
$this->parcels = [];
foreach ($data['parcels'] as $parcel_data) {
$this->parcels[] = Parcel::import($parcel_data);
}
}
if (isset($data['labels'])) {
$this->labels = [];
foreach ($data['labels'] as $url) {
$this->labels[] = Label::import($url, $connection);
}
}
if (isset($data['order'])) {
$this->order = Order::import($data['order'], $connection);
}
if (isset($data['allow'])) {
$this->allow = $data['allow'];
}
}
示例2: fetch
public function fetch($mixed)
{
if ($mixed instanceof LabelRef) {
$path = $mixed->url;
} else {
$path = "labels/{$mixed}";
}
$response = $this->client()->get($path);
if ($response->getStatusCode() == 200) {
$content_disposition = $response->getHeader('Content-Disposition');
$filename = null;
if (preg_match('/filename="([^"]+)"/', $content_disposition[0], $mm)) {
$filename = $mm[1];
}
if ($filename) {
return Label::import(['filename' => $filename, 'content' => $response->getBody()], $this->connection);
}
}
}