mirror of
https://github.com/Mactronique/cua_webinterface.git
synced 2026-03-24 00:42:18 +01:00
add entity + easyadmin
This commit is contained in:
2
.env
2
.env
@@ -29,5 +29,5 @@ APP_SECRET=1cfb268791faa36148b27cf29db67cbe
|
||||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
|
||||
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
|
||||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
|
||||
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7
|
||||
DATABASE_URL=mysql://root:nopassword@127.0.0.1:3306/cua?serverVersion=mariadb-10.5.0
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,3 +14,5 @@
|
||||
.phpunit.result.cache
|
||||
/phpunit.xml
|
||||
###< symfony/phpunit-bridge ###
|
||||
|
||||
/mysql
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"php": "^7.2.5",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"easycorp/easyadmin-bundle": "^2.3",
|
||||
"sensio/framework-extra-bundle": "^5.1",
|
||||
"symfony/asset": "5.1.*",
|
||||
"symfony/console": "5.1.*",
|
||||
|
||||
152
composer.lock
generated
152
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "654e80c9004c18f27b51b861e11c96df",
|
||||
"content-hash": "1e4a52b06ac0db704cd3a86f9dd8bf24",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
@@ -1215,6 +1215,91 @@
|
||||
],
|
||||
"time": "2020-05-29T18:32:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "easycorp/easyadmin-bundle",
|
||||
"version": "v2.3.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/EasyCorp/EasyAdminBundle.git",
|
||||
"reference": "c28301cc7f7df9531fd3b8b91196ab11a71074c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/EasyCorp/EasyAdminBundle/zipball/c28301cc7f7df9531fd3b8b91196ab11a71074c4",
|
||||
"reference": "c28301cc7f7df9531fd3b8b91196ab11a71074c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/common": "^2.8",
|
||||
"doctrine/doctrine-bundle": "^1.8|^2.0",
|
||||
"doctrine/orm": "^2.6.3",
|
||||
"doctrine/persistence": "^1.3.4",
|
||||
"pagerfanta/pagerfanta": "^1.0.1|^2.0",
|
||||
"php": "^7.1.3",
|
||||
"symfony/asset": "^4.2|^5.0",
|
||||
"symfony/cache": "^4.2|^5.0",
|
||||
"symfony/config": "^4.2|^5.0",
|
||||
"symfony/dependency-injection": "^4.2|^5.0",
|
||||
"symfony/doctrine-bridge": "^4.2|^5.0",
|
||||
"symfony/error-handler": "^4.4|^5.0",
|
||||
"symfony/event-dispatcher": "^4.2|^5.0",
|
||||
"symfony/expression-language": "^4.2|^5.0",
|
||||
"symfony/finder": "^4.2|^5.0",
|
||||
"symfony/form": "^4.2|^5.0",
|
||||
"symfony/framework-bundle": "^4.2|^5.0",
|
||||
"symfony/http-foundation": "^4.2|^5.0",
|
||||
"symfony/http-kernel": "^4.3.7|^5.0",
|
||||
"symfony/polyfill-mbstring": "^1.7",
|
||||
"symfony/property-access": "^4.2|^5.0",
|
||||
"symfony/security-bundle": "^4.2|^5.0",
|
||||
"symfony/translation": "^4.2|^5.0",
|
||||
"symfony/twig-bridge": "^4.2|^5.0",
|
||||
"symfony/twig-bundle": "^4.2|^5.0",
|
||||
"symfony/validator": "^4.2|^5.0",
|
||||
"twig/twig": "^2.11.3|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/data-fixtures": "^1.3",
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.0",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/browser-kit": "^4.2|^5.0",
|
||||
"symfony/console": "^4.2|^5.0",
|
||||
"symfony/css-selector": "^4.2|^5.0",
|
||||
"symfony/dom-crawler": "^4.2|^5.0",
|
||||
"symfony/phpunit-bridge": "^4.3.5|^5.0",
|
||||
"symfony/var-dumper": "^4.2|^5.0",
|
||||
"symfony/yaml": "^4.2|^5.0"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"EasyCorp\\Bundle\\EasyAdminBundle\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Project Contributors",
|
||||
"homepage": "https://github.com/EasyCorp/EasyAdminBundle/blob/master/CONTRIBUTORS.md"
|
||||
}
|
||||
],
|
||||
"description": "Admin generator for Symfony applications",
|
||||
"homepage": "https://github.com/EasyCorp/EasyAdminBundle",
|
||||
"keywords": [
|
||||
"admin",
|
||||
"backend",
|
||||
"generator"
|
||||
],
|
||||
"time": "2020-05-07T18:49:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"version": "2.1.17",
|
||||
@@ -1651,6 +1736,71 @@
|
||||
],
|
||||
"time": "2020-04-13T14:42:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pagerfanta/pagerfanta",
|
||||
"version": "v2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/BabDev/Pagerfanta.git",
|
||||
"reference": "fd00eb74632fecc0265327e9fe0eddc08c72b238"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/BabDev/Pagerfanta/zipball/fd00eb74632fecc0265327e9fe0eddc08c72b238",
|
||||
"reference": "fd00eb74632fecc0265327e9fe0eddc08c72b238",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": "^7.2",
|
||||
"symfony/deprecation-contracts": "^2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/collections": "^1.4",
|
||||
"doctrine/dbal": "^2.5",
|
||||
"doctrine/orm": "^2.5",
|
||||
"doctrine/phpcr-odm": "^1.3",
|
||||
"friendsofphp/php-cs-fixer": "^2.16.3",
|
||||
"jackalope/jackalope-doctrine-dbal": "^1.3",
|
||||
"mandango/mandango": "^1.0@dev",
|
||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
||||
"propel/propel": "^2.0@dev",
|
||||
"propel/propel1": "^1.7",
|
||||
"ruflin/elastica": "^1.3 || ^2.0 || ^3.0 || ^5.0 || ^6.0",
|
||||
"solarium/solarium": "^2.3 || ^3.0 || ^4.0 || ^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/collections": "To use the Doctrine Collection and Selectable adapter.",
|
||||
"doctrine/dbal": "To use the Doctrine DBAL adapters.",
|
||||
"doctrine/mongodb-odm": "To use the Doctrine MongoDB ODM Adapter.",
|
||||
"doctrine/orm": "To use the Doctrine ORM Adapter.",
|
||||
"doctrine/phpcr-odm": "To use the Doctrine PHPCR ODM Adapter.",
|
||||
"solarium/solarium": "To use the SolariumAdapter."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-2.x": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Pagerfanta\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Pagination for PHP",
|
||||
"keywords": [
|
||||
"page",
|
||||
"pagination",
|
||||
"paginator",
|
||||
"paging"
|
||||
],
|
||||
"time": "2020-06-09T15:25:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.1.0",
|
||||
|
||||
@@ -12,4 +12,5 @@ return [
|
||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
|
||||
];
|
||||
|
||||
71
config/packages/easy_admin.yaml
Normal file
71
config/packages/easy_admin.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
easy_admin:
|
||||
list:
|
||||
max_results: 30
|
||||
entities:
|
||||
# List the entity class name you want to manage
|
||||
Customer:
|
||||
class: App\Entity\Customer
|
||||
label: Customers
|
||||
form:
|
||||
fields:
|
||||
- property: 'name'
|
||||
|
||||
- property: 'contacts'
|
||||
type: 'collection'
|
||||
type_options:
|
||||
entry_type: App\Form\ContactEmbeddedFormType
|
||||
allow_delete: true
|
||||
allow_add: true
|
||||
by_reference: false
|
||||
Project:
|
||||
class: App\Entity\Project
|
||||
list:
|
||||
fields: ['code', 'customer', 'name', 'enabled', 'checkDependencies', 'checkSecurity', 'contacts']
|
||||
form:
|
||||
fields:
|
||||
-
|
||||
property: 'code'
|
||||
help: 'Need unique. Max 10 char'
|
||||
-
|
||||
property: 'customer'
|
||||
help: 'Customer owner of this project'
|
||||
-
|
||||
property: 'name'
|
||||
-
|
||||
property: 'path'
|
||||
help: 'Path of the project on server'
|
||||
-
|
||||
property: 'lockPath'
|
||||
help: 'Project composer.lock path. relativ to the path project.'
|
||||
-
|
||||
property: 'phpPath'
|
||||
help: 'PHP executable name or absolute path.'
|
||||
-
|
||||
property: 'privateDependencies'
|
||||
help: 'List here (one per line) all private depdendencies included in this project.'
|
||||
-
|
||||
property: 'privateDependenciesStrategy'
|
||||
type: 'choice'
|
||||
type_options:
|
||||
choices: {'Remove': 'remove', 'Hash': 'hash'}
|
||||
help: 'Select the strategy to proccess the private dependencies before send composer.lock to the security check service.'
|
||||
-
|
||||
property: 'checkDependencies'
|
||||
-
|
||||
property: 'checkSecurity'
|
||||
-
|
||||
property: 'enabled'
|
||||
-
|
||||
property: 'contacts'
|
||||
type: 'entity'
|
||||
type_options: { class: 'App\Entity\Contact', multiple: true, attr: { data-widget: 'select2'} }
|
||||
Dependency:
|
||||
class: App\Entity\Dependency
|
||||
list:
|
||||
fields: ['id', 'project', 'library', 'version', 'state', 'toVersion', 'deprecated', 'updatedAt']
|
||||
actions: ['-edit', '-remove', '-new']
|
||||
SecurityIssue:
|
||||
class: App\Entity\SecurityIssue
|
||||
list:
|
||||
fields: ['id', 'project', 'library', 'version', 'state', 'updatedAt']
|
||||
actions: ['-edit', '-remove', '-new', 'show']
|
||||
4
config/routes/easy_admin.yaml
Normal file
4
config/routes/easy_admin.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
easy_admin_bundle:
|
||||
resource: '@EasyAdminBundle/Controller/EasyAdminController.php'
|
||||
prefix: /
|
||||
type: annotation
|
||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: library/mariadb:10.5
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: nopassword
|
||||
volumes:
|
||||
- ./mysql/data:/var/lib/mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
|
||||
146
src/Entity/Contact.php
Normal file
146
src/Entity/Contact.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ContactRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ContactRepository::class)
|
||||
*/
|
||||
class Contact
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="contacts")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Project::class, inversedBy="contacts", cascade={"persist"})
|
||||
* @ORM\JoinTable(
|
||||
* name="contacts_projects",
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="project_code", referencedColumnName="code")},
|
||||
* joinColumns={@ORM\JoinColumn(name="contact_id", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="2", max="255")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Email()
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $sendAlert = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->project = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return sprintf('%s (%s)', $this->name ?? 'no name contact', $this->customer ?? 'No customer name');
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCustomer(): ?Customer
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
public function setCustomer(?Customer $customer): self
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Project[]
|
||||
*/
|
||||
public function getProject(): Collection
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function addProject(Project $project): self
|
||||
{
|
||||
if (!$this->project->contains($project)) {
|
||||
$this->project[] = $project;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProject(Project $project): self
|
||||
{
|
||||
if ($this->project->contains($project)) {
|
||||
$this->project->removeElement($project);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSendAlert(): ?bool
|
||||
{
|
||||
return $this->sendAlert;
|
||||
}
|
||||
|
||||
public function setSendAlert(bool $sendAlert): self
|
||||
{
|
||||
$this->sendAlert = $sendAlert;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
192
src/Entity/Customer.php
Normal file
192
src/Entity/Customer.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\CustomerRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=CustomerRepository::class)
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Customer
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="added_at", type="datetime")
|
||||
*/
|
||||
private $addedAt;
|
||||
|
||||
/**
|
||||
* @var null|\DateTime
|
||||
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=Project::class, mappedBy="customer")
|
||||
*/
|
||||
private $projects;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=Contact::class, mappedBy="customer", cascade={"remove", "persist"}, orphanRemoval=true)
|
||||
*/
|
||||
private $contacts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->projects = new ArrayCollection();
|
||||
$this->addedAt = new \DateTime();
|
||||
$this->contacts = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name ?? 'customer #'.$this->id;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Project[]
|
||||
*/
|
||||
public function getProjects(): Collection
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
public function addProject(Project $project): self
|
||||
{
|
||||
if (!$this->projects->contains($project)) {
|
||||
$this->projects[] = $project;
|
||||
$project->setCustomer($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProject(Project $project): self
|
||||
{
|
||||
if ($this->projects->contains($project)) {
|
||||
$this->projects->removeElement($project);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($project->getCustomer() === $this) {
|
||||
$project->setCustomer(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getAddedAt(): \DateTime
|
||||
{
|
||||
return $this->addedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $addedAt
|
||||
* @return Customer
|
||||
*/
|
||||
private function setAddedAt(\DateTime $addedAt): Customer
|
||||
{
|
||||
$this->addedAt = $addedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getUpdatedAt(): ?\DateTime
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $updatedAt
|
||||
* @return Customer
|
||||
*/
|
||||
private function setUpdatedAt(?\DateTime $updatedAt): Customer
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist()
|
||||
*/
|
||||
public function prePersist()
|
||||
{
|
||||
$this->addedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreUpdate()
|
||||
*/
|
||||
public function preUpdate()
|
||||
{
|
||||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Contact[]
|
||||
*/
|
||||
public function getContacts(): Collection
|
||||
{
|
||||
return $this->contacts;
|
||||
}
|
||||
|
||||
public function addContact(Contact $contact): self
|
||||
{
|
||||
if (!$this->contacts->contains($contact)) {
|
||||
$this->contacts[] = $contact;
|
||||
$contact->setCustomer($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeContact(Contact $contact): self
|
||||
{
|
||||
if ($this->contacts->contains($contact)) {
|
||||
$this->contacts->removeElement($contact);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($contact->getCustomer() === $this) {
|
||||
$contact->setCustomer(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
173
src/Entity/Dependency.php
Normal file
173
src/Entity/Dependency.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\DependencyRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=DependencyRepository::class)
|
||||
* @ORM\Table(name="dependencies")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Dependency
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @#ORM\Column(type="string", length=50)
|
||||
* @ORM\ManyToOne(targetEntity="Project", inversedBy="dependencies")
|
||||
* @ORM\JoinColumn(name="project", referencedColumnName="code")
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $library;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250, nullable=true)
|
||||
*/
|
||||
private $to_library;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250, nullable=true)
|
||||
*/
|
||||
private $to_version;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*/
|
||||
private $deprecated;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="updated_at", type="datetime")
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProject(): ?string
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(string $project): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLibrary(): ?string
|
||||
{
|
||||
return $this->library;
|
||||
}
|
||||
|
||||
public function setLibrary(string $library): self
|
||||
{
|
||||
$this->library = $library;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function setVersion(string $version): self
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getState(): ?string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function setState(string $state): self
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getToLibrary(): ?string
|
||||
{
|
||||
return $this->to_library;
|
||||
}
|
||||
|
||||
public function setToLibrary(?string $to_library): self
|
||||
{
|
||||
$this->to_library = $to_library;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getToVersion(): ?string
|
||||
{
|
||||
return $this->to_version;
|
||||
}
|
||||
|
||||
public function setToVersion(?string $to_version): self
|
||||
{
|
||||
$this->to_version = $to_version;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeprecated(): ?bool
|
||||
{
|
||||
return $this->deprecated;
|
||||
}
|
||||
|
||||
public function setDeprecated(?bool $deprecated): self
|
||||
{
|
||||
$this->deprecated = $deprecated;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
private function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreUpdate()
|
||||
* @ORM\PrePersist()
|
||||
*/
|
||||
public function preUpdate()
|
||||
{
|
||||
$this->updatedAt=new \DateTime();
|
||||
}
|
||||
}
|
||||
436
src/Entity/Project.php
Normal file
436
src/Entity/Project.php
Normal file
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ProjectRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ProjectRepository::class)
|
||||
* @ORM\Table(name="projects")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Project
|
||||
{
|
||||
public const STRATEGY_REMOVE = 'remove';
|
||||
public const STRATEGY_HASH = 'hash';
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Id()
|
||||
* @ORM\Column(type="string", length=10)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="1", max="10")
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var null|Customer
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="projects")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(type="string", length=100)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="1", max="100")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="1", max="255")
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(name="lock_path", type="string", length=255)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="1", max="255")
|
||||
*/
|
||||
private $lockPath = 'composer.lock';
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(name="php_path", type="string", length=255)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min="1", max="255")
|
||||
*/
|
||||
private $phpPath = 'php';
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(name="private_dependencies", type="text", nullable=true)
|
||||
*/
|
||||
private $privateDependencies;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*
|
||||
* @ORM\Column(name="private_dependencies_strategy", type="string", length=10, nullable=true)
|
||||
*/
|
||||
private $privateDependenciesStrategy = self::STRATEGY_REMOVE;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(name="check_dependencies", type="boolean", nullable=true)
|
||||
*/
|
||||
private $checkDependencies = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(name="check_security", type="boolean", nullable=true)
|
||||
*/
|
||||
private $checkSecurity = true;
|
||||
|
||||
/**
|
||||
* @var null|\DateTime
|
||||
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @var null|\DateTime
|
||||
* @ORM\Column(name="added_at", type="datetime")
|
||||
*/
|
||||
private $addedAt;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(name="enabled", type="boolean")
|
||||
*/
|
||||
private $enabled = true;
|
||||
|
||||
/**
|
||||
* @var array|ArrayCollection|Dependency[]
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=Dependency::class, mappedBy="project")
|
||||
*/
|
||||
private $dependencies;
|
||||
|
||||
/**
|
||||
* @var array|ArrayCollection|SecurityIssue[]
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=SecurityIssue::class, mappedBy="project")
|
||||
*/
|
||||
private $securityIssues;
|
||||
|
||||
/**
|
||||
* @var array|ArrayCollection|Contact[]
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Contact::class, mappedBy="project", cascade={"remove", "persist"})
|
||||
*/
|
||||
private $contacts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dependencies = new ArrayCollection();
|
||||
$this->securityIssues = new ArrayCollection();
|
||||
$this->contacts = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getCustomer(): ?Customer
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
public function setCustomer(?Customer $customer): self
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): ?string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPath(): ?string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setPath(string $path): self
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLockPath(): ?string
|
||||
{
|
||||
return $this->lockPath;
|
||||
}
|
||||
|
||||
public function setLockPath(string $lockPath): self
|
||||
{
|
||||
$this->lockPath = $lockPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhpPath(): ?string
|
||||
{
|
||||
return $this->phpPath;
|
||||
}
|
||||
|
||||
public function setPhpPath(string $phpPath): self
|
||||
{
|
||||
$this->phpPath = $phpPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrivateDependencies(): ?string
|
||||
{
|
||||
return $this->privateDependencies;
|
||||
}
|
||||
|
||||
public function setPrivateDependencies(?string $privateDependencies): self
|
||||
{
|
||||
$this->privateDependencies = $privateDependencies;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrivateDependenciesStrategy(): ?string
|
||||
{
|
||||
return $this->privateDependenciesStrategy;
|
||||
}
|
||||
|
||||
public function setPrivateDependenciesStrategy(?string $privateDependenciesStrategy): self
|
||||
{
|
||||
$this->privateDependenciesStrategy = $privateDependenciesStrategy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCheckDependencies(): ?bool
|
||||
{
|
||||
return $this->checkDependencies;
|
||||
}
|
||||
|
||||
public function setCheckDependencies(?bool $checkDependencies): self
|
||||
{
|
||||
$this->checkDependencies = $checkDependencies;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCheckSecurity(): ?bool
|
||||
{
|
||||
return $this->checkSecurity;
|
||||
}
|
||||
|
||||
public function setCheckSecurity(?bool $checkSecurity): self
|
||||
{
|
||||
$this->checkSecurity = $checkSecurity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getAddedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->addedAt;
|
||||
}
|
||||
|
||||
public function isEnabled(): ?bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
public function setEnabled(bool $enabled): self
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Dependency[]
|
||||
*/
|
||||
public function getDependencies(): Collection
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
public function addDependency(Dependency $dependency): self
|
||||
{
|
||||
if (!$this->dependencies->contains($dependency)) {
|
||||
$this->dependencies[] = $dependency;
|
||||
$dependency->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDependency(Dependency $dependency): self
|
||||
{
|
||||
if ($this->dependencies->contains($dependency)) {
|
||||
$this->dependencies->removeElement($dependency);
|
||||
// set the owning side to null (unless already changed)
|
||||
// if ($dependency->getProject() === $this) {
|
||||
// $dependency->setProject(null);
|
||||
// }
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SecurityIssue[]
|
||||
*/
|
||||
public function getSecurityIssues(): Collection
|
||||
{
|
||||
return $this->securityIssues;
|
||||
}
|
||||
|
||||
public function addProject(SecurityIssue $securityIssue): self
|
||||
{
|
||||
if (!$this->securityIssues->contains($securityIssue)) {
|
||||
$this->securityIssues[] = $securityIssue;
|
||||
$securityIssue->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProject(SecurityIssue $securityIssue): self
|
||||
{
|
||||
if ($this->securityIssues->contains($securityIssue)) {
|
||||
$this->securityIssues->removeElement($securityIssue);
|
||||
// set the owning side to null (unless already changed)
|
||||
// if ($securityIssue->getProject() === $this) {
|
||||
// $securityIssue->setProject(null);
|
||||
// }
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist()
|
||||
*/
|
||||
public function prePersist()
|
||||
{
|
||||
$this->addedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreUpdate()
|
||||
*/
|
||||
public function preUpdate()
|
||||
{
|
||||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Contact[]
|
||||
*/
|
||||
public function getContacts(): Collection
|
||||
{
|
||||
return $this->contacts;
|
||||
}
|
||||
|
||||
public function addContact(Contact $contact): self
|
||||
{
|
||||
if (!$this->contacts->contains($contact)) {
|
||||
$this->contacts[] = $contact;
|
||||
$contact->addProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeContact(Contact $contact): self
|
||||
{
|
||||
if ($this->contacts->contains($contact)) {
|
||||
$this->contacts->removeElement($contact);
|
||||
$contact->removeProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Assert\Callback()
|
||||
*/
|
||||
public function checkContact(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
if ($this->contacts->isEmpty() || $this->customer === null) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->contacts as $key => $contact) {
|
||||
/** @var Contact $contact */
|
||||
if ($contact->getCustomer() !== $this->customer) {
|
||||
$context->buildViolation(
|
||||
'The contact "%contact_name%" is not affected to this customer',
|
||||
[
|
||||
'%contact_name%' => $contact->__toString(),
|
||||
]
|
||||
)
|
||||
->atPath('contacts')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function setAddedAt(\DateTimeInterface $addedAt): self
|
||||
{
|
||||
$this->addedAt = $addedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
139
src/Entity/SecurityIssue.php
Normal file
139
src/Entity/SecurityIssue.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SecurityIssueRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=SecurityIssueRepository::class)
|
||||
* @ORM\Table(name="security")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class SecurityIssue
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @#ORM\Column(type="string", length=50)
|
||||
* @ORM\ManyToOne(targetEntity="Project", inversedBy="securityIssues")
|
||||
* @ORM\JoinColumn(name="project", referencedColumnName="code")
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $library;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private $details;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="updated_at", type="datetime")
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProject(): ?string
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(string $project): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLibrary(): ?string
|
||||
{
|
||||
return $this->library;
|
||||
}
|
||||
|
||||
public function setLibrary(string $library): self
|
||||
{
|
||||
$this->library = $library;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function setVersion(string $version): self
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getState(): ?string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function setState(string $state): self
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
private function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDetails(): ?string
|
||||
{
|
||||
return $this->details;
|
||||
}
|
||||
|
||||
public function setDetails(string $details): self
|
||||
{
|
||||
$this->details = $details;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreUpdate()
|
||||
* @ORM\PrePersist()
|
||||
*/
|
||||
public function preUpdate()
|
||||
{
|
||||
$this->updatedAt=new \DateTime();
|
||||
}
|
||||
}
|
||||
28
src/Form/ContactEmbeddedFormType.php
Normal file
28
src/Form/ContactEmbeddedFormType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Contact;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ContactEmbeddedFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name')
|
||||
->add('email')
|
||||
->add('sendAlert')
|
||||
// ->add('customer')
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Contact::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
47
src/Migrations/Version20200610195136.php
Normal file
47
src/Migrations/Version20200610195136.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20200610195136 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE customer (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, added_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE projects (code VARCHAR(10) NOT NULL, customer_id INT NOT NULL, name VARCHAR(100) NOT NULL, path VARCHAR(255) NOT NULL, lock_path VARCHAR(255) NOT NULL, php_path VARCHAR(255) NOT NULL, private_dependencies LONGTEXT DEFAULT NULL, private_dependencies_strategy VARCHAR(10) DEFAULT NULL, check_dependencies TINYINT(1) DEFAULT NULL, check_security TINYINT(1) DEFAULT NULL, updated_at DATETIME DEFAULT NULL, added_at DATETIME NOT NULL, enabled TINYINT(1) NOT NULL, INDEX IDX_5C93B3A49395C3F3 (customer_id), PRIMARY KEY(code)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE security (id INT AUTO_INCREMENT NOT NULL, project VARCHAR(10) DEFAULT NULL, library VARCHAR(255) NOT NULL, version VARCHAR(255) NOT NULL, state VARCHAR(20) NOT NULL, details LONGTEXT NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_C59BD5C12FB3D0EE (project), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE dependencies (id INT AUTO_INCREMENT NOT NULL, project VARCHAR(10) DEFAULT NULL, library VARCHAR(255) NOT NULL, version VARCHAR(250) NOT NULL, state VARCHAR(20) NOT NULL, to_library VARCHAR(250) DEFAULT NULL, to_version VARCHAR(250) DEFAULT NULL, deprecated TINYINT(1) DEFAULT NULL, updated_at DATETIME NOT NULL, INDEX IDX_EA0F708D2FB3D0EE (project), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE projects ADD CONSTRAINT FK_5C93B3A49395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
|
||||
$this->addSql('ALTER TABLE security ADD CONSTRAINT FK_C59BD5C12FB3D0EE FOREIGN KEY (project) REFERENCES projects (code)');
|
||||
$this->addSql('ALTER TABLE dependencies ADD CONSTRAINT FK_EA0F708D2FB3D0EE FOREIGN KEY (project) REFERENCES projects (code)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE projects DROP FOREIGN KEY FK_5C93B3A49395C3F3');
|
||||
$this->addSql('ALTER TABLE security DROP FOREIGN KEY FK_C59BD5C12FB3D0EE');
|
||||
$this->addSql('ALTER TABLE dependencies DROP FOREIGN KEY FK_EA0F708D2FB3D0EE');
|
||||
$this->addSql('DROP TABLE customer');
|
||||
$this->addSql('DROP TABLE projects');
|
||||
$this->addSql('DROP TABLE security');
|
||||
$this->addSql('DROP TABLE dependencies');
|
||||
}
|
||||
}
|
||||
35
src/Migrations/Version20200610195919.php
Normal file
35
src/Migrations/Version20200610195919.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20200610195919 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE customer CHANGE updated_at updated_at DATETIME DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE customer CHANGE updated_at updated_at DATETIME NOT NULL');
|
||||
}
|
||||
}
|
||||
41
src/Migrations/Version20200610200627.php
Normal file
41
src/Migrations/Version20200610200627.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20200610200627 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, customer_id INT NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, send_alert TINYINT(1) NOT NULL, INDEX IDX_4C62E6389395C3F3 (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE contacts_projects (contact_id INT NOT NULL, project_code VARCHAR(10) NOT NULL, INDEX IDX_49C336E1E7A1254A (contact_id), INDEX IDX_49C336E14E84F880 (project_code), PRIMARY KEY(contact_id, project_code)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6389395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
|
||||
$this->addSql('ALTER TABLE contacts_projects ADD CONSTRAINT FK_49C336E1E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id)');
|
||||
$this->addSql('ALTER TABLE contacts_projects ADD CONSTRAINT FK_49C336E14E84F880 FOREIGN KEY (project_code) REFERENCES projects (code)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE contacts_projects DROP FOREIGN KEY FK_49C336E1E7A1254A');
|
||||
$this->addSql('DROP TABLE contact');
|
||||
$this->addSql('DROP TABLE contacts_projects');
|
||||
}
|
||||
}
|
||||
50
src/Repository/ContactRepository.php
Normal file
50
src/Repository/ContactRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Contact;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Contact|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Contact|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Contact[] findAll()
|
||||
* @method Contact[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ContactRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Contact::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Contact[] Returns an array of Contact objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('c')
|
||||
->andWhere('c.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('c.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Contact
|
||||
{
|
||||
return $this->createQueryBuilder('c')
|
||||
->andWhere('c.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
50
src/Repository/CustomerRepository.php
Normal file
50
src/Repository/CustomerRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Customer|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Customer|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Customer[] findAll()
|
||||
* @method Customer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CustomerRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Customer::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Customer[] Returns an array of Customer objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('c')
|
||||
->andWhere('c.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('c.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Customer
|
||||
{
|
||||
return $this->createQueryBuilder('c')
|
||||
->andWhere('c.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
50
src/Repository/DependencyRepository.php
Normal file
50
src/Repository/DependencyRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Dependency;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Dependency|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Dependency|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Dependency[] findAll()
|
||||
* @method Dependency[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class DependencyRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Dependency::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Dependency[] Returns an array of Dependency objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('d')
|
||||
->andWhere('d.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('d.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Dependency
|
||||
{
|
||||
return $this->createQueryBuilder('d')
|
||||
->andWhere('d.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
50
src/Repository/ProjectRepository.php
Normal file
50
src/Repository/ProjectRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Project;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Project|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Project|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Project[] findAll()
|
||||
* @method Project[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ProjectRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Project::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Project[] Returns an array of Project objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('p.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Project
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
50
src/Repository/SecurityIssueRepository.php
Normal file
50
src/Repository/SecurityIssueRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\SecurityIssue;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method SecurityIssue|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method SecurityIssue|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method SecurityIssue[] findAll()
|
||||
* @method SecurityIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class SecurityIssueRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SecurityIssue::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return SecurityIssue[] Returns an array of SecurityIssue objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->andWhere('s.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('s.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?SecurityIssue
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->andWhere('s.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
16
symfony.lock
16
symfony.lock
@@ -78,6 +78,19 @@
|
||||
"doctrine/sql-formatter": {
|
||||
"version": "1.1.0"
|
||||
},
|
||||
"easycorp/easyadmin-bundle": {
|
||||
"version": "2.0",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "2.0",
|
||||
"ref": "0a51040a43c6f2172a3a0135cd15daf2043905d7"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/easy_admin.yaml",
|
||||
"config/routes/easy_admin.yaml"
|
||||
]
|
||||
},
|
||||
"egulias/email-validator": {
|
||||
"version": "2.1.17"
|
||||
},
|
||||
@@ -102,6 +115,9 @@
|
||||
"ocramius/proxy-manager": {
|
||||
"version": "2.8.0"
|
||||
},
|
||||
"pagerfanta/pagerfanta": {
|
||||
"version": "v2.3.0"
|
||||
},
|
||||
"php": {
|
||||
"version": "7.4"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user