Commit 9157fd1b authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'zf-3.x'

parents cd3af6df cb01545b
vendor/
.idea/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
<component name="ProjectDictionaryState">
<dictionary name="gauthierb" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Bitwise operation issuesJavaScript</id>
</State>
<State>
<id>Blade files</id>
</State>
<State>
<id>CSS</id>
</State>
<State>
<id>Code StylePHP</id>
</State>
<State>
<id>Code quality toolsJavaScript</id>
</State>
<State>
<id>Data flow issuesJavaScript</id>
</State>
<State>
<id>GeneralPHP</id>
</State>
<State>
<id>JavaScript</id>
</State>
<State>
<id>Naming conventionsJavaScript</id>
</State>
<State>
<id>PHP</id>
</State>
<State>
<id>Potentially confusing code constructsJavaScript</id>
</State>
<State>
<id>Probable bugsJavaScript</id>
</State>
<State>
<id>SQL</id>
</State>
<State>
<id>XPath</id>
</State>
<State>
<id>XSLT</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>Blade files</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/faq.iml" filepath="$PROJECT_DIR$/.idea/faq.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="377c0a23-f30c-4ff0-85a4-04e91db7c38b" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1745" />
<option name="y" value="-4" />
<option name="width" value="1855" />
<option name="height" value="1084" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="options.lastSelected" value="reference.settings.php.debug.xdebug.proxy" />
<property name="options.splitter.details.proportions" value="0.2" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="settings.editor.selected.configurable" value="database.main" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration>$USER_HOME$/.subversion</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="377c0a23-f30c-4ff0-85a4-04e91db7c38b" name="Default Changelist" comment="" />
<created>1552311894042</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1552311894042</updated>
<workItem from="1552311895213" duration="5000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="5000" />
</component>
<component name="ToolWindowManager">
<frame x="1745" y="-4" width="1855" height="1084" extended-state="6" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.48175967" visible="true" weight="0.2697623" />
<window_info id="Structure" order="1" sideWeight="0.51824033" side_tool="true" visible="true" weight="0.2697623" />
<window_info id="Favorites" order="2" sideWeight="0.5043011" side_tool="true" weight="0.25815368" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32903227" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Messages" order="7" />
<window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.2731183" />
<window_info anchor="bottom" id="Terminal" order="10" weight="0.47419354" />
<window_info anchor="bottom" id="Docker" order="11" weight="0.41827956" />
<window_info anchor="bottom" id="Database Console" order="12" weight="0.32903227" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Remote Host" order="3" />
<window_info anchor="right" id="Database" order="4" weight="0.21669431" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="masterDetails">
<states>
<state key="ScopeChooserConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
......@@ -4,16 +4,15 @@
"repositories": [
{
"type": "composer",
"url": "https://dev.unicaen.fr/packagist"
"url": "https://gest.unicaen.fr/packagist"
}
],
"require": {
"unicaen/app": "^1.3"
"unicaen/app": "^3.0"
},
"require-dev": {
"zendframework/zend-test": "2.4.*",
"phpunit/PHPUnit": "^5.6",
"snapshotpl/zf-snap-event-debugger": "1.*",
"zendframework/zend-test": "^3.0",
"phpunit/phpunit": "^5.6",
"phpspec/prophecy": "^1.6"
},
"autoload": {
......
......@@ -2,6 +2,7 @@
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use UnicaenAuth\Guard\PrivilegeController;
use UnicaenFaq\Controller\Factory\FaqControllerFactory;
use UnicaenFaq\Form\Factory\FaqFormFactory;
use UnicaenFaq\Provider\Privilege\FaqPrivileges;
......@@ -38,7 +39,7 @@ return array(
],
],
'guards' => [
'\UnicaenAuth\Guard\PrivilegeController' => [
PrivilegeController::class => [
[
'controller' => 'UnicaenFaq\Controller\Index',
'action' => [
......
--
-- Table FAQ.
--
create table faq (
id serial not null constraint faq_pk primary key,
question text not null,
reponse text not null,
ordre smallint
);
create unique index faq_id_uindex on faq (id);
--
-- Jeu d'essai.
--
insert into faq(question, reponse, ordre) values
('qu''est-ce qu''une question ?'::text, 'c''est une phrase appelant une réponse.'::text, 10);
/*
--
-- création si besoin de la catégorie de privilège 'faq'.
--
insert into categorie_privilege(code, libelle, ordre) values
('faq', 'faq', 10);
--
-- privilège 'modification'.
--
insert into privilege(categorie_id, code, libelle, ordre)
select cp.id, 'modification', 'modification de la faq', 10
from categorie_privilege cp where cp.code = 'faq';
*/
\ No newline at end of file
......@@ -2,10 +2,10 @@
namespace UnicaenFaq\Controller\Factory;
use Interop\Container\ContainerInterface;
use UnicaenFaq\Controller\FaqController;
use UnicaenFaq\Form\FaqForm;
use UnicaenFaq\Service\FaqService;
use Zend\Mvc\Controller\ControllerManager;
use Zend\ServiceManager\ServiceLocatorInterface;
class FaqControllerFactory
......@@ -13,15 +13,15 @@ class FaqControllerFactory
/**
* Create service
*
* @param ControllerManager $controllerManager
* @param ContainerInterface $container
* @return FaqController
*/
public function __invoke(ControllerManager $controllerManager)
public function __invoke(ContainerInterface $container)
{
$faqService = $this->getFaqService($controllerManager->getServiceLocator());
$faqService = $this->getFaqService($container);
/** @var FaqForm $form */
$form = $controllerManager->getServiceLocator()->get('FormElementManager')->get('UnicaenFaq\Form\FaqForm');
$form = $container->get('FormElementManager')->get('UnicaenFaq\Form\FaqForm');
$controller = new FaqController($form);
$controller->setFaqService($faqService);
......
......@@ -2,18 +2,17 @@
namespace UnicaenFaq\Form\Factory;
use UnicaenFaq\Form\FaqForm;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject;
use Zend\Form\FormElementManager;
use Interop\Container\ContainerInterface;
use UnicaenFaq\Form\FaqForm;
use Zend\Hydrator\HydratorPluginManager;
class FaqFormFactory
{
public function __invoke(FormElementManager $formElementManager)
public function __invoke(ContainerInterface $container)
{
$sl = $formElementManager->getServiceLocator();
/** @var DoctrineObject $hydrator */
$hydrator = $sl->get('HydratorManager')->get('DoctrineModule\Stdlib\Hydrator\DoctrineObject');
$hydrator = $container->get(HydratorPluginManager::class)->get(DoctrineObject::class);
$form = new FaqForm();
$form->setHydrator($hydrator);
......
......@@ -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(ServiceLocatorInterface $serviceLocator)
private function getEntityManager(ContainerInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
......@@ -44,7 +31,7 @@ final class FaqServiceFactory implements FactoryInterface
return $em;
}
private function getFaqEntityClass(ServiceLocatorInterface $serviceLocator)
private function getFaqEntityClass(ContainerInterface $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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment