Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_jobs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_jobs
Commits
dffc4257
Commit
dffc4257
authored
3 years ago
by
Stefan Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[BUGFIX] Fix totally stupid job teaser repository filter integration (tons of side effects)
parent
1af7639f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/JobTeaserController.php
+2
-2
2 additions, 2 deletions
Classes/Controller/JobTeaserController.php
Classes/Domain/Repository/JobRepository.php
+17
-22
17 additions, 22 deletions
Classes/Domain/Repository/JobRepository.php
with
19 additions
and
24 deletions
Classes/Controller/JobTeaserController.php
+
2
−
2
View file @
dffc4257
...
...
@@ -54,7 +54,7 @@ class JobTeaserController extends ActionController {
*/
public
function
indexAction
():
void
{
$allowedLocations
=
[];
if
(
!
empty
(
$this
->
settings
[
'locations'
]
)
)
{
if
(
$this
->
settings
[
'locations'
]
!==
''
)
{
$allowedLocations
=
GeneralUtility
::
trimExplode
(
','
,
$this
->
settings
[
'locations'
]);
}
$totalAmountOfOffers
=
$this
->
jobRepository
->
countAll
(
$allowedLocations
);
...
...
@@ -65,7 +65,7 @@ class JobTeaserController extends ActionController {
$featuredOffers
=
$this
->
jobRepository
->
findByFeaturedOffer
(
$allowedLocations
);
$this
->
view
->
assign
(
'totalAmountOfOffers'
,
$totalAmountOfOffers
);
$this
->
view
->
assign
(
'filteredLocations'
,
!
empty
(
$allowedLocations
));
$this
->
view
->
assign
(
'filteredLocations'
,
(
bool
)
count
(
$allowedLocations
));
$this
->
view
->
assign
(
'featuredOffers'
,
$featuredOffers
);
}
}
This diff is collapsed.
Click to expand it.
Classes/Domain/Repository/JobRepository.php
+
17
−
22
View file @
dffc4257
...
...
@@ -26,7 +26,6 @@ namespace SGalinski\SgJobs\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Object\ObjectManagerInterface
;
use
TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings
;
use
TYPO3\CMS\Extbase\Persistence\QueryInterface
;
...
...
@@ -49,7 +48,6 @@ class JobRepository extends Repository {
public
function
__construct
(
ObjectManagerInterface
$objectManager
)
{
parent
::
__construct
(
$objectManager
);
// Appearently some of the extbase classes still need the objectManager
$querySettings
=
$objectManager
->
get
(
Typo3QuerySettings
::
class
);
$querySettings
->
setRespectStoragePage
(
TRUE
);
$this
->
setDefaultQuerySettings
(
$querySettings
);
...
...
@@ -77,7 +75,7 @@ class JobRepository extends Repository {
* @param int $limit
* @param int $offset
* @return mixed
* @throws \
InvalidArgument
Exception
* @throws \
TYPO3\CMS\Extbase\Persistence\Exception\InvalidQuery
Exception
*/
public
function
findBackendJobs
(
$recordPageId
,
array
$filters
=
[],
$limit
=
0
,
$offset
=
0
)
{
$query
=
$this
->
createQuery
();
...
...
@@ -111,7 +109,7 @@ class JobRepository extends Repository {
return
$query
->
matching
(
$query
->
logicalAnd
(
$constraints
))
->
execute
();
}
if
(
\count
(
$constraints
)
>
0
)
{
if
(
\count
(
$constraints
)
>
0
)
{
return
$query
->
matching
(
$constraints
[
0
])
->
execute
();
}
...
...
@@ -146,7 +144,7 @@ class JobRepository extends Repository {
$constraints
=
[];
if
(
$jobIds
!==
NULL
&&
\is_array
(
$jobIds
)
&&
\count
(
$jobIds
))
{
if
(
\is_array
(
$jobIds
)
&&
\count
(
$jobIds
))
{
$companyConstraints
=
[];
foreach
(
$jobIds
as
$jobId
)
{
if
(
$jobId
)
{
...
...
@@ -261,7 +259,6 @@ class JobRepository extends Repository {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public
function
countAll
(
array
$companies
=
[]):
int
{
/** @var QueryInterface $query */
$query
=
$this
->
createQuery
();
$constraints
=
[];
...
...
@@ -284,32 +281,30 @@ class JobRepository extends Repository {
* Gets the featured jobs filtered by companies
*
* @param array $companies
* @return mixed
* @param int $limit
* @return array|ExtbaseQueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public
function
findByFeaturedOffer
(
array
$companies
=
[])
{
/** @var QueryInterface $query */
public
function
findByFeaturedOffer
(
array
$companies
=
[],
int
$limit
=
3
)
{
$query
=
$this
->
createQuery
();
$constraints
=
[];
$storagePageIds
=
$query
->
getQuerySettings
()
->
getStoragePageIds
();
if
(
empty
(
$storagePageIds
))
{
if
(
count
(
$storagePageIds
)
<=
0
)
{
// if no record storage page has been selected in the plugin, ignore it
$query
->
getQuerySettings
()
->
setRespectStoragePage
(
FALSE
);
}
if
(
\count
(
$companies
)
!==
0
)
{
$constraints
[]
=
$query
->
in
(
'company'
,
$companies
);
$query
->
setOrderings
(
[
'featured_offer'
=>
QueryInterface
::
ORDER_DESCENDING
]
);
$query
->
setLimit
(
3
);
}
else
{
$constraints
[]
=
$query
->
equals
(
'featured_offer'
,
TRUE
);
if
(
\count
(
$companies
))
{
$query
->
matching
(
$query
->
in
(
'company'
,
$companies
));
}
return
$query
->
matching
(
$query
->
logicalAnd
(
$constraints
))
->
execute
();
$query
->
setOrderings
(
[
'featured_offer'
=>
QueryInterface
::
ORDER_DESCENDING
]
);
$query
->
setLimit
(
$limit
);
return
$query
->
execute
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment