@eui/cli 21.0.0-alpha.9 → 21.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/eui-cli.js +61 -41
- package/bin/scripts/build-app.js +12 -0
- package/bin/scripts/lint-app.js +22 -0
- package/bin/scripts/new.js +39 -0
- package/bin/scripts/serve-app.js +12 -0
- package/lib/app-utils/build.js +176 -0
- package/lib/app-utils/projects.js +41 -0
- package/lib/app-utils/serve.js +78 -0
- package/lib/build.js +14 -39
- package/lib/cli.js +22 -5
- package/lib/config.js +1 -0
- package/lib/generators.js +5 -8
- package/lib/install.js +7 -7
- package/lib/post-build.js +1 -3
- package/lib/skeletons/_angular/base/angular.json +2 -31
- package/lib/skeletons/_angular/base/package.json +24 -23
- package/lib/skeletons/_angular/base/src/app/app.component.spec.ts +2 -2
- package/lib/skeletons/_angular/base/src/app/app.component.ts +2 -2
- package/lib/skeletons/_angular/base/src/app/features/module2/module2.component.ts +1 -1
- package/lib/skeletons/_angular/base/src/karma.conf.js +42 -2
- package/lib/skeletons/_angular/base/src/tsconfig.spec.json +1 -5
- package/lib/skeletons/_angular/base/tsconfig.json +1 -1
- package/lib/skeletons/_angular/base-mobile/package.json +4 -4
- package/lib/skeletons/_angular/base-mobile/tsconfig.json +27 -0
- package/lib/skeletons/_angular/options/ecl-ec/src/app/app.component.ts +16 -16
- package/lib/skeletons/_angular/options/ecl-ec/src/app/features/home/home.component.ts +4 -4
- package/lib/skeletons/_angular/options/ecl-eu/src/app/app.component.ts +16 -16
- package/lib/skeletons/_angular/options/ecl-eu/src/app/features/home/home.component.ts +4 -4
- package/lib/skeletons/_angular/options/ecl-eu/src/app/shared/shared.module.ts +1 -5
- package/lib/skeletons/_angular/options/pnpm/package.json +72 -0
- package/lib/utils.js +204 -0
- package/package.json +10 -13
- package/.version.properties +0 -1
- package/lib/skeletons/_angular/base/.euirc.json +0 -8
- package/lib/skeletons/web-symfony/myapp-web/angular.json +0 -169
- package/lib/skeletons/web-symfony/myapp-web/package.json +0 -23
- package/lib/skeletons/web-symfony/myapp-web/src/app/app-routing.module.ts +0 -18
- package/lib/skeletons/web-symfony/myapp-web/src/app/app.component.ts +0 -77
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/components/products.component.html +0 -160
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/components/products.component.scss +0 -0
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/components/products.component.ts +0 -104
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/models/product.model.ts +0 -6
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/products-routing.module.ts +0 -16
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/products.module.ts +0 -16
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/services/products.service.ts +0 -29
- package/lib/skeletons/web-symfony/myapp-web/src/environments/environment.ts +0 -17
- package/lib/skeletons/web-symfony/myapp-web-rest/.env +0 -28
- package/lib/skeletons/web-symfony/myapp-web-rest/bin/console +0 -42
- package/lib/skeletons/web-symfony/myapp-web-rest/composer.json +0 -67
- package/lib/skeletons/web-symfony/myapp-web-rest/composer.lock +0 -3572
- package/lib/skeletons/web-symfony/myapp-web-rest/config/bootstrap.php +0 -21
- package/lib/skeletons/web-symfony/myapp-web-rest/config/bundles.php +0 -12
- package/lib/skeletons/web-symfony/myapp-web-rest/config/config.yml +0 -0
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/cache.yaml +0 -19
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/dev/routing.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/doctrine.yaml +0 -29
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/doctrine_migrations.yaml +0 -5
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/framework.yaml +0 -17
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/prod/doctrine.yaml +0 -32
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/routing.yaml +0 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/sensio_framework_extra.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/test/framework.yaml +0 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/test/routing.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/twig.yaml +0 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes/annotations.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes/dev/twig.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes.yaml +0 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/services.yaml +0 -27
- package/lib/skeletons/web-symfony/myapp-web-rest/public/index.php +0 -27
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Controller/ProductController.php +0 -196
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Entity/Product.php +0 -99
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Kernel.php +0 -53
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Migrations/Version20190604101623.php +0 -31
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Migrations/Version20190604101638.php +0 -35
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Repository/ProductRepository.php +0 -51
- package/lib/skeletons/web-symfony/myapp-web-rest/symfony.lock +0 -274
- package/lib/skeletons/web-symfony/myapp-web-rest/templates/base.html.twig +0 -12
- package/lib/skeletons/web-symfony/myapp-web-rest/templates/lucky/number.html.twig +0 -1
- package/lib/skeletons/web-symfony/myapp-web-rest/templates/product/index.html.twig +0 -20
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
use Symfony\Component\Dotenv\Dotenv;
|
|
4
|
-
|
|
5
|
-
require dirname(__DIR__).'/vendor/autoload.php';
|
|
6
|
-
|
|
7
|
-
// Load cached env vars if the .env.local.php file exists
|
|
8
|
-
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
|
|
9
|
-
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
|
|
10
|
-
$_ENV += $env;
|
|
11
|
-
} elseif (!class_exists(Dotenv::class)) {
|
|
12
|
-
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
|
13
|
-
} else {
|
|
14
|
-
// load all the .env files
|
|
15
|
-
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
$_SERVER += $_ENV;
|
|
19
|
-
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
|
|
20
|
-
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
|
|
21
|
-
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
return [
|
|
4
|
-
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
|
5
|
-
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
|
|
6
|
-
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
|
7
|
-
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
|
8
|
-
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
|
|
9
|
-
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
|
10
|
-
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
|
11
|
-
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
|
12
|
-
];
|
|
File without changes
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
framework:
|
|
2
|
-
cache:
|
|
3
|
-
# Put the unique name of your app here: the prefix seed
|
|
4
|
-
# is used to compute stable namespaces for cache keys.
|
|
5
|
-
#prefix_seed: your_vendor_name/app_name
|
|
6
|
-
|
|
7
|
-
# The app cache caches to the filesystem by default.
|
|
8
|
-
# Other options include:
|
|
9
|
-
|
|
10
|
-
# Redis
|
|
11
|
-
#app: cache.adapter.redis
|
|
12
|
-
#default_redis_provider: redis://localhost
|
|
13
|
-
|
|
14
|
-
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
|
15
|
-
#app: cache.adapter.apcu
|
|
16
|
-
|
|
17
|
-
# Namespaced pools use the above "app" backend by default
|
|
18
|
-
#pools:
|
|
19
|
-
#my.dedicated.cache: ~
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
parameters:
|
|
2
|
-
# Adds a fallback DATABASE_URL if the env var is not set.
|
|
3
|
-
# This allows you to run cache:warmup even if your
|
|
4
|
-
# environment variables are not available yet.
|
|
5
|
-
# You should not need to change this value.
|
|
6
|
-
env(DATABASE_URL): ''
|
|
7
|
-
|
|
8
|
-
doctrine:
|
|
9
|
-
dbal:
|
|
10
|
-
# configure these for your database server
|
|
11
|
-
driver: 'pdo_mysql'
|
|
12
|
-
server_version: '5.7'
|
|
13
|
-
charset: utf8mb4
|
|
14
|
-
default_table_options:
|
|
15
|
-
charset: utf8mb4
|
|
16
|
-
collate: utf8mb4_unicode_ci
|
|
17
|
-
|
|
18
|
-
url: '%env(resolve:DATABASE_URL)%'
|
|
19
|
-
orm:
|
|
20
|
-
auto_generate_proxy_classes: true
|
|
21
|
-
naming_strategy: doctrine.orm.naming_strategy.underscore
|
|
22
|
-
auto_mapping: true
|
|
23
|
-
mappings:
|
|
24
|
-
App:
|
|
25
|
-
is_bundle: false
|
|
26
|
-
type: annotation
|
|
27
|
-
dir: '%kernel.project_dir%/src/Entity'
|
|
28
|
-
prefix: 'App\Entity'
|
|
29
|
-
alias: App
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
framework:
|
|
2
|
-
secret: '%env(APP_SECRET)%'
|
|
3
|
-
#default_locale: en
|
|
4
|
-
#csrf_protection: true
|
|
5
|
-
#http_method_override: true
|
|
6
|
-
|
|
7
|
-
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
|
8
|
-
# Remove or comment this section to explicitly disable session support.
|
|
9
|
-
session:
|
|
10
|
-
handler_id: ~
|
|
11
|
-
cookie_secure: auto
|
|
12
|
-
cookie_samesite: lax
|
|
13
|
-
|
|
14
|
-
#esi: true
|
|
15
|
-
#fragments: true
|
|
16
|
-
php_errors:
|
|
17
|
-
log: true
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
doctrine:
|
|
2
|
-
orm:
|
|
3
|
-
auto_generate_proxy_classes: false
|
|
4
|
-
metadata_cache_driver:
|
|
5
|
-
type: service
|
|
6
|
-
id: doctrine.system_cache_provider
|
|
7
|
-
query_cache_driver:
|
|
8
|
-
type: service
|
|
9
|
-
id: doctrine.system_cache_provider
|
|
10
|
-
result_cache_driver:
|
|
11
|
-
type: service
|
|
12
|
-
id: doctrine.result_cache_provider
|
|
13
|
-
|
|
14
|
-
services:
|
|
15
|
-
doctrine.result_cache_provider:
|
|
16
|
-
class: Symfony\Component\Cache\DoctrineProvider
|
|
17
|
-
public: false
|
|
18
|
-
arguments:
|
|
19
|
-
- '@doctrine.result_cache_pool'
|
|
20
|
-
doctrine.system_cache_provider:
|
|
21
|
-
class: Symfony\Component\Cache\DoctrineProvider
|
|
22
|
-
public: false
|
|
23
|
-
arguments:
|
|
24
|
-
- '@doctrine.system_cache_pool'
|
|
25
|
-
|
|
26
|
-
framework:
|
|
27
|
-
cache:
|
|
28
|
-
pools:
|
|
29
|
-
doctrine.result_cache_pool:
|
|
30
|
-
adapter: cache.app
|
|
31
|
-
doctrine.system_cache_pool:
|
|
32
|
-
adapter: cache.system
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# This file is the entry point to configure your own services.
|
|
2
|
-
# Files in the packages/ subdirectory configure your dependencies.
|
|
3
|
-
|
|
4
|
-
# Put parameters here that don't need to change on each machine where the app is deployed
|
|
5
|
-
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
|
6
|
-
parameters:
|
|
7
|
-
|
|
8
|
-
services:
|
|
9
|
-
# default configuration for services in *this* file
|
|
10
|
-
_defaults:
|
|
11
|
-
autowire: true # Automatically injects dependencies in your services.
|
|
12
|
-
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
|
13
|
-
|
|
14
|
-
# makes classes in src/ available to be used as services
|
|
15
|
-
# this creates a service per class whose id is the fully-qualified class name
|
|
16
|
-
App\:
|
|
17
|
-
resource: '../src/*'
|
|
18
|
-
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
|
19
|
-
|
|
20
|
-
# controllers are imported separately to make sure services can be injected
|
|
21
|
-
# as action arguments even if you don't extend any base controller class
|
|
22
|
-
App\Controller\:
|
|
23
|
-
resource: '../src/Controller'
|
|
24
|
-
tags: ['controller.service_arguments']
|
|
25
|
-
|
|
26
|
-
# add more service definitions when explicit configuration is needed
|
|
27
|
-
# please note that last definitions always *replace* previous ones
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
use App\Kernel;
|
|
4
|
-
use Symfony\Component\Debug\Debug;
|
|
5
|
-
use Symfony\Component\HttpFoundation\Request;
|
|
6
|
-
|
|
7
|
-
require dirname(__DIR__).'/config/bootstrap.php';
|
|
8
|
-
|
|
9
|
-
if ($_SERVER['APP_DEBUG']) {
|
|
10
|
-
umask(0000);
|
|
11
|
-
|
|
12
|
-
Debug::enable();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
|
|
16
|
-
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
|
|
20
|
-
Request::setTrustedHosts([$trustedHosts]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
|
24
|
-
$request = Request::createFromGlobals();
|
|
25
|
-
$response = $kernel->handle($request);
|
|
26
|
-
$response->send();
|
|
27
|
-
$kernel->terminate($request, $response);
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
namespace App\Controller;
|
|
3
|
-
use App\Entity\Product;
|
|
4
|
-
use App\Controller\OutputController;
|
|
5
|
-
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
6
|
-
use Symfony\Component\Routing\Annotation\Route;
|
|
7
|
-
use Symfony\Component\HttpFoundation\Response;
|
|
8
|
-
use Symfony\Component\HttpFoundation\Request;
|
|
9
|
-
use Symfony\Component\HttpFoundation\AcceptHeader;
|
|
10
|
-
use Doctrine\ORM\ORMException;
|
|
11
|
-
use Doctrine\DBAL\DBALException;
|
|
12
|
-
|
|
13
|
-
class ProductController extends AbstractController
|
|
14
|
-
{
|
|
15
|
-
/**
|
|
16
|
-
* @Route("/api/product", name="product_create", methods = {"OPTIONS","POST"})
|
|
17
|
-
*/
|
|
18
|
-
public function create()
|
|
19
|
-
{
|
|
20
|
-
try
|
|
21
|
-
{
|
|
22
|
-
$params = json_decode(file_get_contents('php://input'), true);
|
|
23
|
-
|
|
24
|
-
$request = Request::createFromGlobals();
|
|
25
|
-
|
|
26
|
-
if ($request->isMethod('POST')) {
|
|
27
|
-
//ENTITY MANAGER
|
|
28
|
-
$entityManager = $this->getDoctrine()->getManager();
|
|
29
|
-
$product = new Product();
|
|
30
|
-
$product->setName($params['name']);
|
|
31
|
-
$product->setPrice($params['price']);
|
|
32
|
-
$product->setDescription($params['description']);
|
|
33
|
-
|
|
34
|
-
$entityManager->persist($product);
|
|
35
|
-
$entityManager->flush();
|
|
36
|
-
|
|
37
|
-
//GET PRODUCT
|
|
38
|
-
$product = $this->getDoctrine()->getRepository(Product::class)->find($product->getProductId());
|
|
39
|
-
if (!$product) {
|
|
40
|
-
throw $this->createNotFoundException('error');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//OUTPUT
|
|
44
|
-
$response = new Response(json_encode($product->toArray()));
|
|
45
|
-
|
|
46
|
-
}else{
|
|
47
|
-
$response = new Response();
|
|
48
|
-
$response -> setStatusCode(Response::HTTP_OK);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$response -> setStatusCode(Response::HTTP_OK);
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
catch (\Exception $e) {
|
|
57
|
-
$response = New Response(json_encode(array('error' => $e->getMessage())));
|
|
58
|
-
$response -> setStatusCode(Response::HTTP_BAD_REQUEST);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return $this->setheaders($response, "POST");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @Route("/api/product/update", name="product_udpate", methods = {"OPTIONS","POST"})
|
|
68
|
-
*/
|
|
69
|
-
public function update()
|
|
70
|
-
{
|
|
71
|
-
try
|
|
72
|
-
{
|
|
73
|
-
//PARAMS
|
|
74
|
-
$params = json_decode(file_get_contents('php://input'), true);
|
|
75
|
-
|
|
76
|
-
//GET PRODUCT
|
|
77
|
-
$request = Request::createFromGlobals();
|
|
78
|
-
if ($request->isMethod('POST')) {
|
|
79
|
-
$product = $this->getDoctrine()->getRepository(Product::class)->find($request->request->get('productId'));
|
|
80
|
-
if (!$product) {
|
|
81
|
-
throw $this->createNotFoundException('product not found');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
//ENTITY MANAGER
|
|
85
|
-
$entityManager = $this->getDoctrine()->getManager();
|
|
86
|
-
$product->setName($params['name']);
|
|
87
|
-
$product->setPrice($params['price']);
|
|
88
|
-
$product->setDescription($params['description']);
|
|
89
|
-
$entityManager->merge($product);
|
|
90
|
-
$entityManager->flush();
|
|
91
|
-
|
|
92
|
-
//OUTPUT
|
|
93
|
-
$response = new Response(json_encode($product->toArray()));
|
|
94
|
-
} else{
|
|
95
|
-
$response = new Response();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
$response -> setStatusCode(Response::HTTP_OK);
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
catch (\Exception $e) {
|
|
102
|
-
$response = New Response(json_encode(array('error' => $e->getMessage())));
|
|
103
|
-
$response -> setStatusCode(Response::HTTP_BAD_REQUEST);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return $this->setheaders($response,"POST");
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @Route("/api/product/delete/{id}", name="product_delete", methods = {"OPTIONS","DELETE"})
|
|
113
|
-
*/
|
|
114
|
-
public function delete($id)
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
$request = Request::createFromGlobals();
|
|
119
|
-
|
|
120
|
-
if ($request->isMethod('DELETE')) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//GET PRODUCT
|
|
124
|
-
$repository = $this->getDoctrine()->getRepository(Product::class);
|
|
125
|
-
$product = $repository->find($id);
|
|
126
|
-
if (!$product) {
|
|
127
|
-
throw $this->createNotFoundException('product not found');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
//OUTPUT
|
|
131
|
-
$response = new Response(json_encode($product->toArray()));
|
|
132
|
-
|
|
133
|
-
//ENTITY MANAGER
|
|
134
|
-
$entityManager = $this->getDoctrine()->getManager();
|
|
135
|
-
$entityManager->remove($product);
|
|
136
|
-
$entityManager->flush();
|
|
137
|
-
|
|
138
|
-
}else{
|
|
139
|
-
$response = new Response();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
$response -> setStatusCode(Response::HTTP_OK);
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
catch (\Exception $e) {
|
|
146
|
-
$response = New Response(json_encode(array('error' => $e->getMessage())));
|
|
147
|
-
$response -> setStatusCode(Response::HTTP_BAD_REQUEST);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return $this->setheaders($response,"DELETE");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @Route("/api/products", name="products", methods = {"OPTIONS", "GET"})
|
|
158
|
-
*/
|
|
159
|
-
public function products()
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
$response = [];
|
|
163
|
-
try
|
|
164
|
-
{
|
|
165
|
-
//GET PRODUCTS
|
|
166
|
-
$repository = $this->getDoctrine()->getRepository(Product::class);
|
|
167
|
-
$products = $repository->findAll();
|
|
168
|
-
foreach ($products as $product) {
|
|
169
|
-
$response[] = $product->toArray();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
//OUTPUT
|
|
173
|
-
$response = new Response(json_encode(array('items' => $response)));
|
|
174
|
-
$response -> setStatusCode(Response::HTTP_OK);
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
catch (\Exception $e) {
|
|
178
|
-
$response = New Response(json_encode(array('error' => $e->getMessage())));
|
|
179
|
-
$response -> setStatusCode(Response::HTTP_BAD_REQUEST);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return $this->setheaders($response,"GET");
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
//CORS
|
|
187
|
-
function setheaders($response,$method) {
|
|
188
|
-
$response->headers->set('Content-Type', 'application/json');
|
|
189
|
-
$response->headers->set('Access-Control-Allow-Origin', 'http://localhost:4200');
|
|
190
|
-
$response->headers->set('Access-Control-Allow-Headers','Cache-Control,X-Requested-With,Content-Type');
|
|
191
|
-
$response->headers->set('Access-Control-Allow-Credentials','true');
|
|
192
|
-
$response->headers->set('Cache-Control','no-cache');
|
|
193
|
-
$response->headers->set('Access-Control-Allow-Methods',$method);
|
|
194
|
-
return $response;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Entity;
|
|
4
|
-
|
|
5
|
-
use Doctrine\ORM\Mapping as ORM;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
|
|
9
|
-
* @ORM\Table(name="product")
|
|
10
|
-
*/
|
|
11
|
-
class Product
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* @ORM\Id()
|
|
15
|
-
* @ORM\GeneratedValue()
|
|
16
|
-
* @ORM\Column(type="integer")
|
|
17
|
-
*/
|
|
18
|
-
private $productId;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @ORM\Column(type="string", length=255)
|
|
22
|
-
*/
|
|
23
|
-
private $name;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @ORM\Column(type="integer")
|
|
27
|
-
*/
|
|
28
|
-
private $price;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @ORM\Column(type="text", nullable=true)
|
|
32
|
-
*/
|
|
33
|
-
private $description;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
public function getProductId(): ?int
|
|
37
|
-
{
|
|
38
|
-
return $this->productId;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public function setProductId(int $productId): self
|
|
42
|
-
{
|
|
43
|
-
$this->productId = $productId;
|
|
44
|
-
|
|
45
|
-
return $this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public function getName(): ?string
|
|
49
|
-
{
|
|
50
|
-
return $this->name;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public function setName(string $name): self
|
|
54
|
-
{
|
|
55
|
-
$this->name = $name;
|
|
56
|
-
|
|
57
|
-
return $this;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public function getPrice(): ?int
|
|
61
|
-
{
|
|
62
|
-
return $this->price;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public function setPrice(int $price): self
|
|
66
|
-
{
|
|
67
|
-
$this->price = $price;
|
|
68
|
-
|
|
69
|
-
return $this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public function getDescription(): ?string
|
|
73
|
-
{
|
|
74
|
-
return $this->description;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public function setDescription(?string $description): self
|
|
78
|
-
{
|
|
79
|
-
$this->description = $description;
|
|
80
|
-
|
|
81
|
-
return $this;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public function toArray() {
|
|
85
|
-
$vars = get_object_vars ( $this );
|
|
86
|
-
$array = array ();
|
|
87
|
-
foreach ( $vars as $key => $value ) {
|
|
88
|
-
$array [ltrim ( $key, '_' )] = $value;
|
|
89
|
-
}
|
|
90
|
-
return $array;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App;
|
|
4
|
-
|
|
5
|
-
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
|
6
|
-
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
7
|
-
use Symfony\Component\Config\Resource\FileResource;
|
|
8
|
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
9
|
-
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
|
10
|
-
use Symfony\Component\Routing\RouteCollectionBuilder;
|
|
11
|
-
|
|
12
|
-
class Kernel extends BaseKernel
|
|
13
|
-
{
|
|
14
|
-
use MicroKernelTrait;
|
|
15
|
-
|
|
16
|
-
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
|
17
|
-
|
|
18
|
-
public function registerBundles(): iterable
|
|
19
|
-
{
|
|
20
|
-
$contents = require $this->getProjectDir().'/config/bundles.php';
|
|
21
|
-
foreach ($contents as $class => $envs) {
|
|
22
|
-
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
|
|
23
|
-
yield new $class();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public function getProjectDir(): string
|
|
29
|
-
{
|
|
30
|
-
return \dirname(__DIR__);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
|
34
|
-
{
|
|
35
|
-
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
|
|
36
|
-
$container->setParameter('container.dumper.inline_class_loader', true);
|
|
37
|
-
$confDir = $this->getProjectDir().'/config';
|
|
38
|
-
|
|
39
|
-
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
|
|
40
|
-
$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
|
|
41
|
-
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
|
|
42
|
-
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
protected function configureRoutes(RouteCollectionBuilder $routes): void
|
|
46
|
-
{
|
|
47
|
-
$confDir = $this->getProjectDir().'/config';
|
|
48
|
-
|
|
49
|
-
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
|
|
50
|
-
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
|
|
51
|
-
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace DoctrineMigrations;
|
|
6
|
-
|
|
7
|
-
use Doctrine\DBAL\Schema\Schema;
|
|
8
|
-
use Doctrine\Migrations\AbstractMigration;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Auto-generated Migration: Please modify to your needs!
|
|
12
|
-
*/
|
|
13
|
-
final class Version20190604101623 extends AbstractMigration
|
|
14
|
-
{
|
|
15
|
-
public function getDescription() : string
|
|
16
|
-
{
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public function up(Schema $schema) : void
|
|
21
|
-
{
|
|
22
|
-
// this up() migration is auto-generated, please modify it to your needs
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public function down(Schema $schema) : void
|
|
27
|
-
{
|
|
28
|
-
// this down() migration is auto-generated, please modify it to your needs
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace DoctrineMigrations;
|
|
6
|
-
|
|
7
|
-
use Doctrine\DBAL\Schema\Schema;
|
|
8
|
-
use Doctrine\Migrations\AbstractMigration;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Auto-generated Migration: Please modify to your needs!
|
|
12
|
-
*/
|
|
13
|
-
final class Version20190604101638 extends AbstractMigration
|
|
14
|
-
{
|
|
15
|
-
public function getDescription() : string
|
|
16
|
-
{
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public function up(Schema $schema) : void
|
|
21
|
-
{
|
|
22
|
-
// this up() migration is auto-generated, please modify it to your needs
|
|
23
|
-
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
|
24
|
-
|
|
25
|
-
$this->addSql('CREATE TABLE product (product_id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, price INT NOT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(product_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public function down(Schema $schema) : void
|
|
29
|
-
{
|
|
30
|
-
// this down() migration is auto-generated, please modify it to your needs
|
|
31
|
-
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
|
32
|
-
|
|
33
|
-
$this->addSql('DROP TABLE product');
|
|
34
|
-
}
|
|
35
|
-
}
|