Collective\Html\HtmlBuilder::style PHP Method

style() public method

Generate a link to a CSS file.
public style ( string $url, array $attributes = [], boolean $secure = null ) : Illuminate\Support\HtmlString
$url string
$attributes array
$secure boolean
return Illuminate\Support\HtmlString
    public function style($url, $attributes = [], $secure = null)
    {
        $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
        $attributes = $attributes + $defaults;
        $attributes['href'] = $this->url->asset($url, $secure);
        return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
    }

Usage Example

Beispiel #1
0
 /**
  * Generate a link to a CSS file. With Stylist, this could actually generate
  * numerous style tags, due to CSS inheritance requirements.
  *
  * @param  string  $url
  * @param  array   $attributes
  * @param  bool    $secure
  * @return string
  */
 public function style($url, $attributes = array(), $secure = null)
 {
     $styles = [];
     $theme = StylistFacade::current();
     // If our theme has a parent, we want its stylesheet, as well.
     // @todo: This is dog-ugly - need to figure out a better approach.
     if ($theme->hasParent()) {
         $parent = StylistFacade::get($theme->getParent());
         StylistFacade::activate($parent);
         $styles[] = $this->style($url, $attributes, $secure);
         StylistFacade::activate($theme);
     }
     $styles[] = $this->html->style($this->assetUrl($url), $attributes, $secure);
     return implode("\n", $styles);
 }
All Usage Examples Of Collective\Html\HtmlBuilder::style