Skip to content
Snippets Groups Projects
Commit d8251f5b authored by Kevin von Spiczak's avatar Kevin von Spiczak
Browse files

[FEATURE] refactor code, so that multiple storage pids can be used

parent ead302a3
No related branches found
No related tags found
1 merge request!46AZM changes
......@@ -61,6 +61,7 @@ use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException;
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException;
use TYPO3\CMS\Extbase\Property\Exception\TypeConverterException;
......@@ -244,12 +245,13 @@ class JoblistController extends ActionController {
}
unset($filter);
$storagePid = (int) $this->configurationManager->getConfiguration(
$storagePids = GeneralUtility::trimExplode(
',', $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
)['persistence']['storagePid'];
)['persistence']['storagePid']);
$this->assignFilterValues($storagePid, $filters);
$this->view->assign('recordPageId', $storagePid);
$this->assignFilterValues($storagePids, $filters);
$this->view->assign('recordPageIds', $storagePids);
$jobLimit = (int) $this->settings['jobLimit'];
if ($jobId) {
......@@ -305,7 +307,6 @@ class JoblistController extends ActionController {
}
$this->view->assign('jobs', $jobs);
$this->view->assign('jobs2', 'just a job');
$this->view->assign('limit', $jobLimit);
$this->view->assign('numberOfPages', $numberOfPages);
......@@ -326,6 +327,7 @@ class JoblistController extends ActionController {
* @throws AspectNotFoundException
* @throws StopActionException
* @throws SiteNotFoundException
* @throws InvalidArgumentNameException
*/
public function applyFormAction(
JobApplication $applyData = NULL,
......@@ -384,10 +386,11 @@ class JoblistController extends ActionController {
}
$this->view->assign('job', $job);
} else {
$storagePid = (int) $this->configurationManager->getConfiguration(
$storagePids = GeneralUtility::trimExplode(
',', $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
)['persistence']['storagePid'];
$this->view->assign('companies', $this->companyRepository->getAllCompanies($storagePid));
)['persistence']['storagePid']);
$this->view->assign('companies', $this->companyRepository->getAllCompanies($storagePids));
}
// display country options
......@@ -540,7 +543,7 @@ class JoblistController extends ActionController {
* @param JobApplication $applyData
* @return ResponseInterface|null
* @throws NoSuchArgumentException
* @throws StopActionException
* @throws StopActionException|InvalidArgumentNameException
*/
public function applyAction(JobApplication $applyData): ?ResponseInterface {
$folderName = $this->request->getArgument('folderName');
......@@ -666,18 +669,18 @@ class JoblistController extends ActionController {
/**
* Assign filter values
*
* @param int $rootPageId
* @param array $rootPageIds
* @param array $filters
* @throws AspectNotFoundException
*/
protected function assignFilterValues(int $rootPageId, array $filters = []): void {
$countries = $this->companyRepository->getAllCountries($rootPageId, $filters['filterByLocation'] ?? []);
protected function assignFilterValues(array $rootPageIds, array $filters = []): void {
$countries = $this->companyRepository->getAllCountries($rootPageIds, $filters['filterByLocation'] ?? []);
$this->view->assign('countries', $countries);
$cities = $this->companyRepository->getAllCities($rootPageId, $filters['filterByLocation'] ?? []);
$cities = $this->companyRepository->getAllCities($rootPageIds, $filters['filterByLocation'] ?? []);
$this->view->assign('cities', $cities);
$companies = $this->companyRepository->getAllCompanyNames($rootPageId, $filters['filterByLocation'] ?? []);
$companies = $this->companyRepository->getAllCompanyNames($rootPageIds, $filters['filterByLocation'] ?? []);
$this->view->assign('companies', $companies);
$departments = $this->departmentRepository->findAllByFilter($filters['filterByDepartment'] ?? []);
......
......@@ -44,13 +44,13 @@ class CompanyRepository extends Repository {
/**
* Returns all countries filtered by page id
*
* @param int $pageUid
* @param array $pageUids
* @param array $filters
* @return array
* @throws AspectNotFoundException
*/
public function getAllCountries(int $pageUid, array $filters = []) {
$result = $this->getAllCompanies($pageUid, $filters)->toArray();
public function getAllCountries(array $pageUids, array $filters = []): array {
$result = $this->getAllCompanies($pageUids, $filters)->toArray();
$countryArray = [];
/** @var Company $company */
......@@ -69,13 +69,13 @@ class CompanyRepository extends Repository {
/**
* Returns all filtered cities
*
* @param int $pageUid
* @param array $pageUids
* @param array $filters
* @return array
* @throws AspectNotFoundException
*/
public function getAllCities(int $pageUid, array $filters = []) {
$result = $this->getAllCompanies($pageUid, $filters)->toArray();
public function getAllCities(array $pageUids, array $filters = []): array {
$result = $this->getAllCompanies($pageUids, $filters)->toArray();
$cityArray = [];
/** @var Company $company */
......@@ -94,13 +94,13 @@ class CompanyRepository extends Repository {
/**
* Returns all company names filtered by page id
*
* @param int $pageUid
* @param array $pageUids
* @param array $filters
* @return array
* @throws AspectNotFoundException
*/
public function getAllCompanyNames(int $pageUid, array $filters = []) {
$result = $this->getAllCompanies($pageUid, $filters)->toArray();
public function getAllCompanyNames(array $pageUids, array $filters = []): array {
$result = $this->getAllCompanies($pageUids, $filters)->toArray();
$companyArray = [];
/** @var Company $company */
......@@ -119,18 +119,21 @@ class CompanyRepository extends Repository {
/**
* Returns all companies filtered by page id
*
* @param int $pageUid
* @param array $pageUids
* @param array $filters
* @return object[]|QueryResultInterface
* @throws AspectNotFoundException
*/
public function getAllCompanies(int $pageUid, array $filters = []) {
$hash = $pageUid . '_' . implode('-', $filters);
public function getAllCompanies(array $pageUids, array $filters = []) {
$hash = '';
foreach($pageUids as $pageUid) {
$hash .= $pageUid . '_' . implode('-', $filters);
}
if (!isset($this->cache[$hash])) {
$companyConstraints = [];
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]);
$querySettings->setStoragePageIds($pageUids);
$querySettings->setLanguageUid(
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0)
);
......@@ -142,7 +145,7 @@ class CompanyRepository extends Repository {
]
);
$companyConstraints[] = $query->equals('pid', $pageUid);
$companyConstraints[] = $query->equals('pid', $pageUids);
if (count($filters) > 0) {
$constraints = [];
foreach ($filters as $filter) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment