Ejemplo n.º 1
0
 public static function getHassCoreFile()
 {
     $filesystem = \Yii::createObject(["class" => LocalFilesystem::className(), "path" => __DIR__]);
     $classMaps = [];
     foreach ($filesystem->listContents() as $item) {
         if ($item["type"] == "dir") {
             $path = $filesystem->getAdapter()->applyPathPrefix($item["path"]);
             if (!file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
                 continue;
             }
             $reader = new ConfigurationReader();
             $configuration = $reader->read($path . DIRECTORY_SEPARATOR . 'composer.json');
             foreach (array_keys($configuration->autoloadPsr4()) as $namespace) {
                 $classMaps[$namespace] = $path;
             }
         }
     }
     return $classMaps;
 }
Ejemplo n.º 2
0
 /**
  * Sends a request for satis build
  * @param bool $rewrite
  */
 public function update($rewrite = false)
 {
     if (is_file($this->composerJsonFile)) {
         // read the composer.json file and post it's content via REST API
         $config = $this->configurationReader->read($this->composerJsonFile);
         // create payload to send
         $payload = new \stdClass();
         $payload->{'name'} = Strings::webalize($config->name());
         $payload->{'composer.json'} = $config->rawData();
         /** @var Response $response */
         $response = Request::post($this->apiEndpoint . '/repository')->body($payload)->sendsJson()->send();
         if ($response->code == 200) {
             // success
             if ($rewrite) {
                 // rewrite original composer.json with modified one
                 // with occasionally modified 'repositories' section
                 $newComposerJsonContent = $response->body->{'generated-files'}->{'composer.json'}->{'content'};
                 // $newComposerJsonContent is pretty printed string
                 FileSystem::write($this->composerJsonFile, $newComposerJsonContent);
             }
         }
     }
 }