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 ...@@ -115,6 +115,9 @@ class CreateSchool
)); ));
} }
$school = R::findOne('school', 'registry_no = ?', [$registryNo]);
try {
if (!$school) {
$unit = call_user_func($this->fetchUnit, $registryNo); $unit = call_user_func($this->fetchUnit, $registryNo);
if (null === $unit) { if (null === $unit) {
$this->logger->error(sprintf( $this->logger->error(sprintf(
...@@ -130,10 +133,6 @@ class CreateSchool ...@@ -130,10 +133,6 @@ class CreateSchool
$this->ssoLogoutUrl $this->ssoLogoutUrl
)); ));
} }
$school = R::findOne('school', 'registry_no = ?', [$registryNo]);
try {
if (!$school) {
$data = [ $data = [
'id' => '', 'id' => '',
'registry_no' => $unit['registry_no'], 'registry_no' => $unit['registry_no'],
...@@ -157,12 +156,11 @@ class CreateSchool ...@@ -157,12 +156,11 @@ class CreateSchool
} }
$school = $this->schoolService->createSchool($filtered['values']); $school = $this->schoolService->createSchool($filtered['values']);
$this->logger->info(sprintf('School %s imported from MM to database', $registryNo), $filtered['values']); $this->logger->info(sprintf('School %s imported from MM to database', $registryNo), $filtered['values']);
}
$user = R::load('user', $identity->id); $user = R::load('user', $identity->id);
$user->school_id = $school['id']; $user->school_id = $school['id'];
R::store($user); R::store($user);
$this->logger->info(sprintf('Set school %s to user %s', $registryNo, $identity->mail)); $this->logger->info(sprintf('Set school %s to user %s', $registryNo, $identity->mail));
}
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->error(sprintf('Problem inserting school %s form MM in database', $registryNo)); $this->logger->error(sprintf('Problem inserting school %s form MM in database', $registryNo));
$this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]); $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