| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * ObjectGroupTransformer.php | 
					
						
							|  |  |  |  * Copyright (c) 2020 james@firefly-iii.org | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as | 
					
						
							|  |  |  |  * published by the Free Software Foundation, either version 3 of the | 
					
						
							|  |  |  |  * License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | declare(strict_types=1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Transformers; | 
					
						
							| 
									
										
										
										
											2021-09-18 10:26:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  | use FireflyIII\Models\ObjectGroup; | 
					
						
							|  |  |  | use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Class AccountTransformer | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class ObjectGroupTransformer extends AbstractTransformer | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     protected ObjectGroupRepositoryInterface $repository; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * AccountTransformer constructor. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-02-12 07:15:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->repository = app(ObjectGroupRepositoryInterface::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Transform the account. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-06-21 12:34:58 +02:00
										 |  |  |      * @param ObjectGroup $objectGroup | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function transform(ObjectGroup $objectGroup): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->repository->setUser($objectGroup->user); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return [ | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:40 +01:00
										 |  |  |             'id'         => (string)$objectGroup->id, | 
					
						
							| 
									
										
										
										
											2022-04-03 17:47:27 +02:00
										 |  |  |             'created_at' => $objectGroup->created_at?->toAtomString(), | 
					
						
							|  |  |  |             'updated_at' => $objectGroup->updated_at?->toAtomString(), | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  |             'title'      => $objectGroup->title, | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:40 +01:00
										 |  |  |             'order'      => (int)$objectGroup->order, | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  |             'links'      => [ | 
					
						
							|  |  |  |                 [ | 
					
						
							|  |  |  |                     'rel' => 'self', | 
					
						
							| 
									
										
										
										
											2023-06-21 12:34:58 +02:00
										 |  |  |                     'uri' => '/object_groups/' . $objectGroup->id, | 
					
						
							| 
									
										
										
										
											2020-06-20 16:28:23 +02:00
										 |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |