Beispiel #1
0
 /**
  * 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;
 }