Skip to content

Commit

Permalink
Add documentation and many code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Nov 13, 2024
1 parent 94b0ee8 commit 1d387af
Show file tree
Hide file tree
Showing 36 changed files with 42 additions and 69 deletions.
2 changes: 2 additions & 0 deletions Classes/Cache/IdentifierBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function getFilepath(string $requestUri): string
$parts['path'] = rawurldecode($parts['path']);
}

// @todo add Event

$absoluteBasePath = GeneralUtility::makeInstance(CacheService::class)->getAbsoluteBaseDirectory();
$resultPath = GeneralUtility::resolveBackPath($absoluteBasePath . implode('/', $parts));

Expand Down
2 changes: 0 additions & 2 deletions Classes/Cache/Listener/EnableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use SFC\Staticfilecache\Service\ConfigurationService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

class EnableListener
{
Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/NoBackendUserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* No active BE user.
Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/NoUserOrGroupSetListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/NoWorkspacePreviewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Core\Context\Context;

Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/SiteCacheableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Core\Site\Entity\Site;

Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/ValidDoktypeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/Listener/ValidPageInformationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

Expand Down
8 changes: 2 additions & 6 deletions Classes/Cache/RemoteFileBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ class RemoteFileBackend extends AbstractBackend implements TaggableBackendInterf

/**
* Is freezed?
*
* @var bool
*/
protected $freeze = false;
protected bool $freeze = false;

/**
* Hash length.
*
* @var int
*/
protected $hashLength = 3;
protected int $hashLength = 3;

/**
* Set hash length.
Expand Down
3 changes: 0 additions & 3 deletions Classes/Cache/StaticDatabaseBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ abstract class StaticDatabaseBackend extends Typo3DatabaseBackend implements Log
{
use LoggerAwareTrait;

/**
* Configuration.
*/
protected ConfigurationService $configuration;

/**
Expand Down
1 change: 0 additions & 1 deletion Classes/Cache/StaticFileBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)

$this->removeStaticFiles($entryIdentifier);


$this->eventDispatcher->dispatch(new GeneratorCreate($entryIdentifier, $fileName, $data, $realLifetime));
} catch (\Exception $exception) {
$this->logger->error('Error in cache create process', ['exception' => $exception]);
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/BoostQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SFC\Staticfilecache\Command;

use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use SFC\Staticfilecache\Domain\Repository\QueueRepository;
use SFC\Staticfilecache\Service\QueueService;
use Symfony\Component\Console\Input\InputInterface;
Expand Down
2 changes: 0 additions & 2 deletions Classes/Command/FlushCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace SFC\Staticfilecache\Command;

use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
use SFC\Staticfilecache\Service\CacheService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down
3 changes: 0 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Cache\UriFrontend;
use TYPO3\CMS\Backend\Template\Components\Menu\Menu;
use TYPO3\CMS\Backend\Template\Components\Menu\MenuItem;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Domain\Repository\PageRepository;
use SFC\Staticfilecache\Domain\Repository\QueueRepository;
Expand All @@ -23,7 +21,6 @@
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Repository/CacheRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* CacheRepository.
*/
class CacheRepository extends AbstractRepository
{
/**
Expand Down
2 changes: 0 additions & 2 deletions Classes/Event/GeneratorConfigManipulationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace SFC\Staticfilecache\Event;

use Psr\Http\Message\ResponseInterface;

final class GeneratorConfigManipulationEvent
{
public function __construct(
Expand Down
2 changes: 0 additions & 2 deletions Classes/Event/GeneratorContentManipulationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace SFC\Staticfilecache\Event;

use Psr\Http\Message\ResponseInterface;

final class GeneratorContentManipulationEvent
{
public function __construct(
Expand Down
3 changes: 1 addition & 2 deletions Classes/Generator/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace SFC\Staticfilecache\Generator;

use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\ConfigurationService;
Expand Down Expand Up @@ -43,7 +42,7 @@ protected function renderTemplateToFile(string $templateName, array $variables,
$renderer = GeneralUtility::makeInstance(StandaloneView::class);
$renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateName));
$renderer->assignMultiple($variables);
$content = trim((string) $renderer->render());
$content = trim($renderer->render());
// Note: Create even empty htaccess files (do not check!!!), so the delete is in sync
$this->writeFile($htaccessFile, $content);
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/Generator/BrotliGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Event\GeneratorContentManipulationEvent;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class BrotliGenerator extends AbstractGenerator implements LoggerAwareInterface
{
Expand Down
2 changes: 0 additions & 2 deletions Classes/Generator/ConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Event\GeneratorConfigManipulationEvent;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\ConfigurationService;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ConfigGenerator extends AbstractGenerator
Expand Down
3 changes: 0 additions & 3 deletions Classes/Generator/GzipGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Event\GeneratorContentManipulationEvent;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;

class GzipGenerator extends AbstractGenerator
Expand Down
3 changes: 0 additions & 3 deletions Classes/Generator/HtaccessGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\ConfigurationService;
use SFC\Staticfilecache\Service\DateTimeService;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;

class HtaccessGenerator extends AbstractGenerator
{
Expand Down
6 changes: 0 additions & 6 deletions Classes/Generator/PhpGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@

namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use SFC\Staticfilecache\Event\GeneratorContentManipulationEvent;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\ConfigurationService;
use SFC\Staticfilecache\Service\DateTimeService;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;

/**
* PlainGenerator.
*/
class PhpGenerator extends HtaccessGenerator
{
public function generate(GeneratorCreate $generatorCreateEvent): void
Expand Down
1 change: 1 addition & 0 deletions Classes/Middleware/FallbackMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected function handleViaFallback(ServerRequestInterface $request): ResponseI
throw new Exception('StaticFileCache Cookie is set', 12738912);
}

// @todo ID Buulder with DI
$possibleStaticFile = GeneralUtility::makeInstance(IdentifierBuilder::class)->getFilepath((string) $uri);

$headers = $this->getHeaders($event->getRequest(), $possibleStaticFile);
Expand Down
2 changes: 0 additions & 2 deletions Classes/Middleware/GenerateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
namespace SFC\Staticfilecache\Middleware;

use Psr\Http\Message\RequestInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\CacheDataCollector;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace SFC\Staticfilecache\Service;

use SFC\Staticfilecache\Cache\UriFrontend;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
use SFC\Staticfilecache\Domain\Repository\QueueRepository;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down
1 change: 0 additions & 1 deletion Classes/Service/CookieService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Service\DateTimeService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssets/AbstractInlineAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class AbstractInlineFiles.
*
* @author Marcus Förster ; https://github.com/xerc
*/
abstract class AbstractInlineAssets
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssets/InlineFavIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace SFC\Staticfilecache\Service\InlineAssets;

/**
* Class InlineFavIcon.
*
* @author Marcus Förster ; https://github.com/xerc
*/
class InlineFavIcon extends AbstractInlineAssets
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssets/InlineImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace SFC\Staticfilecache\Service\InlineAssets;

/**
* Class InlineImages.
*
* @author Marcus Förster ; https://github.com/xerc
*/
class InlineImages extends AbstractInlineAssets
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssets/InlineScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace SFC\Staticfilecache\Service\InlineAssets;

/**
* Class InlineScripts.
*
* @author Marcus Förster ; https://github.com/xerc
*/
class InlineScripts extends AbstractInlineAssets
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssets/InlineStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace SFC\Staticfilecache\Service\InlineAssets;

/**
* Class InlineStyles.
*
* @author Marcus Förster ; https://github.com/xerc
*/
class InlineStyles extends AbstractInlineAssets
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/InlineAssetsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class InlineAssetsService.
*
* @author Marcus Förster ; https://github.com/xerc
*/
class InlineAssetsService
Expand Down
2 changes: 0 additions & 2 deletions Classes/Service/QueueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use SFC\Staticfilecache\Domain\Repository\QueueRepository;

/**
* Queue service.
*
* @see BoostQueueCommand
*/
class QueueService implements LoggerAwareInterface
Expand Down
Loading

0 comments on commit 1d387af

Please sign in to comment.