mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +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++; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user