Skip to content

Commit

Permalink
Feat: Add column page.enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbart committed Oct 1, 2023
1 parent 8f0f3d9 commit 76f899c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Admin/PageAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use ProjetNormandie\PageBundle\Entity\Page;
Expand Down Expand Up @@ -45,6 +46,10 @@ protected function configureFormFields(FormMapper $form): void
'choices' => Page::getStatusChoices(),
]
)
->add('enabled', CheckboxType::class, [
'label' => 'label.enabled',
'required' => false,
])
->add('translations', TranslationsType::class, [
'required' => true,
'fields' => [
Expand Down Expand Up @@ -72,6 +77,7 @@ protected function configureListFields(ListMapper $list): void
]
)
->add('slug', null, ['label' => 'label.slug'])
->add('enabled', null, ['label' => 'label.enabled'])
->add('createdAt', null, ['label' => 'label.createdAt'])
->add('updatedAt', null, ['label' => 'label.updatedAt'])
->add('_action', 'actions', [
Expand All @@ -91,6 +97,7 @@ protected function configureShowFields(ShowMapper $show): void
->add('id', null, ['label' => 'label.id'])
->add('name', null, ['label' => 'label.name'])
->add('status', null, ['label' => 'label.status'])
->add('enabled', null, ['label' => 'label.enabled'])
->add('createdAt', null, ['label' => 'label.createdAt'])
->add('updatedAt', null, ['label' => 'label.updatedAt'])
->add('getText', null, ['label' => 'label.text', 'safe' => true]);
Expand Down
26 changes: 26 additions & 0 deletions src/Entity/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Page implements TimestampableInterface, TranslatableInterface, SluggableIn
*/
private string $status = self::STATUS_PUBLIC;

/**
* @ORM\Column(name="enabled", type="boolean", nullable=false, options={"default":true})
*/
private bool $enabled = true;


/**
* @return string
Expand Down Expand Up @@ -128,6 +133,27 @@ public function getStatus(): string
return $this->status;
}

/**
* Set enabled
* @param bool $enabled
* @return $this
*/
public function setEnabled(bool $enabled): Page
{
$this->enabled = $enabled;

return $this;
}

/**
* Get $enabled
* @return bool
*/
public function getEnabled(): bool
{
return $this->enabled;
}

/**
* @param string $title
* @return $this
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/config/serialization/Page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ ProjetNormandie\PageBundle\Entity\Page:
groups:
- 'page.read'
- 'page.list'
enabled:
groups:
- 'page.read'
- 'page.list'
name:
groups:
- 'page.read'
Expand Down

0 comments on commit 76f899c

Please sign in to comment.