BlazyStylePluginBase.php in Blazy 8
File
src/Dejavu/BlazyStylePluginBase.php
View source
<?php
namespace Drupal\blazy\Dejavu;
use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\blazy\BlazyManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class BlazyStylePluginBase extends StylePluginBase {
use BlazyStyleBaseTrait;
use BlazyStylePluginTrait;
protected $usesRowPlugin = TRUE;
protected $usesGrouping = FALSE;
public function __construct(array $configuration, $plugin_id, $plugin_definition, BlazyManagerInterface $blazy_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->blazyManager = $blazy_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('blazy.manager'));
}
public function buildElement(array &$element, $row, $index) {
$settings =& $element['settings'];
$item_id = empty($settings['item_id']) ? 'box' : $settings['item_id'];
if (!empty($settings['image'])) {
$image = $this
->getImageRenderable($settings, $row, $index);
$element['item'] = $this
->getImageItem($image);
$element[$item_id] = empty($image['rendered']) ? [] : $image['rendered'];
}
$element['caption'] = $this
->getCaption($index, $settings);
if (!empty($settings['layout'])) {
$this
->getLayout($settings, $index);
}
}
}