Skip to content

Commit bf8ca49

Browse files
preparation
1 parent 0b7d89a commit bf8ca49

File tree

10 files changed

+408
-19
lines changed

10 files changed

+408
-19
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/var/
2+
/.git/
3+
.idea
4+
/public/bundles/
5+
/public/assets/

.gitignore

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
2-
###> symfony/framework-bundle ###
3-
/.env.local
4-
/.env.local.php
5-
/.env.*.local
6-
/config/secrets/prod/prod.decrypt.private.php
71
/public/bundles/
2+
/public/assets/
83
/var/
94
/vendor/
10-
###< symfony/framework-bundle ###
11-
12-
###> symfony/phpunit-bridge ###
13-
.phpunit
14-
.phpunit.result.cache
15-
/phpunit.xml
16-
###< symfony/phpunit-bridge ###
5+
.idea

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ RUN set -eux; \
8080
composer clear-cache
8181

8282
# copy only specifically what we need
83-
COPY .env .env.prod .env.test ./
83+
COPY .env .env.test ./
8484
COPY bin bin/
8585
COPY config config/
8686
COPY public public/
8787
COPY src src/
88-
COPY infra infra/
8988

9089
RUN set -eux; \
9190
mkdir -p var/cache var/log; \

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "project",
33
"license": "proprietary",
44
"require": {
5-
"php": "^7.2.5",
5+
"php": "^7.4",
66
"ext-ctype": "*",
77
"ext-iconv": "*",
88
"sensio/framework-extra-bundle": "^5.1",

config/routes.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
#index:
2-
# path: /
3-
# controller: App\Controller\DefaultController::index
1+
product_create:
2+
path: /api/v1/products
3+
controller: App\Controller\ProductController::createAction
4+
methods: [POST]
5+
6+
product_list:
7+
path: /api/v1/products
8+
controller: App\Controller\ProductController::indexAction
9+
methods: [GET]
10+
11+
order_create:
12+
path: /api/v1/orders
13+
controller: App\Controller\OrderController::createAction
14+
methods: [POST]

src/Controller/OrderController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Controller;
6+
7+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8+
use Symfony\Component\HttpFoundation\Request;
9+
use Symfony\Component\HttpFoundation\Response;
10+
11+
class OrderController extends AbstractController
12+
{
13+
public function createAction(Request $request): Response
14+
{
15+
return new Response();
16+
}
17+
}

src/Controller/ProductController.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Controller;
6+
7+
use App\Entity\Product;
8+
use Doctrine\Persistence\ObjectManager;
9+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10+
use Symfony\Component\HttpFoundation\JsonResponse;
11+
use Symfony\Component\HttpFoundation\Request;
12+
use Symfony\Component\HttpFoundation\Response;
13+
14+
class ProductController extends AbstractController
15+
{
16+
private ObjectManager $entityManager;
17+
18+
public function __construct(ObjectManager $entityManager)
19+
{
20+
$this->entityManager = $entityManager;
21+
}
22+
23+
public function indexAction(Request $request): Response
24+
{
25+
$products = $this->entityManager->getRepository(Product::class)->findAll();
26+
27+
return new JsonResponse($products);
28+
}
29+
30+
public function createAction(Request $request): Response
31+
{
32+
return new Response();
33+
}
34+
}

src/Entity/Customer.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace App\Entity;
6+
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Table(name="app_customer")
11+
* @ORM\Entity()
12+
*/
13+
class Customer
14+
{
15+
/**
16+
* @var int
17+
*
18+
* @ORM\Column(name="id", type="integer")
19+
* @ORM\Id()
20+
* @ORM\GeneratedValue(strategy="AUTO")
21+
*/
22+
private ?int $id;
23+
24+
/**
25+
* @var string
26+
*
27+
* @ORM\Column(name="email", type="string")
28+
*/
29+
private string $email;
30+
31+
/**
32+
* @var string
33+
*
34+
* @ORM\Column(name="phone_number", type="string")
35+
*/
36+
private string $phoneNumber;
37+
38+
/**
39+
* @return int|null
40+
*/
41+
public function getId(): ?int
42+
{
43+
return $this->id;
44+
}
45+
46+
/**
47+
* @return string
48+
*/
49+
public function getEmail(): string
50+
{
51+
return $this->email;
52+
}
53+
54+
/**
55+
* @param string $email
56+
*/
57+
public function setEmail(string $email): void
58+
{
59+
$this->email = $email;
60+
}
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getPhoneNumber(): string
66+
{
67+
return $this->phoneNumber;
68+
}
69+
70+
/**
71+
* @param string $phoneNumber
72+
*/
73+
public function setPhoneNumber(string $phoneNumber): void
74+
{
75+
$this->phoneNumber = $phoneNumber;
76+
}
77+
}

src/Entity/Order.php

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace App\Entity;
6+
7+
use Doctrine\Common\Collections\ArrayCollection;
8+
use Doctrine\Common\Collections\Collection;
9+
use Doctrine\ORM\Mapping as ORM;
10+
11+
/**
12+
* @ORM\Table(name="app_order")
13+
* @ORM\Entity()
14+
*/
15+
class Order
16+
{
17+
/**
18+
* @var int
19+
*
20+
* @ORM\Column(name="id", type="integer")
21+
* @ORM\Id()
22+
* @ORM\GeneratedValue(strategy="AUTO")
23+
*/
24+
private int $id;
25+
26+
/**
27+
* @var Customer
28+
*
29+
* @ORM\OneToOne(targetEntity="Customer", cascade={"all"})
30+
*/
31+
private Customer $customer;
32+
33+
/**
34+
* @var Collection
35+
*
36+
* @ORM\ManyToMany(targetEntity="Product", cascade={"all"})
37+
*/
38+
private Collection $products;
39+
40+
/**
41+
* @var \DateTimeImmutable
42+
*
43+
* @ORM\Column(name="date_time", type="datetime_immutable")
44+
*/
45+
private \DateTimeImmutable $dateTime;
46+
47+
/**
48+
* @var string|null
49+
*
50+
* @ORM\Column(name="comments", type="text", nullable=true)
51+
*/
52+
private ?string $comments;
53+
54+
public function __construct()
55+
{
56+
$this->products = new ArrayCollection();
57+
}
58+
59+
/**
60+
* @return int|null
61+
*/
62+
public function getId(): ?int
63+
{
64+
return $this->id;
65+
}
66+
67+
/**
68+
* @return Customer
69+
*/
70+
public function getCustomer(): Customer
71+
{
72+
return $this->customer;
73+
}
74+
75+
/**
76+
* @param Customer $customer
77+
*/
78+
public function setCustomer(Customer $customer): void
79+
{
80+
$this->customer = $customer;
81+
}
82+
83+
/**
84+
* @return \DateTimeImmutable
85+
*/
86+
public function getDateTime(): \DateTimeImmutable
87+
{
88+
return $this->dateTime;
89+
}
90+
91+
/**
92+
* @param \DateTimeImmutable $dateTime
93+
*/
94+
public function setDateTime(\DateTimeImmutable $dateTime): void
95+
{
96+
$this->dateTime = $dateTime;
97+
}
98+
99+
/**
100+
* @return Collection
101+
*/
102+
public function getProducts(): Collection
103+
{
104+
return $this->products;
105+
}
106+
107+
/**
108+
* @param Product $product
109+
*/
110+
public function addProduct(Product $product): void
111+
{
112+
if ($this->products->contains($product)) {
113+
return;
114+
}
115+
116+
$this->products->add($product);
117+
}
118+
119+
/**
120+
* @return string
121+
*/
122+
public function getComments(): string
123+
{
124+
return $this->comments;
125+
}
126+
127+
/**
128+
* @param string $comments
129+
*/
130+
public function setComments(string $comments): void
131+
{
132+
$this->comments = $comments;
133+
}
134+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy