PHP code example of agence-adeliom / easy-block-bundle
1. Go to this page and download the library: Download agence-adeliom/easy-block-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/ */
agence-adeliom / easy-block-bundle example snippets
namespace App\Controller\Admin;
...
use App\Entity\EasyFaq\Entry;
use App\Entity\EasyFaq\Category;
class DashboardController extends AbstractDashboardController
{
...
public function configureMenuItems(): iterable
{
...
yield MenuItem::linkToCrud('easy.block.admin.menu.shared_blocks', 'fa fa-file-alt', Block::class);
...
class ArticleCrudController extends AbstractCrudController
{
public function configureFields(string $pageName): iterable
{
yield AssociationField::new('block');
}
}
# block is an entity object
{{ easy_block(block) }}
# render with extra data
{{ easy_block(block, extra) }}
# render by key
{{ easy_block(key, extra) }}
use Symfony\Contracts\EventDispatcher\Event;
$dispatcher->addListener('easy_block.render_block', function (Event $event) {
// will be executed when the easy_block.render_block event is dispatched
// Get
$block = $event->getArgument('block');
$blockType = $event->getArgument('blockType');
$settings = $event->getArgument('settings');
// Set
$event->setArgument("block", $block);
$event->setArgument("blockType", $blockType);
$event->setArgument("settings", $settings);
});