1. Go to this page and download the library: Download hpodevteam/page-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hpodevteam / page-bundle example snippets
namespace App\Entity;
use App\Repository\PageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Hippocampe\Bundle\PageBundle\Traits\SectionWidget;
/**
* @ORM\Entity(repositoryClass=PageRepository::class)
*/
class Page
{
use SectionWidget;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
//
public function getId(): ?int
{
return $this->id;
}
//
}
namespace App\Controller\Admin;
use App\Entity\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Hippocampe\Bundle\PageBundle\Form\Admin\Type\SectionRowType;
class PageCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Page::class;
}
public function configureCrud(Crud $crud): Crud
{
return $crud
// You can use your own templates here and extends @Page/admin/entity/{actions}.html.twig
->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);
}
}
{YourEntity}CrudController.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.