-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from pixelant/addCategoryContentMapping
Add category page content mapping
- Loading branch information
Showing
19 changed files
with
554 additions
and
6 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
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
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,66 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Pixelant\PxaProductManager\Hook; | ||
|
||
use Pixelant\PxaProductManager\Domain\Repository\CategoryRepository; | ||
use Pixelant\PxaProductManager\Service\BackendUriService; | ||
use Pixelant\PxaProductManager\Service\TemplateService; | ||
use Pixelant\PxaProductManager\Utility\ConfigurationUtility; | ||
use TYPO3\CMS\Backend\Controller\PageLayoutController; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Object\ObjectManager; | ||
|
||
/** | ||
* Class PageHookRelatedCategories | ||
* @package Pixelant\PxaProductManager\Hook | ||
*/ | ||
class PageHookRelatedCategories | ||
{ | ||
/** | ||
* @param array $params | ||
* @param PageLayoutController $pageLayoutController | ||
* @return string | ||
* @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException | ||
*/ | ||
public function render(array $params, PageLayoutController $pageLayoutController) | ||
{ | ||
/** @var CategoryRepository $categoriesRepository */ | ||
$categoriesRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(CategoryRepository::class); | ||
$categories = $categoriesRepository->findByRelatedToContentPage($pageLayoutController->id); | ||
|
||
if (!$categories) { | ||
return ''; | ||
} | ||
|
||
/** @var BackendUriService $backendUriService */ | ||
$backendUriService = GeneralUtility::makeInstance(BackendUriService::class); | ||
|
||
$data = []; | ||
|
||
foreach ($categories as $category) { | ||
$uri = $backendUriService->buildUri('record_edit', [ | ||
"edit[sys_category][{$category['uid']}]" => 'edit', | ||
'returnUrl' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI') | ||
]); | ||
|
||
$data[] = [ | ||
'uri' => $uri, | ||
'title' => $category['title'] | ||
]; | ||
} | ||
|
||
$backendPathsTs = ConfigurationUtility::getTSConfig()['backend']; | ||
|
||
/** @var TemplateService $templateService */ | ||
$templateService = GeneralUtility::makeInstance(TemplateService::class); | ||
|
||
$templateService->setTemplateRootPaths($backendPathsTs['templateRootPaths']) | ||
->setPartialRootPaths($backendPathsTs['partialRootPaths']) | ||
->setLayoutRootPaths($backendPathsTs['layoutRootPaths']); | ||
|
||
return $templateService->generateStandaloneTemplate('PageModule/RelatedCategories', [ | ||
'data' => $data | ||
]); | ||
} | ||
} |
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 Pixelant\PxaProductManager\Service; | ||
|
||
use TYPO3\CMS\Backend\Routing\UriBuilder; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class BackendUriService | ||
{ | ||
/** | ||
* @param string $module | ||
* @param array $params | ||
* @return string | ||
*/ | ||
public function buildUri(string $module, array $params) | ||
{ | ||
/** @var UriBuilder $uriBuilder */ | ||
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); | ||
|
||
try { | ||
$uri = $uriBuilder->buildUriFromRoute($module, $params, UriBuilder::ABSOLUTE_URL); | ||
} catch (\TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException $e) { | ||
return ''; | ||
} | ||
|
||
return (string)$uri; | ||
} | ||
} |
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,97 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Pixelant\PxaProductManager\Service; | ||
|
||
use Pixelant\PxaProductManager\Utility\ConfigurationUtility; | ||
use Pixelant\PxaProductManager\Utility\MainUtility; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
|
||
class TemplateService | ||
{ | ||
/** | ||
* @var StandaloneView | ||
*/ | ||
protected $template; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $layoutRootPaths; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $templateRootPaths; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $partialRootPaths; | ||
|
||
/** | ||
* TemplateService constructor. | ||
* @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->template = MainUtility::getObjectManager()->get(StandaloneView::class); | ||
$viewTs = ConfigurationUtility::getTSConfig()['view']; | ||
$this->template->setTemplateRootPaths($viewTs['templateRootPaths']); | ||
$this->template->setPartialRootPaths($viewTs['partialRootPaths']); | ||
$this->template->setLayoutRootPaths($viewTs['layoutRootPaths']); | ||
} | ||
|
||
/** | ||
* @param string $templateName | ||
* @param array $variables | ||
* @return string | ||
*/ | ||
public function generateStandaloneTemplate(string $templateName, array $variables = []) | ||
{ | ||
$this->template->setTemplate($templateName); | ||
$this->template->assignMultiple($variables); | ||
|
||
return $this->template->render(); | ||
} | ||
|
||
/** | ||
* @param string $controller | ||
* @return TemplateService | ||
*/ | ||
public function setController(string $controller): TemplateService | ||
{ | ||
$this->template->getRenderingContext()->setControllerName($controller); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param mixed $layoutRootPaths | ||
* @return TemplateService | ||
*/ | ||
public function setLayoutRootPaths(array $layoutRootPaths) | ||
{ | ||
$this->template->setLayoutRootPaths($layoutRootPaths); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param array $templateRootPaths | ||
* @return TemplateService | ||
*/ | ||
public function setTemplateRootPaths(array $templateRootPaths): TemplateService | ||
{ | ||
$this->template->setTemplateRootPaths($templateRootPaths); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param array $partialRootPaths | ||
* @return TemplateService | ||
*/ | ||
public function setPartialRootPaths(array $partialRootPaths): TemplateService | ||
{ | ||
$this->template->setPartialRootPaths($partialRootPaths); | ||
return $this; | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Pixelant\PxaProductManager\UserFunction; | ||
|
||
use Pixelant\PxaProductManager\Service\BackendUriService; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class SysCategoryExtendedTca | ||
{ | ||
/** | ||
* @param $PA | ||
* @param $fObj | ||
* @return string | ||
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException | ||
*/ | ||
public function pageModuleLinkField($PA, $fObj) | ||
{ | ||
if (! current($PA['row']['pxapm_content_page'])) { | ||
return ''; | ||
} | ||
|
||
$page = current($PA['row']['pxapm_content_page']); | ||
|
||
/** @var BackendUriService $backendUriService */ | ||
$backendUriService = GeneralUtility::makeInstance(BackendUriService::class); | ||
|
||
$uri = $backendUriService->buildUri('web_layout', [ | ||
'id' => $page['uid'] | ||
]); | ||
|
||
return "<a class='btn btn-default' href='{$uri}'> | ||
<span class='text-primary'>{$page['title']}</span> | ||
</a>"; | ||
} | ||
} |
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
Oops, something went wrong.
89ece9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error code: 0 - Error Fetching http headers
NamelessCoder\GizzleGitPlugins\GizzlePlugins\ClonePlugin:000000007087a5dc00000000796cac4e: