Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OlzArtgrisFileManagerConf | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getConf | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Apps\Files\Service; |
| 4 | |
| 5 | use Artgris\Bundle\FileManagerBundle\Service\CustomConfServiceInterface; |
| 6 | use Olz\Utils\WithUtilsTrait; |
| 7 | use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; |
| 8 | |
| 9 | #[Autoconfigure(public: true)] |
| 10 | class OlzArtgrisFileManagerConf implements CustomConfServiceInterface { |
| 11 | use WithUtilsTrait; |
| 12 | |
| 13 | /** @return array{dir: string} */ |
| 14 | // @phpstan-ignore-next-line |
| 15 | public function getConf($extra = []): array { |
| 16 | $data_path = $this->envUtils()->getDataPath(); |
| 17 | |
| 18 | $user = $this->authUtils()->getCurrentUser(); |
| 19 | if (!$user) { |
| 20 | $this->httpUtils()->dieWithHttpError(401); |
| 21 | throw new \Exception('should already have failed'); |
| 22 | } |
| 23 | if (!$this->authUtils()->hasPermission('ftp', $user)) { |
| 24 | $this->httpUtils()->dieWithHttpError(403); |
| 25 | throw new \Exception('should already have failed'); |
| 26 | } |
| 27 | $user_root = $user->getRoot(); |
| 28 | if (!$user_root) { |
| 29 | $this->httpUtils()->dieWithHttpError(403); |
| 30 | throw new \Exception('should already have failed'); |
| 31 | } |
| 32 | |
| 33 | return [ |
| 34 | 'dir' => "{$data_path}OLZimmerbergAblage/{$user_root}", |
| 35 | ]; |
| 36 | } |
| 37 | } |