public function ParagraphsClassBehavior::view in Paragraphs Class 8
Extends the paragraph render array with behavior.
Parameters
array &$build: A renderable array representing the paragraph. The module may add elements to $build prior to rendering. The structure of $build is a renderable array as expected by drupal_render().
\Drupal\paragraphs\Entity\Paragraph $paragraph: The paragraph.
\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The entity view display holding the display options configured for the entity components.
string $view_mode: The view mode the entity is rendered in.
Return value
array A render array provided by the plugin.
Overrides ParagraphsBehaviorInterface::view
File
- src/
Plugin/ paragraphs/ Behavior/ ParagraphsClassBehavior.php, line 34
Class
- ParagraphsClassBehavior
- Custom paragraph wrapper class.
Namespace
Drupal\paragraphs_class\Plugin\paragraphs\BehaviorCode
public function view(array &$build, Paragraph $paragraph, EntityViewDisplayInterface $display, $view_mode) {
$class = $paragraph
->getBehaviorSetting($this
->getPluginId(), 'wrapper_class');
$build['#attributes']['class'][] = $class;
}