3 namespace Drupal\bootstrap_layouts\Plugin\BootstrapLayouts;
5 use Drupal\bootstrap_layouts\BootstrapLayout;
6 use Drupal\Core\Plugin\PluginBase;
7 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Class BootstrapLayoutsHandlerBase
13 abstract class BootstrapLayoutsHandlerBase extends PluginBase implements BootstrapLayoutsHandlerInterface {
15 use ContainerAwareTrait;
20 public function __construct(array $configuration, $plugin_id, $plugin_definition, ContainerInterface $container = NULL) {
21 parent::__construct($configuration, $plugin_id, $plugin_definition);
22 if (!isset($container)) {
23 $container = \Drupal::getContainer();
25 $this->setContainer($container);
31 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
32 return new static($configuration, $plugin_id, $plugin_definition, $container);
38 public function getLabel() {
39 return isset($this->pluginDefinition['label']) ? $this->pluginDefinition['label'] : $this->getPluginId();
45 public function loadInstance($entity_id) {
46 $layouts = $this->loadInstances([$entity_id]);
47 return reset($layouts);
53 public function saveInstance($entity_id, BootstrapLayout $layout) {
54 $this->saveInstances([$entity_id => $layout]);