Всем привет, два месяца назад занялся изучением Drupal. Дошел до создания плагинов для ParagraphBehevior, но имею проблему, параграф не отображается в настройках в админке
<?php
namespace Drupal\Blog_paragraphs\Plugin\Paragraphs\Behavior;
use
Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\paragraphs\ParagraphInterface;
use Drupal\paragraphs\ParagraphsBehaviorBase;
use Drupal\paragraphs\Annotation\ParagraphsBehavior;
/**
* Provides a paragraphs behaviour plugin for background styles.
*
* @ParagraphsBehavior(
* id = "ParagraphBehaviorGallery",
* label = @Translation("Test text"),
* description = @Translation("description text"),
* )
*/
class ParagraphBehaviorGallery extends ParagraphsBehaviorBase {
public static function
isApplicable(ParagraphsType $paragraphs_type) {
return $paragraphs_type->id()=='paragraph_test1';
}
public function
view(array &$build, Paragraph $paragraph, EntityViewDisplayInterface $display, $view_mode) {
// TODO: Implement view() method.
}
public function
buildBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
$form ["items_per_row"] = [
'#type' => 'select',
'#title' => $this->t('Number of images per row'),
'#options' => $this->getGallaryOptions() ,
];
return $form;
}
private function
getGallaryOptions() {
return [
"2" => $this->formatPlural('2', "1 Photo per row", "@count photos per row"),
"3" => $this->formatPlural('3', "1 Photo per row", "@count photos per row"),
"4" => $this->formatPlural('4', "1 Photo per row", "@count photos per row"),
];
}
}
?>
Комментарии
Не работает плагин