FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AdminLicenseToYAML.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2024 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\UI\Page;
9 
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\HttpFoundation\Response;
17 
19 {
20  const NAME = "admin_license_to_yaml";
21 
22  function __construct()
23  {
24  parent::__construct(self::NAME, array(
25  self::TITLE => "Admin License Rules Export",
26  self::MENU_LIST => "Admin::License Admin::Rules Export",
27  self::REQUIRES_LOGIN => true,
28  self::PERMISSION => Auth::PERM_ADMIN
29  ));
30  }
31 
36  protected function handle(Request $request)
37  {
39  $dbManager = $this->getObject('db.manager');
41  $compatibilityDao = $this->getObject('dao.compatibility');
42  $licenseYamlExport = new LicenseCompatibilityRulesYamlExport($dbManager,
43  $compatibilityDao);
44  $content = $licenseYamlExport->createYaml(0);
45  $fileName = "fossology-license-comp-rules-export-".date("YMj-Gis");
46  $headers = array(
47  'Content-type' => 'text/x-yaml, charset=UTF-8',
48  'Content-Disposition' => 'attachment; filename='.$fileName.'.yaml',
49  'Pragma' => 'no-cache',
50  'Cache-Control' => 'no-cache, must-revalidate, maxage=1, post-check=0, pre-check=0',
51  'Expires' => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT');
52 
53  return new Response($content, Response::HTTP_OK, $headers);
54  }
55 }
56 
57 register_plugin(new AdminLicenseToYAML());
Helper class to export license list as a YAML from the DB.
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24