Code cleanup

This commit is contained in:
James Cole
2021-03-21 09:15:40 +01:00
parent da1751940e
commit 206845575c
317 changed files with 7418 additions and 7362 deletions

View File

@@ -108,6 +108,27 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
return $objectGroup->piggyBanks;
}
/**
* @inheritDoc
*/
public function resetOrder(): void
{
Log::debug('Now in resetOrder');
$list = $this->get();
$index = 1;
/** @var ObjectGroup $objectGroup */
foreach ($list as $objectGroup) {
if ($index !== (int)$objectGroup->order) {
Log::debug(
sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order)
);
$objectGroup->order = $index;
$objectGroup->save();
}
$index++;
}
}
/**
* @param string $query
* @param int $limit
@@ -164,11 +185,11 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
*/
public function update(ObjectGroup $objectGroup, array $data): ObjectGroup
{
if(array_key_exists('title', $data)) {
if (array_key_exists('title', $data)) {
$objectGroup->title = $data['title'];
}
if(array_key_exists('order', $data)) {
if (array_key_exists('order', $data)) {
$this->setOrder($objectGroup, (int)$data['order']);
}
@@ -184,25 +205,4 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
{
$this->user = $user;
}
/**
* @inheritDoc
*/
public function resetOrder(): void
{
Log::debug('Now in resetOrder');
$list = $this->get();
$index = 1;
/** @var ObjectGroup $objectGroup */
foreach ($list as $objectGroup) {
if ($index !== (int)$objectGroup->order) {
Log::debug(
sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order)
);
$objectGroup->order = $index;
$objectGroup->save();
}
$index++;
}
}
}

View File

@@ -37,11 +37,6 @@ interface ObjectGroupRepositoryInterface
*/
public function deleteAll(): void;
/**
* Delete all.
*/
public function resetOrder(): void;
/**
* Delete empty ones.
*/
@@ -71,6 +66,11 @@ interface ObjectGroupRepositoryInterface
*/
public function getPiggyBanks(ObjectGroup $objectGroup): Collection;
/**
* Delete all.
*/
public function resetOrder(): void;
/**
* @param string $query
* @param int $limit