Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hpodevteam/pagebundle

This bundle is used to create section page with EasyAdmin > 3
https://github.com/hpodevteam/pagebundle

doctrine orm symfony symfony-bundle

Last synced: 24 days ago
JSON representation

This bundle is used to create section page with EasyAdmin > 3

Awesome Lists containing this project

README

        

# Page-bundle

## Installation
```bash
composer require "hpodevteam/page-bundle"
```

## Configuration

Open your ```config/packages/page.yaml``` file and add :

```yaml
page:
sections:
spacer: 'your spacing class'
colors:
color1:
name: 'Your color name'
value: '#fff'
# You can set other colors
```

Open your ```config/packages/vich_uploader.yaml``` file and add :

```yaml
parameters:
app.path.section_image: /uploads/section_image

vich_uploader:
mappings:
section_image:
uri_prefix: '%app.path.section_image%'
upload_destination: '%kernel.project_dir%/public/uploads/section_image'
namer: Vich\UploaderBundle\Naming\OrignameNamer

```

## Usage

Add trait ```SectionWidget``` to the entity to be managed.

```php
id;
}

//
}
```

Then in ```{YourEntity}CrudController.php``` file

```php
overrideTemplates([
'crud/edit' => '@Page/admin/entity/edit.html.twig',
'crud/new' => '@Page/admin/entity/new.html.twig'
])
// This is mandatory
->setFormThemes(['@Page/admin/section/form_theme.html.twig'])
;
}

// Optionnal for tabs
// This allow you to redirect to parent instead of getting redirected to Crud::INDEX page
public function getRedirectResponseAfterSave(AdminContext $context, string $action): RedirectResponse
{
$submitButtonName = $context->getRequest()->request->all()['ea']['newForm']['btn'];

if (Action::SAVE_AND_RETURN === $submitButtonName) {
$url = $this->get(AdminUrlGenerator::class)
->setController('Entity\\To\\Redirect')
->setAction(Action::EDIT)
->setEntityId($yourEntityId);

return $this->redirect($url);
}

return parent::getRedirectResponseAfterSave($context, $action);
}
}
```