Commit e7795c67 authored by root's avatar root Committed by Vassilis Kanellopoulos

disable mm find if school already in database

parent e3dad5c2
......@@ -115,6 +115,9 @@ class CreateSchool
));
}
$school = R::findOne('school', 'registry_no = ?', [$registryNo]);
try {
if (!$school) {
$unit = call_user_func($this->fetchUnit, $registryNo);
if (null === $unit) {
$this->logger->error(sprintf(
......@@ -130,10 +133,6 @@ class CreateSchool
$this->ssoLogoutUrl
));
}
$school = R::findOne('school', 'registry_no = ?', [$registryNo]);
try {
if (!$school) {
$data = [
'id' => '',
'registry_no' => $unit['registry_no'],
......@@ -157,12 +156,11 @@ class CreateSchool
}
$school = $this->schoolService->createSchool($filtered['values']);
$this->logger->info(sprintf('School %s imported from MM to database', $registryNo), $filtered['values']);
}
$user = R::load('user', $identity->id);
$user->school_id = $school['id'];
R::store($user);
$this->logger->info(sprintf('Set school %s to user %s', $registryNo, $identity->mail));
}
} catch (Exception $e) {
$this->logger->error(sprintf('Problem inserting school %s form MM in database', $registryNo));
$this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment