/** * {@inheritdoc} */ protected function registerAssets() { $config = $this->getConfig(); $theme = $config['theme']; $jsInit = new Snippet(); $jsInit->setCallback([$this, 'jsInitSnippet'])->setLocation(Target::AFTER_JS)->setPriority(99); return [new JavaScript('assets/highlightjs/highlight.pack.min.js'), new Stylesheet("assets/highlightjs/styles/{$theme}.css"), $jsInit]; }
public function tweet($what) { $app = $this->getContainer(); $asset = new Snippet(); $asset->setCallback('<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>')->setLocation(Target::END_OF_BODY); $app['asset.queue.snippet']->add($asset); if (is_numeric($what)) { $what = 'https://twitter.com/x/status/' . $what; } if (strpos($what, 'http') !== 0) { $what = 'https://' . $what; } $res = sprintf('<blockquote class="twitter-tweet" lang="en"> (loading tweet) <a href="%s">%s</a></blockquote>', $what, $what); return new \Twig_Markup($res, 'UTF-8'); }
protected function addAssets() { $app = $this->getContainer(); $config = $this->getConfig(); $pfill = $config['picturefill']; $extPath = $app['resources']->getUrl('extensions'); $vendor = 'vendor/cdowdy/'; $extName = 'boltpicture/'; $pictureFillJS = $extPath . $vendor . $extName . 'picturefill/' . $this->_currentPictureFill . '/picturefill.min.js'; $pictureFill = <<<PFILL <script src="{$pictureFillJS}" async defer></script> PFILL; $asset = new Snippet(); $asset->setCallback($pictureFill)->setZone(ZONE::FRONTEND)->setLocation(Target::AFTER_HEAD_CSS); // variable to check if script is added to the page if ($pfill) { if ($this->_scriptAdded) { $app['asset.queue.snippet']->add($asset); } else { $this->_scriptAdded = TRUE; } } }