Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
app
Commits
8b21311c
Commit
8b21311c
authored
Feb 16, 2021
by
Bertrand Gauthier
Browse files
Support des fonctions Doctrine compriseEntre() et pasHistorise()
parent
cf7d3aa3
Pipeline
#9569
failed with stages
in 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
config/module.config.php
View file @
8b21311c
...
...
@@ -10,6 +10,8 @@ use UnicaenApp\HostLocalization\HostLocalization;
use
UnicaenApp\HostLocalization\HostLocalizationFactory
;
use
UnicaenApp\Message\View\Helper\MessageHelper
;
use
UnicaenApp\Message\View\Helper\MessageHelperFactory
;
use
UnicaenApp\ORM\Query\Functions\CompriseEntre
;
use
UnicaenApp\ORM\Query\Functions\PasHistorise
;
use
UnicaenApp\Service\InstadiaServiceFactory
;
use
UnicaenApp\Service\Mailer\MailerService
;
use
UnicaenApp\Service\Mailer\MailerServiceFactory
;
...
...
@@ -477,6 +479,14 @@ return [
],
],
],
'configuration'
=>
[
'orm_default'
=>
[
'string_functions'
=>
[
'compriseEntre'
=>
CompriseEntre
::
class
,
'pasHistorise'
=>
PasHistorise
::
class
,
],
],
],
],
'view_manager'
=>
[
...
...
src/UnicaenApp/ORM/Query/Functions/CompriseEntre.php
0 → 100644
View file @
8b21311c
<?php
namespace
UnicaenApp\ORM\Query\Functions
;
use
Doctrine\ORM\Query\AST\Functions\FunctionNode
;
use
Doctrine\ORM\Query\Lexer
;
use
Doctrine\ORM\Query\Parser
;
use
Doctrine\ORM\Query\SqlWalker
;
class
CompriseEntre
extends
FunctionNode
{
public
$histoCreation
;
public
$histoDestruction
;
public
$dateObs
;
public
function
getSql
(
SqlWalker
$sqlWalker
)
{
$sql
=
sprintf
(
'comprise_entre(%s, %s'
,
$this
->
histoCreation
->
dispatch
(
$sqlWalker
),
$this
->
histoDestruction
->
dispatch
(
$sqlWalker
));
if
(
$this
->
dateObs
){
$sql
.
=
','
.
$this
->
dateObs
->
dispatch
(
$sqlWalker
);
}
$sql
.
=
')'
;
return
$sql
;
}
/**
* NB: le format DQL attendu est "compriseEntre"
* (et non pas "UNICAEN_ORACLE.COMPRISE_ENTRE").
*
* @param Parser $parser
*/
public
function
parse
(
Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
Lexer
::
T_IDENTIFIER
);
$parser
->
match
(
Lexer
::
T_OPEN_PARENTHESIS
);
$this
->
histoCreation
=
$parser
->
ArithmeticPrimary
();
if
(
Lexer
::
T_COMMA
===
$lexer
->
lookahead
[
'type'
]){
$parser
->
match
(
Lexer
::
T_COMMA
);
$this
->
histoDestruction
=
$parser
->
ArithmeticPrimary
();
}
if
(
Lexer
::
T_COMMA
===
$lexer
->
lookahead
[
'type'
]){
$parser
->
match
(
Lexer
::
T_COMMA
);
$this
->
dateObs
=
$parser
->
ArithmeticPrimary
();
}
$parser
->
match
(
Lexer
::
T_CLOSE_PARENTHESIS
);
}
}
\ No newline at end of file
src/UnicaenApp/ORM/Query/Functions/PasHistorise.php
0 → 100644
View file @
8b21311c
<?php
namespace
UnicaenApp\ORM\Query\Functions
;
use
Doctrine\ORM\Query\AST\Functions\FunctionNode
;
use
Doctrine\ORM\Query\Lexer
;
use
Doctrine\ORM\Query\Parser
;
use
Doctrine\ORM\Query\SqlWalker
;
/**
* Fonction DQL maison "pasHistorise()".
*
* NB: le format DQL attendu est "pasHistorise(EntityExpression)".
* Exemples :
* <pre>
* $qb->andWhere("1 = pasHistorise(sr)")
* $qb->andWhere("1 = pasHistorise(int.serviceReferentiel)")
* </pre>
*
* Fait appel à la fonction Oracle UNICAEN_ORACLE.COMPRISE_ENTRE().
*/
class
PasHistorise
extends
FunctionNode
{
public
$alias
;
public
$dateObservation
;
/**
* Parsing.
*
* NB: le format DQL attendu est "pasHistorise(EntityExpression)".
* Exemple :
* pasHistorise(s)
* pasHistorise(int.serviceReferentiel)
*
* @param Parser $parser
*/
public
function
parse
(
Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
Lexer
::
T_IDENTIFIER
);
$parser
->
match
(
Lexer
::
T_OPEN_PARENTHESIS
);
$this
->
alias
=
$parser
->
EntityExpression
();
if
(
Lexer
::
T_COMMA
===
$lexer
->
lookahead
[
'type'
]){
$parser
->
match
(
Lexer
::
T_COMMA
);
$this
->
dateObservation
=
$parser
->
ArithmeticPrimary
();
}
$parser
->
match
(
Lexer
::
T_CLOSE_PARENTHESIS
);
}
/**
* Génère le code SQL.
*
* @param SqlWalker $sqlWalker
* @return string
*/
public
function
getSql
(
SqlWalker
$sqlWalker
)
{
$expr1
=
clone
(
$this
->
alias
);
$expr2
=
clone
(
$this
->
alias
);
$expr1
->
field
=
'histoCreation'
;
$expr2
->
field
=
'histoDestruction'
;
$sql
=
sprintf
(
'comprise_entre(%s, %s, %s)'
,
$expr1
->
dispatch
(
$sqlWalker
),
$expr2
->
dispatch
(
$sqlWalker
),
$this
->
dateObservation
?
$this
->
dateObservation
->
dispatch
(
$sqlWalker
)
:
'null'
);
return
$sql
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment