FOSSology  4.4.0
Open Source License Compliance by Open Source Software
FileInfoController.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2018 Siemens AG
4  Author: Author: Soham Banerjee <sohambanerjee4abc@hotmail.com>
5  SPDX-FileCopyrightText: © 2023 Soham Banerjee <sohambanerjee4abc@hotmail.com>
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
14 namespace Fossology\UI\Api\Controllers;
15 
20 use Psr\Http\Message\ServerRequestInterface;
21 
22 
24 {
29  private $viewInfo;
30 
31  public function __construct($container)
32  {
33  parent::__construct($container);
34  $this->viewInfo = $this->restHelper->getPlugin('view_info');
35  }
36 
46  public function getItemInfo($request, $response, $args)
47  {
48  $uploadPk = $args["id"];
49  $uploadTreeId = $args["itemId"];
50  $apiVersion = ApiVersion::getVersion($request);
51  $this->uploadAccessible($uploadPk);
52  $this->isItemExists($uploadPk, $uploadTreeId);
53  $response_view = $this->viewInfo->ShowView($uploadPk, $uploadTreeId);
54  $response_meta = $this->viewInfo->ShowMetaView($uploadPk, $uploadTreeId);
55  $response_package_info = $this->viewInfo->ShowPackageInfo($uploadPk, $uploadTreeId);
56  $response_tag_info = $this->viewInfo->ShowTagInfo($uploadPk, $uploadTreeId);
57  $response_reuse_info = $this->viewInfo->showReuseInfo($uploadPk);
58  $finalValue = new FileInfo($response_view, $response_meta, $response_package_info, $response_tag_info, $response_reuse_info);
59  return $response->withJson($finalValue->getarray($apiVersion), 200);
60  }
61 }
Base controller for REST calls.
isItemExists(int $uploadId, int $itemId)
Override Slim response for withJson function.
static getVersion(ServerRequestInterface $request)
Definition: ApiVersion.php:29
FileInfo model to contain general error and return values.
Definition: FileInfo.php:22