Part-DB.Part-DB-server/src/Controller/AdminPages/ProjectAdminController.php

93 lines
3.3 KiB
PHP
Raw Normal View History

2019-04-26 18:31:09 +02:00
<?php
2020-02-22 18:14:36 +01:00
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
2022-11-29 22:28:53 +01:00
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
2020-02-22 18:14:36 +01: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.
*
* 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/>.
*/
2020-01-05 15:46:58 +01:00
declare(strict_types=1);
2019-04-28 13:10:11 +02:00
namespace App\Controller\AdminPages;
2019-04-26 18:31:09 +02:00
use App\Entity\Attachments\ProjectAttachment;
use App\Entity\ProjectSystem\Project;
use App\Entity\Parameters\ProjectParameter;
use App\Form\AdminPages\ProjectAdminForm;
2022-12-18 17:28:42 +01:00
use App\Services\ImportExportSystem\EntityExporter;
use App\Services\ImportExportSystem\EntityImporter;
use App\Services\Trees\StructuralElementRecursionHelper;
2019-04-26 18:31:09 +02:00
use Doctrine\ORM\EntityManagerInterface;
2020-01-05 22:49:00 +01:00
use Symfony\Component\HttpFoundation\RedirectResponse;
2019-04-26 18:31:09 +02:00
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/project")
2019-04-26 18:31:09 +02:00
*/
class ProjectAdminController extends BaseAdminController
2019-04-26 18:31:09 +02:00
{
protected string $entity_class = Project::class;
protected string $twig_template = 'admin/project_admin.html.twig';
protected string $form_class = ProjectAdminForm::class;
protected string $route_base = 'project';
protected string $attachment_class = ProjectAttachment::class;
protected ?string $parameter_class = ProjectParameter::class;
2019-04-26 18:31:09 +02:00
/**
* @Route("/{id}", name="project_delete", methods={"DELETE"})
*/
public function delete(Request $request, Project $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
2019-04-26 18:31:09 +02:00
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="project_edit")
* @Route("/{id}/edit", requirements={"id"="\d+"})
2019-04-26 18:31:09 +02:00
*/
public function edit(Project $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
2019-04-26 18:31:09 +02:00
{
return $this->_edit($entity, $request, $em, $timestamp);
2019-04-26 18:31:09 +02:00
}
/**
* @Route("/new", name="project_new")
* @Route("/{id}/clone", name="device_clone")
2019-04-26 18:31:09 +02:00
* @Route("/")
*/
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Project $entity = null): Response
2019-04-26 18:31:09 +02:00
{
return $this->_new($request, $em, $importer, $entity);
2019-04-26 18:31:09 +02:00
}
/**
* @Route("/export", name="project_export_all")
2019-04-26 18:31:09 +02:00
*/
2020-02-02 14:05:36 +01:00
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
2019-04-26 18:31:09 +02:00
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="project_export")
2019-04-26 18:31:09 +02:00
*/
public function exportEntity(Project $entity, EntityExporter $exporter, Request $request): Response
2019-04-26 18:31:09 +02:00
{
return $this->_exportEntity($entity, $exporter, $request);
}
}