Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Doctrine HTTP Filter
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Packages
Doctrine HTTP Filter
Commits
6eb19f1e
Commit
6eb19f1e
authored
1 month ago
by
Адлан Шамавов
Browse files
Options
Downloads
Patches
Plain Diff
fix: Обработка null значения в фильтре Where
parent
8409c1c0
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Фильтры Like, ILike, Range, In, Date, DateRange
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Exception/FilterParameterValueIsNullException.php
+15
-0
15 additions, 0 deletions
src/Exception/FilterParameterValueIsNullException.php
src/Filter/Where.php
+6
-0
6 additions, 0 deletions
src/Filter/Where.php
src/HttpFilter.php
+3
-3
3 additions, 3 deletions
src/HttpFilter.php
with
24 additions
and
3 deletions
src/Exception/FilterParameterValueIsNullException.php
0 → 100644
+
15
−
0
View file @
6eb19f1e
<?php
declare
(
strict_types
=
1
);
namespace
IQDEV\Packages\DoctrineHttpFilter\Exception
;
use
Exception
;
class
FilterParameterValueIsNullException
extends
Exception
{
public
function
__construct
(
string
$key
)
{
parent
::
__construct
(
'Filter parameter value of key ['
.
$key
.
'] is null.'
);
}
}
This diff is collapsed.
Click to expand it.
src/Filter/Where.php
+
6
−
0
View file @
6eb19f1e
...
...
@@ -5,16 +5,22 @@ declare(strict_types=1);
namespace
IQDEV\Packages\DoctrineHttpFilter\Filter
;
use
Doctrine\ORM\QueryBuilder
;
use
IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException
;
use
IQDEV\Packages\DoctrineHttpFilter\HttpFilter
;
final
class
Where
extends
HttpFilter
{
/** @throws FilterParameterValueIsNullException */
public
function
addToQuery
(
QueryBuilder
$queryBuilder
):
QueryBuilder
{
$queryBuilder
->
where
(
$this
->
getColumn
()
.
' = :'
.
$this
->
getParameterKey
(),
);
if
(
$this
->
getHttpValue
()
===
null
)
{
throw
new
FilterParameterValueIsNullException
(
$this
->
field
);
}
$queryBuilder
->
setParameter
(
$this
->
getParameterKey
(),
$this
->
getHttpValue
());
return
$queryBuilder
;
...
...
This diff is collapsed.
Click to expand it.
src/HttpFilter.php
+
3
−
3
View file @
6eb19f1e
...
...
@@ -15,7 +15,7 @@ abstract class HttpFilter
public
function
__construct
(
protected
string
$tableAlias
,
protected
string
$fi
l
ed
,
protected
string
$fie
l
d
,
?Request
$request
=
null
,
)
{
$this
->
request
=
$request
??
Request
::
createFromGlobals
();
...
...
@@ -23,7 +23,7 @@ abstract class HttpFilter
protected
function
getColumn
():
string
{
return
$this
->
tableAlias
.
'.'
.
$this
->
fi
l
ed
;
return
$this
->
tableAlias
.
'.'
.
$this
->
fie
l
d
;
}
protected
function
getHttpValue
():
mixed
...
...
@@ -37,7 +37,7 @@ abstract class HttpFilter
return
null
;
}
return
$filter
[
$this
->
fi
l
ed
]
??
null
;
return
$filter
[
$this
->
fie
l
d
]
??
null
;
}
public
function
getParameterKey
():
string
...
...
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