mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,48 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <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/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory as FakerFactory;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityReason;
|
||||
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityType;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
|
||||
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
/**
|
||||
* @var \Faker\Generator
|
||||
*/
|
||||
private $faker;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
@@ -55,30 +41,53 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
return 16400;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random scope
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Scope
|
||||
*/
|
||||
private function getRandomScope()
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
|
||||
return $this->getReference($scopeRef);
|
||||
$persons = $this->em
|
||||
->getRepository(Person::class)
|
||||
->findAll();
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$activityNbr = rand(0, 3);
|
||||
|
||||
for ($i = 0; $i < $activityNbr; ++$i ) {
|
||||
$activity = $this->newRandomActivity($person);
|
||||
|
||||
if (null !== $activity) {
|
||||
$manager->persist($activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function newRandomActivity($person): ?Activity
|
||||
{
|
||||
$activity = (new Activity())
|
||||
->setUser($this->getRandomUser())
|
||||
->setPerson($person)
|
||||
->setDate($this->faker->dateTimeThisYear())
|
||||
->setDurationTime($this->faker->dateTime(36000))
|
||||
->setType($this->getRandomActivityType())
|
||||
->setScope($this->getRandomScope());
|
||||
|
||||
// ->setAttendee($this->faker->boolean())
|
||||
|
||||
for ($i = 0; rand(0, 4) > $i; ++$i) {
|
||||
$reason = $this->getRandomActivityReason();
|
||||
|
||||
if (null !== $reason) {
|
||||
$activity->addReason($reason);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random activityType
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityType
|
||||
*/
|
||||
private function getRandomActivityType()
|
||||
{
|
||||
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
|
||||
return $this->getReference($typeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random activityReason
|
||||
* Return a random activityReason.
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
||||
*/
|
||||
@@ -90,57 +99,38 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random user
|
||||
* Return a random activityType.
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityType
|
||||
*/
|
||||
private function getRandomActivityType()
|
||||
{
|
||||
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
|
||||
|
||||
return $this->getReference($typeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random scope.
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Scope
|
||||
*/
|
||||
private function getRandomScope()
|
||||
{
|
||||
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
|
||||
|
||||
return $this->getReference($scopeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random user.
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\User
|
||||
*/
|
||||
private function getRandomUser()
|
||||
{
|
||||
$userRef = array_rand(LoadUsers::$refs);
|
||||
|
||||
return $this->getReference($userRef);
|
||||
}
|
||||
|
||||
public function newRandomActivity($person): ?Activity
|
||||
{
|
||||
$activity = (new Activity())
|
||||
->setUser($this->getRandomUser())
|
||||
->setPerson($person)
|
||||
->setDate($this->faker->dateTimeThisYear())
|
||||
->setDurationTime($this->faker->dateTime(36000))
|
||||
->setType($this->getRandomActivityType())
|
||||
->setScope($this->getRandomScope())
|
||||
;
|
||||
|
||||
// ->setAttendee($this->faker->boolean())
|
||||
|
||||
for ($i = 0; $i < rand(0, 4); $i++) {
|
||||
$reason = $this->getRandomActivityReason();
|
||||
if (null !== $reason) {
|
||||
$activity->addReason($reason);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$persons = $this->em
|
||||
->getRepository(Person::class)
|
||||
->findAll();
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$activityNbr = rand(0,3);
|
||||
|
||||
for ($i = 0; $i < $activityNbr; $i ++) {
|
||||
$activity = $this->newRandomActivity($person);
|
||||
if (null !== $activity) {
|
||||
$manager->persist($activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait;
|
||||
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivity;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
|
||||
/**
|
||||
* Load notififications into database
|
||||
* Load notififications into database.
|
||||
*/
|
||||
class LoadActivityNotifications extends AbstractFixture implements DependentFixtureInterface
|
||||
{
|
||||
@@ -25,9 +31,9 @@ class LoadActivityNotifications extends AbstractFixture implements DependentFixt
|
||||
'center a_social',
|
||||
'center a_administrative',
|
||||
'center a_direction',
|
||||
'multi_center'
|
||||
'multi_center',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
public function getDependencies()
|
||||
|
@@ -1,81 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <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/>.
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
|
||||
/**
|
||||
* Description of LoadActivityReason
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
* Description of LoadActivityReason.
|
||||
*/
|
||||
class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public static $references = [];
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return 16300;
|
||||
}
|
||||
|
||||
public static $references = array();
|
||||
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$reasons = [
|
||||
[
|
||||
'name' => ['fr' => 'Recherche logement', 'en' => 'Housing research', 'nl' => 'Woning zoektoch'],
|
||||
'category' => 'cat_Housing'],
|
||||
'category' => 'cat_Housing', ],
|
||||
[
|
||||
'name' => ['fr' => 'Problème avec propriétaire', 'en' => 'Landlord problems', 'nl' => 'Huisbaas problemen'],
|
||||
'category' => 'cat_Housing'],
|
||||
'category' => 'cat_Housing', ],
|
||||
[
|
||||
'name' => ['fr' => 'Retard de payement', 'en' => 'Payement problems', 'nl' => 'Betalings vertragingen'],
|
||||
'category' => 'cat_Housing'],
|
||||
'category' => 'cat_Housing', ],
|
||||
[
|
||||
'name' => ['fr' => 'Explication législation', 'en' => 'Legislation explanation', 'nl' => 'Legislative uitleg'],
|
||||
'category' => 'cat_Unemployment procedure'],
|
||||
'category' => 'cat_Unemployment procedure', ],
|
||||
[
|
||||
'name' => ['fr' => 'Coaching entretien d\'activation', 'en' => 'Interview coaching', 'nl' => 'Interview coaching'],
|
||||
'category' => 'cat_Unemployment procedure'],
|
||||
'category' => 'cat_Unemployment procedure', ],
|
||||
[
|
||||
'name' => ['fr' => 'Récupération des allocations', 'en' => 'Allowance recovery', 'nl' => 'Terugwinning van de uitkeringen'],
|
||||
'category' => 'cat_Unemployment procedure']
|
||||
'category' => 'cat_Unemployment procedure', ],
|
||||
];
|
||||
|
||||
|
||||
foreach ($reasons as $r) {
|
||||
print "Creating activity reason : " . $r['name']['en'] . "\n";
|
||||
echo 'Creating activity reason : ' . $r['name']['en'] . "\n";
|
||||
$activityReason = (new ActivityReason())
|
||||
->setName(($r['name']))
|
||||
->setActive(true)
|
||||
->setCategory($this->getReference($r['category']));
|
||||
$manager->persist($activityReason);
|
||||
$reference = 'activity_reason_'.$r['name']['en'];
|
||||
$reference = 'activity_reason_' . $r['name']['en'];
|
||||
$this->addReference($reference, $activityReason);
|
||||
static::$references[] = $reference;
|
||||
}
|
||||
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@@ -1,35 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <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/>.
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||
|
||||
/**
|
||||
* Description of LoadActivityReasonCategory
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
* Description of LoadActivityReasonCategory.
|
||||
*/
|
||||
class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
@@ -37,27 +23,26 @@ class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtu
|
||||
{
|
||||
return 16200;
|
||||
}
|
||||
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$categs = [
|
||||
['name' =>
|
||||
['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']],
|
||||
['name' =>
|
||||
['fr' => 'Démarches chômage', 'en' => 'Unemployment procedure', 'nl' => 'Werkloosheid werkwijze']],
|
||||
['name' => ['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']],
|
||||
['name' => ['fr' => 'Démarches chômage', 'en' => 'Unemployment procedure', 'nl' => 'Werkloosheid werkwijze']],
|
||||
];
|
||||
|
||||
|
||||
foreach ($categs as $c) {
|
||||
print "Creating activity reason category : " . $c['name']['en'] . "\n";
|
||||
echo 'Creating activity reason category : ' . $c['name']['en'] . "\n";
|
||||
$activityReasonCategory = (new ActivityReasonCategory())
|
||||
->setName(($c['name']))
|
||||
->setActive(true);
|
||||
$manager->persist($activityReasonCategory);
|
||||
$this->addReference(
|
||||
'cat_'.$c['name']['en'],
|
||||
$activityReasonCategory);
|
||||
'cat_' . $c['name']['en'],
|
||||
$activityReasonCategory
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@@ -1,86 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <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/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
|
||||
/**
|
||||
* Description of LoadActivityType
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
* Description of LoadActivityType.
|
||||
*/
|
||||
class LoadActivityType extends Fixture implements OrderedFixtureInterface
|
||||
{
|
||||
public static $references = [];
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return 16100;
|
||||
}
|
||||
|
||||
public static $references = array();
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$types = [
|
||||
# Exange
|
||||
// Exange
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Entretien physique avec l\'usager'],
|
||||
'category' => 'exchange' ],
|
||||
'name' => ['fr' => 'Entretien physique avec l\'usager'],
|
||||
'category' => 'exchange', ],
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'],
|
||||
'category' => 'exchange' ],
|
||||
'name' => ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'],
|
||||
'category' => 'exchange', ],
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'],
|
||||
'category' => 'exchange' ],
|
||||
# Meeting
|
||||
'name' => ['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'],
|
||||
'category' => 'exchange', ],
|
||||
// Meeting
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Point technique encadrant'],
|
||||
'category' => 'meeting' ],
|
||||
'name' => ['fr' => 'Point technique encadrant'],
|
||||
'category' => 'meeting', ],
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Réunion avec des partenaires'],
|
||||
'category' => 'meeting' ],
|
||||
'name' => ['fr' => 'Réunion avec des partenaires'],
|
||||
'category' => 'meeting', ],
|
||||
[
|
||||
'name' =>
|
||||
['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'],
|
||||
'category' => 'meeting' ],
|
||||
'name' => ['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'],
|
||||
'category' => 'meeting', ],
|
||||
];
|
||||
|
||||
foreach ($types as $t) {
|
||||
print "Creating activity type : " . $t['name']['fr'] . " (cat:". $t['category'] . " \n";
|
||||
echo 'Creating activity type : ' . $t['name']['fr'] . ' (cat:' . $t['category'] . " \n";
|
||||
$activityType = (new ActivityType())
|
||||
->setName(($t['name']))
|
||||
->setCategory($this->getReference('activity_type_cat_'.$t['category']))
|
||||
->setCategory($this->getReference('activity_type_cat_' . $t['category']))
|
||||
->setSocialIssuesVisible(1)
|
||||
->setSocialActionsVisible(1);
|
||||
$manager->persist($activityType);
|
||||
$reference = 'activity_type_'.$t['name']['fr'];
|
||||
$reference = 'activity_type_' . $t['name']['fr'];
|
||||
$this->addReference($reference, $activityType);
|
||||
static::$references[] = $reference;
|
||||
}
|
||||
|
@@ -1,40 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <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/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||
|
||||
/**
|
||||
* Fixtures for ActivityTypeCategory
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
* Fixtures for ActivityTypeCategory.
|
||||
*/
|
||||
class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterface
|
||||
{
|
||||
public static $references = array();
|
||||
public static $references = [];
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
@@ -55,13 +40,13 @@ class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterfac
|
||||
];
|
||||
|
||||
foreach ($categories as $cat) {
|
||||
print "Creating activity type category : " . $cat['ref'] . "\n";
|
||||
echo 'Creating activity type category : ' . $cat['ref'] . "\n";
|
||||
|
||||
$newCat = (new ActivityTypeCategory())
|
||||
->setName(($cat['name']));
|
||||
|
||||
$manager->persist($newCat);
|
||||
$reference = 'activity_type_cat_'.$cat['ref'];
|
||||
$reference = 'activity_type_cat_' . $cat['ref'];
|
||||
|
||||
$this->addReference($reference, $newCat);
|
||||
static::$references[] = $reference;
|
||||
|
@@ -1,38 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* 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/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
|
||||
/**
|
||||
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
||||
* and a role CHILL_ACTIVITY_SEE for administrative
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* and a role CHILL_ACTIVITY_SEE for administrative.
|
||||
*/
|
||||
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
@@ -41,12 +29,12 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
||||
return 16000;
|
||||
}
|
||||
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
||||
foreach (LoadScopes::$references as $scopeRef){
|
||||
|
||||
foreach (LoadScopes::$references as $scopeRef) {
|
||||
$scope = $this->getReference($scopeRef);
|
||||
//create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
@@ -54,50 +42,52 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
||||
if ($scope->getName()['en'] === 'administrative') {
|
||||
break 2; // we do not want any power on administrative
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'])) {
|
||||
break 2; // we do not want any power on social or administrative
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s "
|
||||
printf(
|
||||
'Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s '
|
||||
. "permission group, scope '%s' \n",
|
||||
$permissionsGroup->getName(), $scope->getName()['en']);
|
||||
$permissionsGroup->getName(),
|
||||
$scope->getName()['en']
|
||||
);
|
||||
$roleScopeUpdate = (new RoleScope())
|
||||
->setRole('CHILL_ACTIVITY_UPDATE')
|
||||
->setScope($scope);
|
||||
->setRole('CHILL_ACTIVITY_UPDATE')
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeUpdate);
|
||||
$roleScopeCreate = (new RoleScope())
|
||||
->setRole(ActivityVoter::CREATE_ACCOMPANYING_COURSE)
|
||||
->setScope($scope);
|
||||
->setRole(ActivityVoter::CREATE_ACCOMPANYING_COURSE)
|
||||
->setScope($scope);
|
||||
$roleScopeCreate = (new RoleScope())
|
||||
->setRole(ActivityVoter::CREATE_PERSON)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeCreate);
|
||||
$roleScopeDelete = (new RoleScope())
|
||||
->setRole('CHILL_ACTIVITY_DELETE')
|
||||
->setScope($scope);
|
||||
->setRole('CHILL_ACTIVITY_DELETE')
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeDelete);
|
||||
$roleScopeList = (new RoleScope())
|
||||
->setRole(ActivityStatsVoter::LISTS)
|
||||
;
|
||||
->setRole(ActivityStatsVoter::LISTS);
|
||||
$permissionsGroup->addRoleScope($roleScopeList);
|
||||
$roleScopeStat = (new RoleScope())
|
||||
->setRole(ActivityStatsVoter::STATS)
|
||||
;
|
||||
->setRole(ActivityStatsVoter::STATS);
|
||||
$permissionsGroup->addRoleScope($roleScopeStat);
|
||||
|
||||
$manager->persist($roleScopeUpdate);
|
||||
$manager->persist($roleScopeCreate);
|
||||
$manager->persist($roleScopeDelete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user