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
cf1fdc24
Commit
cf1fdc24
authored
7 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Creation of job repository with filters
parent
1d8ddd0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Domain/Repository/JobRepository.php
+101
-0
101 additions, 0 deletions
Classes/Domain/Repository/JobRepository.php
with
101 additions
and
0 deletions
Classes/Domain/Repository/JobRepository.php
0 → 100644
+
101
−
0
View file @
cf1fdc24
<?php
namespace
SGalinski\SgJobs\Domain\Repository
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Extbase\Persistence\QueryInterface
;
use
TYPO3\CMS\Extbase\Persistence\Repository
;
/**
* Job Repository
*/
class
JobRepository
extends
Repository
{
/**
* initializes the object
*/
public
function
initializeObject
()
{
$querySettings
=
$this
->
createQuery
()
->
getQuerySettings
();
$querySettings
->
setIgnoreEnableFields
(
TRUE
);
$querySettings
->
setEnableFieldsToBeIgnored
([
'disabled'
]);
$this
->
setDefaultQuerySettings
(
$querySettings
);
}
/**
* Queries the job records based on filters
*
* @param int $pageUid
* @param array $filters
* @param boolean $raw
* @return mixed
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public
function
findJobs
(
$pageUid
,
array
$filters
=
[],
$raw
=
FALSE
)
{
$query
=
$this
->
createQuery
();
$querySettings
=
$query
->
getQuerySettings
();
$querySettings
->
setStoragePageIds
([
$pageUid
]);
$query
->
setQuerySettings
(
$querySettings
);
$query
->
setOrderings
(
[
'sorting'
=>
QueryInterface
::
ORDER_ASCENDING
,
]
);
$constraints
=
[];
if
(
isset
(
$filters
[
'locations'
])
&&
is_array
(
$filters
[
'locations'
])
&&
count
(
$filters
[
'locations'
]))
{
$locationConstraints
=
[];
foreach
(
$filters
[
'locations'
]
as
$location
)
{
if
((
int
)
$location
)
{
$locationConstraints
[]
=
$query
->
contains
(
'location'
,
$location
);
}
}
if
(
count
(
$locationConstraints
))
{
$constraints
[]
=
$query
->
logicalOr
(
$locationConstraints
);
}
}
if
(
isset
(
$filters
[
'search'
])
&&
$filters
[
'search'
]
!==
''
)
{
$searchConstraints
=
[];
$searchConstraints
[]
=
$query
->
equals
(
'uid'
,
$filters
[
'search'
]);
$searchConstraints
[]
=
$query
->
like
(
'title'
,
'%'
.
$filters
[
'search'
]
.
'%'
);
$searchConstraints
[]
=
$query
->
like
(
'subtitle'
,
'%'
.
$filters
[
'search'
]
.
'%'
);
$searchConstraints
[]
=
$query
->
like
(
'description'
,
'%'
.
$filters
[
'search'
]
.
'%'
);
$constraints
[]
=
$query
->
logicalOr
(
$searchConstraints
);
}
if
(
count
(
$constraints
)
>
1
)
{
$query
->
matching
(
$query
->
logicalAnd
(
$constraints
));
}
elseif
(
count
(
$constraints
))
{
$query
->
matching
(
$constraints
[
0
]);
}
return
$query
->
execute
(
$raw
);
}
}
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