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
7a6b1a98
Commit
7a6b1a98
authored
May 11, 2018
by
Frédéric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync contenttypes.yml
parent
66b70ac0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
7 deletions
+43
-7
Synchronisation.php
src/Synchronisation/Synchronisation.php
+10
-1
ContentTypeFile.php
src/Utils/ContentTypeFile.php
+33
-6
No files found.
src/Synchronisation/Synchronisation.php
View file @
7a6b1a98
...
...
@@ -48,6 +48,14 @@ class Synchronisation
$keys
=
$parser
->
getKeys
();
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
$keys
);
$file
->
createOrUpdateFile
();
$file
->
updateInFile
();
}
/**
*
*/
public
function
delete
()
{
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
[]);
$file
->
deleteInFile
();
}
}
\ No newline at end of file
src/Utils/ContentTypeFile.php
View file @
7a6b1a98
...
...
@@ -39,10 +39,10 @@ class ContentTypeFile
}
/**
*
Create or update
file
*
Update content type in
file
*/
public
function
createOrUpdate
File
()
{
$
yamlD
ata
=
[
public
function
updateIn
File
()
{
$
d
ata
=
[
$this
->
contentType
=>
[
'name'
=>
ucfirst
(
$this
->
contentType
),
'singular_name'
=>
ucfirst
(
$this
->
contentType
),
...
...
@@ -50,9 +50,14 @@ class ContentTypeFile
]
];
/** @var YamlFile $file */
$file
=
$this
->
application
[
'filesystem'
]
->
getFile
(
strtolower
(
"extensions_config://contenttypes/
$this->contentType
.yml"
));
$file
->
dump
(
$yamlData
);
$this
->
updateOrDelete
(
$data
,
false
);
}
/**
* Delete content type in file
*/
public
function
deleteInFile
()
{
$this
->
updateOrDelete
([],
true
);
}
/**
...
...
@@ -74,4 +79,25 @@ class ContentTypeFile
return
$fields
;
}
/**
* @param array $data
* @param bool $delete
*/
private
function
updateOrDelete
(
array
$data
=
[],
$delete
=
false
)
{
/** @var YamlFile $file */
$file
=
$this
->
application
[
'filesystem'
]
->
getFile
(
strtolower
(
'config://contenttypes.yml'
));
if
(
$file
->
exists
())
{
$yamlData
=
$file
->
parse
();
if
(
$delete
)
{
unset
(
$yamlData
[
$this
->
contentType
]);
}
else
{
$yamlData
+=
$data
;
}
$file
->
dump
(
$yamlData
,
[
'inline'
=>
4
]);
}
}
}
\ No newline at end of file
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