1 | <?php |
||
10 | class SetTempUrlKey extends Command |
||
11 | { |
||
12 | /** |
||
13 | * The name and signature of the console command. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $signature = 'ovh:set-temp-url-key |
||
18 | {--key= : The key you want to set up on your container} |
||
19 | {--force : Forcibly set a new key on the container}'; |
||
20 | |||
21 | /** |
||
22 | * The console command description. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $description = 'Set temp url key on the private container, making the use of Storage::temporaryUrl() possible'; |
||
27 | |||
28 | /** |
||
29 | * The Object Storage Container. |
||
30 | * |
||
31 | * @var Container |
||
32 | */ |
||
33 | protected $container; |
||
34 | |||
35 | /** |
||
36 | * Create a new command instance. |
||
37 | * |
||
38 | * @return void |
||
|
|||
39 | */ |
||
40 | public function __construct() |
||
46 | |||
47 | /** |
||
48 | * Execute the console command. |
||
49 | * |
||
50 | * If the '--force' flag is provided, a new Temp URL Key will be generated and |
||
51 | * forcefully set in the Container's metadata, overriding any existing keys. |
||
52 | * |
||
53 | * If the command is not forced and there's an existing key, the User will be |
||
54 | * prompted to override the existing keys. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function handle(): void |
||
64 | |||
65 | /** |
||
66 | * If there's no existing Temp URL Key present in the Container, continue. |
||
67 | * |
||
68 | * Otherwise, if there's already an existing Temp URL Key present in the |
||
69 | * Container, the User will be prompted to choose if we should override it |
||
70 | * or not. |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | protected function askIfShouldOverrideExistingKey(): bool |
||
85 | |||
86 | /** |
||
87 | * Generates a random Temp URL Key. |
||
88 | * |
||
89 | * For more details, please refer to: |
||
90 | * - https://docs.ovh.com/gb/en/public-cloud/share_an_object_via_a_temporary_url/#generate-the-temporary-address-tempurl |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | protected function getRandomKey(): string |
||
98 | |||
99 | /** |
||
100 | * Updates the Temp URL Key for the Container. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | protected function setContainerKey(): void |
||
116 | } |
||
117 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.