Fix `MetadataService->apply_layout()`

When `search_with_layout()` is called with `$view = null` no `items` 
will be returned and the foreach will fail.