Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/Contract/Lib/FileResolverContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StaticResolverBundle\Contract\Lib;

use DateInterval;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use Pimcore\Cache;
use Pimcore\File;

class FileResolverContract implements FileResolverContractInterface
{
public function getValidFilename(string $tmpFilename, ?string $language = null, string $replacement = '-'): string {

Check warning on line 24 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwg&open=AZraU-niOdNxCidlYXwg&pullRequest=121
return File::getValidFilename($tmpFilename, $language, $replacement);
}

public function putPhpFile(string $path, string $data): void {

Check warning on line 28 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwh&open=AZraU-niOdNxCidlYXwh&pullRequest=121
File::putPhpFile($path, $data);
}

public function getContext() {

Check warning on line 32 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwi&open=AZraU-niOdNxCidlYXwi&pullRequest=121
return File::getContext();
}

public function setContext($context): void {

Check warning on line 36 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwj&open=AZraU-niOdNxCidlYXwj&pullRequest=121
File::setContext($context);
}

public function getLocalTempFilePath(?string $fileExtension = null, bool $keep = false): string {

Check warning on line 40 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwk&open=AZraU-niOdNxCidlYXwk&pullRequest=121
return File::getLocalTempFilePath($fileExtension, $keep);
}

/**
* @throws FilesystemException
*/
public function recursiveDeleteEmptyDirs(FilesystemOperator $storage, string $storagePath): void {

Check warning on line 47 in src/Contract/Lib/FileResolverContract.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=pimcore_static-resolver-bundle&issues=AZraU-niOdNxCidlYXwl&open=AZraU-niOdNxCidlYXwl&pullRequest=121
File::recursiveDeleteEmptyDirs($storage, $storagePath);
}
}
32 changes: 32 additions & 0 deletions src/Contract/Lib/FileResolverContractInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StaticResolverBundle\Contract\Lib;

use League\Flysystem\FilesystemOperator;

interface FileResolverContractInterface
{
public function getValidFilename(string $tmpFilename, ?string $language = null, string $replacement = '-'): string;
public function putPhpFile(string $path, string $data): void;
/**
* @return null|resource
*/
public function getContext();
/**
* @param resource $context
*/
public function setContext($context): void;
public function getLocalTempFilePath(?string $fileExtension = null, bool $keep = false): string;
public function recursiveDeleteEmptyDirs(FilesystemOperator $storage, string $storagePath): void;
}
23 changes: 23 additions & 0 deletions src/Lib/FileResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StaticResolverBundle\Lib;

use Pimcore\Bundle\StaticResolverBundle\Contract\Lib\FileResolverContract;

/**
* @internal
*/
final class FileResolver extends FileResolverContract implements FileResolverInterface
{
}
23 changes: 23 additions & 0 deletions src/Lib/FileResolverInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StaticResolverBundle\Lib;

use Pimcore\Bundle\StaticResolverBundle\Contract\Lib\FileResolverContractInterface;

/**
* @internal
*/
interface FileResolverInterface extends FileResolverContractInterface
{
}