| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 06:17:48 +01:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * AboutController.php | 
					
						
							| 
									
										
										
										
											2021-02-17 06:17:48 +01:00
										 |  |  |  * Copyright (c) 2021 james@firefly-iii.org | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * 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. | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * GNU Affero General Public License for more details. | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * 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/>. | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 06:17:48 +01:00
										 |  |  | namespace FireflyIII\Api\V1\Controllers\System; | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | use DB; | 
					
						
							| 
									
										
										
										
											2021-02-17 06:17:48 +01:00
										 |  |  | use FireflyIII\Api\V1\Controllers\Controller; | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | use FireflyIII\Transformers\UserTransformer; | 
					
						
							| 
									
										
										
										
											2018-06-21 18:56:44 +02:00
										 |  |  | use Illuminate\Http\JsonResponse; | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | use League\Fractal\Resource\Item; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-06-21 18:56:44 +02:00
										 |  |  |  * Returns basic information about this installation. | 
					
						
							| 
									
										
										
										
											2019-09-04 17:39:39 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-12 04:53:18 +02:00
										 |  |  |  * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2018-07-06 07:15:42 +02:00
										 |  |  |  * Class AboutController. | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | class AboutController extends Controller | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-06-21 18:56:44 +02:00
										 |  |  |      * Returns system information. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return JsonResponse | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-06-21 18:56:44 +02:00
										 |  |  |     public function about(): JsonResponse | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         $search        = ['~', '#']; | 
					
						
							|  |  |  |         $replace       = ['\~', '# ']; | 
					
						
							|  |  |  |         $phpVersion    = str_replace($search, $replace, PHP_VERSION); | 
					
						
							| 
									
										
										
										
											2018-03-26 19:19:11 +02:00
										 |  |  |         $phpOs         = str_replace($search, $replace, PHP_OS); | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |         $currentDriver = DB::getDriverName(); | 
					
						
							|  |  |  |         $data | 
					
						
							| 
									
										
										
										
											2021-03-28 11:39:26 +02:00
										 |  |  |                        = [ | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |             'version'     => config('firefly.version'), | 
					
						
							|  |  |  |             'api_version' => config('firefly.api_version'), | 
					
						
							|  |  |  |             'php_version' => $phpVersion, | 
					
						
							|  |  |  |             'os'          => $phpOs, | 
					
						
							|  |  |  |             'driver'      => $currentDriver, | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-03 16:51:44 +02:00
										 |  |  |         return response()->json(['data' => $data])->header('Content-Type', self::CONTENT_TYPE); | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-06-21 18:56:44 +02:00
										 |  |  |      * Returns information about the user. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return JsonResponse | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2019-09-04 17:39:39 +02:00
										 |  |  |     public function user(): JsonResponse | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-09-04 17:39:39 +02:00
										 |  |  |         $manager = $this->getManager(); | 
					
						
							| 
									
										
										
										
											2018-12-15 22:03:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         /** @var UserTransformer $transformer */ | 
					
						
							|  |  |  |         $transformer = app(UserTransformer::class); | 
					
						
							|  |  |  |         $transformer->setParameters($this->parameters); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $resource = new Item(auth()->user(), $transformer, 'users'); | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-03 16:51:44 +02:00
										 |  |  |         return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); | 
					
						
							| 
									
										
										
										
											2018-02-13 18:23:26 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-05 19:35:58 +01:00
										 |  |  | } |