refs #637. create pxe template crud
parent
7889554b36
commit
960d225ed8
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\OgBoot\OgLive;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
#[AsController]
|
||||
abstract class AbstractOgLiveController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly string $ogBootApiUrl,
|
||||
protected readonly EntityManagerInterface $entityManager
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgBoot\OgLive;
|
||||
|
||||
class GetIsosAction
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgBoot\PxeTemplate;
|
||||
|
||||
class DeleteAction
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgBoot\Pxe;
|
||||
|
||||
class GetAction
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgBoot\PxeTemplate;
|
||||
|
||||
class GetCollectionAction
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgBoot\PxeTemplate;
|
||||
|
||||
class PostAction
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Entity\PxeTemplate;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
final class PxeTemplateInput
|
||||
{
|
||||
#[Assert\NotBlank(message: 'validators.pxe_template.name.not_blank')]
|
||||
#[Groups(['pxe-template:write'])]
|
||||
#[ApiProperty(description: 'The name of the pxeTemplate', example: "PxeTemplate 1")]
|
||||
public ?string $name = null;
|
||||
|
||||
#[Groups(['pxe-template:write'])]
|
||||
#[ApiProperty(description: 'The content of the pxeTemplate', example: "content of the pxeTemplate 1")]
|
||||
public ?string $templateContent = null;
|
||||
|
||||
public function __construct(?PxeTemplate $pxeTemplate = null)
|
||||
{
|
||||
if (!$pxeTemplate) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->name = $pxeTemplate->getName();
|
||||
$this->templateContent = $pxeTemplate->getTemplateContent();
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?PxeTemplate $pxeTemplate = null): PxeTemplate
|
||||
{
|
||||
if (!$pxeTemplate) {
|
||||
$pxeTemplate = new PxeTemplate();
|
||||
}
|
||||
|
||||
$pxeTemplate->setName($this->name);
|
||||
$pxeTemplate->setTemplateContent($this->templateContent);
|
||||
|
||||
return $pxeTemplate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\PxeTemplate;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Get(shortName: 'PxeTemplate')]
|
||||
final class PxeTemplateOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['pxe-template:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['pxe-template:read'])]
|
||||
public ?string $templateContent = '';
|
||||
|
||||
#[Groups(['pxe-template:read'])]
|
||||
public \DateTime $createdAt;
|
||||
|
||||
#[Groups(['pxe-template:read'])]
|
||||
public ?string $createdBy = null;
|
||||
|
||||
public function __construct(PxeTemplate $pxeTemplate)
|
||||
{
|
||||
parent::__construct($pxeTemplate);
|
||||
|
||||
$this->name = $pxeTemplate->getName();
|
||||
$this->templateContent = $pxeTemplate->getTemplateContent();
|
||||
$this->createdAt = $pxeTemplate->getCreatedAt();
|
||||
$this->createdBy = $pxeTemplate->getCreatedBy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PxeTemplateRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PxeTemplateRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_NAME', fields: ['name'])]
|
||||
#[UniqueEntity(fields: ['name'], message: 'validators.pxe_template.name.unique')]
|
||||
class PxeTemplate extends AbstractEntity
|
||||
{
|
||||
use NameableTrait;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $templateContent = null;
|
||||
|
||||
public function getTemplateContent(): ?string
|
||||
{
|
||||
return $this->templateContent;
|
||||
}
|
||||
|
||||
public function setTemplateContent(string $templateContent): static
|
||||
{
|
||||
$this->templateContent = $templateContent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Factory;
|
||||
|
||||
use App\Entity\PxeTemplate;
|
||||
use App\Repository\PxeTemplateRepository;
|
||||
use Zenstruck\Foundry\ModelFactory;
|
||||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
||||
use Zenstruck\Foundry\Persistence\Proxy;
|
||||
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;
|
||||
|
||||
/**
|
||||
* @extends PersistentProxyObjectFactory<PxeTemplate>
|
||||
*/
|
||||
final class PxeTemplateFactory extends ModelFactory
|
||||
{
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
||||
*
|
||||
* @todo inject services if required
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
|
||||
*
|
||||
* @todo add your default values here
|
||||
*/
|
||||
protected function getDefaults(): array
|
||||
{
|
||||
return [
|
||||
'createdAt' => self::faker()->dateTime(),
|
||||
'name' => self::faker()->text(255),
|
||||
'templateContent' => self::faker()->text(255),
|
||||
'updatedAt' => self::faker()->dateTime()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
||||
*/
|
||||
protected function initialize(): self
|
||||
{
|
||||
return $this
|
||||
// ->afterInstantiate(function(PxeTemplate $pxeTemplate): void {})
|
||||
;
|
||||
}
|
||||
|
||||
protected static function getClass(): string
|
||||
{
|
||||
return PxeTemplate::class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PxeBootFile;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PxeBootFile>
|
||||
*/
|
||||
class PxeBootFileRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PxeBootFile::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return PxeBootFile[] Returns an array of PxeBootFile objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('p.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?PxeBootFile
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PxeTemplate;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<PxeTemplate>
|
||||
*/
|
||||
class PxeTemplateRepository extends AbstractRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PxeTemplate::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service\OgBoot;
|
||||
|
||||
class ConfigService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\State\Processor;
|
||||
|
||||
class PxeTemplateProcessor
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\State\Provider;
|
||||
|
||||
class PxeTemplateProvider
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Functional;
|
||||
|
||||
class PxeTemplateTest
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue