/** * Convert to an array suitable for use as Twitter Card structured properties * * @since 1.0.0 * * @return array { * @type string Twitter card property * @type mixed property value * } */ public function toArray() { $card = parent::toArray(); $image_properties = $this->imageCardProperties(); if (!empty($image_properties)) { $card['image'] = $image_properties; } unset($image_properties); if (isset($this->creator) && $this->creator) { $creator = $this->creator->asCardProperties(); if ($creator) { $card['creator'] = $creator; } unset($creator); } return $card; }
/** * Convert to an array suitable for use as Twitter Card structured properties * * @since 1.0.0 * * @return array { * @type string Twitter card property * @type string|array property value * } */ public function toArray() { $card = parent::toArray(); if (isset($this->description) && $this->description) { $card['description'] = $this->description; } $image_properties = $this->imageCardProperties(); if (!empty($image_properties)) { $card['image'] = $image_properties; } unset($image_properties); if (!empty($this->details)) { // product card table is 1-based $details_position = 1; foreach ($this->details as $label => $data) { $card['label' . $details_position] = $label; $card['data' . $details_position] = $data; $details_position++; } unset($details_position); } if (isset($this->creator) && $this->creator) { $creator = $this->creator->asCardProperties(); if ($creator) { $card['creator'] = $creator; } unset($creator); } return $card; }
/** * Convert to an array suitable for use as Twitter Card structured properties * * @since 1.0.0 * * @return array { * @type string Twitter card property * @type mixed property value * } */ public function toArray() { $card = parent::toArray(); $images = $this->getImages(); if (!empty($images)) { $image_count = count($images); // flatten to just \Twitter\Cards\Components\Image $images = array_values($images); for ($i = 0; $i < $image_count; $i++) { $card['image' . $i] = $images[$i]->asCardProperties(); } unset($image_count); } unset($images); if (isset($this->creator) && $this->creator) { $creator = $this->creator->asCardProperties(); if ($creator) { $card['creator'] = $creator; } unset($creator); } return $card; }