Lavary\Menu\Builder::formatGroupClass PHP Method

formatGroupClass() public static method

Get the valid attributes from the options.
public static formatGroupClass ( $new, $old ) : string
return string
    public static function formatGroupClass($new, $old)
    {
        if (isset($new['class'])) {
            $classes = trim(trim(array_get($old, 'class')) . ' ' . trim(array_get($new, 'class')));
            return implode(' ', array_unique(explode(' ', $classes)));
        }
        return array_get($old, 'class');
    }

Usage Example

コード例 #1
0
ファイル: Item.php プロジェクト: vdjkelly/laravel-menu
 /**
  * Make the item active
  *
  * @return Lavary\Menu\Item
  */
 public function active($pattern = null)
 {
     if (!is_null($pattern)) {
         $pattern = ltrim(preg_replace('/\\/\\*/', '(/.*)?', $pattern), '/');
         if (preg_match("@^{$pattern}\\z@", \Request::path())) {
             $this->activate();
         }
         return $this;
     }
     $this->attributes['class'] = Builder::formatGroupClass(array('class' => $this->builder->conf('active_class')), $this->attributes);
     return $this;
 }