Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jehba
ddec-info-ng
Commits
2a550223
Commit
2a550223
authored
Sep 09, 2019
by
Baudouin Feildel
Browse files
Merge branch '9-activation-de-la-recherche' into 'master'
Resolve "Activation de la recherche" Closes
#9
See merge request
!3
parents
61244642
417170ee
Pipeline
#787
passed with stage
in 1 minute and 49 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
data/ddec/49/jean-paul-II/info.json
View file @
2a550223
...
...
@@ -2,6 +2,7 @@
"type"
:
"etablissement"
,
"parent"
:
"ddec/49"
,
"name"
:
"Saint Jean-Paul II"
,
"searchEnabled"
:
false
,
"contact"
:
{
"address"
:
"15 Rue Du Petit Pré"
,
...
...
src/Controller/DdecController.php
View file @
2a550223
...
...
@@ -15,6 +15,7 @@ use App\Security\PageVoter;
use
App\Service\Formatters\BaseFormatter
;
use
App\Service\Formatters\EmptyFormatter
;
use
App\Service\Formatters\Formatters
;
use
Exception
;
use
Psr\Log\LoggerInterface
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -40,7 +41,7 @@ class DdecController extends AbstractController
/**
* @param Content $content
* @return BaseFormatter
* @throws
\
Exception
* @throws Exception
*/
private
function
getFormatter
(
?Content
$content
):
BaseFormatter
{
if
(
$content
==
null
)
...
...
@@ -56,7 +57,7 @@ class DdecController extends AbstractController
*
* @param string $id
* @return Response
* @throws
\
Exception
* @throws Exception
*/
public
function
getDdec
(
$id
)
{
...
...
@@ -70,9 +71,8 @@ class DdecController extends AbstractController
$formatter
=
$this
->
getFormatter
(
$ddec
->
getContent
());
$menu
=
new
Menu
();
$menu
->
setFilteringEnabled
(
true
);
$panel
=
new
Panel
(
"Établissements"
);
$panel
->
setSearchEnabled
(
true
);
$panel
->
setSearchEnabled
(
$ddec
->
isSearchEnabled
()
);
foreach
(
$ddec
->
getEtablissements
()
as
$etab
)
{
if
(
$this
->
isGranted
(
PageVoter
::
ATTRIBUTE_READ
,
$etab
))
{
...
...
@@ -100,7 +100,7 @@ class DdecController extends AbstractController
* @param string $ddecId
* @param string $etabId
* @return Response
* @throws
\
Exception
* @throws Exception
*/
public
function
getEtablissementOrDdecContent
(
string
$ddecId
,
string
$etabId
):
Response
{
...
...
@@ -119,13 +119,14 @@ class DdecController extends AbstractController
/**
* @param Etablissement $etab
* @return Response
* @throws
\
Exception
* @throws Exception
*/
private
function
getEtablissement
(
Etablissement
$etab
):
Response
{
$formatter
=
$this
->
getFormatter
(
$etab
->
getContent
());
$menu
=
new
Menu
();
$panel
=
new
Panel
(
'Pages'
);
$panel
->
setSearchEnabled
(
$etab
->
isSearchEnabled
());
foreach
(
$etab
->
getPages
()
as
$p
)
{
if
(
$this
->
isGranted
(
PageVoter
::
ATTRIBUTE_READ
,
$p
))
{
...
...
@@ -173,7 +174,7 @@ class DdecController extends AbstractController
* @param string $etabId
* @param string $dashId
* @return Response
* @throws
\
Exception
* @throws Exception
*/
public
function
getDashboardOrEtabContent
(
string
$ddecId
,
string
$etabId
,
string
$dashId
):
Response
{
$ddec
=
$this
->
ddecRepository
->
find
(
$ddecId
);
...
...
@@ -192,7 +193,7 @@ class DdecController extends AbstractController
/**
* @param Dashboard $dashboard
* @return Response
* @throws
\
Exception
* @throws Exception
*/
private
function
getDashboard
(
Dashboard
$dashboard
):
Response
{
$formatter
=
$this
->
getFormatter
(
$dashboard
->
getContent
());
...
...
src/Entity/Content/Ddec.php
View file @
2a550223
...
...
@@ -5,6 +5,7 @@ namespace App\Entity\Content;
use
App\Repository\Content\EtablissementRepository
;
use
App\Utils\Directory
;
use
App\Utils\TArray
;
use
Seld\JsonLint\ParsingException
;
class
Ddec
extends
AbstractPage
{
...
...
@@ -28,11 +29,23 @@ class Ddec extends AbstractPage
*/
private
$content
;
/**
* @var boolean
*/
private
$searchEnabled
;
/**
* @var bool
*/
private
$infoFileNotRead
=
true
;
/**
* Ddec constructor.
* @param string $projectDir
* @param string $id
* @param EtablissementRepository $etablissementRepository
* @throws ParsingException
*/
public
function
__construct
(
string
$projectDir
,
string
$id
,
EtablissementRepository
$etablissementRepository
)
{
parent
::
__construct
(
Directory
::
combine
(
array
(
$projectDir
,
...
...
@@ -45,10 +58,11 @@ class Ddec extends AbstractPage
$this
->
readInfo
(
$etablissementRepository
);
}
/**
* @param EtablissementRepository $etablissementRepository
* @return $this
*/
/**
* @param EtablissementRepository $etablissementRepository
* @return $this
* @throws ParsingException
*/
private
function
readInfo
(
EtablissementRepository
$etablissementRepository
)
{
if
(
$this
->
infoFileNotRead
)
{
$info
=
$this
->
getInfoJson
();
...
...
@@ -57,6 +71,7 @@ class Ddec extends AbstractPage
$this
->
contact
=
new
ContactInfo
(
$info
->
contact
);
$nbrEtab
=
count
(
$info
->
etablissements
);
$this
->
etablissements
=
new
TArray
(
$nbrEtab
);
$this
->
searchEnabled
=
$info
->
searchEnabled
??
true
;
if
(
isset
(
$info
->
content
))
{
$this
->
content
=
new
Content
(
$this
,
$info
->
content
);
...
...
@@ -137,6 +152,22 @@ class Ddec extends AbstractPage
$this
->
content
=
$content
;
}
/**
* @return bool
*/
public
function
isSearchEnabled
():
bool
{
return
$this
->
searchEnabled
;
}
/**
* @param bool $searchEnabled
*/
public
function
setSearchEnabled
(
bool
$searchEnabled
):
void
{
$this
->
searchEnabled
=
$searchEnabled
;
}
/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
...
...
@@ -150,7 +181,8 @@ class Ddec extends AbstractPage
"name"
=>
$this
->
getName
(),
"contact"
=>
$this
->
contact
->
jsonSerialize
(),
"etablissements"
=>
$this
->
jsonSerializeEtablissements
(),
"content"
=>
$this
->
content
->
jsonSerialize
()
"content"
=>
$this
->
content
->
jsonSerialize
(),
"searchEnabled"
=>
$this
->
searchEnabled
,
];
}
...
...
src/Entity/Content/Etablissement.php
View file @
2a550223
...
...
@@ -6,6 +6,7 @@ namespace App\Entity\Content;
use
App\Repository\Content\DashboardRepository
;
use
App\Utils\Directory
;
use
App\Utils\TArray
;
use
Seld\JsonLint\ParsingException
;
class
Etablissement
extends
AbstractPage
{
...
...
@@ -30,6 +31,11 @@ class Etablissement extends AbstractPage
*/
public
$content
=
null
;
/**
* @var boolean
*/
private
$searchEnabled
;
/**
* @var bool
*/
...
...
@@ -45,6 +51,14 @@ class Etablissement extends AbstractPage
*/
private
$dashboardRepo
;
/**
* Etablissement constructor.
* @param Ddec $ddec
* @param string $installDir
* @param string $id
* @param DashboardRepository $dashboardRepository
* @throws ParsingException
*/
public
function
__construct
(
Ddec
$ddec
,
string
$installDir
,
string
$id
,
DashboardRepository
$dashboardRepository
)
{
parent
::
__construct
(
Directory
::
combine
(
array
(
$installDir
,
...
...
@@ -60,6 +74,10 @@ class Etablissement extends AbstractPage
$this
->
readInfo
();
}
/**
* @return $this
* @throws ParsingException
*/
private
function
readInfo
()
{
if
(
$this
->
infoFileNotRead
)
{
$info
=
$this
->
getInfoJson
();
...
...
@@ -68,6 +86,7 @@ class Etablissement extends AbstractPage
$this
->
contact
=
new
ContactInfo
(
$info
->
contact
);
$nbrPages
=
count
(
$info
->
pages
);
$this
->
pages
=
new
TArray
(
$nbrPages
);
$this
->
searchEnabled
=
$info
->
searchEnabled
??
true
;
for
(
$i
=
0
;
$i
<
$nbrPages
;
$i
++
)
{
$this
->
pages
[
$i
]
=
$this
->
dashboardRepo
->
find
(
$this
,
$info
->
pages
[
$i
]);
...
...
@@ -151,6 +170,22 @@ class Etablissement extends AbstractPage
$this
->
content
=
$content
;
}
/**
* @return bool
*/
public
function
isSearchEnabled
():
bool
{
return
$this
->
searchEnabled
;
}
/**
* @param bool $searchEnabled
*/
public
function
setSearchEnabled
(
bool
$searchEnabled
):
void
{
$this
->
searchEnabled
=
$searchEnabled
;
}
/**
* @return Ddec
*/
...
...
@@ -172,7 +207,8 @@ class Etablissement extends AbstractPage
"contact"
=>
$this
->
contact
->
jsonSerialize
(),
"content"
=>
$this
->
content
,
"pages"
=>
$this
->
jsonSerializePages
(),
"parent"
=>
"ddec/"
.
$this
->
ddec
->
getId
()
"parent"
=>
"ddec/"
.
$this
->
ddec
->
getId
(),
"searchEnabled"
=>
$this
->
searchEnabled
,
];
}
...
...
src/Entity/Content/Menu.php
View file @
2a550223
...
...
@@ -4,8 +4,10 @@ namespace App\Entity\Content;
use
App\Utils\TArray
;
use
InvalidArgumentException
;
use
JsonSerializable
;
class
Menu
implements
\
JsonSerializable
class
Menu
implements
JsonSerializable
{
/**
* @var string
...
...
@@ -22,12 +24,6 @@ class Menu implements \JsonSerializable
*/
private
$backTo
=
null
;
/**
* @var bool
*/
private
$filteringEnabled
;
/**
* Menu constructor.
* @param mixed $info
...
...
@@ -48,10 +44,8 @@ class Menu implements \JsonSerializable
$this
->
title
=
""
;
$this
->
panels
=
new
TArray
(
0
);
}
else
{
throw
new
\
InvalidArgumentException
(
'$info is neither object, string nor null.'
);
throw
new
InvalidArgumentException
(
'$info is neither object, string nor null.'
);
}
$this
->
filteringEnabled
=
false
;
}
/**
...
...
@@ -103,20 +97,6 @@ class Menu implements \JsonSerializable
$this
->
backTo
=
$backTo
;
}
/**
* @return bool
*/
public
function
isFilteringEnabled
():
bool
{
return
$this
->
filteringEnabled
;
}
/**
* @param bool $filteringEnabled
*/
public
function
setFilteringEnabled
(
bool
$filteringEnabled
):
void
{
$this
->
filteringEnabled
=
$filteringEnabled
;
}
public
function
jsonSerialize
()
{
return
[
"title"
=>
$this
->
title
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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