initial
This commit is contained in:
parent
2a1ce070a2
commit
fe4e4fa940
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PhpCSFixerValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
9
assets/app.js
Normal file
9
assets/app.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Welcome to your app's main JavaScript file!
|
||||||
|
*
|
||||||
|
* This file will be included onto the page via the importmap() Twig function,
|
||||||
|
* which should already be in your base.html.twig.
|
||||||
|
*/
|
||||||
|
import './styles/app.css';
|
||||||
|
|
||||||
|
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
|
3
assets/styles/app.css
Normal file
3
assets/styles/app.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
body {
|
||||||
|
background-color: skyblue;
|
||||||
|
}
|
@ -78,6 +78,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"deployer/deployer": "^7.3",
|
||||||
"phpunit/phpunit": "10.*",
|
"phpunit/phpunit": "10.*",
|
||||||
"symfony/maker-bundle": "^1.52"
|
"symfony/maker-bundle": "^1.52"
|
||||||
}
|
}
|
||||||
|
45
composer.lock
generated
45
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "717ed6c3538dfaff4c72623709f0f132",
|
"content-hash": "4e665d72a03b66f5922cfc55b5e1410d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/semver",
|
"name": "composer/semver",
|
||||||
@ -5714,6 +5714,49 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
{
|
||||||
|
"name": "deployer/deployer",
|
||||||
|
"version": "v7.3.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/deployphp/deployer.git",
|
||||||
|
"reference": "3535bdb2f6360662bd95f6e26fce31dbc269af64"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/deployphp/deployer/zipball/3535bdb2f6360662bd95f6e26fce31dbc269af64",
|
||||||
|
"reference": "3535bdb2f6360662bd95f6e26fce31dbc269af64",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"dep"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Anton Medvedev",
|
||||||
|
"email": "anton@medv.io"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Deployment Tool",
|
||||||
|
"homepage": "https://deployer.org",
|
||||||
|
"support": {
|
||||||
|
"docs": "https://deployer.org/docs",
|
||||||
|
"issues": "https://github.com/deployphp/deployer/issues",
|
||||||
|
"source": "https://github.com/deployphp/deployer"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/sponsors/antonmedv",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-11-07T10:27:12+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
"version": "1.11.1",
|
"version": "1.11.1",
|
||||||
|
5
config/packages/asset_mapper.yaml
Normal file
5
config/packages/asset_mapper.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
framework:
|
||||||
|
asset_mapper:
|
||||||
|
# The paths to make available to the asset mapper.
|
||||||
|
paths:
|
||||||
|
- assets/
|
21
importmap.php
Normal file
21
importmap.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the importmap for this application.
|
||||||
|
*
|
||||||
|
* - "path" is a path inside the asset mapper system. Use the
|
||||||
|
* "debug:asset-map" command to see the full list of paths.
|
||||||
|
*
|
||||||
|
* - "entrypoint" (JavaScript only) set to true for any module that will
|
||||||
|
* be used as an "entrypoint" (and passed to the importmap() Twig function).
|
||||||
|
*
|
||||||
|
* The "importmap:require" command can be used to add new entries to this file.
|
||||||
|
*
|
||||||
|
* This file has been auto-generated by the importmap commands.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'frontend' => [
|
||||||
|
'path' => './public/js/frontend.js',
|
||||||
|
'entrypoint' => true,
|
||||||
|
],
|
||||||
|
];
|
@ -9,6 +9,7 @@ use App\Service\PrinterService;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class PrinterCrudController extends AbstractController
|
class PrinterCrudController extends AbstractController
|
||||||
@ -29,10 +30,11 @@ class PrinterCrudController extends AbstractController
|
|||||||
#[Route('/printer/{id}', name: 'get_printer', methods: ['GET'])]
|
#[Route('/printer/{id}', name: 'get_printer', methods: ['GET'])]
|
||||||
public function getPrinter(?Printer $printer): JsonResponse
|
public function getPrinter(?Printer $printer): JsonResponse
|
||||||
{
|
{
|
||||||
|
//TODO: ungleich null und in funktion auslagern
|
||||||
if (!$printer) {
|
if (!$printer) {
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'message' => ErrorMessages::DOESNT_EXIST->value,
|
'message' => ErrorMessages::DOESNT_EXIST->value,
|
||||||
]);
|
], Response::HTTP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->json($printer);
|
return $this->json($printer);
|
||||||
@ -44,7 +46,7 @@ class PrinterCrudController extends AbstractController
|
|||||||
if (!$printer) {
|
if (!$printer) {
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'message' => ErrorMessages::DOESNT_EXIST->value,
|
'message' => ErrorMessages::DOESNT_EXIST->value,
|
||||||
]);
|
], Response::HTTP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->printerService->deletePrinter($printer);
|
$this->printerService->deletePrinter($printer);
|
||||||
@ -61,7 +63,7 @@ class PrinterCrudController extends AbstractController
|
|||||||
if (!$this->printerService->validateJson($jsonContent)) {
|
if (!$this->printerService->validateJson($jsonContent)) {
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'message' => ErrorMessages::DATA_INCOMPLETE->value,
|
'message' => ErrorMessages::DATA_INCOMPLETE->value,
|
||||||
]);
|
], Response::HTTP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$printer = $this->printerService->createPrinter($jsonContent);
|
$printer = $this->printerService->createPrinter($jsonContent);
|
||||||
@ -75,7 +77,7 @@ class PrinterCrudController extends AbstractController
|
|||||||
if (!$printer) {
|
if (!$printer) {
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'message' => ErrorMessages::DOESNT_EXIST->value,
|
'message' => ErrorMessages::DOESNT_EXIST->value,
|
||||||
]);
|
], Response::HTTP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->printerService->editPrinter($printer, $request->getContent());
|
$this->printerService->editPrinter($printer, $request->getContent());
|
||||||
|
@ -15,6 +15,7 @@ class Printer implements JsonSerializable
|
|||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
|
//TODO doctrine required
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $name = null;
|
private ?string $name = null;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class PrinterService
|
|||||||
|
|
||||||
public function createPrinter(string $jsonString): Printer
|
public function createPrinter(string $jsonString): Printer
|
||||||
{
|
{
|
||||||
|
//TODO use serializer for validation
|
||||||
$printer = $this->serializer->deserialize($jsonString, Printer::class, 'json');
|
$printer = $this->serializer->deserialize($jsonString, Printer::class, 'json');
|
||||||
|
|
||||||
$this->entityManager->persist($printer);
|
$this->entityManager->persist($printer);
|
||||||
@ -33,11 +34,13 @@ class PrinterService
|
|||||||
public function validateJson(string $jsonString): bool
|
public function validateJson(string $jsonString): bool
|
||||||
{
|
{
|
||||||
$array = json_decode($jsonString, true);
|
$array = json_decode($jsonString, true);
|
||||||
|
//TODO: find another way
|
||||||
return array_keys($array) == self::REQUIRED_PROPERTIES;
|
return array_keys($array) == self::REQUIRED_PROPERTIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editPrinter(Printer $printer, string $json): Printer
|
public function editPrinter(Printer $printer, string $json): Printer
|
||||||
{
|
{
|
||||||
|
//TODO use deserialize
|
||||||
$jsonArray = json_decode($json, true);
|
$jsonArray = json_decode($json, true);
|
||||||
|
|
||||||
$printer->setName($jsonArray['name'] ?? $printer->getName());
|
$printer->setName($jsonArray['name'] ?? $printer->getName());
|
||||||
|
@ -84,7 +84,7 @@ class PrinterServiceTest extends TestCase
|
|||||||
#[Test]
|
#[Test]
|
||||||
public function editPrinterShouldUpdatePrinterWithJsonContent(){
|
public function editPrinterShouldUpdatePrinterWithJsonContent(){
|
||||||
$json = '{
|
$json = '{
|
||||||
"name": "Bambu A1 Mini",
|
"name": "Bambu A1 Mini"
|
||||||
}';
|
}';
|
||||||
|
|
||||||
$printer = new Printer();
|
$printer = new Printer();
|
||||||
|
Loading…
Reference in New Issue
Block a user