protected function filterByContext($items, $context)
    {
        $filteredItems = [];
        foreach ($items as $categoryName => $category) {

            $filteredCategory = [];
            foreach ($category as $item) {
                $itemContext = is_array($item->context) ? $item->context : [$item->context];
                if (in_array($context, $itemContext)) {
                    $filteredCategory[] = $item;
                }
            }

            if (count($filteredCategory)) {
                $filteredItems[$categoryName] = $filteredCategory;
            }
        }

        return $filteredItems;
    }
protected function filterByContext($items, $context)
    {
        $filteredItems = [];
        foreach ($items as $categoryName => $category) {

            $filteredCategory = [];
            foreach ($category as $item) {
                $itemContext = is_array($item->context) ? $item->context : [$item->context];
                if (in_array($context, $itemContext)) {
                    $filteredCategory[] = $item;
                }
            }

            if (count($filteredCategory)) {
                $filteredItems[$categoryName] = $filteredCategory;
            }
        }

        return $filteredItems;
    }
protected function filterByContext ( $ items , $ context ) { $ filteredItems = [ ] ; foreach ( $ items as $ categoryName => $ category ) { $ filteredCategory = [ ] ; foreach ( $ category as $ item ) { $ itemContext = is_array ( $ item -> context ) ? $ item -> context : [ $ item -> context ] ; if ( in_array ( $ context , $ itemContext ) ) { $ filteredCategory [ ] = $ item ; } } if ( count ( $ filteredCategory ) ) { $ filteredItems [ $ categoryName ] = $ filteredCategory ; } } return $ filteredItems ; }
Filters a set of items by a given context.
@param  array $items
@param  string $context
@return array
Filters a set of items by a given context .