$item) { $list[] = ["@type" => "ListItem", "position" => $index + 1, "url" => $item["url"], "name" => $item["name"]]; } return [ "@context" => self::CONTEXT, "@graph" => [ [ "@type" => "CollectionPage", "@id" => $url . "#webpage", "url" => $url, "name" => $name, "description" => $description, "inLanguage" => LANGUAGE_ID, "about" => ["@id" => Config::host() . "/#store"], "mainEntity" => ["@id" => $url . "#offers"], "workTranslation" => PageSchema::translations($path, "CollectionPage"), ], [ "@type" => "ItemList", "@id" => $url . "#offers", "url" => $url, "numberOfItems" => count($list), "itemListElement" => $list, ], ], ]; } public static function detail(array $offer): array { $url = Config::host() . $offer["path"]; $store = ["@id" => Config::host() . "/#store"]; $event = [ "@type" => "SaleEvent", "@id" => $url . "#event", "url" => $url, "name" => $offer["name"], "description" => $offer["description"], "inLanguage" => LANGUAGE_ID, "eventStatus" => "https://schema.org/EventScheduled", "eventAttendanceMode" => "https://schema.org/MixedEventAttendanceMode", "location" => $store, "organizer" => $store, ]; foreach (["startDate" => "start", "endDate" => "end"] as $property => $key) { if ($offer[$key] !== "") { $event[$property] = $offer[$key]; } } $page = [ "@type" => "WebPage", "@id" => $url . "#webpage", "url" => $url, "name" => $offer["name"], "description" => $offer["description"], "inLanguage" => LANGUAGE_ID, "mainEntity" => ["@id" => $url . "#event"], "workTranslation" => PageSchema::translations($offer["path"], "WebPage"), ]; if ($offer["image"]) { $event["image"] = PageSchema::image($url . "#image", $offer["image"]["url"], $offer["image"]["width"], $offer["image"]["height"]); $page["primaryImageOfPage"] = ["@id" => $url . "#image"]; } return ["@context" => self::CONTEXT, "@graph" => [$page, $event]]; } public static function date(string $value): string { return $value !== "" ? date(DATE_ATOM, DateTime::createFromUserTime($value)->getTimestamp()) : ""; } }