Newscoop\Entity\Article::getData PHP Method

getData() public method

Get article type field data.
public getData ( string $field ) : mixed
$field string
return mixed
    public function getData($field)
    {
        if ($this->data === null) {
            $this->data = new \ArticleData($this->type, $this->number, $this->getLanguageId());
        }
        if ($field == null) {
            return $this->data;
        }
        if (is_array($this->data)) {
            return array_key_exists($field, $this->data) ? $this->data[$field] : null;
        } else {
            return $this->data->getFieldValue($field);
        }
    }

Usage Example

Example #1
0
 /**
  * Get article switches
  *
  * @param Newscoop\Entity\Article $article
  * @return array
  */
 public function getArticleSwitches($article)
 {
     $switches = array();
     foreach ($this->switches as $switch) {
         try {
             if ($article->getData($switch)) {
                 $switches[] = $switch;
             }
         } catch (\Exception $e) {
             /*just ignore if switch don't exists*/
         }
     }
 }
All Usage Examples Of Newscoop\Entity\Article::getData