public function asViewMode($viewMode, callable $method)
    {
        $prevViewMode = $this->viewMode();
        $this->viewMode($viewMode);
        $method();
        $this->viewMode($prevViewMode);
    }
public function asViewMode($viewMode, callable $method)
    {
        $prevViewMode = $this->viewMode();
        $this->viewMode($viewMode);
        $method();
        $this->viewMode($prevViewMode);
    }
public function asViewMode ( $ viewMode , callable $ method ) { $ prevViewMode = $ this -> viewMode ( ) ; $ this -> viewMode ( $ viewMode ) ; $ method ( ) ; $ this -> viewMode ( $ prevViewMode ) ; }
Runs the given callable as it were under the given view mode.

### Usage

```php
$this->viewMode('full');
echo 'before: ' . $this->viewMode();

echo $this->asViewMode('teaser', function () {
echo 'callable: ' . $this->viewMode();
});

echo 'after: ' . $this->viewMode();

// output:
// before: full
// callable: teaser
// after: full
```

@param string|array $viewMode View Mode slug, or an array of slugs
@param callable $method A callable function to run, it receives `$this` as
only argument
@return mixed Callable return
Runs the given callable as it were under the given view mode .