mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Addign fixtures for doc acl and document categories
This commit is contained in:
parent
170795d92f
commit
c02ae50fb6
@ -3,4 +3,5 @@ Dev branches
|
||||
============
|
||||
|
||||
- adding .gitlab-ci to upgrade automatically packagist (master)
|
||||
- adding fixtures for ACL and DocumentCategory
|
||||
|
||||
|
92
DataFixtures/ORM/LoadDocumentACL.php
Normal file
92
DataFixtures/ORM/LoadDocumentACL.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
|
||||
/**
|
||||
* Adding acl for person document
|
||||
*
|
||||
*/
|
||||
class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function getOrder()
|
||||
{
|
||||
return 35000;
|
||||
}
|
||||
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
||||
printf("processing permission group %s \n", $permissionsGroup->getName());
|
||||
foreach (LoadScopes::$references as $scopeRef){
|
||||
$scope = $this->getReference($scopeRef);
|
||||
printf("processing scope %s \n", $scope->getName()['en']);
|
||||
//create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
case 'social':
|
||||
if ($scope->getName()['en'] === 'administrative') {
|
||||
printf("denying power on administrative \n");
|
||||
break 2; // we do not want any power on administrative
|
||||
}
|
||||
break;
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
|
||||
printf("denying power on %s\n", $scope->getName()['en']);
|
||||
break 2; // we do not want any power on social or administrative
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Adding Person report acl to %s "
|
||||
. "permission group, scope '%s' \n",
|
||||
$permissionsGroup->getName(), $scope->getName()['en']);
|
||||
$roleScopeUpdate = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::CREATE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeUpdate);
|
||||
$roleScopeCreate = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::UPDATE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeCreate);
|
||||
$roleScopeDelete = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::DELETE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeDelete);
|
||||
$manager->persist($roleScopeUpdate);
|
||||
$manager->persist($roleScopeCreate);
|
||||
$manager->persist($roleScopeDelete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
}
|
60
DataFixtures/ORM/LoadDocumentCategory.php
Normal file
60
DataFixtures/ORM/LoadDocumentCategory.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
namespace Chill\DocStoreBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class LoadDocumentCategory extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function getOrder()
|
||||
{
|
||||
return 35010;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$category = (new DocumentCategory('chill-doc-store', 10))
|
||||
->setDocumentClass(\Chill\DocStoreBundle\Entity\PersonDocument::class)
|
||||
->setName([
|
||||
'fr' => "Document d'identité",
|
||||
'en' => "Identity"
|
||||
])
|
||||
;
|
||||
|
||||
$manager->persist($category);
|
||||
|
||||
$category = (new DocumentCategory('chill-doc-store', 20))
|
||||
->setDocumentClass(\Chill\DocStoreBundle\Entity\PersonDocument::class)
|
||||
->setName([
|
||||
'fr' => "Courrier reçu",
|
||||
'en' => "Received email"
|
||||
])
|
||||
;
|
||||
|
||||
$manager->persist($category);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
||||
$loader->load('services/media.yml');
|
||||
$loader->load('services/controller.yml');
|
||||
$loader->load('services/menu.yml');
|
||||
|
||||
$loader->load('services/fixtures.yml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
|
@ -129,17 +129,6 @@ class StoredObject implements AsyncFileInterface
|
||||
return $this->getFilename();
|
||||
}
|
||||
|
||||
public function setAsyncFile(/*AsyncFileInterface*/ $async)
|
||||
{
|
||||
dump($async);
|
||||
//$this->setFilename($async->getObjectName());
|
||||
}
|
||||
|
||||
public function getAsyncFile()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKeyInfos()
|
||||
{
|
||||
return $this->keyInfos;
|
||||
|
4
Resources/config/services/fixtures.yml
Normal file
4
Resources/config/services/fixtures.yml
Normal file
@ -0,0 +1,4 @@
|
||||
services:
|
||||
Chill\DocStoreBundle\DataFixtures\ORM\:
|
||||
resource: ../../../DataFixtures/ORM
|
||||
tags: [ 'doctrine.fixture.orm' ]
|
Loading…
x
Reference in New Issue
Block a user