Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OSE
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
OSE
Commits
f8c09b4a
You need to sign in or sign up before continuing.
Commit
f8c09b4a
authored
Nov 23, 2015
by
lecluse
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring plus de gestion de session par le plugin contexte : c'était inutile...
parent
92e0d5cf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
module/Application/src/Application/Controller/Plugin/Context.php
+4
-56
4 additions, 56 deletions
...Application/src/Application/Controller/Plugin/Context.php
with
4 additions
and
56 deletions
module/Application/src/Application/Controller/Plugin/Context.php
+
4
−
56
View file @
f8c09b4a
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
namespace
Application\Controller\Plugin
;
namespace
Application\Controller\Plugin
;
use
Application\Service\Traits\IntervenantAwareTrait
;
use
Zend\Mvc\Controller\Plugin\Params
;
use
Zend\Mvc\Controller\Plugin\Params
;
use
Zend\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\Session\Container
;
use
Common\Exception\LogicException
;
use
Common\Exception\LogicException
;
use
Common\Exception\RuntimeException
;
use
Common\Exception\RuntimeException
;
...
@@ -15,7 +15,6 @@ use Common\Exception\RuntimeException;
...
@@ -15,7 +15,6 @@ use Common\Exception\RuntimeException;
* @method mixed *FromRoute($name = null, $default = null) Description
* @method mixed *FromRoute($name = null, $default = null) Description
* @method mixed *FromQuery($name = null, $default = null) Description
* @method mixed *FromQuery($name = null, $default = null) Description
* @method mixed *FromPost($name = null, $default = null) Description
* @method mixed *FromPost($name = null, $default = null) Description
* @method mixed *FromSession($name = null, $default = null) Description
* @method mixed *FromSources($name = null, $default = null, array $sources = null) Description
* @method mixed *FromSources($name = null, $default = null, array $sources = null) Description
* @method mixed *FromQueryPost($name = null, $default = null) Description
* @method mixed *FromQueryPost($name = null, $default = null) Description
*
*
...
@@ -25,17 +24,13 @@ use Common\Exception\RuntimeException;
...
@@ -25,17 +24,13 @@ use Common\Exception\RuntimeException;
class
Context
extends
Params
implements
ServiceLocatorAwareInterface
class
Context
extends
Params
implements
ServiceLocatorAwareInterface
{
{
use
ServiceLocatorAwareTrait
;
use
ServiceLocatorAwareTrait
;
use
IntervenantAwareTrait
;
/**
/**
* @var bool
* @var bool
*/
*/
protected
$mandatory
=
false
;
protected
$mandatory
=
false
;
/**
* @var Container
*/
protected
$sessionContainer
;
/**
/**
*
*
* @param bool $mandatory
* @param bool $mandatory
...
@@ -73,8 +68,6 @@ class Context extends Params implements ServiceLocatorAwareInterface
...
@@ -73,8 +68,6 @@ class Context extends Params implements ServiceLocatorAwareInterface
break
;
break
;
case
(
$method
=
'FromPost'
)
===
substr
(
$name
,
$length
=
-
8
)
:
case
(
$method
=
'FromPost'
)
===
substr
(
$name
,
$length
=
-
8
)
:
break
;
break
;
case
(
$method
=
'FromSession'
)
===
substr
(
$name
,
$length
=
-
11
)
:
break
;
case
(
$method
=
'FromSources'
)
===
substr
(
$name
,
$length
=
-
11
)
:
case
(
$method
=
'FromSources'
)
===
substr
(
$name
,
$length
=
-
11
)
:
break
;
break
;
case
'FromQueryPost'
===
substr
(
$name
,
$length
=
-
13
)
:
case
'FromQueryPost'
===
substr
(
$name
,
$length
=
-
13
)
:
...
@@ -158,12 +151,9 @@ class Context extends Params implements ServiceLocatorAwareInterface
...
@@ -158,12 +151,9 @@ class Context extends Params implements ServiceLocatorAwareInterface
{
{
if
(
is_scalar
(
$sourceCodes
))
{
if
(
is_scalar
(
$sourceCodes
))
{
$sourceCode
=
(
string
)(
int
)
$sourceCodes
;
$sourceCode
=
(
string
)(
int
)
$sourceCodes
;
if
(
!
(
$intervenant
=
$this
->
getServiceIntervenant
()
->
getBySourceCode
(
$sourceCode
)))
{
$this
->
getProcessusImport
()
->
intervenant
(
$sourceCode
);
// Import
if
(
!
(
$intervenant
=
$this
->
getServiceIntervenant
()
->
getBySourceCode
(
$sourceCode
)))
{
if
(
!
(
$intervenant
=
$this
->
getServiceIntervenant
()
->
getBySourceCode
(
$sourceCode
)))
{
throw
new
RuntimeException
(
"L'intervenant suivant est introuvable après import : sourceCode =
$sourceCode
."
);
throw
new
RuntimeException
(
"L'intervenant suivant est introuvable après import : sourceCode =
$sourceCode
."
);
}
}
}
return
$intervenant
;
return
$intervenant
;
}
}
...
@@ -185,7 +175,7 @@ class Context extends Params implements ServiceLocatorAwareInterface
...
@@ -185,7 +175,7 @@ class Context extends Params implements ServiceLocatorAwareInterface
*/
*/
public
function
fromSources
(
$name
,
$default
=
null
,
array
$sources
=
[])
public
function
fromSources
(
$name
,
$default
=
null
,
array
$sources
=
[])
{
{
$defaultSources
=
[
'context'
,
'route'
,
'query'
,
'post'
,
'session'
];
$defaultSources
=
[
'context'
,
'route'
,
'query'
,
'post'
];
if
(
empty
(
$sources
))
$sources
=
$defaultSources
;
if
(
empty
(
$sources
))
$sources
=
$defaultSources
;
foreach
(
$sources
as
$source
){
foreach
(
$sources
as
$source
){
...
@@ -198,46 +188,4 @@ class Context extends Params implements ServiceLocatorAwareInterface
...
@@ -198,46 +188,4 @@ class Context extends Params implements ServiceLocatorAwareInterface
return
$default
;
return
$default
;
}
}
/**
* Return a single session parameter.
*
* @param string $name Parameter name to retrieve.
* @param mixed $default Default value to use when the requested parameter is not set.
* @return mixed
*/
public
function
fromSession
(
$name
,
$default
=
null
)
{
if
(
!
isset
(
$this
->
getSessionContainer
()
->
$name
))
{
return
$default
;
}
return
$this
->
getSessionContainer
()
->
$name
;
}
/**
* @return Container
*/
protected
function
getSessionContainer
()
{
if
(
null
===
$this
->
sessionContainer
)
{
$this
->
sessionContainer
=
new
Container
(
get_class
(
$this
->
getController
()));
}
return
$this
->
sessionContainer
;
}
/**
* @return \Application\Service\Intervenant
*/
protected
function
getServiceIntervenant
()
{
return
$this
->
getServiceLocator
()
->
getServiceLocator
()
->
get
(
'applicationIntervenant'
);
}
/**
* @return \Import\Processus\Import
*/
protected
function
getProcessusImport
()
{
return
$this
->
getServiceLocator
()
->
getServiceLocator
()
->
get
(
'importProcessusImport'
);
}
}
}
\ No newline at end of file
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