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
990c0286
Commit
990c0286
authored
May 14, 2018
by
Frédéric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cron
parent
b0f8797a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
TourinsoftExtension.php
src/TourinsoftExtension.php
+59
-0
ContentTypeFile.php
src/Utils/ContentTypeFile.php
+2
-1
Data.php
src/Utils/Data.php
+6
-2
No files found.
src/TourinsoftExtension.php
View file @
990c0286
...
...
@@ -2,15 +2,23 @@
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
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
;
use
Symfony\Component\HttpFoundation\ParameterBag
;
...
...
@@ -145,4 +153,54 @@ class TourinsoftExtension extends SimpleExtension
];
}
/**
* {@inheritdoc}
*/
protected
function
subscribe
(
EventDispatcherInterface
$dispatcher
)
{
$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($flux);
$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/ContentTypeFile.php
View file @
990c0286
...
...
@@ -53,7 +53,8 @@ class ContentTypeFile
$this
->
flux
->
getCode
()
=>
[
'name'
=>
ucfirst
(
$this
->
flux
->
getContentType
()),
'singular_name'
=>
ucfirst
(
$this
->
flux
->
getContentType
()),
'fields'
=>
$this
->
getFields
()
'fields'
=>
$this
->
getFields
(),
'default_status'
=>
'published'
]
];
...
...
src/Utils/Data.php
View file @
990c0286
...
...
@@ -42,8 +42,11 @@ class Data
$this
->
deleteData
();
$items
=
$this
->
getFormattedItems
();
$contentType
=
$this
->
getContentType
();
// $contentType['status'] = 'published';
foreach
(
$items
as
$k
=>
$item
)
{
$this
->
application
[
'storage.request.save'
]
->
action
(
$item
,
$
this
->
getContentType
()
,
null
,
null
,
null
,
null
);
$this
->
application
[
'storage.request.save'
]
->
action
(
$item
,
$
contentType
,
null
,
null
,
null
,
null
);
}
}
...
...
@@ -76,8 +79,9 @@ class Data
$key
=
strtolower
(
$k
);
$data
[
$key
]
=
$v
;
}
$data
[
'status'
]
=
'published'
;
$data
[
'date
_
publish'
]
=
new
\DateTimeImmutable
();
$data
[
'datepublish'
]
=
new
\DateTimeImmutable
();
array_push
(
$items
,
$data
);
}
return
$items
;
...
...
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