private function getMicrosoftTags(AppConfiguration $configuration) { $tags = []; // Start URL // https://msdn.microsoft.com/en-us/library/gg491732(v=vs.85).aspx#msapplication-starturl if (($startUrl = $configuration->getStartUrl()) !== null) { $tags[] = ["meta", "name" => "msapplication-starturl", "content" => $startUrl]; } // Theme color // https://msdn.microsoft.com/en-us/library/gg491732(v=vs.85).aspx#msapplication-navbutton-color if (($themeColor = $configuration->getThemeColor()) !== null) { $tags[] = ["meta", "name" => "msapplication-navbutton-color", "content" => $themeColor]; } return $tags; }
/** * Returns the manifest data as an array. * * @param AppConfiguration $configuration The configuration to create the manifest from. * * @return array */ public function get(AppConfiguration $configuration) { $manifest = []; if (($backgroundColor = $configuration->getBackgroundColor()) !== null) { $manifest["background_color"] = $backgroundColor; } if (($description = $configuration->getDescription()) !== null) { $manifest["description"] = $description; } if (($direction = $configuration->getDirection()) !== null) { $manifest["dir"] = $direction; } if (($display = $configuration->getDisplay()) !== null) { $manifest["display"] = $display; } if (count($icons = $configuration->getIcons()) > 0) { $manifest["icons"] = []; foreach ($icons as $icon) { $manifest["icons"][] = $this->getImageData($icon); } } if (($language = $configuration->getLanguage()) !== null) { $manifest["lang"] = $language; } if (($name = $configuration->getName()) !== null) { $manifest["name"] = $name; } if (($orientation = $configuration->getOrientation()) !== null) { $manifest["orientation"] = $orientation; } if (($scope = $configuration->getScope()) !== null) { $manifest["scope"] = $scope; } if (count($screenshots = $configuration->getScreenshots()) > 0) { $manifest["screenshots"] = []; foreach ($screenshots as $screenshot) { $manifest["screenshots"][] = $this->getImageData($screenshot); } } if (($shortName = $configuration->getShortName()) !== null) { $manifest["short_name"] = $shortName; } if (($startUrl = $configuration->getStartUrl()) !== null) { $manifest["start_url"] = $startUrl; } if (($themeColor = $configuration->getThemeColor()) !== null) { $manifest["theme_color"] = $themeColor; } return $manifest; }
/** * Creates an instance of the {@link AppConfiguration} class based on the values in the provided JSON string. Use * the {@link fromManifestFile} method to use a file as source. * * @param string $json A JSON string that is compatible with the Web App Manifest * specification. * * @return AppConfiguration * * @see https://www.w3.org/TR/appmanifest/ */ public static function fromManifest($json) { $app = new AppConfiguration(); $data = json_decode($json, true); if (isset($data["background_color"])) { $app->setBackgroundColor($data["background_color"]); } if (isset($data["description"])) { $app->setDescription($data["description"]); } if (isset($data["dir"])) { $app->setDirection($data["dir"]); } if (isset($data["display"])) { $app->setDisplay($data["display"]); } if (isset($data["icons"])) { foreach ($data["icons"] as $icon) { $app->addIcon(self::imageFromData($icon)); } } if (isset($data["lang"])) { $app->setLanguage($data["lang"]); } if (isset($data["name"])) { $app->setName($data["name"]); } if (isset($data["orientation"])) { $app->setOrientation($data["orientation"]); } if (isset($data["scope"])) { $app->setScope($data["scope"]); } if (isset($data["screenshots"])) { foreach ($data["screenshots"] as $screenshot) { $app->addScreenshot(self::imageFromData($screenshot)); } } if (isset($data["short_name"])) { $app->setShortName($data["short_name"]); } if (isset($data["start_url"])) { $app->setStartUrl($data["start_url"]); } if (isset($data["theme_color"])) { $app->setThemeColor($data["theme_color"]); } return $app; }