本文整理汇总了PHP中Library\Utility\Helper::humanFilesize方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::humanFilesize方法的具体用法?PHP Helper::humanFilesize怎么用?PHP Helper::humanFilesize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library\Utility\Helper
的用法示例。
在下文中一共展示了Helper::humanFilesize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItemAttachmentListForPreview
/**
* @todo: in thin method we can get also a files, that doesn't written in DB if any exists
*
* @param array $itemIdList
* @return array
*/
public function getItemAttachmentListForPreview($itemIdList)
{
/**
* @var ExpenseItemAttachments $attachmentsDao
* @var \DDD\Domain\Finance\Expense\ExpenseItemAttachments $attachment
*/
$attachmentsDao = $this->getServiceLocator()->get('dao_finance_expense_expense_item_attachments');
$attachmentList = [];
if (count($itemIdList)) {
$attachmentsDomain = $attachmentsDao->getAttachmentsForPreview($itemIdList);
if ($attachmentsDomain->count()) {
foreach ($attachmentsDomain as $attachment) {
$filePath = $this->getExpenseItemImagePath($attachment->getExpenseId(), $attachment->getItemId(), $attachment->getFilename(), $attachment->getDateCreatedNeededFormat());
if (is_readable($filePath)) {
$filesize = Helper::humanFilesize(filesize($filePath));
$extension = pathinfo($attachment->getFilename(), PATHINFO_EXTENSION);
$attachmentList[$attachment->getItemId()] = ['id' => $attachment->getId(), 'name' => $attachment->getFilename(), 'size' => $filesize, 'path' => $filePath, 'extension' => $extension, 'isImage' => in_array(strtolower($extension), ['png', 'jpg', 'jpeg', 'gif']) ? 1 : 0];
}
}
}
}
return $attachmentList;
}