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
faq
Commits
81666568
Commit
81666568
authored
Mar 10, 2019
by
Bertrand Gauthier
Browse files
Corrections pour passer à ZF3.
parent
a5a9a840
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenFaq/Service/FaqServiceFactory.php
View file @
81666568
...
...
@@ -3,32 +3,19 @@
namespace
UnicaenFaq\Service
;
use
Doctrine\ORM\EntityManager
;
use
Interop\Container\ContainerInterface
;
use
Zend\ServiceManager\Exception\InvalidArgumentException
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
final
class
FaqServiceFactory
implements
FactoryInterface
{
/**
* @param ServiceLocatorInterface $serviceLocator
* @return FaqService
*/
public
function
createService
(
ServiceLocatorInterface
$serviceLocator
)
{
$faqEntityClass
=
$this
->
getFaqEntityClass
(
$serviceLocator
);
if
(
!
class_exists
(
$faqEntityClass
))
{
throw
new
InvalidArgumentException
(
"La classe spécifiée dans l'option de 'unicaen-faq.faq_entity_class' n'existe pas"
);
}
$em
=
$this
->
getEntityManager
(
$serviceLocator
);
$service
=
new
FaqService
(
$em
,
$faqEntityClass
);
return
$service
;
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
private
function
getEntityManager
(
ServiceLocato
rInterface
$serviceLocator
)
private
function
getEntityManager
(
Containe
rInterface
$serviceLocator
)
{
$config
=
$serviceLocator
->
get
(
'config'
);
...
...
@@ -44,7 +31,7 @@ final class FaqServiceFactory implements FactoryInterface
return
$em
;
}
private
function
getFaqEntityClass
(
ServiceLocato
rInterface
$serviceLocator
)
private
function
getFaqEntityClass
(
Containe
rInterface
$serviceLocator
)
{
$config
=
$serviceLocator
->
get
(
'config'
);
...
...
@@ -54,4 +41,19 @@ final class FaqServiceFactory implements FactoryInterface
return
$config
[
'unicaen-faq'
][
'faq_entity_class'
];
}
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
$faqEntityClass
=
$this
->
getFaqEntityClass
(
$container
);
if
(
!
class_exists
(
$faqEntityClass
))
{
throw
new
InvalidArgumentException
(
"La classe spécifiée dans l'option de 'unicaen-faq.faq_entity_class' n'existe pas"
);
}
$em
=
$this
->
getEntityManager
(
$container
);
$service
=
new
FaqService
(
$em
,
$faqEntityClass
);
return
$service
;
}
}
\ 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