-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Controller\Admin; | ||
|
||
use App\Entity\WorkGroup; | ||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\{ IdField, FormField, BooleanField, TextField, UrlField, EmailField, AssociationField }; | ||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||
|
||
class WorkGroupCrud extends AbstractCrudController | ||
{ | ||
// it must return a FQCN (fully-qualified class name) of a Doctrine ORM entity | ||
public static function getEntityFqcn(): string | ||
{ | ||
return WorkGroup::class; | ||
} | ||
|
||
public function configureCrud(Crud $crud): Crud | ||
{ | ||
return $crud | ||
->setEntityLabelInSingular('werkgroep') | ||
->setEntityLabelInPlural('Werkgroepen') | ||
->setEntityPermission('ROLE_ADMIN') | ||
; | ||
} | ||
|
||
public function configureFields(string $pageName): iterable | ||
{ | ||
return [ | ||
IdField::new('id')->hideOnForm(), | ||
TextField::new('name', 'Werkgroepnaam'), | ||
AssociationField::new('contact', 'Contactpersoon'), | ||
AssociationField::new('members', 'Leden')->hideOnIndex(), | ||
FormField::addPanel('Contactinformatie'), | ||
AssociationField::new('email', 'E-mailadres'), | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\Common\Collections\{ ArrayCollection, Collection }; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table("admin_workgroup") | ||
*/ | ||
class WorkGroup { | ||
|
||
/** | ||
* @ORM\Column(type="integer", options={ "unsigned": false }) | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private ?int $id = null; | ||
|
||
/** | ||
* @ORM\Column(type="string", length=50) | ||
*/ | ||
private string $name = ''; | ||
|
||
/** @ORM\ManyToOne(targetEntity="Member") | ||
* @ORM\JoinColumn(nullable=true) | ||
*/ | ||
private ?Member $contact = null; | ||
|
||
/** | ||
* @ORM\ManyToMany(targetEntity="Member", mappedBy="workGroups") | ||
*/ | ||
private Collection $members; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="Email") | ||
* @ORM\JoinColumn(nullable=true) | ||
*/ | ||
private ?Email $email = null; | ||
|
||
public function __construct() { | ||
$this->members = new ArrayCollection(); | ||
} | ||
|
||
public function __toString() { | ||
return $this->name; | ||
} | ||
|
||
public function getId(): ?int { return $this->id; } | ||
|
||
public function getName(): string { return $this->name; } | ||
public function setName(string $name): void { $this->name = $name; } | ||
|
||
public function getMembers(): Collection { return $this->members; } | ||
|
||
public function addMember(Member $member): self { | ||
if (!$this->members->contains($member)) { | ||
$this->members[] = $member; | ||
} | ||
return $this; | ||
} | ||
public function removeMember(Member $member): self { | ||
if ($this->members->contains($member)) { | ||
$this->members->removeElement($member); | ||
} | ||
return $this; | ||
} | ||
|
||
public function getContact(): ?Member { return $this->contact; } | ||
public function setContact(?Member $contact): void { $this->contact = $contact; } | ||
|
||
public function getEmail(): ?Email { return $this->email; } | ||
public function setEmail(?Email $email): void { $this->email = $email; } | ||
} |