Exemplo n.º 1
0
 /**
  * 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
  */
 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;
 }
Exemplo n.º 2
0
 /**
  * Setter for style.
  *
  * @param \ChapterThree\AppleNewsAPI\Document\Styles\ComponentStyle|string $style
  *   Either a ComponentStyle object, or a string reference to one defined in
  *   $document.
  * @param \ChapterThree\AppleNewsAPI\Document|NULL $document
  *   If required by first parameter.
  *
  * @return $this
  */
 public function setStyle($style, Document $document = NULL)
 {
     $class = 'ChapterThree\\AppleNewsAPI\\Document\\Styles\\ComponentStyle';
     if (is_string($style)) {
         // Check that style exists.
         if ($document && empty($document->getComponentLayouts()[$style])) {
             $this->triggerError("No component style \"{$style}\" found.");
             return $this;
         }
     } elseif (!$style instanceof $class) {
         $this->triggerError("Style not of class {$class}.");
         return $this;
     }
     $this->style = $style;
     return $this;
 }