Craft\SeomaticService::getCreatorJSONLD PHP Method

getCreatorJSONLD() public method

* -------------------------------------------------------------------------------- Get the Creator JSON-LD --------------------------------------------------------------------------------
public getCreatorJSONLD ( $creator, $helper, $locale )
    public function getCreatorJSONLD($creator, $helper, $locale)
    {
        /* -- Cache it in our class; no need to fetch it more than once */
        if (isset($this->cachedCreatorJSONLD[$locale])) {
            return $this->cachedCreatorJSONLD[$locale];
        }
        $creatorJSONLD = array();
        /* -- Settings generic to all Creator types */
        $creatorJSONLD['type'] = ucfirst($creator['siteCreatorType']);
        /*
                if ($creator['siteCreatorSubType'])
                    $creatorJSONLD['type'] = $creator['siteCreatorSubType'];
                if ($creator['siteCreatorSpecificType'])
                    $creatorJSONLD['type'] = $creator['siteCreatorSpecificType'];
        */
        $creatorJSONLD['name'] = $creator['genericCreatorName'];
        $creatorJSONLD['alternateName'] = $creator['genericCreatorAlternateName'];
        $creatorJSONLD['description'] = $creator['genericCreatorDescription'];
        $creatorJSONLD['url'] = $creator['genericCreatorUrl'];
        if ($creator['genericCreatorImage']) {
            $creatorImage = array("type" => "ImageObject", "url" => $creator['genericCreatorImage'], "height" => $creator['genericCreatorImageHeight'], "width" => $creator['genericCreatorImageWidth']);
        } else {
            $creatorImage = "";
        }
        if (isset($creator['genericCreatorImage'])) {
            $creatorJSONLD['image'] = $creatorImage;
        }
        $creatorJSONLD['telephone'] = $creator['genericCreatorTelephone'];
        $creatorJSONLD['email'] = $creator['genericCreatorEmail'];
        $address = array("type" => "PostalAddress", "streetAddress" => $creator['genericCreatorStreetAddress'], "addressLocality" => $creator['genericCreatorAddressLocality'], "addressRegion" => $creator['genericCreatorAddressRegion'], "postalCode" => $creator['genericCreatorPostalCode'], "addressCountry" => $creator['genericCreatorAddressCountry']);
        $address = array_filter($address);
        $creatorJSONLD['address'] = $address;
        if (count($creatorJSONLD['address']) == 1) {
            unset($creatorJSONLD['address']);
        }
        /* -- This needs to be an additional fieldtype if we implement it
                if ($creator['genericCreatorTelephone'])
                {
                    $contactPoint = array(
                        "type" => "ContactPoint",
                        "telephone" => $creator['genericCreatorTelephone'],
                        "contactType" => "Contact",
                    );
                    $contactPoint = array_filter($contactPoint);
                    $creatorJSONLD['contactPoint'] = array($contactPoint);
                }
        */
        /* -- Settings for all person Creator types */
        if ($creator['siteCreatorType'] == "Person") {
            $creatorJSONLD['gender'] = $creator['personCreatorGender'];
            $creatorJSONLD['birthPlace'] = $creator['personCreatorBirthPlace'];
        }
        /* -- Settings for all organization Creator types */
        if ($creator['siteCreatorType'] == "Organization" || $creator['siteCreatorType'] == "Corporation") {
            if (isset($creator['genericCreatorImage'])) {
                $creatorJSONLD['logo'] = $creatorImage;
            }
            $geo = array("type" => "GeoCoordinates", "latitude" => $creator['genericCreatorGeoLatitude'], "longitude" => $creator['genericCreatorGeoLongitude']);
            $geo = array_filter($geo);
            $locImage = "";
            if (isset($identity['genericCreatorImage'])) {
                $locImage = $creatorImage;
            }
            $location = array("type" => "Place", "name" => $creator['genericCreatorName'], "alternateName" => $creator['genericCreatorAlternateName'], "description" => $creator['genericCreatorDescription'], "hasMap" => $helper['creatorMapUrl'], "telephone" => $creator['genericCreatorTelephone'], "image" => $locImage, "logo" => $locImage, "url" => $creator['genericCreatorUrl'], "geo" => $geo, "address" => $address);
            $location = array_filter($location);
            $creatorJSONLD['location'] = $location;
            if (count($creatorJSONLD['location']['geo']) == 1) {
                unset($creatorJSONLD['location']['geo']);
            }
            if (count($creatorJSONLD['location']['address']) == 1) {
                unset($creatorJSONLD['location']['address']);
            }
            if (count($creatorJSONLD['location']) == 1) {
                unset($creatorJSONLD['location']);
            }
            $creatorJSONLD['duns'] = $creator['organizationCreatorDuns'];
            $creatorJSONLD['founder'] = $creator['organizationCreatorFounder'];
            $creatorJSONLD['foundingDate'] = $creator['organizationCreatorFoundingDate'];
            $creatorJSONLD['foundingLocation'] = $creator['organizationCreatorFoundingLocation'];
            if (isset($creator['contactPoint'])) {
                $creatorJSONLD['contactPoint'] = $creator['contactPoint'];
            }
        }
        /* -- Settings on a per-Creator sub-type basis */
        switch ($creator['siteCreatorSubType']) {
            case 'Airline':
                break;
            case 'Corporation':
                $creatorJSONLD['tickerSymbol'] = $creator['corporationCreatorTickerSymbol'];
                break;
            case 'EducationalOrganization':
                break;
            case 'GovernmentOrganization':
                break;
            case 'LocalBusiness':
                break;
            case 'NGO':
                break;
            case 'PerformingGroup':
                break;
            case 'SportsOrganization':
                break;
        }
        /* -- Settings on a per-Creator specific-type basis */
        switch ($creator['siteCreatorSpecificType']) {
            case 'FoodEstablishment':
            case 'Bakery':
            case 'BarOrPub':
            case 'Brewery':
            case 'CafeOrCoffeeShop':
            case 'FastFoodRestaurant':
            case 'IceCreamShop':
            case 'Restaurant':
            case 'Winery':
                $creatorJSONLD['servesCuisine'] = $creator['restaurantCreatorServesCuisine'];
                $creatorJSONLD['menu'] = $creator['restaurantCreatorMenuUrl'];
                $creatorJSONLD['acceptsReservations'] = $creator['restaurantCreatorReservationsUrl'];
                break;
        }
        $result = array_filter($creatorJSONLD);
        $this->cachedCreatorJSONLD[$locale] = $result;
        return $result;
    }