mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user