Skip to content

Commit 2c7b003

Browse files
authored
Added File class (#121)
1 parent 16509e2 commit 2c7b003

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Lib;
15+
16+
use DateInterval;
17+
use League\Flysystem\FilesystemException;
18+
use League\Flysystem\FilesystemOperator;
19+
use Pimcore\Cache;
20+
use Pimcore\File;
21+
22+
class FileResolverContract implements FileResolverContractInterface
23+
{
24+
public function getValidFilename(string $tmpFilename, ?string $language = null, string $replacement = '-'): string {
25+
return File::getValidFilename($tmpFilename, $language, $replacement);
26+
}
27+
28+
public function putPhpFile(string $path, string $data): void {
29+
File::putPhpFile($path, $data);
30+
}
31+
32+
public function getContext() {
33+
return File::getContext();
34+
}
35+
36+
public function setContext($context): void {
37+
File::setContext($context);
38+
}
39+
40+
public function getLocalTempFilePath(?string $fileExtension = null, bool $keep = false): string {
41+
return File::getLocalTempFilePath($fileExtension, $keep);
42+
}
43+
44+
/**
45+
* @throws FilesystemException
46+
*/
47+
public function recursiveDeleteEmptyDirs(FilesystemOperator $storage, string $storagePath): void {
48+
File::recursiveDeleteEmptyDirs($storage, $storagePath);
49+
}
50+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Lib;
15+
16+
use League\Flysystem\FilesystemOperator;
17+
18+
interface FileResolverContractInterface
19+
{
20+
public function getValidFilename(string $tmpFilename, ?string $language = null, string $replacement = '-'): string;
21+
public function putPhpFile(string $path, string $data): void;
22+
/**
23+
* @return null|resource
24+
*/
25+
public function getContext();
26+
/**
27+
* @param resource $context
28+
*/
29+
public function setContext($context): void;
30+
public function getLocalTempFilePath(?string $fileExtension = null, bool $keep = false): string;
31+
public function recursiveDeleteEmptyDirs(FilesystemOperator $storage, string $storagePath): void;
32+
}

src/Lib/FileResolver.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StaticResolverBundle\Lib;
15+
16+
use Pimcore\Bundle\StaticResolverBundle\Contract\Lib\FileResolverContract;
17+
18+
/**
19+
* @internal
20+
*/
21+
final class FileResolver extends FileResolverContract implements FileResolverInterface
22+
{
23+
}

src/Lib/FileResolverInterface.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StaticResolverBundle\Lib;
15+
16+
use Pimcore\Bundle\StaticResolverBundle\Contract\Lib\FileResolverContractInterface;
17+
18+
/**
19+
* @internal
20+
*/
21+
interface FileResolverInterface extends FileResolverContractInterface
22+
{
23+
}

0 commit comments

Comments
 (0)