Merge branch 'release/2.0.1'
This commit is contained in:
commit
cc1e159614
3 changed files with 13 additions and 22 deletions
|
@ -1,12 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Sequence\Service;
|
namespace DigiComp\Sequence\Service;
|
||||||
|
|
||||||
use Neos\Flow\Annotations as Flow;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SequenceException
|
* SequenceException
|
||||||
*/
|
*/
|
||||||
class Exception extends \Exception
|
class Exception extends \Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Sequence\Service;
|
namespace DigiComp\Sequence\Service;
|
||||||
|
|
||||||
|
use DigiComp\Sequence\Domain\Model\Insert;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
@ -40,8 +41,6 @@ class SequenceGenerator
|
||||||
/**
|
/**
|
||||||
* @param string|object $type
|
* @param string|object $type
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getNextNumberFor($type)
|
public function getNextNumberFor($type)
|
||||||
|
@ -66,11 +65,11 @@ class SequenceGenerator
|
||||||
*/
|
*/
|
||||||
protected function validateFreeNumber($count, $type)
|
protected function validateFreeNumber($count, $type)
|
||||||
{
|
{
|
||||||
/** @var $em EntityManager */
|
/* @var EntityManager $em */
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
try {
|
try {
|
||||||
$em->getConnection()->insert(
|
$em->getConnection()->insert(
|
||||||
'digicomp_sequence_domain_model_insert',
|
$em->getClassMetadata(Insert::class)->getTableName(),
|
||||||
['number' => $count, 'type' => $type]
|
['number' => $count, 'type' => $type]
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
@ -79,8 +78,7 @@ class SequenceGenerator
|
||||||
} catch (DBALException $e) {
|
} catch (DBALException $e) {
|
||||||
if ($e->getPrevious() && $e->getPrevious() instanceof \PDOException) {
|
if ($e->getPrevious() && $e->getPrevious() instanceof \PDOException) {
|
||||||
// Do nothing, new Doctrine handling hides the above error
|
// Do nothing, new Doctrine handling hides the above error
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->systemLogger->logException($e);
|
$this->systemLogger->logException($e);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -100,7 +98,7 @@ class SequenceGenerator
|
||||||
{
|
{
|
||||||
$type = $this->inferTypeFromSource($type);
|
$type = $this->inferTypeFromSource($type);
|
||||||
|
|
||||||
return ($this->validateFreeNumber($to, $type));
|
return $this->validateFreeNumber($to, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,25 +108,20 @@ class SequenceGenerator
|
||||||
*/
|
*/
|
||||||
public function getLastNumberFor($type)
|
public function getLastNumberFor($type)
|
||||||
{
|
{
|
||||||
/** @var $em EntityManager */
|
/* @var EntityManager $em */
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
$result = $em->getConnection()->executeQuery(
|
return $em->getConnection()->executeQuery(
|
||||||
'SELECT MAX(number) AS count FROM digicomp_sequence_domain_model_insert WHERE type=:type',
|
'SELECT MAX(number) FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type = :type',
|
||||||
['type' => $this->inferTypeFromSource($type)]
|
['type' => $this->inferTypeFromSource($type)]
|
||||||
);
|
)->fetchAll(\PDO::FETCH_COLUMN)[0];
|
||||||
$count = $result->fetchAll();
|
|
||||||
$count = $count[0]['count'];
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|object $stringOrObject
|
* @param string|object $stringOrObject
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function inferTypeFromSource($stringOrObject)
|
protected function inferTypeFromSource($stringOrObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,8 @@
|
||||||
"TYPO3.FluidAdaptor-20161130112935",
|
"TYPO3.FluidAdaptor-20161130112935",
|
||||||
"Neos.Media-20161219094126",
|
"Neos.Media-20161219094126",
|
||||||
"Neos.Flow-20170125103800",
|
"Neos.Flow-20170125103800",
|
||||||
"Neos.Flow-20170127183102"
|
"Neos.Flow-20170127183102",
|
||||||
|
"DigiComp.SettingValidator-20170603120900"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue