示例#1
0
 public function actionIndex()
 {
     $validator = new JsonSchemaValidator();
     $versions = $validator->getAvailableVersions();
     foreach ($versions as $version) {
         $v = new JsonSchemaValidator($version);
         $v->buildDefinitions();
         $v->saveToDb();
     }
     \Yii::$app->session->addFlash('message', 'Documentation updated');
     return $this->redirect(\Yii::$app->request->referrer);
 }
示例#2
0
 public function load($version = null)
 {
     $version = $version ? $version : $this->getVersion();
     if (!isset($this->cache[$version]['data'])) {
         $validator = new JsonSchemaValidator($version);
         if (!$validator->getVersionDir(false)) {
             $this->setVersion(0);
             $validator = new JsonSchemaValidator(null);
         }
         $this->cache[$version]['data'] = json_decode($validator->getDocData(), 1);
         $this->cache[$version]['timestamp'] = time();
     }
     $this->rawContent = $this->cache[$version]['data'];
     return $this;
 }