Skip to content

Commit

Permalink
Bugfix: get service (#43)
Browse files Browse the repository at this point in the history
Closes: #42
  • Loading branch information
christophlehmann authored May 19, 2020
1 parent 88a9d6f commit b8a8a60
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions Classes/EventListener/AbstractEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

class AbstractEventListener
{
/**
* @var OptimizeImageService
*/
protected $service;

public function __construct()
public function getService(): OptimizeImageService
{
$service = GeneralUtility::makeInstance(OptimizeImageService::class);
return GeneralUtility::makeInstance(OptimizeImageService::class);
}
}
2 changes: 1 addition & 1 deletion Classes/EventListener/AfterFileProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AfterFileProcessing extends AbstractEventListener
public function __invoke(AfterFileProcessingEvent $event): void
{
if ($event->getProcessedFile()->isUpdated() && !$event->getProcessedFile()->usesOriginalFile()) {
$this->service->process(
$this->getService()->process(
$event->getProcessedFile()->getPublicUrl(true),
$event->getProcessedFile()->getExtension()
);
Expand Down
2 changes: 1 addition & 1 deletion Classes/EventListener/BeforeFileAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BeforeFileAdded extends AbstractEventListener
{
public function __invoke(BeforeFileAddedEvent $event): void
{
$this->service->process(
$this->getService()->process(
$event->getSourceFilePath(),
pathinfo($event->getFileName(), PATHINFO_EXTENSION),
true
Expand Down
2 changes: 1 addition & 1 deletion Classes/EventListener/BeforeFileReplaced.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BeforeFileReplaced extends AbstractEventListener
{
public function __invoke(BeforeFileReplacedEvent $event): void
{
$this->service->process(
$this->getService()->process(
$event->getLocalFilePath(),
$event->getFile()->getExtension(),
true
Expand Down

0 comments on commit b8a8a60

Please sign in to comment.