本文整理匯總了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;
}