mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 20:28:54 +02:00
Added an PHP CS fixer config file and applied it to files.
We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,16 +17,13 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\AttachmentTypeAttachment;
|
||||
use App\Form\AdminPages\AttachmentTypeAdminForm;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
use App\Services\StructuralElementRecursionHelper;
|
||||
|
@ -37,11 +34,9 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
|
||||
/**
|
||||
* @Route("/attachment_type")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class AttachmentTypeController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = AttachmentType::class;
|
||||
protected $twig_template = 'AdminPages/AttachmentTypeAdmin.html.twig';
|
||||
protected $form_class = AttachmentTypeAdminForm::class;
|
||||
|
@ -50,9 +45,7 @@ class AttachmentTypeController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="attachment_type_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, AttachmentType $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -60,13 +53,10 @@ class AttachmentTypeController extends BaseAdminController
|
|||
return $this->_delete($request, $entity, $recursionHelper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="attachment_type_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param AttachmentType $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em)
|
||||
|
@ -78,9 +68,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
* @Route("/new", name="attachment_type_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
|
@ -90,8 +77,7 @@ class AttachmentTypeController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="attachment_type_export_all")
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -101,13 +87,11 @@ class AttachmentTypeController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="attachment_type_export")
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
@ -38,22 +37,18 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Core\Tests\Encoder\PasswordEncoder;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
abstract class BaseAdminController extends AbstractController
|
||||
{
|
||||
|
||||
protected $entity_class = '';
|
||||
protected $form_class = '';
|
||||
protected $twig_template = '';
|
||||
protected $route_base = '';
|
||||
protected $attachment_class = '';
|
||||
|
||||
|
||||
protected $passwordEncoder;
|
||||
protected $translator;
|
||||
protected $attachmentHelper;
|
||||
|
@ -62,11 +57,11 @@ abstract class BaseAdminController extends AbstractController
|
|||
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder,
|
||||
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler)
|
||||
{
|
||||
if ($this->entity_class === '' || $this->form_class === '' || $this->twig_template === '' || $this->route_base === '') {
|
||||
if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) {
|
||||
throw new \InvalidArgumentException('You have to override the $entity_class, $form_class, $route_base and $twig_template value in your subclasss!');
|
||||
}
|
||||
|
||||
if ($this->attachment_class === '') {
|
||||
if ('' === $this->attachment_class) {
|
||||
throw new \InvalidArgumentException('You have to override the $attachment_class value in your subclass!');
|
||||
}
|
||||
|
||||
|
@ -78,7 +73,6 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
protected function _edit(NamedDBElement $entity, Request $request, EntityManagerInterface $em)
|
||||
{
|
||||
|
||||
$this->denyAccessUnlessGranted('read', $entity);
|
||||
|
||||
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
|
||||
|
@ -99,14 +93,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
/** @var $attachment FormInterface */
|
||||
$options = [
|
||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
'download_url' => $attachment['downloadURL']->getData(),
|
||||
];
|
||||
try {
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$this->translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
$this->translator->trans('attachment.download_failed').' '.$ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -118,14 +112,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
//Rebuild form, so it is based on the updated data. Important for the parent field!
|
||||
//We can not use dynamic form events here, because the parent entity list is build from database!
|
||||
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
|
||||
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
||||
} elseif ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('entity.edit_flash.invalid'));
|
||||
}
|
||||
|
||||
return $this->render($this->twig_template, [
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'attachment_helper' => $this->attachmentHelper
|
||||
'attachment_helper' => $this->attachmentHelper,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -155,14 +149,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
/** @var $attachment FormInterface */
|
||||
$options = [
|
||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
'download_url' => $attachment['downloadURL']->getData(),
|
||||
];
|
||||
try {
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$this->translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
$this->translator->trans('attachment.download_failed').' '.$ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -171,10 +165,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
$em->flush();
|
||||
$this->addFlash('success', $this->translator->trans('entity.created_flash'));
|
||||
|
||||
return $this->redirectToRoute($this->route_base . '_edit', ['id' => $new_entity->getID()]);
|
||||
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]);
|
||||
}
|
||||
|
||||
if ($form->isSubmitted() && ! $form->isValid()) {
|
||||
if ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('entity.created_flash.invalid'));
|
||||
}
|
||||
|
||||
|
@ -187,14 +181,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
$file = $import_form['file']->getData();
|
||||
$data = $import_form->getData();
|
||||
|
||||
$options = array('parent' => $data['parent'], 'preserve_children' => $data['preserve_children'],
|
||||
'format' => $data['format'], 'csv_separator' => $data['csv_separator']);
|
||||
$options = ['parent' => $data['parent'], 'preserve_children' => $data['preserve_children'],
|
||||
'format' => $data['format'], 'csv_separator' => $data['csv_separator'], ];
|
||||
|
||||
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
|
||||
|
||||
foreach ($errors as $name => $error) {
|
||||
/** @var $error ConstraintViolationList */
|
||||
$this->addFlash('error', $name . ':' . $error);
|
||||
/* @var $error ConstraintViolationList */
|
||||
$this->addFlash('error', $name.':'.$error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,8 +206,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
//Show errors to user:
|
||||
foreach ($errors as $name => $error) {
|
||||
/** @var $error ConstraintViolationList */
|
||||
$this->addFlash('error', $name . ':' . $error);
|
||||
/* @var $error ConstraintViolationList */
|
||||
$this->addFlash('error', $name.':'.$error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,7 +216,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'form' => $form->createView(),
|
||||
'import_form' => $import_form->createView(),
|
||||
'mass_creation_form' => $mass_creation_form->createView(),
|
||||
'attachment_helper' => $this->attachmentHelper
|
||||
'attachment_helper' => $this->attachmentHelper,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -259,7 +253,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->addFlash('error', 'csfr_invalid');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute($this->route_base . '_new');
|
||||
return $this->redirectToRoute($this->route_base.'_new');
|
||||
}
|
||||
|
||||
protected function _exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -270,7 +264,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
$entities = $em->getRepository($this->entity_class)->findAll();
|
||||
|
||||
return $exporter->exportEntityFromRequest($entities,$request);
|
||||
return $exporter->exportEntityFromRequest($entities, $request);
|
||||
}
|
||||
|
||||
protected function _exportEntity(NamedDBElement $entity, EntityExporter $exporter, Request $request)
|
||||
|
@ -279,4 +273,4 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
return $exporter->exportEntityFromRequest($entity, $request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\CategoryAttachment;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Form\AdminPages\CategoryAdminForm;
|
||||
|
@ -36,11 +34,9 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
|
||||
/**
|
||||
* @Route("/category")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class CategoryController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Category::class;
|
||||
protected $twig_template = 'AdminPages/CategoryAdmin.html.twig';
|
||||
protected $form_class = CategoryAdminForm::class;
|
||||
|
@ -49,9 +45,7 @@ class CategoryController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="category_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Category $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -62,9 +56,7 @@ class CategoryController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="category_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Category $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Category $entity, Request $request, EntityManagerInterface $em)
|
||||
|
@ -76,9 +68,6 @@ class CategoryController extends BaseAdminController
|
|||
* @Route("/new", name="category_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
|
@ -88,9 +77,7 @@ class CategoryController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="category_export_all")
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -100,14 +87,11 @@ class CategoryController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="category_export")
|
||||
* @param Category $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Category $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\CurrencyAttachment;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Form\AdminPages\CurrencyAdminForm;
|
||||
|
@ -38,7 +36,6 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
* @Route("/currency")
|
||||
*
|
||||
* Class CurrencyController
|
||||
* @package App\Controller\AdminPages
|
||||
*/
|
||||
class CurrencyController extends BaseAdminController
|
||||
{
|
||||
|
@ -50,9 +47,7 @@ class CurrencyController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="currency_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Currency $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -63,9 +58,7 @@ class CurrencyController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="currency_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Currency $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Currency $entity, Request $request, EntityManagerInterface $em)
|
||||
|
@ -77,9 +70,6 @@ class CurrencyController extends BaseAdminController
|
|||
* @Route("/new", name="currency_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
|
@ -89,9 +79,7 @@ class CurrencyController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="currency_export_all")
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -101,13 +89,11 @@ class CurrencyController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="currency_export")
|
||||
* @param Currency $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\DeviceAttachment;
|
||||
use App\Entity\Devices\Device;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
|
@ -36,11 +34,9 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
|
||||
/**
|
||||
* @Route("/device")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class DeviceController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Device::class;
|
||||
protected $twig_template = 'AdminPages/DeviceAdmin.html.twig';
|
||||
protected $form_class = BaseEntityAdminForm::class;
|
||||
|
@ -49,9 +45,7 @@ class DeviceController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="device_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Device $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Device $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -62,9 +56,7 @@ class DeviceController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="device_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Device $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Device $entity, Request $request, EntityManagerInterface $em)
|
||||
|
@ -76,9 +68,6 @@ class DeviceController extends BaseAdminController
|
|||
* @Route("/new", name="device_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
|
@ -88,9 +77,7 @@ class DeviceController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="device_export_all")
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -100,14 +87,11 @@ class DeviceController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="device_export")
|
||||
* @param Device $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Device $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,17 +17,13 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
||||
use App\Entity\Attachments\FootprintAttachment;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Form\AdminPages\FootprintAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
|
@ -40,11 +36,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
/**
|
||||
* @Route("/footprint")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class FootprintController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Footprint::class;
|
||||
protected $twig_template = 'AdminPages/FootprintAdmin.html.twig';
|
||||
protected $form_class = FootprintAdminForm::class;
|
||||
|
@ -59,7 +53,6 @@ class FootprintController extends BaseAdminController
|
|||
return $this->_delete($request, $entity, $recursionHelper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="footprint_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
|
@ -82,9 +75,9 @@ class FootprintController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="footprint_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -94,13 +87,11 @@ class FootprintController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="footprint_export")
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\ManufacturerAttachment;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Supplier;
|
||||
|
@ -38,11 +36,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
/**
|
||||
* @Route("/manufacturer")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class ManufacturerController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Manufacturer::class;
|
||||
protected $twig_template = 'AdminPages/ManufacturerAdmin.html.twig';
|
||||
protected $form_class = CompanyForm::class;
|
||||
|
@ -77,13 +73,11 @@ class ManufacturerController extends BaseAdminController
|
|||
return $this->_new($request, $em, $importer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/export", name="manufacturer_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -93,13 +87,13 @@ class ManufacturerController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="manufacturer_export")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param Supplier $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\MeasurementUnitAttachment;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
|
@ -38,11 +36,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
/**
|
||||
* @Route("/measurement_unit")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class MeasurementUnitController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = MeasurementUnit::class;
|
||||
protected $twig_template = 'AdminPages/MeasurementUnitAdmin.html.twig';
|
||||
protected $form_class = MeasurementUnitAdminForm::class;
|
||||
|
@ -79,9 +75,9 @@ class MeasurementUnitController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="measurement_unit_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -91,13 +87,11 @@ class MeasurementUnitController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="measurement_unit_export")
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,13 +17,11 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Form\AdminPages\StorelocationAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -37,11 +35,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
/**
|
||||
* @Route("/store_location")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class StorelocationController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Storelocation::class;
|
||||
protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig';
|
||||
protected $form_class = StorelocationAdminForm::class;
|
||||
|
@ -56,7 +52,6 @@ class StorelocationController extends BaseAdminController
|
|||
return $this->_delete($request, $entity, $recursionHelper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="store_location_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
|
@ -79,9 +74,9 @@ class StorelocationController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="store_location_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -91,13 +86,13 @@ class StorelocationController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="store_location_export")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\SupplierAttachment;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Form\AdminPages\SupplierForm;
|
||||
|
@ -37,11 +35,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
/**
|
||||
* @Route("/supplier")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class SupplierController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = Supplier::class;
|
||||
protected $twig_template = 'AdminPages/SupplierAdmin.html.twig';
|
||||
protected $form_class = SupplierForm::class;
|
||||
|
@ -76,12 +72,11 @@ class SupplierController extends BaseAdminController
|
|||
return $this->_new($request, $em, $importer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/export", name="supplier_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -91,13 +86,11 @@ class SupplierController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="supplier_export")
|
||||
* @param Request $request
|
||||
* @param Supplier $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,14 +17,11 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use App\DataTables\AttachmentDataTable;
|
||||
use App\DataTables\PartsDataTable;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
|
@ -37,14 +34,13 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
|
||||
class AttachmentFileController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* Download the selected attachment
|
||||
* Download the selected attachment.
|
||||
*
|
||||
* @Route("/attachment/{id}/download", name="attachment_download")
|
||||
* @param Attachment $attachment
|
||||
* @param AttachmentManager $helper
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function download(Attachment $attachment, AttachmentManager $helper)
|
||||
|
@ -59,7 +55,6 @@ class AttachmentFileController extends AbstractController
|
|||
throw new \RuntimeException('The file associated with the attachment is not existing!');
|
||||
}
|
||||
|
||||
|
||||
$file_path = $helper->toAbsoluteFilePath($attachment);
|
||||
$response = new BinaryFileResponse($file_path);
|
||||
|
||||
|
@ -70,12 +65,12 @@ class AttachmentFileController extends AbstractController
|
|||
}
|
||||
|
||||
/**
|
||||
* View the attachment
|
||||
* View the attachment.
|
||||
*
|
||||
* @Route("/attachment/{id}/view", name="attachment_view")
|
||||
* @param Attachment $attachment
|
||||
* @param AttachmentManager $helper
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function view(Attachment $attachment, AttachmentManager $helper)
|
||||
|
@ -90,7 +85,6 @@ class AttachmentFileController extends AbstractController
|
|||
throw new \RuntimeException('The file associated with the attachment is not existing!');
|
||||
}
|
||||
|
||||
|
||||
$file_path = $helper->toAbsoluteFilePath($attachment);
|
||||
$response = new BinaryFileResponse($file_path);
|
||||
|
||||
|
@ -102,8 +96,7 @@ class AttachmentFileController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/attachment/list", name="attachment_list")
|
||||
* @param DataTableFactory $dataTable
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function attachmentsTable(DataTableFactory $dataTable, Request $request)
|
||||
|
@ -118,8 +111,7 @@ class AttachmentFileController extends AbstractController
|
|||
}
|
||||
|
||||
return $this->render('attachment_list.html.twig', [
|
||||
'datatable' => $table
|
||||
'datatable' => $table,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -44,8 +43,6 @@ class DebugController extends AbstractController
|
|||
|
||||
$this->addFlash('testkjfd', 'Blabla. This message type should be not know to template!');
|
||||
|
||||
|
||||
|
||||
return $this->render('base.html.twig');
|
||||
}
|
||||
|
||||
|
@ -81,6 +78,5 @@ class DebugController extends AbstractController
|
|||
$translator->trans('flash.info');
|
||||
|
||||
$translator->trans('validator.noLockout');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use App\Controller\AdminPages\BaseAdminController;
|
||||
use App\Entity\Attachments\GroupAttachment;
|
||||
use App\Entity\UserSystem\Group;
|
||||
|
@ -49,9 +47,7 @@ class GroupController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="group_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
* @param Group $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Group $entity, Request $request, EntityManagerInterface $em)
|
||||
|
@ -62,9 +58,7 @@ class GroupController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/new", name="group_new")
|
||||
* @Route("/")
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
|
@ -74,9 +68,7 @@ class GroupController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="group_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Group $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Group $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -86,9 +78,7 @@ class GroupController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/export", name="group_export_all")
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -98,13 +88,11 @@ class GroupController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="group_export")
|
||||
* @param Group $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Group $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -18,16 +18,12 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Services\GitVersionInfo;
|
||||
use SebastianBergmann\CodeCoverage\Node\File;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Cache\CacheItem;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
@ -43,12 +39,12 @@ class HomepageController extends AbstractController
|
|||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function getBanner() : string
|
||||
public function getBanner(): string
|
||||
{
|
||||
$banner = $this->getParameter('banner');
|
||||
if (empty($banner)) {
|
||||
$banner_path = $this->kernel->getProjectDir()
|
||||
. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'banner.md';
|
||||
.\DIRECTORY_SEPARATOR.'config'.\DIRECTORY_SEPARATOR.'banner.md';
|
||||
|
||||
return file_get_contents($banner_path);
|
||||
}
|
||||
|
@ -64,7 +60,7 @@ class HomepageController extends AbstractController
|
|||
return $this->render('homepage.html.twig', [
|
||||
'banner' => $this->getBanner(),
|
||||
'git_branch' => $versionInfo->getGitBranchName(),
|
||||
'git_commit' => $versionInfo->getGitCommitHash()
|
||||
'git_commit' => $versionInfo->getGitCommitHash(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -18,7 +18,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -40,15 +39,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
/**
|
||||
* @Route("/part")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class PartController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/{id}/info", name="part_info")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Part $part
|
||||
* @param AttachmentManager $attachmentHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function show(Part $part, AttachmentManager $attachmentHelper, PricedetailHelper $pricedetailHelper, PartPreviewGenerator $previewGenerator)
|
||||
|
@ -61,7 +58,7 @@ class PartController extends AbstractController
|
|||
'part' => $part,
|
||||
'attachment_helper' => $attachmentHelper,
|
||||
'pricedetail_helper' => $pricedetailHelper,
|
||||
'pictures' => $previewGenerator->getPreviewAttachments($part)
|
||||
'pictures' => $previewGenerator->getPreviewAttachments($part),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -69,10 +66,6 @@ class PartController extends AbstractController
|
|||
/**
|
||||
* @Route("/{id}/edit", name="part_edit")
|
||||
*
|
||||
* @param Part $part
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function edit(Part $part, Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
|
||||
|
@ -90,25 +83,24 @@ class PartController extends AbstractController
|
|||
/** @var $attachment FormInterface */
|
||||
$options = [
|
||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
'download_url' => $attachment['downloadURL']->getData(),
|
||||
];
|
||||
try {
|
||||
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
$translator->trans('attachment.download_failed').' '.$ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$em->persist($part);
|
||||
$em->flush();
|
||||
$this->addFlash('info', $translator->trans('part.edited_flash'));
|
||||
//Reload form, so the SIUnitType entries use the new part unit
|
||||
$form = $this->createForm(PartBaseType::class, $part);
|
||||
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
||||
} elseif ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', $translator->trans('part.edited_flash.invalid'));
|
||||
}
|
||||
|
||||
|
@ -122,15 +114,14 @@ class PartController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/delete", name="part_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Part $part
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Part $part)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('delete', $part);
|
||||
|
||||
if ($this->isCsrfTokenValid('delete' . $part->getId(), $request->request->get('_token'))) {
|
||||
if ($this->isCsrfTokenValid('delete'.$part->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
//Remove part
|
||||
|
@ -148,9 +139,6 @@ class PartController extends AbstractController
|
|||
/**
|
||||
* @Route("/new", name="part_new")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param TranslatorInterface $translator
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
|
||||
|
@ -176,14 +164,14 @@ class PartController extends AbstractController
|
|||
/** @var $attachment FormInterface */
|
||||
$options = [
|
||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
'download_url' => $attachment['downloadURL']->getData(),
|
||||
];
|
||||
try {
|
||||
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
$translator->trans('attachment.download_failed').' '.$ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +183,7 @@ class PartController extends AbstractController
|
|||
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
|
||||
}
|
||||
|
||||
if ($form->isSubmitted() && ! $form->isValid()) {
|
||||
if ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', $translator->trans('part.created_flash.invalid'));
|
||||
}
|
||||
|
||||
|
@ -203,16 +191,13 @@ class PartController extends AbstractController
|
|||
[
|
||||
'part' => $new_part,
|
||||
'form' => $form->createView(),
|
||||
'attachment_helper' => $attachmentHelper
|
||||
'attachment_helper' => $attachmentHelper,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/clone", name="part_clone")
|
||||
* @param Part $part
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param TranslatorInterface $translator
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function clone(Part $part, Request $request, EntityManagerInterface $em, TranslatorInterface $translator)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -53,7 +52,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/category_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'entity' => $category
|
||||
'entity' => $category,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -75,7 +74,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/footprint_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'entity' => $footprint
|
||||
'entity' => $footprint,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/manufacturer_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'entity' => $manufacturer
|
||||
'entity' => $manufacturer,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -119,7 +118,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/store_location_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'entity' => $storelocation
|
||||
'entity' => $storelocation,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -141,16 +140,13 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/supplier_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'entity' => $supplier
|
||||
'entity' => $supplier,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/parts/by_tag/{tag}", name="part_list_tags")
|
||||
* @param string $tag
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function showTag(string $tag, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -164,7 +160,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/tags_list.html.twig', [
|
||||
'tag' => $tag,
|
||||
'datatable' => $table
|
||||
'datatable' => $table,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -184,16 +180,13 @@ class PartListsController extends AbstractController
|
|||
|
||||
return $this->render('Parts/lists/search_list.html.twig', [
|
||||
'datatable' => $table,
|
||||
'keyword' => $keyword
|
||||
'keyword' => $keyword,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/parts", name="parts_show_all")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function showAll(Request $request, DataTableFactory $dataTable)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -46,7 +45,7 @@ class RedirectController extends AbstractController
|
|||
/**
|
||||
* This function is called whenever a route was not matching the localized routes.
|
||||
* The purpose is to redirect the user to the localized version of the page.
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function addLocalePart(Request $request)
|
||||
|
@ -63,36 +62,39 @@ class RedirectController extends AbstractController
|
|||
//Check if the user needs to change the password. In that case redirect him to settings_page
|
||||
if ($user instanceof User && $user->isNeedPwChange()) {
|
||||
$this->session->getFlashBag()->add('warning', $this->translator->trans('flash.password_change_needed'));
|
||||
|
||||
return $this->redirectToRoute('user_settings', ['_locale' => $locale]);
|
||||
}
|
||||
|
||||
//$new_url = str_replace($request->getPathInfo(), '/' . $locale . $request->getPathInfo(), $request->getUri());
|
||||
$new_url = $request->getUriForPath('/' . $locale . $request->getPathInfo());
|
||||
$new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo());
|
||||
|
||||
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
|
||||
if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable())
|
||||
&& strpos($new_url, 'index.php') === false) {
|
||||
&& false === strpos($new_url, 'index.php')) {
|
||||
//Like Request::getUriForPath only with index.php
|
||||
$new_url = $request->getSchemeAndHttpHost(). $request->getBaseUrl().'/index.php/' . $locale . $request->getPathInfo();
|
||||
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
|
||||
}
|
||||
|
||||
return $this->redirect($new_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mod_rewrite is availabe (URL rewriting is possible).
|
||||
* If this is true, we can redirect to /en, otherwise we have to redirect to index.php/en.
|
||||
* When the PHP is not used via Apache SAPI, we just assume that URL rewriting is available
|
||||
* When the PHP is not used via Apache SAPI, we just assume that URL rewriting is available.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkIfModRewriteAvailable()
|
||||
{
|
||||
if (!function_exists('apache_get_modules')) {
|
||||
if (!\function_exists('apache_get_modules')) {
|
||||
//If we can not check for apache modules, we just hope for the best and assume url rewriting is available
|
||||
//If you want to enforce index.php versions of the url, you can override this via ENV vars.
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check if the mod_rewrite module is loaded
|
||||
return in_array('mod_rewrite', apache_get_modules(), false);
|
||||
return \in_array('mod_rewrite', apache_get_modules(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -35,8 +34,6 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
|
||||
/**
|
||||
* This controller has the purpose to provide the data for all treeviews.
|
||||
*
|
||||
* @package App\Controller
|
||||
*/
|
||||
class TreeController extends AbstractController
|
||||
{
|
||||
|
@ -57,13 +54,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function categoryTree(TreeBuilder $builder, Category $category = null)
|
||||
{
|
||||
if ($category !== null) {
|
||||
if (null !== $category) {
|
||||
$tree[] = $builder->elementToTreeNode($category);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Category::class);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
@ -73,13 +69,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function footprintTree(TreeBuilder $builder, Footprint $footprint = null)
|
||||
{
|
||||
if ($footprint !== null) {
|
||||
if (null !== $footprint) {
|
||||
$tree[] = $builder->elementToTreeNode($footprint);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Footprint::class);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
@ -89,13 +84,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function locationTree(TreeBuilder $builder, Storelocation $location = null)
|
||||
{
|
||||
if ($location !== null) {
|
||||
if (null !== $location) {
|
||||
$tree[] = $builder->elementToTreeNode($location);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Storelocation::class);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
@ -105,13 +99,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function manufacturerTree(TreeBuilder $builder, Manufacturer $manufacturer = null)
|
||||
{
|
||||
if ($manufacturer !== null) {
|
||||
if (null !== $manufacturer) {
|
||||
$tree[] = $builder->elementToTreeNode($manufacturer);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Manufacturer::class);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
@ -121,13 +114,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function supplierTree(TreeBuilder $builder, Supplier $supplier = null)
|
||||
{
|
||||
if ($supplier !== null) {
|
||||
if (null !== $supplier) {
|
||||
$tree[] = $builder->elementToTreeNode($supplier);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Supplier::class);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
@ -137,15 +129,12 @@ class TreeController extends AbstractController
|
|||
*/
|
||||
public function deviceTree(TreeBuilder $builder, Device $device = null)
|
||||
{
|
||||
if ($device !== null) {
|
||||
if (null !== $device) {
|
||||
$tree[] = $builder->elementToTreeNode($device);
|
||||
} else {
|
||||
$tree = $builder->typeToTree(Device::class, null);
|
||||
}
|
||||
|
||||
|
||||
return $this->json($tree, 200, [], ['skip_null_values' => true]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use App\Services\Attachments\BuiltinAttachmentsFinder;
|
||||
use App\Services\TagFinder;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -34,9 +32,9 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
|||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
* In this controller the endpoints for the typeaheads are collected
|
||||
* In this controller the endpoints for the typeaheads are collected.
|
||||
*
|
||||
* @Route("/typeahead")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class TypeaheadController extends AbstractController
|
||||
{
|
||||
|
@ -47,15 +45,15 @@ class TypeaheadController extends AbstractController
|
|||
{
|
||||
$array = $finder->find($query);
|
||||
|
||||
|
||||
$normalizers = [
|
||||
new ObjectNormalizer()
|
||||
new ObjectNormalizer(),
|
||||
];
|
||||
$encoders = [
|
||||
new JsonEncoder()
|
||||
$encoders = [
|
||||
new JsonEncoder(),
|
||||
];
|
||||
$serializer = new Serializer($normalizers, $encoders);
|
||||
$data = $serializer->serialize($array, 'json');
|
||||
|
||||
return new JsonResponse($data, 200, [], true);
|
||||
}
|
||||
|
||||
|
@ -67,13 +65,14 @@ class TypeaheadController extends AbstractController
|
|||
$array = $finder->searchTags($query);
|
||||
|
||||
$normalizers = [
|
||||
new ObjectNormalizer()
|
||||
new ObjectNormalizer(),
|
||||
];
|
||||
$encoders = [
|
||||
new JsonEncoder()
|
||||
$encoders = [
|
||||
new JsonEncoder(),
|
||||
];
|
||||
$serializer = new Serializer($normalizers, $encoders);
|
||||
$data = $serializer->serialize($array, 'json');
|
||||
|
||||
return new JsonResponse($data, 200, [], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
@ -47,18 +46,15 @@ use Symfony\Component\Validator\Constraints\Length;
|
|||
/**
|
||||
* @Route("/user")
|
||||
* Class UserController
|
||||
* @package App\Controller
|
||||
*/
|
||||
class UserController extends AdminPages\BaseAdminController
|
||||
{
|
||||
|
||||
protected $entity_class = User::class;
|
||||
protected $twig_template = 'AdminPages/UserAdmin.html.twig';
|
||||
protected $form_class = UserAdminForm::class;
|
||||
protected $route_base = 'user';
|
||||
protected $attachment_class = UserAttachment::class;
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="user_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
|
@ -84,17 +80,18 @@ class UserController extends AdminPages\BaseAdminController
|
|||
*/
|
||||
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
{
|
||||
if ($entity->getID() == User::ID_ANONYMOUS) {
|
||||
if (User::ID_ANONYMOUS == $entity->getID()) {
|
||||
throw new \InvalidArgumentException('You can not delete the anonymous user! It is needed for permission checking without a logged in user');
|
||||
}
|
||||
|
||||
return $this->_delete($request, $entity, $recursionHelper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/export", name="user_export_all")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
|
@ -104,8 +101,9 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}/export", name="user_export")
|
||||
* @param Request $request
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(User $entity, EntityExporter $exporter, Request $request)
|
||||
|
@ -113,7 +111,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/info", name="user_info_self")
|
||||
* @Route("/{id}/info")
|
||||
|
@ -135,17 +132,17 @@ class UserController extends AdminPages\BaseAdminController
|
|||
}
|
||||
|
||||
//Show permissions to user
|
||||
$builder = $this->createFormBuilder()->add('permissions',PermissionsType::class, [
|
||||
$builder = $this->createFormBuilder()->add('permissions', PermissionsType::class, [
|
||||
'mapped' => false,
|
||||
'disabled' => true,
|
||||
'inherit' => true,
|
||||
'data' => $user
|
||||
'data' => $user,
|
||||
]);
|
||||
|
||||
return $this->render('Users/user_info.html.twig', [
|
||||
'user' => $user,
|
||||
'avatar' => $avatar,
|
||||
'form' => $builder->getForm()->createView()
|
||||
'form' => $builder->getForm()->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -161,8 +158,8 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
$page_need_reload = false;
|
||||
|
||||
if(!$user instanceof User) {
|
||||
return new \RuntimeException("This controller only works only for Part-DB User objects!");
|
||||
if (!$user instanceof User) {
|
||||
return new \RuntimeException('This controller only works only for Part-DB User objects!');
|
||||
}
|
||||
|
||||
//When user change its settings, he should be logged in fully.
|
||||
|
@ -233,7 +230,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
return $this->render('Users/user_settings.html.twig', [
|
||||
'settings_form' => $form->createView(),
|
||||
'pw_form' => $pw_form->createView(),
|
||||
'page_need_reload' => $page_need_reload
|
||||
'page_need_reload' => $page_need_reload,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -250,10 +247,10 @@ class UserController extends AdminPages\BaseAdminController
|
|||
* @return string containing either just a URL or a complete image tag
|
||||
* @source https://gravatar.com/site/implement/images/php/
|
||||
*/
|
||||
public function getGravatar(?string $email, int $s = 80, string $d = 'mm', string $r = 'g', bool $img = false, array $atts = array())
|
||||
public function getGravatar(?string $email, int $s = 80, string $d = 'mm', string $r = 'g', bool $img = false, array $atts = [])
|
||||
{
|
||||
if ($email === null) {
|
||||
return "";
|
||||
if (null === $email) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$url = 'https://www.gravatar.com/avatar/';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue