diff --git a/Classes/Service/Exception.php b/Classes/Service/Exception.php index 0a46197..4d1cd00 100644 --- a/Classes/Service/Exception.php +++ b/Classes/Service/Exception.php @@ -1,12 +1,9 @@ entityManager; try { $em->getConnection()->insert( - 'digicomp_sequence_domain_model_insert', + $em->getClassMetadata(Insert::class)->getTableName(), ['number' => $count, 'type' => $type] ); return true; @@ -79,8 +78,7 @@ class SequenceGenerator } catch (DBALException $e) { if ($e->getPrevious() && $e->getPrevious() instanceof \PDOException) { // Do nothing, new Doctrine handling hides the above error - } - else { + } else { $this->systemLogger->logException($e); } } catch (\Exception $e) { @@ -100,7 +98,7 @@ class SequenceGenerator { $type = $this->inferTypeFromSource($type); - return ($this->validateFreeNumber($to, $type)); + return $this->validateFreeNumber($to, $type); } /** @@ -110,25 +108,20 @@ class SequenceGenerator */ public function getLastNumberFor($type) { - /** @var $em EntityManager */ + /* @var EntityManager $em */ $em = $this->entityManager; - $result = $em->getConnection()->executeQuery( - 'SELECT MAX(number) AS count FROM digicomp_sequence_domain_model_insert WHERE type=:type', + return $em->getConnection()->executeQuery( + 'SELECT MAX(number) FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type = :type', ['type' => $this->inferTypeFromSource($type)] - ); - $count = $result->fetchAll(); - $count = $count[0]['count']; - - return $count; + )->fetchAll(\PDO::FETCH_COLUMN)[0]; } /** * @param string|object $stringOrObject * - * @throws Exception - * * @return string + * @throws Exception */ protected function inferTypeFromSource($stringOrObject) { diff --git a/composer.json b/composer.json index c08726b..b5eba4a 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,8 @@ "TYPO3.FluidAdaptor-20161130112935", "Neos.Media-20161219094126", "Neos.Flow-20170125103800", - "Neos.Flow-20170127183102" + "Neos.Flow-20170127183102", + "DigiComp.SettingValidator-20170603120900" ] } -} +} \ No newline at end of file