PHP code example of amazeelabs / silverback_gutenberg
1. Go to this page and download the library: Download amazeelabs/silverback_gutenberg 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/ */
amazeelabs / silverback_gutenberg example snippets
namespace Drupal\custom_gutenberg\Plugin\Validation\GutenbergValidator;
use Drupal\silverback_gutenberg\GutenbergValidation\GutenbergValidatorBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* @GutenbergValidator(
* id="my_block_validator",
* label = @Translation("My block validator")
* )
*/
class MyBlockValidator extends GutenbergValidatorBase {
use StringTranslationTrait;
/**
* {@inheritDoc}
*/
public function applies(array $block) {
return $block['blockName'] === 'custom/my-block';
}
/**
* {@inheritDoc}
*/
public function validatedFields(array $block = []) {
return [
'email' => [
'field_label' => $this->t('Email'),
'rules' => ['