4 * Contains \Drupal\bootstrap\Plugin\PrerenderManager.
7 namespace Drupal\bootstrap\Plugin;
9 use Drupal\bootstrap\Theme;
10 use Drupal\bootstrap\Utility\Element;
13 * Manages discovery and instantiation of Bootstrap pre-render callbacks.
15 * @ingroup plugins_prerender
17 class PrerenderManager extends PluginManager {
20 * Constructs a new \Drupal\bootstrap\Plugin\PrerenderManager object.
22 * @param \Drupal\bootstrap\Theme $theme
23 * The theme to use for discovery.
25 public function __construct(Theme $theme) {
26 parent::__construct($theme, 'Plugin/Prerender', 'Drupal\bootstrap\Plugin\Prerender\PrerenderInterface', 'Drupal\bootstrap\Annotation\BootstrapPrerender');
27 $this->setCacheBackend(\Drupal::cache('discovery'), 'theme:' . $theme->getName() . ':prerender', $this->getCacheTags());
31 * Pre-render render array element callback.
33 * @param array $element
34 * The render array element.
37 * The modified render array element.
39 public static function preRender(array $element) {
40 if (!empty($element['#bootstrap_ignore_pre_render'])) {
44 $e = Element::create($element);
46 if ($e->isType('machine_name')) {
47 $e->addClass('form-inline', 'wrapper_attributes');
50 // Add smart descriptions to the element, if necessary.
51 $e->smartDescription();