PHP code example of agence-adeliom / easy-gutenberg-bundle
1. Go to this page and download the library: Download agence-adeliom/easy-gutenberg-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-gutenberg-bundle example snippets
namespace App\Controller\Admin;
...
use App\Entity\EasyFaq\Entry;
use App\Entity\EasyFaq\Category;
abstract class PageCrudController extends AbstractCrudController
{
...
public function configureCrud(Crud $crud): Crud
{
return parent::configureCrud($crud)
// Add the form theme
->addFormTheme('@EasyGutenberg/form/gutenberg_widget.html.twig')
;
}
public function configureFields(string $pageName): iterable
{
...
yield GutenbergField::new("content");
...
namespace App\Blocks;
use Adeliom\EasyGutenbergBundle\Blocks\AbstractBlockType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class TwoColsType extends AbstractBlockType
{
public function buildBlock(FormBuilderInterface $builder, array $options): void
{
$builder->add("left_col", TextType::class, ["label" => 'Left column content']);
$builder->add("right_col", TextType::class, ["label" => 'Right column content']);
}
public static function getName(): string
{
return 'Two columns';
}
public static function getDescription(): string
{
return 'Make a two columns layout';
}
public static function getIcon(): string
{
return '';
}
public static function getTemplate(): string
{
return "blocks/two_cols.html.twig";
}
}
# This convert and render the content
{{ easy_gutenberg(page.content) }}
# This render the blocks's assets must be called after 'easy_gutenberg'
{{ easy_gutenberg_assets() }}
public static function configureAssets(): array
{
return [
'js' => [],
'css' => [],
'webpack' => [],
];
}
public static function configureAdminAssets(): array
{
return [
'js' => [],
'css' => [],
];
}
public static function configureAdminFormTheme(): array
{
return [];
}
public static function getCategory(): string
{
return 'common';
}
public static function getVariations(): array
{
return [
[
"name": 'variation_with_bg',
"isDefault": true,
"title": "Variation With background",
"icon": '',
"attributes": [
"with-bg": true
],
]
];
}
public static function getAttributes(): array
{
return [
"with-bg" => ['type' => 'boolean']
];
}
public static function getSupports(): array
{
return array_merge(parent::getSupports(),[
'align' => false,
]);
}
bash
php bin/console make:gutenberg
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.