This is an old revision of the document!
Table of Contents
DownloadService
Layer: Service · Source: lib/service/DownloadService.php:24 (lines 24–405)
class DownloadService
Business logic for download management
Docblock Metadata
^ Tag ^ Value ^ | ''@category'' | Service Class | | ''@author'' | M.Noermoehammad | | ''@license'' | MIT | | ''@version'' | 1.0 | | ''@since'' | Since Release 1.0 |
Inheritance
No parent, interface or trait. This is a root type.
Constants (0)
None.
Properties (0)
None declared.
Methods (24)
^ Visibility ^ Method ^ Summary ^ Line ^ | public | ''__construct()'' | (undocumented) | 30 | | public | ''validateDownloadRequest()'' | Validate download request | 43 | | public | ''getDownloadInfo()'' | Get download info by identifier | 58 | | public | ''getMediaByIdentifier()'' | Get media by identifier | 69 | | public | ''isDownloadExpired()'' | Check if download is expired | 86 | | public | ''isMimeTypeAllowed()'' | Check if MIME type is allowed | 103 | | public | ''createDownloadRecord()'' | Create download record | 115 | | public | ''deleteDownloadRecord()'' | Delete download record | 137 | | public | ''deleteDownloadRecords()'' | Delete multiple download records | 148 | | public | ''expireDownloadRecord()'' | Expire a download record | 165 | | public | ''expireDownloadRecords()'' | Expire multiple download records | 182 | | public | ''regenerateDownloadRecord()'' | Regenerate download identifier | 199 | | public | ''regenerateDownloadRecords()'' | Regenerate multiple download records | 220 | | public | ''generateDownloadIdentifier()'' | Generate download identifier | 236 | | public | ''refreshDownloadExpiry()'' | Refresh download expiry | 259 | | public | ''getDownloadUrl()'' | Get download URL | 278 | | public | ''recordDownloadAttempt()'' | Record download attempt | 299 | | public | ''getDownloadStatistics()'' | Get download statistics | 317 | | public | ''getDownloadCountByMedia()'' | Get download count by media | 348 | | public | ''getDownloadsByMedia()'' | Get downloads by media | 359 | | public | ''getDownloadHistory()'' | Get download history | 370 | | public | ''getFileTypeDistribution()'' | Get file type distribution | 380 | | public | ''getRecentDownloads()'' | Get recent downloads | 391 | | public | ''getAllDownloads()'' | Get all downloads with media info | 401 |
__construct()
public function __construct(DownloadModel $downloadModel, MediaDao $mediaDao)
lines 30–35 (6)
^ Parameter ^ Type ^ Default ^ Description ^ | ''$downloadModel'' | [[scriptlog:lib:model:downloadmodel|''DownloadModel'']] | //required// | //none// | | ''$mediaDao'' | [[scriptlog:lib:dao:mediadao|''MediaDao'']] | //required// | //none// |
validateDownloadRequest()
public function validateDownloadRequest($identifier)
lines 43–50 (8)
Validate download request
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — array|null
getDownloadInfo()
public function getDownloadInfo($identifier)
lines 58–61 (4)
Get download info by identifier
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — array|null
getMediaByIdentifier()
public function getMediaByIdentifier($identifier)
lines 69–78 (10)
Get media by identifier
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — array|null
isDownloadExpired()
public function isDownloadExpired($identifier)
lines 86–95 (10)
Check if download is expired
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
isMimeTypeAllowed()
public function isMimeTypeAllowed($mimeType)
lines 103–106 (4)
Check if MIME type is allowed
^ Parameter ^ Type ^ Default ^ Description ^ | ''$mimeType'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
createDownloadRecord()
public function createDownloadRecord($mediaId, $ipAddress)
lines 115–129 (15)
Create download record
^ Parameter ^ Type ^ Default ^ Description ^ | ''$mediaId'' | ''(untyped)'' | //required// | //none// | | ''$ipAddress'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — int
deleteDownloadRecord()
public function deleteDownloadRecord($identifier)
lines 137–140 (4)
Delete download record
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
deleteDownloadRecords()
public function deleteDownloadRecords($identifiers)
lines 148–157 (10)
Delete multiple download records
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifiers'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
expireDownloadRecord()
public function expireDownloadRecord($identifier)
lines 165–174 (10)
Expire a download record
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
expireDownloadRecords()
public function expireDownloadRecords($identifiers)
lines 182–191 (10)
Expire multiple download records
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifiers'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
regenerateDownloadRecord()
public function regenerateDownloadRecord($identifier)
lines 199–212 (14)
Regenerate download identifier
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — string|false
regenerateDownloadRecords()
public function regenerateDownloadRecords($identifiers)
lines 220–229 (10)
Regenerate multiple download records
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifiers'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
generateDownloadIdentifier()
public function generateDownloadIdentifier()
lines 236–251 (16)
Generate download identifier
Takes no parameters.
Returns: (none declared) — string
refreshDownloadExpiry()
public function refreshDownloadExpiry($identifier)
lines 259–269 (11)
Refresh download expiry
^ Parameter ^ Type ^ Default ^ Description ^ | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — bool
getDownloadUrl()
public function getDownloadUrl($_mediaId, $identifier)
lines 278–287 (10)
Get download URL
^ Parameter ^ Type ^ Default ^ Description ^ | ''$_mediaId'' | ''(untyped)'' | //required// | //none// | | ''$identifier'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — string
recordDownloadAttempt()
public function recordDownloadAttempt($mediaId, $identifier, $ipAddress, $userAgent, $status = 'success')
lines 299–310 (12)
Record download attempt
^ Parameter ^ Type ^ Default ^ Description ^ | ''$mediaId'' | ''(untyped)'' | //required// | //none// | | ''$identifier'' | ''(untyped)'' | //required// | //none// | | ''$ipAddress'' | ''(untyped)'' | //required// | //none// | | ''$userAgent'' | ''(untyped)'' | //required// | //none// | | ''$status'' | ''(untyped)'' | '''success''' | //none// |
Returns: (none declared) — bool
getDownloadStatistics()
public function getDownloadStatistics()
lines 317–340 (24)
Get download statistics
Takes no parameters.
Returns: (none declared) — array
getDownloadCountByMedia()
public function getDownloadCountByMedia($mediaId)
lines 348–351 (4)
Get download count by media
^ Parameter ^ Type ^ Default ^ Description ^ | ''$mediaId'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — int
getDownloadsByMedia()
public function getDownloadsByMedia($mediaId)
lines 359–362 (4)
Get downloads by media
^ Parameter ^ Type ^ Default ^ Description ^ | ''$mediaId'' | ''(untyped)'' | //required// | //none// |
Returns: (none declared) — array
getDownloadHistory()
public function getDownloadHistory($limit = 50)
lines 370–373 (4)
Get download history
^ Parameter ^ Type ^ Default ^ Description ^ | ''$limit'' | ''(untyped)'' | ''50'' | //none// |
Returns: (none declared) — array
getFileTypeDistribution()
public function getFileTypeDistribution()
lines 380–383 (4)
Get file type distribution
Takes no parameters.
Returns: (none declared) — array
getRecentDownloads()
public function getRecentDownloads($limit = 10)
lines 391–394 (4)
Get recent downloads
^ Parameter ^ Type ^ Default ^ Description ^ | ''$limit'' | ''(untyped)'' | ''10'' | //none// |
Returns: (none declared) — array
getAllDownloads()
public function getAllDownloads()
lines 401–404 (4)
Get all downloads with media info
Takes no parameters.
Returns: (none declared) — array
Imports
^ Alias ^ Fully-qualified name ^ | ''Sanitize'' | [[scriptlog:lib:core:sanitize|''Scriptlog\Core\Sanitize'']] | | ''MediaDao'' | [[scriptlog:lib:dao:mediadao|''Scriptlog\Dao\MediaDao'']] | | ''DownloadModel'' | [[scriptlog:lib:model:downloadmodel|''Scriptlog\Model\DownloadModel'']] |
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
