Skip to content

Commit

Permalink
Add Deafault and config map to load default seal (refs #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoVS committed Dec 12, 2016
1 parent 0e3a6e0 commit 30747ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conf-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
'app.enabled.apps' => false,
'maps.center' => [-23.633201663141417, -46.6043472290039],
'maps.zoom.default' => 11,
'export.excelName' => 'gestao-de-hortas-dados-exportados.xls'
'export.excelName' => 'gestao-de-hortas-dados-exportados.xls',
// assuming that's a first instalation and the default seal will be the seal '2'
// if the verified seal is other needs to change this ID
'app.verifiedSealsIds' => [2]
];
26 changes: 26 additions & 0 deletions db-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use MapasCulturais\Entities\Agent;
use MapasCulturais\Entities\Seal;
use MapasCulturais\Entities\SpaceSealRelation;
use MapasCulturais\Entities\AgentSealRelation;

$app = MapasCulturais\App::i();
$em = $app->em;
Expand Down Expand Up @@ -186,4 +187,29 @@
$seal_relation->save();
}
},
'hor: add default seal to all agents' => function() use($app){
$app->em->flush();

$app->user = $app->repo('User')->find(1);
$app->auth->authenticatedUser = $app->repo('User')->find(1);
$owner_agent = $app->user->profile;
$seal = $app->repo('Seal')->findOneBy(['name' => 'SME']);

if(!$seal){
echo "Seal \"SME\" needs to be created before this db-update run";
return false;
}
$agents = $app->repo('Agent')->findAll();
foreach ($agents as $agent) {
$seal_relation = new AgentSealRelation;
$seal_relation->seal = $seal;
$seal_relation->objectId = $agent->id;
$seal_relation->object_type = $agent->entityClassName;
$seal_relation->agent = $owner_agent;
$seal_relation->owner = $agent;
$seal_relation->owner_relation = $owner_agent;
echo "\nAdding seal \"$seal->name\" to agent \"$agent->name\"";
$seal_relation->save();
}
}
];

0 comments on commit 30747ec

Please sign in to comment.