-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
1,251 additions
and
470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units; | ||
|
||
use In2code\Lux\Domain\Cache\CacheLayer; | ||
use In2code\Lux\Domain\Model\Transfer\FilterDto; | ||
use In2code\Lux\Utility\BackendUtility; | ||
use In2code\Lux\Utility\ObjectUtility; | ||
use In2code\Lux\Utility\StringUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
|
||
abstract class AbstractUnit | ||
{ | ||
protected array $arguments = []; | ||
protected ?FilterDto $filter = null; | ||
protected ?CacheLayer $cacheLayer = null; | ||
protected string $templateRootPath = 'EXT:lux/Resources/Private/Templates/Backend/Units'; | ||
protected string $partialRootPath = 'EXT:lux/Resources/Private/Partials'; | ||
protected string $classPrefix = 'In2code\Lux\Backend\Units\\'; | ||
|
||
/** | ||
* Optional string for cacheLayer | ||
* | ||
* @var string | ||
*/ | ||
protected string $cacheLayerClass = ''; | ||
|
||
/** | ||
* Optional string for cacheLayer | ||
* | ||
* @var string | ||
*/ | ||
protected string $cacheLayerFunction = ''; | ||
|
||
/** | ||
* Optional string for filter from session | ||
* | ||
* @var string | ||
*/ | ||
protected string $filterClass = ''; | ||
|
||
/** | ||
* Optional string for filter from session | ||
* | ||
* @var string | ||
*/ | ||
protected string $filterFunction = ''; | ||
|
||
public function __construct(array $arguments = []) | ||
{ | ||
$this->arguments = $arguments; | ||
} | ||
|
||
public function get(): string | ||
{ | ||
$this->initialize(); | ||
return $this->getHtml(); | ||
} | ||
|
||
protected function initialize(): void | ||
{ | ||
$this->initializeFilter(); | ||
$this->initializeCacheLayer(); | ||
} | ||
|
||
protected function initializeFilter(): void | ||
{ | ||
$filter = ObjectUtility::getFilterDto(); | ||
if ($this->filterClass !== '' && $this->filterFunction !== '') { | ||
$filterFromSession = BackendUtility::getSessionValue('filter', $this->filterFunction, $this->filterClass); | ||
if (is_a($filterFromSession, FilterDto::class)) { | ||
$filter = $filterFromSession; | ||
} | ||
} | ||
$this->filter = $filter; | ||
} | ||
|
||
protected function initializeCacheLayer(): void | ||
{ | ||
if ($this->cacheLayerClass !== '' && $this->cacheLayerFunction !== '') { | ||
$this->cacheLayer = GeneralUtility::makeInstance(CacheLayer::class); | ||
$this->cacheLayer->initialize($this->cacheLayerClass, $this->cacheLayerFunction); | ||
} | ||
} | ||
|
||
protected function getHtml(): string | ||
{ | ||
$view = GeneralUtility::makeInstance(StandaloneView::class); | ||
$view->setTemplateRootPaths([$this->templateRootPath]); | ||
$view->setPartialRootPaths([$this->partialRootPath]); | ||
$view->setTemplate($this->getTemplatePath()); | ||
$view->assignMultiple([ | ||
'cacheLayerClass' => $this->cacheLayerClass, | ||
'cacheLayerFunction' => $this->cacheLayerFunction, | ||
'filterClass' => $this->filterClass, | ||
'filterFunction' => $this->filterFunction, | ||
'cacheLayer' => $this->cacheLayer, | ||
'filter' => $this->filter, | ||
'arguments' => $this->arguments, | ||
] + $this->assignAdditionalVariables()); | ||
return $view->render(); | ||
} | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
return []; | ||
} | ||
|
||
protected function getArgument(string $key): string | ||
{ | ||
if (array_key_exists($key, $this->arguments)) { | ||
return (string)$this->arguments[$key]; | ||
} | ||
return ''; | ||
} | ||
|
||
protected function getTemplatePath(): string | ||
{ | ||
$path = StringUtility::removeStringPrefix(static::class, $this->classPrefix); | ||
return str_replace('\\', '/', $path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\DataProvider\BrowserAmountDataProvider; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Browser extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/Browser/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
return [ | ||
'browserData' => GeneralUtility::makeInstance(BrowserAmountDataProvider::class, $this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\DataProvider\DownloadsDataProvider; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Downloads extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/Downloads/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
return [ | ||
'numberOfDownloadsData' => GeneralUtility::makeInstance(DownloadsDataProvider::class, $this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\DataProvider\PagevisistsDataProvider; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Pagevisits extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/Pagevisits/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
return [ | ||
'numberOfVisitorsData' => GeneralUtility::makeInstance(PagevisistsDataProvider::class), | ||
]; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Classes/Backend/Units/Analysis/Dashboard/Pagevisitsleads.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\Repository\PagevisitRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Pagevisitsleads extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
$pagevisitsRepository = GeneralUtility::makeInstance(PagevisitRepository::class); | ||
return [ | ||
'latestPagevisits' => $pagevisitsRepository->findLatestPagevisits($this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\DataProvider\SocialMediaDataProvider; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Socialmedia extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/SocialMedia/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
return [ | ||
'socialMediaData' => GeneralUtility::makeInstance(SocialMediaDataProvider::class, $this->filter), | ||
]; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Classes/Backend/Units/Analysis/Dashboard/Top/Downloads.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard\Top; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\Repository\DownloadRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Downloads extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/TopDownloads/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
$downloadRepository = GeneralUtility::makeInstance(DownloadRepository::class); | ||
return [ | ||
'downloads' => $downloadRepository->findCombinedByHref($this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard\Top; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\Repository\NewsvisitRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class News extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/TopNews/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
$newsvisitRepository = GeneralUtility::makeInstance(NewsvisitRepository::class); | ||
return [ | ||
'news' => $newsvisitRepository->findCombinedByNewsIdentifier($this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard\Top; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\Repository\PagevisitRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Pages extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/TopPages/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
$pagevisitsRepository = GeneralUtility::makeInstance(PagevisitRepository::class); | ||
return [ | ||
'pages' => $pagevisitsRepository->findCombinedByPageIdentifier($this->filter), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\Lux\Backend\Units\Analysis\Dashboard\Top; | ||
|
||
use In2code\Lux\Backend\Units\AbstractUnit; | ||
use In2code\Lux\Backend\Units\UnitInterface; | ||
use In2code\Lux\Controller\AnalysisController; | ||
use In2code\Lux\Domain\Repository\SearchRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Search extends AbstractUnit implements UnitInterface | ||
{ | ||
protected string $cacheLayerClass = AnalysisController::class; | ||
protected string $cacheLayerFunction = 'dashboardAction'; | ||
protected string $filterClass = 'Analysis'; | ||
protected string $filterFunction = 'dashboard'; | ||
|
||
protected function assignAdditionalVariables(): array | ||
{ | ||
if ($this->cacheLayer->isCacheAvailable('Box/Analysis/TopSearch/' . $this->filter->getHash())) { | ||
return []; | ||
} | ||
$searchRepository = GeneralUtility::makeInstance(SearchRepository::class); | ||
return [ | ||
'searchterms' => $searchRepository->findCombinedBySearchIdentifier($this->filter), | ||
]; | ||
} | ||
} |
Oops, something went wrong.