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
e1cfcbc9
Commit
e1cfcbc9
authored
Sep 03, 2018
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(all): create command Cron:run ; update translation
parent
7d3a4216
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
165 additions
and
62 deletions
+165
-62
FluxController.php
src/Controller/Backend/FluxController.php
+1
-0
FluxType.php
src/Form/FluxType.php
+4
-2
KeyType.php
src/Form/KeyType.php
+1
-1
CronCommand.php
src/Nut/CronCommand.php
+80
-0
Synchronisation.php
src/Synchronisation/Synchronisation.php
+31
-3
TourinsoftExtension.php
src/TourinsoftExtension.php
+18
-55
Schema.php
src/Utils/Schema.php
+12
-0
list.html.twig
templates/Backend/flux/list.html.twig
+3
-1
en.yml
translations/en.yml
+8
-0
fr.yml
translations/fr.yml
+7
-0
No files found.
src/Controller/Backend/FluxController.php
View file @
e1cfcbc9
...
...
@@ -17,6 +17,7 @@ class FluxController extends BackendBase
* @var Application
*/
private
$application
;
/**
* @var array
*/
...
...
src/Form/FluxType.php
View file @
e1cfcbc9
...
...
@@ -25,7 +25,7 @@ class FluxType extends AbstractType
'title'
,
TextType
::
class
,
[
'label'
=>
Translator
::
__
(
'
Title
'
),
'label'
=>
Translator
::
__
(
'
appolo.tourinsoft.contenttype.titre_pluriel
'
),
'required'
=>
true
,
'attr'
=>
[
'class'
=>
'form-control'
...
...
@@ -66,7 +66,7 @@ class FluxType extends AbstractType
'contentType'
,
TextType
::
class
,
[
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.content
_type
'
),
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.content
type.type_singulier
'
),
'required'
=>
true
,
'attr'
=>
[
'class'
=>
'form-control'
...
...
@@ -81,9 +81,11 @@ class FluxType extends AbstractType
),
])
->
add
(
'viewless'
,
CheckboxType
::
class
,
[
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.contenttype.viewless'
),
'required'
=>
false
])
->
add
(
'searchable'
,
CheckboxType
::
class
,
[
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.contenttype.searchable'
),
'required'
=>
false
])
;
...
...
src/Form/KeyType.php
View file @
e1cfcbc9
...
...
@@ -38,7 +38,7 @@ class KeyType extends AbstractType
$locale
,
TextType
::
class
,
[
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.
key'
)
.
sprintf
(
Translator
::
__
(
' for %s syndication
'
),
$locale
),
'label'
=>
Translator
::
__
(
'appolo.tourinsoft.
syndication_key'
)
.
sprintf
(
Translator
::
__
(
' (%s)
'
),
$locale
),
'required'
=>
$required
,
'attr'
=>
[
'class'
=>
'form-control'
...
...
src/Nut/CronCommand.php
0 → 100644
View file @
e1cfcbc9
<?php
namespace
Bolt\Extension\Appolo\Tourinsoft\Nut
;
use
Bolt\Application
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Extension\Appolo\Tourinsoft\Synchronisation\Synchronisation
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Pimple
as
Container
;
class
CronCommand
extends
Command
{
/**
* @var Container
*/
private
$container
;
/**
* @var array
*/
private
$config
;
/**
* CronCommand constructor.
* @param Container $container
* @param array $config
*/
public
function
__construct
(
Container
$container
,
array
$config
=
[])
{
parent
::
__construct
();
$this
->
container
=
$container
;
$this
->
config
=
$config
;
}
/**
* CronCommand Configure
*/
protected
function
configure
()
{
$this
->
setName
(
'cron:run'
)
->
setDescription
(
'Synchronize the flux tourinsoft '
)
;
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
* @throws \Exception
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/** @var Application $app */
$app
=
$this
->
container
;
/** @var Flux $flux */
$flux
=
$app
[
'storage'
]
->
getRepository
(
Flux
::
class
)
->
findAll
();
/** @var Flux $item */
foreach
(
$flux
as
$item
)
{
$item
->
setSynchronizedAt
(
new
\DateTime
());
$app
[
'storage'
]
->
getRepository
(
Flux
::
class
)
->
update
(
$item
);
$sync
=
new
Synchronisation
(
$this
->
config
,
$app
,
$item
);
$sync
->
cron
();
}
$output
->
writeln
([
'CRON RUN'
,
'============'
,
"<comment>Synchronisation terminée</comment>"
]);
}
}
\ No newline at end of file
src/Synchronisation/Synchronisation.php
View file @
e1cfcbc9
...
...
@@ -45,6 +45,7 @@ class Synchronisation
$this
->
application
=
$application
;
}
/**
* Synchronisation flux
*/
...
...
@@ -61,7 +62,6 @@ class Synchronisation
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
,
$fields
,
$options
);
$file
->
updateInFile
();
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
updateStep1
();
...
...
@@ -72,7 +72,34 @@ class Synchronisation
}
/**
*
* Cron synchronisation
*/
public
function
cron
()
{
$options
=
$this
->
config
[
'tourinsoft'
];
$options
[
'keys'
]
=
$this
->
flux
->
getKeys
();
// Parse tourinsoft flux
$parser
=
new
Parser
(
$options
);
$fields
=
$parser
->
getFields
();
$arrayStream
=
$parser
->
getArrayStream
();
// Write in contenttypes.yml file
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
,
$fields
,
$options
);
$file
->
updateInFile
();
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
updateCron
();
// Add data
$data
=
new
Data
(
$this
->
application
,
$this
->
flux
->
getCode
(),
$arrayStream
,
$options
);
$data
->
insert
();
}
/**
* Delete
*/
public
function
delete
()
{
// Write in contenttypes.yml file
...
...
@@ -86,6 +113,6 @@ class Synchronisation
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
updateStep1
();
}
}
\ No newline at end of file
src/TourinsoftExtension.php
View file @
e1cfcbc9
...
...
@@ -2,32 +2,27 @@
namespace
Bolt\Extension\Appolo\Tourinsoft
;
use
Bolt\AccessControl\Token\Token
;
use
Bolt\Asset\File\JavaScript
;
use
Bolt\Asset\File\Stylesheet
;
use
Bolt\Controller\Zone
;
use
Bolt\Events\CronEvent
;
use
Bolt\Events\CronEvents
;
use
Bolt\Extension\Appolo\Tourinsoft\Controller\Backend\FluxController
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Extension\Appolo\Tourinsoft\Synchronisation\Synchronisation
;
use
Bolt\Extension\DatabaseSchemaTrait
;
use
Bolt\Extension\SimpleExtension
;
use
Bolt\Extension\StorageTrait
;
use
Bolt\Menu\MenuEntry
;
use
Silex\Application
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\Form\Extension\Core\Type\FormType
;
use
Bolt\Extension\SimpleExtension
;
use
Pimple
as
Container
;
use
Bolt\Extension\Appolo\Tourinsoft\TwigFilters\PipeToArray
;
use
Bolt\Extension\Appolo\Tourinsoft\TwigFilters\HashtagToArray
;
use
Bolt\Extension\Appolo\Tourinsoft\TwigFilters\LabelFilter
;
use
Bolt\Extension\Appolo\Tourinsoft\TwigFilters\TarifFilter
;
use
Bolt\Extension\Appolo\Tourinsoft\TwigFilters\TourinsoftFilter
;
use
Bolt\Extension\Appolo\Tourinsoft\Controller\Backend\FluxController
;
use
Bolt\Extension\Appolo\Tourinsoft\Nut\CronCommand
;
use
Bolt\Storage\Entity\Authtoken
;
use
Bolt\Storage\Entity\Users
;
use
Silex\Application
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\Form\Extension\Core\Type\FormType
;
/**
...
...
@@ -40,6 +35,17 @@ class TourinsoftExtension extends SimpleExtension
use
DatabaseSchemaTrait
;
/**
* @param Container $container
* @return array
*/
protected
function
registerNutCommands
(
Container
$container
)
{
return
[
new
Nut\CronCommand
(
$container
,
$this
->
getConfig
())
];
}
/**
* @return array
*/
protected
function
registerMenuEntries
()
...
...
@@ -153,46 +159,4 @@ class TourinsoftExtension extends SimpleExtension
{
$dispatcher
->
addListener
(
CronEvents
::
CRON_DAILY
,
[
$this
,
'tourinsoftCron'
]);
}
/**
* Callback method for the custom cron job.
*
* @param CronEvent $event
* @throws \Exception
*/
public
function
tourinsoftCron
(
CronEvent
$event
)
{
$this
->
InitializeRootSession
();
$flux
=
$this
->
getContainer
()[
'storage'
]
->
getRepository
(
Flux
::
class
)
->
findAll
();
/** @var Flux $item */
foreach
(
$flux
as
$item
)
{
$item
->
setSynchronizedAt
(
new
\DateTime
());
$this
->
getContainer
()[
'storage'
]
->
getRepository
(
Flux
::
class
)
->
update
(
$item
);
$sync
=
new
Synchronisation
(
$this
->
getConfig
(),
$this
->
getContainer
(),
$item
);
$sync
->
sync
();
}
// Return a message to the console
$event
->
output
->
writeln
(
"<comment>Synchronisation terminée</comment>"
);
}
/**
* @throws \Exception
*/
private
function
initializeRootSession
()
{
$user
=
$this
->
getContainer
()[
'storage'
]
->
getRepository
(
Users
::
class
)
->
find
(
1
);
$authToken
=
new
Authtoken
();
$authToken
->
setUserId
(
$user
->
getId
());
$authToken
->
setToken
(
uniqid
());
$authToken
->
setSalt
(
$user
->
getSalt
());
$authToken
->
setLastseen
(
new
\DateTime
());
$authToken
->
setValidity
((
new
\DateTime
())
->
add
(
new
\DateInterval
(
'P8D'
)));
$token
=
new
Token
(
$user
,
$authToken
);
$this
->
getContainer
()[
'session'
]
->
set
(
'authentication'
,
$token
);
}
}
\ No newline at end of file
src/Utils/Schema.php
View file @
e1cfcbc9
...
...
@@ -22,6 +22,9 @@ class Schema
$this
->
application
=
$application
;
}
/**
* Update Step 1
*/
public
function
updateStep1
()
{
$this
->
application
[
'config'
]
->
initialize
();
...
...
@@ -32,6 +35,15 @@ class Schema
}
/**
* Update Cron
*/
public
function
updateCron
()
{
$output
=
$this
->
schemaManager
()
->
update
();
$this
->
session
()
->
set
(
'dbupdate_result'
,
$output
->
getResponseStrings
());
}
/**
* @return \Bolt\Storage\Database\Schema\Manager
*/
protected
function
schemaManager
()
...
...
templates/Backend/flux/list.html.twig
View file @
e1cfcbc9
...
...
@@ -22,10 +22,11 @@
<tbody
class=
"sortable striping_odd ui-sortable"
>
<tr
class=
"header"
>
<th
class=
"hidden-xs"
>
{{
__
(
'appolo.tourinsoft.id'
)
}}
</th>
<th>
{{
__
(
'
T
itle'
)
}}
</th>
<th>
{{
__
(
'
general.phrase.t
itle'
)
}}
</th>
<th>
{{
__
(
'appolo.tourinsoft.code'
)
}}
</th>
<th>
{{
__
(
'appolo.tourinsoft.key'
)
}}
</th>
<th>
{{
__
(
'appolo.tourinsoft.content_type'
)
}}
</th>
<th>
{{
__
(
'appolo.tourinsoft.synchronized_at'
)
}}
</th>
<th
style=
"text-align: right;"
>
<span
class=
"hidden-xs"
>
{{
__
(
'general.phrase.action-plural'
)
}}
</span>
</th>
...
...
@@ -42,6 +43,7 @@
{#
{{
item.key }}#}
</td>
<td>
{{
item.contentType
}}
</td>
<td>
{{
item.synchronizedAt
|
date
(
'd/m/Y H:i'
)
}}
</td>
<td
class=
"actions"
>
<div
class=
"btn-group"
>
<button
type=
"button"
class=
"btn btn-default dropdown-toggle btn-xs"
data-toggle=
"dropdown"
>
...
...
translations/en.yml
View file @
e1cfcbc9
...
...
@@ -6,6 +6,7 @@ appolo.tourinsoft.select_an_action: Select an action
appolo.tourinsoft.id
:
"
#"
appolo.tourinsoft.code
:
Code
appolo.tourinsoft.key
:
Key
appolo.tourinsoft.syndication_key
:
Syndication key
appolo.tourinsoft.content_type
:
Content type
appolo.tourinsoft.actions_for_flux
:
Actions for flux
appolo.tourinsoft.new_flux
:
New Flux
...
...
@@ -24,3 +25,9 @@ appolo.tourinsoft.content_type_is_required: Content type is required
# Flash Messages
appolo.tourinsoft.flux_delete
:
Flux deleted
appolo.tourinsoft.flux_inexistant
:
Flux inexistant
# Options ContentTypes
appolo.tourinsoft.contenttype.titre_pluriel
:
Stream title (plural)
appolo.tourinsoft.contenttype.type_singulier
:
Content type (singular)
appolo.tourinsoft.contenttype.searchable
:
Searchable
appolo.tourinsoft.contenttype.viewless
:
Viewless
\ No newline at end of file
translations/fr.yml
View file @
e1cfcbc9
...
...
@@ -6,6 +6,7 @@ appolo.tourinsoft.select_an_action: Sélectionner une action
appolo.tourinsoft.id
:
"
#"
appolo.tourinsoft.code
:
Code
appolo.tourinsoft.key
:
Clé
appolo.tourinsoft.syndication_key
:
Clé de syndication
appolo.tourinsoft.content_type
:
Type de contenu
appolo.tourinsoft.actions_for_flux
:
Actions pour les flux
appolo.tourinsoft.new_flux
:
Nouveau Flux
...
...
@@ -24,3 +25,9 @@ appolo.tourinsoft.content_type_is_required: Le type de contenu est requis
# Flash Messages
appolo.tourinsoft.flux_delete
:
Flux supprimé
appolo.tourinsoft.flux_inexistant
:
Flux inexistant
# Options ContentTypes
appolo.tourinsoft.contenttype.titre_pluriel
:
Titre du flux (au pluriel)
appolo.tourinsoft.contenttype.type_singulier
:
Type de contenu (au singulier)
appolo.tourinsoft.contenttype.searchable
:
Consultable (Searchable)
appolo.tourinsoft.contenttype.viewless
:
Pas de vue (Viewless)
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