Переглянути джерело

Merge branch 'develop'

master
Guillaume Bourgeois 2 роки тому
джерело
коміт
823987febb
13 змінених файлів з 373 додано та 3 видалено
  1. +48
    -0
      Container/Workshop/SolutionContainer.php
  2. +8
    -1
      Controller/ControllerTrait.php
  3. +30
    -0
      Controller/Workshop/SolutionAdminController.php
  4. +55
    -0
      Definition/Field/Workshop/SolutionFieldDefinition.php
  5. +4
    -2
      Definition/Field/Workshop/WorkshopFieldDefinition.php
  6. +18
    -0
      Factory/Workshop/SolutionFactory.php
  7. +47
    -0
      Model/Workshop/Solution.php
  8. +8
    -0
      Model/Workshop/SolutionInterface.php
  9. +82
    -0
      Model/Workshop/Workshop.php
  10. +15
    -0
      Repository/Workshop/SolutionRepository.php
  11. +14
    -0
      Repository/Workshop/SolutionRepositoryQuery.php
  12. +32
    -0
      Repository/Workshop/SolutionStore.php
  13. +12
    -0
      Resources/translations/admin.fr.yaml

+ 48
- 0
Container/Workshop/SolutionContainer.php Переглянути файл

@@ -0,0 +1,48 @@
<?php

namespace Lc\PietroBundle\Container\Workshop;

use Lc\PietroBundle\Definition\Field\Workshop\SolutionFieldDefinition;
use Lc\PietroBundle\Factory\Workshop\SolutionFactory;
use Lc\PietroBundle\Repository\Workshop\SolutionRepositoryQuery;
use Lc\PietroBundle\Repository\Workshop\SolutionStore;

class SolutionContainer
{
protected SolutionFactory $factory;
protected SolutionRepositoryQuery $repositoryQuery;
protected SolutionStore $store;
protected SolutionFieldDefinition $fieldDefinition;

public function __construct(
SolutionFactory $factory,
SolutionRepositoryQuery $repositoryQuery,
SolutionStore $store,
SolutionFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): SolutionFactory
{
return $this->factory;
}

public function getRepositoryQuery(): SolutionRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): SolutionStore
{
return $this->store;
}

public function getFieldDefinition(): SolutionFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 8
- 1
Controller/ControllerTrait.php Переглянути файл

@@ -11,6 +11,7 @@ use Lc\PietroBundle\Container\Subthematic\SubthematicContainer;
use Lc\PietroBundle\Container\Territory\TerritoryContainer;
use Lc\PietroBundle\Container\Thematic\ThematicContainer;
use Lc\PietroBundle\Container\Workshop\EntryContainer;
use Lc\PietroBundle\Container\Workshop\SolutionContainer;
use Lc\PietroBundle\Container\Workshop\TypeContainer;
use Lc\PietroBundle\Container\Workshop\WorkshopContainer;
use Lc\PietroBundle\Container\Workshop\WorkshopThematicContainer;
@@ -33,7 +34,8 @@ trait ControllerTrait
WorkshopContainer::class => WorkshopContainer::class,
WorkshopThematicContainer::class => WorkshopThematicContainer::class,
EntryContainer::class => EntryContainer::class,
TypeContainer::class => TypeContainer::class
TypeContainer::class => TypeContainer::class,
SolutionContainer::class => SolutionContainer::class
]
);
}
@@ -97,4 +99,9 @@ trait ControllerTrait
{
return $this->get(TypeContainer::class);
}

public function getSolutionContainer(): SolutionContainer
{
return $this->get(SolutionContainer::class);
}
}

+ 30
- 0
Controller/Workshop/SolutionAdminController.php Переглянути файл

@@ -0,0 +1,30 @@
<?php

namespace Lc\PietroBundle\Controller\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\PietroBundle\Controller\AbstractAdminController;
use Lc\PietroBundle\Model\Workshop\EntryInterface;
use Lc\SovBundle\Generator\CsvGenerator;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Request;

abstract class SolutionAdminController extends AbstractAdminController
{
public function createEntity(string $entityFqcn)
{
return $this->getSolutionContainer()->getFactory()->create();
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getSolutionContainer()->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getSolutionContainer()->getFieldDefinition()->getFields($pageName);
}
}

+ 55
- 0
Definition/Field/Workshop/SolutionFieldDefinition.php Переглянути файл

@@ -0,0 +1,55 @@
<?php

namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\PietroBundle\Repository\Workshop\WorkshopStore;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Translation\TranslatorAdmin;

class SolutionFieldDefinition extends AbstractFieldDefinition
{
protected WorkshopStore $workshopStore;

public function __construct(TranslatorAdmin $translatorAdmin, WorkshopStore $workshopStore)
{
parent::__construct($translatorAdmin);

$this->workshopStore = $workshopStore;
}

public function configureIndex(): array
{
return [
'workshop',
'title',
'status'
];
}

public function configureForm(): array
{
return [
'workshop',
'title',
'description',
'videoLink',
'status'
];
}

public function configureFields(): array
{
$workshopArray = $this->workshopStore->get();

return [
'workshop' => AssociationField::new('workshop')
->setFormTypeOption('choices', $workshopArray),
'title' => TextField::new('title'),
'description' => CKEditorField::new('description'),
'videoLink' => TextField::new('videoLink'),
];
}
}

+ 4
- 2
Definition/Field/Workshop/WorkshopFieldDefinition.php Переглянути файл

