1 | <?php |
||
14 | class UploadPie implements ImageDriverInterface |
||
15 | { |
||
16 | const CONFIG_PARAM_EXPIRE = 'expire'; |
||
17 | const CONFIG_PARAM_AUTH = 'auth'; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $expireMapping = ['30m' => 1, '1h' => 2, '6h' => 3, '1d' => 4, '1w' => 5]; |
||
23 | |||
24 | /** |
||
25 | * @var UploadPieApi |
||
26 | */ |
||
27 | private $api; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | private $expire; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $auth; |
||
38 | |||
39 | /** |
||
40 | * @param UploadPieApi|null $api |
||
41 | */ |
||
42 | public function __construct(UploadPieApi $api = null) |
||
46 | |||
47 | /** |
||
48 | * @param ArrayNodeDefinition $builder |
||
49 | */ |
||
50 | public function configure(ArrayNodeDefinition $builder) |
||
64 | |||
65 | /** |
||
66 | * @param ContainerBuilder $container |
||
67 | * @param array $config |
||
68 | */ |
||
69 | public function load(ContainerBuilder $container, array $config) |
||
74 | |||
75 | /** |
||
76 | * @param string $binaryImage |
||
77 | * @param string $filename |
||
78 | * |
||
79 | * @return string URL to the image |
||
80 | */ |
||
81 | public function upload($binaryImage, $filename) |
||
85 | |||
86 | /** |
||
87 | * @param string $expire |
||
88 | * |
||
89 | * @return int |
||
90 | */ |
||
91 | private function convertExpireValue($expire) |
||
95 | |||
96 | /** |
||
97 | * @param string $auth |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | private function resolveAuthParam($auth) |
||
111 | } |
||
112 |