Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
10 | abstract class AbstractPathGenerator |
||
11 | { |
||
12 | /** |
||
13 | * @param Media $media |
||
14 | * |
||
15 | * @return string |
||
16 | */ |
||
17 | public static function getBasePathForMediaOriginal($media) |
||
18 | { |
||
19 | $basePath = self::getBasePathForMedia($media); |
||
20 | $originalPath = $media->getCollection()->getOriginalPath(); |
||
21 | if (!empty($originalPath)) { |
||
22 | $basePath .= DIRECTORY_SEPARATOR.$media->getCollection()->getOriginalPath(); |
||
23 | } |
||
24 | |||
25 | return $basePath; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param Media $media |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | public static function getBasePathForMedia($media) |
||
34 | { |
||
35 | return '/'.$media->getCollection()->getName() |
||
36 | .'/'.static::getFolderNameForMedia($media) |
||
37 | .'/'.$media->getModel()->getPrimaryKey() |
||
|
|||
38 | .'/'; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param Media $media |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | public static function getFolderNameForMedia($media) |
||
47 | { |
||
48 | $model = $media->getModel(); |
||
49 | if (method_exists($model, 'getFolderNameForMedia')) { |
||
50 | return $model->getFolderNameForMedia(); |
||
51 | } |
||
52 | |||
53 | return $media->getModel()->getManager()->getTable(); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param Media $media |
||
58 | * @param string $conversionName |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public static function getBasePathForMediaConversion($media, $conversionName) |
||
65 | } |
||
66 | } |
||
67 |