original_string: public function asViewMode($viewMode, callable $method)
      {
          $prevViewMode = $this->viewMode();
          $this->viewMode($viewMode);
          $method();
          $this->viewMode($prevViewMode);
      }
code: public function asViewMode($viewMode, callable $method)
      {
          $prevViewMode = $this->viewMode();
          $this->viewMode($viewMode);
          $method();
          $this->viewMode($prevViewMode);
      }
code_tokens: public function asViewMode ( $ viewMode , callable $ method ) { $ prevViewMode = $ this -> viewMode ( ) ; $ this -> viewMode ( $ viewMode ) ; $ method ( ) ; $ this -> viewMode ( $ prevViewMode ) ; }
docstring: 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
docstring_tokens: Runs the given callable as it were under the given view mode .