@@ -3,8 +3,6 @@
namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\PietroBundle\Repository\Workshop\WorkshopThematicStore;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
@@ -41,6 +39,8 @@ class WorkshopFieldDefinition extends AbstractFieldDefinition
'hook',
'title',
'description',
'emailContact',
'website',
'status'
];
}
@@ -56,6 +56,8 @@ class WorkshopFieldDefinition extends AbstractFieldDefinition
'title' => TextField::new('title'),
'hook' => TextField::new('hook'),
'description' => CKEditorField::new('description'),
'emailContact' => TextField::new('emailContact'),
'website' => TextField::new('website'),
'entries' => AssociationField::new('entries')
->setTemplatePath('@LcPietro/admin/workshop/field/entries.html.twig')
];

+ 18
- 0
Factory/Workshop/SolutionFactory.php Переглянути файл

@@ -0,0 +1,18 @@
<?php

namespace Lc\PietroBundle\Factory\Workshop;

use App\Entity\Workshop\Solution;
use Lc\SovBundle\Factory\AbstractFactory;

class SolutionFactory extends AbstractFactory
{
public function create(): Solution
{
$solution = new Solution();

$solution->setStatus(1);

return $solution;
}
}

+ 47
- 0
Model/Workshop/Solution.php Переглянути файл

@@ -0,0 +1,47 @@
<?php

namespace Lc\PietroBundle\Model\Workshop;

use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;

/**
* @ORM\MappedSuperclass()
*/
abstract class Solution extends AbstractFullEntity implements SolutionInterface, EntityInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopInterface", inversedBy="solutions")
*/
protected $workshop;

/**
* @ORM\Column(type="string", length=256, nullable=true)
*/
protected $videoLink;

public function getWorkshop(): ?WorkshopInterface
{
return $this->workshop;
}

public function setWorkshop(WorkshopInterface $workshop): self
{
$this->workshop = $workshop;

return $this;
}

public function getVideoLink(): ?string
{
return $this->videoLink;
}

public function setVideoLink(?string $videoLink): self
{
$this->videoLink = $videoLink;

return $this;
}
}

+ 8
- 0
Model/Workshop/SolutionInterface.php Переглянути файл

@@ -0,0 +1,8 @@
<?php

namespace Lc\PietroBundle\Model\Workshop;

interface SolutionInterface
{

}

+ 82
- 0
Model/Workshop/Workshop.php Переглянути файл

@@ -33,6 +33,26 @@ abstract class Workshop extends AbstractFullEntity implements WorkshopInterface,
*/
protected $hook;

/**
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Workshop\SolutionInterface", mappedBy="workshop", cascade={"persist", "remove"})
*/
protected $solutions;

/**
* @ORM\Column(type="string", length=256, nullable=true)
*/
protected $videoLink;

/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
protected $emailContact;

/**
* @ORM\Column(type="string", length=256, nullable=true)
*/
protected $website;

public function __construct()
{
$this->entries = new ArrayCollection();
@@ -104,4 +124,66 @@ abstract class Workshop extends AbstractFullEntity implements WorkshopInterface,

return $this;
}

public function getVideoLink(): ?string
{
return $this->videoLink;
}

public function setVideoLink(?string $videoLink): self
{
$this->videoLink = $videoLink;

return $this;
}

/**
* @return Collection|SolutionInterface[]
*/
public function getSolutions(): Collection
{
return $this->solutions;
}

public function addSolution(SolutionInterface $solution): self
{
if (!$this->solutions->contains($solution)) {
$this->solutions[] = $solution;
}

return $this;
}

public function removeSolution(SolutionInterface $solution): self
{
if ($this->solutions->contains($solution)) {
$this->solutions->removeElement($solution);
}

return $this;
}

public function getEmailContact(): ?string
{
return $this->emailContact;
}

public function setEmailContact(string $emailContact): self
{
$this->emailContact = $emailContact;

return $this;
}

public function getWebsite(): ?string
{
return $this->website;
}

public function setWebsite(string $website): self
{
$this->website = $website;

return $this;
}
}

+ 15
- 0
Repository/Workshop/SolutionRepository.php Переглянути файл

@@ -0,0 +1,15 @@
<?php

namespace Lc\PietroBundle\Repository\Workshop;

use App\Entity\Workshop\Solution;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository;

class SolutionRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Solution::class);
}
}

+ 14
- 0
Repository/Workshop/SolutionRepositoryQuery.php Переглянути файл

@@ -0,0 +1,14 @@
<?php

namespace Lc\PietroBundle\Repository\Workshop;

use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class SolutionRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(SolutionRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'solution', $paginator);
}
}

+ 32
- 0
Repository/Workshop/SolutionStore.php Переглянути файл

@@ -0,0 +1,32 @@
<?php

namespace Lc\PietroBundle\Repository\Workshop;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class SolutionStore extends AbstractStore
{
protected SolutionRepositoryQuery $query;

public function __construct(SolutionRepositoryQuery $query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('position');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 12
- 0
Resources/translations/admin.fr.yaml Переглянути файл

@@ -40,6 +40,18 @@ entity:
label: Territoire
fields:
name: Nom
Workshop:
label: Atelier
label_plurial: Ateliers
fields:
workshopThematic: Thématique
entries: Inscriptions
type: Type
hook: Accroche
videoLink: Lien vidéo
emailContact: Email de contact
website: Site internet

form:
field:
dream:

Завантаження…
Відмінити
Зберегти