Example #1
0
 private function create($user, $pluginName, $data)
 {
     try {
         $meta = $this->db->create("{$user}-{$pluginName}", $data);
         $data->_id = $meta->id;
         $data->_rev = $meta->rev;
         return $data;
     } catch (Exception $e) {
         throw ErrorFactory::makeError(ERROR_PLUGIN_ALREADY_EXISTS);
     }
 }
Example #2
0
 public function getPackageFile()
 {
     try {
         $fileMeta = array_shift($this->github->getCommitApi()->getFileCommits($this->user, $this->repo, 'master', 'package.json'));
         $file = $this->github->getObjectApi()->showBlob($this->user, $this->repo, $fileMeta['id'], 'package.json');
         try {
             return json_decode($file['data']);
         } catch (Exception $e) {
             //invalid JSON
             throw ErrorFactory::makeError(ERROR_INVALID_PACKAGE_FILE);
         }
     } catch (Exception $e) {
         throw ErrorFactory::makeError(ERROR_MISSING_PACKAGE_FILE);
     }
 }