Skip to content

Commit

Permalink
Mise à jour pour la version beta2 du CMS.
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Sep 13, 2020
1 parent e4977e5 commit 472a5fa
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Config/service.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"gallery.install": {
"class": "SoosyzeExtension\\Gallery\\Installer",
"hooks": {
"install.node": "hookInstallNode"
"install.user": "hookInstallUser"
}
},
"gallery.hook.app": {
Expand Down
65 changes: 49 additions & 16 deletions Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

use Psr\Container\ContainerInterface;
use Queryflatfile\TableBuilder;
use Soosyze\Components\Template\Template;

class Installer implements \SoosyzeCore\System\Migration
class Installer extends \SoosyzeCore\System\Migration
{
protected $pathContent;

Expand All @@ -20,6 +19,11 @@ public function getDir()
return __DIR__ . '/composer.json';
}

public function boot()
{
$this->loadTranslation('fr', __DIR__ . '/Lang/fr/main.json');
}

public function install(ContainerInterface $ci)
{
$ci->schema()
Expand Down Expand Up @@ -67,12 +71,16 @@ public function install(ContainerInterface $ci)

$ci->query()
->insertInto('node_type', [
'node_type', 'node_type_name', 'node_type_description'
'node_type',
'node_type_name',
'node_type_description',
'node_type_icon'
])
->values([
'node_type' => 'page_gallery',
'node_type_name' => 'Gallery',
'node_type_description' => 'Create an image gallery'
'node_type_description' => 'Create an image gallery.',
'node_type_icon' => 'fa fa-images'
])
->execute();

Expand All @@ -82,29 +90,34 @@ public function install(ContainerInterface $ci)
'field_option', 'field_default_value', 'field_show'
])
->values([
'picture_gallery', $idTitle, 1, 'Title', 'required|string|max:512', '',
'picture_gallery', $idTitle, 1, 'Title', 'required|string|max:512',
'',
null, true
])
->values([
'picture_gallery', $idImage, 2, 'Image', 'required_without:file-name-image|!required|image|max:800kb', '', null, true
'picture_gallery', $idImage, 2, 'Image', 'required_without:file-image-name|!required|image|max:800kb',
'', null, true
])
->values([
'picture_gallery', $idWeight, 3, 'Weight', 'required|int|min:1', '', '1', false
'picture_gallery', $idWeight, 3, 'Weight', 'required|int|min:1',
'', '1', false
])
->values([
'page_gallery', $idBody, 1, 'Body', 'required|string', '', null, true
'page_gallery', $idBody, 1, 'Body', '!required|string', '', null,
true
])
->values([
'page_gallery', $idRelation, 2, 'Pictures', 'required|array|max:128',
json_encode([
'relation_table' => 'entity_picture_gallery',
'local_key' => 'page_gallery_id',
'foreign_key' => 'page_gallery_id',
'relation_table' => 'entity_picture_gallery',
'local_key' => 'page_gallery_id',
'foreign_key' => 'page_gallery_id',
/* 'asc, desc, weight */
'sort' => 'weight',
'order_by' => 'weight',
'count' => 128,
'field_show' => 'title'
'sort' => 'weight',
'order_by' => 'weight',
'count' => 128,
'field_show' => 'title',
'field_type_show' => 'image'
]), null, true
])
->execute();
Expand All @@ -116,6 +129,18 @@ public function seeders(ContainerInterface $ci)

public function hookInstall(ContainerInterface $ci)
{
$this->hookInstallUser($ci);
}

public function hookInstallUser(ContainerInterface $ci)
{
if ($ci->module()->has('User')) {
$ci->query()
->insertInto('role_permission', [ 'role_id', 'permission_id' ])
->values([ 2, 'node.show.published.page_gallery' ])
->values([ 1, 'node.show.published.page_gallery' ])
->execute();
}
}

public function uninstall(ContainerInterface $ci)
Expand Down Expand Up @@ -143,9 +168,17 @@ public function uninstall(ContainerInterface $ci)

public function hookUninstall(ContainerInterface $ci)
{
$this->hookUninstallUser($ci);
}

public function hookInstallNode(ContainerInterface $ci)
public function hookUninstallUser(ContainerInterface $ci)
{
if ($ci->module()->has('User')) {
$ci->query()
->from('role_permission')
->delete()
->where('permission_id', 'like', '%page_gallery%')
->execute();
}
}
}
4 changes: 4 additions & 0 deletions Lang/fr/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Gallery": "Galerie",
"Create an image gallery.": "Créer une gallerie d'images."
}
2 changes: 1 addition & 1 deletion Service/HookNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class HookNode
{
public function hookNodeEntityPictureShow(&$entity)
{
$entity->pathOverride(dirname(__DIR__) . '/Views/');
$entity->addPathOverride(dirname(__DIR__) . '/Views/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
<?php $i++; ?>
<?php endforeach; ?>

</div>
</div>
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "soosyze-extension/gallery",
"type": "soosyze-module",
"description": "Create an image gallery",
"description": "Create an image gallery.",
"version": "1.0",
"autoload": {
"psr-4": {
Expand All @@ -18,8 +18,8 @@
},
"icon": {
"name": "fa fa-images",
"background-color": "#b0c138",
"color": "#fff"
"background-color": "#f6ffa8",
"color": "#4e5700"
}
}
}
Expand Down

0 comments on commit 472a5fa

Please sign in to comment.