Exemplo n.º 1
0
function check_or_create_json_dir(\PickleWeb\Application $app)
{
    if (is_dir($app->config('json_path')) === false) {
        mkdir($app->config('json_path'), 0777, true);
        mkdir($app->config('json_path') . 'users/github', 0777, true);
        mkdir($app->config('json_path') . 'extensions', 0777, true);
    }
}
Exemplo n.º 2
0
 /**
  * @return
  */
 public function update()
 {
     $extensionRepository = $this->app->container->get('extension.repository');
     $vendorDir = $this->app->config('json_path') . '/' . $this->extension->getVendor();
     if (!is_dir($vendorDir)) {
         mkdir($vendorDir);
     }
     $jsonPackage = $this->extension->serialize();
     $repositoryName = $this->extension->getPackageName();
     $this->sha = hash('sha256', $jsonPackage);
     $jsonPathSha = $vendorDir . '/' . $repositoryName . '$' . $this->sha . '.json';
     file_put_contents($jsonPathSha, $jsonPackage);
     $linkPath = $vendorDir . '/' . $repositoryName . '.json';
     if (file_exists($linkPath)) {
         $targetPath = readlink($linkPath);
         unlink($linkPath);
     }
     symlink($jsonPathSha, $vendorDir . '/' . $repositoryName . '.json');
     $shaProviders = $this->updateProviders();
     $this->updateRootPackageJson($shaProviders);
 }
Exemplo n.º 3
0
 /**
  * @param Predis\Client $redis
  */
 public function getApiKey(\PickleWeb\Application $app)
 {
     $redis = $app->container->get('redis.client');
     $key = $redis->hget('extension_apikey', $this->getName());
     if (!$key) {
         $key = bin2hex(openssl_random_pseudo_bytes(32));
         $key .= $app->config('apiSecret');
         $key = hash('sha256', $key);
         $res = $redis->hset('extension_apikey', $this->getName(), $key);
     }
     return $key;
 }