Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Tourinsoft
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bolt Extensions
Tourinsoft
Commits
684a705f
Commit
684a705f
authored
May 11, 2018
by
Frédéric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test
parent
136bce95
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
19 deletions
+26
-19
FluxController.php
src/Controller/Backend/FluxController.php
+1
-0
Synchronisation.php
src/Synchronisation/Synchronisation.php
+6
-3
ContentTypeFile.php
src/Utils/ContentTypeFile.php
+16
-15
Data.php
src/Utils/Data.php
+3
-1
No files found.
src/Controller/Backend/FluxController.php
View file @
684a705f
...
...
@@ -102,6 +102,7 @@ class FluxController extends BackendBase
{
$flux
->
setUpdatedAt
(
new
\DateTime
());
$this
->
getRepository
(
Flux
::
class
)
->
update
(
$flux
);
return
$this
->
redirectToRoute
(
'tourinsoft_admin_flux_index'
);
}
...
...
src/Synchronisation/Synchronisation.php
View file @
684a705f
...
...
@@ -44,6 +44,7 @@ class Synchronisation
* @throws \Exception
*/
public
function
sync
()
{
$this
->
application
[
'schema'
]
->
update
();
$options
=
$this
->
config
[
'tourinsoft'
];
$options
[
'key'
]
=
$this
->
flux
->
getKey
();
...
...
@@ -53,15 +54,17 @@ class Synchronisation
$arrayStream
=
$parser
->
getArrayStream
();
// Write in contenttypes.yml file
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
()
,
$keys
,
$options
);
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
,
$keys
,
$options
);
$file
->
updateInFile
();
sleep
(
20
);
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
update
();
// Add data
$data
=
new
Data
(
$this
->
application
,
$this
->
flux
->
getCo
ntentTyp
e
(),
$arrayStream
);
$data
=
new
Data
(
$this
->
application
,
$this
->
flux
->
getCo
d
e
(),
$arrayStream
);
$data
->
insert
();
}
...
...
@@ -70,7 +73,7 @@ class Synchronisation
*/
public
function
delete
()
{
// Write in contenttypes.yml file
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
()
,
[]);
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
,
[]);
$file
->
deleteInFile
();
// Sync database
...
...
src/Utils/ContentTypeFile.php
View file @
684a705f
...
...
@@ -3,16 +3,13 @@
namespace
Bolt\Extension\Appolo\Tourinsoft\Utils
;
use
Bolt\Application
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Filesystem\Handler\YamlFile
;
use
Symfony\Component\Yaml\Yaml
;
class
ContentTypeFile
{
/**
* @var string
*/
private
$contentType
;
/**
* @var array
*/
private
$keys
;
...
...
@@ -24,24 +21,28 @@ class ContentTypeFile
* @var array
*/
private
$options
;
/**
* @var Flux
*/
private
$flux
;
/**
* ContentTypeFile constructor.
* @param Application $application
* @param
string $contentType
* @param
Flux $flux
* @param array $keys
* @param array $options
* @throws \Exception
*/
public
function
__construct
(
Application
$application
,
$contentType
=
''
,
array
$keys
=
[],
array
$options
=
[])
public
function
__construct
(
Application
$application
,
Flux
$flux
,
array
$keys
=
[],
array
$options
=
[])
{
if
(
empty
(
$
contentType
))
{
throw
new
\Exception
(
'Le
content type est requis
.'
);
if
(
empty
(
$
flux
->
getCode
())
||
empty
(
$flux
->
getContentType
()
))
{
throw
new
\Exception
(
'Le
flux est invalide
.'
);
}
$this
->
contentType
=
$contentType
;
$this
->
keys
=
$keys
;
$this
->
application
=
$application
;
$this
->
options
=
$options
;
$this
->
flux
=
$flux
;
}
/**
...
...
@@ -49,9 +50,9 @@ class ContentTypeFile
*/
public
function
updateInFile
()
{
$data
=
[
$this
->
contentType
=>
[
'name'
=>
ucfirst
(
$this
->
contentType
),
'singular_name'
=>
ucfirst
(
$this
->
contentType
),
$this
->
flux
->
getCode
()
=>
[
'name'
=>
ucfirst
(
$this
->
flux
->
getContentType
()
),
'singular_name'
=>
ucfirst
(
$this
->
flux
->
getContentType
()
),
'fields'
=>
$this
->
getFields
()
]
];
...
...
@@ -100,10 +101,10 @@ class ContentTypeFile
$yamlData
=
$file
->
parse
();
if
(
$delete
)
{
unset
(
$yamlData
[
$this
->
contentType
]);
unset
(
$yamlData
[
$this
->
flux
->
getCode
()
]);
}
else
{
if
(
!
empty
(
$yamlData
[
$this
->
contentType
]))
{
unset
(
$yamlData
[
$this
->
contentType
]);
if
(
!
empty
(
$yamlData
[
$this
->
flux
->
getCode
()
]))
{
unset
(
$yamlData
[
$this
->
flux
->
getCode
()
]);
}
$yamlData
+=
$data
;
}
...
...
src/Utils/Data.php
View file @
684a705f
...
...
@@ -3,7 +3,9 @@
namespace
Bolt\Extension\Appolo\Tourinsoft\Utils
;
use
Bolt\Application
;
use
Bolt\Exception\InvalidRepositoryException
;
use
Bolt\Storage\Entity\Builder
;
use
Bolt\Storage\EntityManager
;
class
Data
{
...
...
@@ -37,7 +39,7 @@ class Data
* Insert data in database
*/
public
function
insert
()
{
$this
->
deleteData
();
//
$this->deleteData();
$items
=
$this
->
getFormattedItems
();
foreach
(
$items
as
$k
=>
$item
)
{
...
...
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