public function setLayout($layout, Document $document = NULL) {
    $class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout';
    if (is_string($layout)) {
      // Check that layout exists.
      if ($document &&
          empty($document->getComponentLayouts()[$layout])
      ) {
        $this->triggerError("No component layout \"${layout}\" found.");
        return $this;
      }
    }
    elseif (!$layout instanceof $class) {
      $this->triggerError("Layout not of class ${class}.");
      return $this;
    }
    $this->layout = $layout;
    return $this;
  }
public function setLayout($layout, Document $document = NULL) {
    $class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout';
    if (is_string($layout)) {
      // Check that layout exists.
      if ($document &&
          empty($document->getComponentLayouts()[$layout])
      ) {
        $this->triggerError("No component layout \"${layout}\" found.");
        return $this;
      }
    }
    elseif (!$layout instanceof $class) {
      $this->triggerError("Layout not of class ${class}.");
      return $this;
    }
    $this->layout = $layout;
    return $this;
  }
public function setLayout ( $ layout , Document $ document = NULL ) { $ class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout' ; if ( is_string ( $ layout ) ) { // Check that layout exists. if ( $ document && empty ( $ document -> getComponentLayouts ( ) [ $ layout ] ) ) { $ this -> triggerError ( "No component layout \"${layout}\" found." ) ; return $ this ; } } elseif ( ! $ layout instanceof $ class ) { $ this -> triggerError ( "Layout not of class ${class}." ) ; return $ this ; } $ this -> layout = $ layout ; return $ this ; }
Setter for layout.

@param \ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout|string $layout
Either a ComponentLayout object, or a string reference to one defined in
$document.
@param \ChapterThree\AppleNewsAPI\Document|NULL $document
If required by first parameter.

@return $this
Setter for layout .