<?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; | |||||
} | |||||
} |
use Lc\PietroBundle\Container\Territory\TerritoryContainer; | use Lc\PietroBundle\Container\Territory\TerritoryContainer; | ||||
use Lc\PietroBundle\Container\Thematic\ThematicContainer; | use Lc\PietroBundle\Container\Thematic\ThematicContainer; | ||||
use Lc\PietroBundle\Container\Workshop\EntryContainer; | use Lc\PietroBundle\Container\Workshop\EntryContainer; | ||||
use Lc\PietroBundle\Container\Workshop\SolutionContainer; | |||||
use Lc\PietroBundle\Container\Workshop\TypeContainer; | use Lc\PietroBundle\Container\Workshop\TypeContainer; | ||||
use Lc\PietroBundle\Container\Workshop\WorkshopContainer; | use Lc\PietroBundle\Container\Workshop\WorkshopContainer; | ||||
use Lc\PietroBundle\Container\Workshop\WorkshopThematicContainer; | use Lc\PietroBundle\Container\Workshop\WorkshopThematicContainer; | ||||
WorkshopContainer::class => WorkshopContainer::class, | WorkshopContainer::class => WorkshopContainer::class, | ||||
WorkshopThematicContainer::class => WorkshopThematicContainer::class, | WorkshopThematicContainer::class => WorkshopThematicContainer::class, | ||||
EntryContainer::class => EntryContainer::class, | EntryContainer::class => EntryContainer::class, | ||||
TypeContainer::class => TypeContainer::class | |||||
TypeContainer::class => TypeContainer::class, | |||||
SolutionContainer::class => SolutionContainer::class | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
{ | { | ||||
return $this->get(TypeContainer::class); | return $this->get(TypeContainer::class); | ||||
} | } | ||||
public function getSolutionContainer(): SolutionContainer | |||||
{ | |||||
return $this->get(SolutionContainer::class); | |||||
} | |||||
} | } |
<?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); | |||||
} | |||||
} |
<?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'), | |||||
]; | |||||
} | |||||
} |
namespace Lc\PietroBundle\Definition\Field\Workshop; | namespace Lc\PietroBundle\Definition\Field\Workshop; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | 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 EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\PietroBundle\Repository\Workshop\WorkshopThematicStore; | use Lc\PietroBundle\Repository\Workshop\WorkshopThematicStore; | ||||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Workshop; | |||||
interface SolutionInterface | |||||
{ | |||||
} |
*/ | */ | ||||
protected $hook; | 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; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->entries = new ArrayCollection(); | $this->entries = new ArrayCollection(); | ||||
return $this; | 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; | |||||
} | |||||
} | } |
<?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); | |||||
} | |||||
} |
<?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); | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |