Exemplo n.º 1
0
 /**
  * @param string $content
  * @param string $filename
  */
 public function processContent($content, $filename = null)
 {
     $data = $this->parseContent($content);
     $data += array('project' => basename($filename, '.info.yml'), 'version' => '');
     $project = new Project($data['project'], $data['core'], $data['version']);
     $project->setDetails($data);
     if (!empty($filename)) {
         $project->setFilename(realpath($filename));
     }
     $this->project = $project;
 }
 /**
  * Returns a directory to save the downloaded project into.
  * @return string
  */
 protected function getDestination()
 {
     $type = $this->project->getProjectType();
     $name = $this->project->getProject();
     $version = $this->project->getVersion();
     $dir = $this->getTempDirectory() . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $name;
     // Build the destination folder tree if it doesn't already exists.
     if (!is_dir($dir)) {
         mkdir($dir, 0775, true);
     }
     return $dir . DIRECTORY_SEPARATOR . $version;
 }
Exemplo n.º 3
0
 /**
  * Locate the base directory of the local project.
  */
 public function locateLocalProject()
 {
     // we need a remote project to do this :(
     $this->hashRemoteProject();
     $project_type = $this->project->getProjectType();
     return realpath($this->local_folder);
 }
Exemplo n.º 4
0
 /**
  * @param string $content
  *
  * @return void
  */
 public function processContent($content)
 {
     $data = $this->parseContent($content);
     // Core attribute is mandatory since Drupal 7.x.
     $data += array('core' => '6.x', 'api' => '', 'projects' => array(), 'libraries' => array());
     $this->core = $data['core'];
     $this->api = $data['api'];
     $this->projects = array();
     $this->libraries = $data['libraries'];
     // Wrap project into objects.
     foreach ($data['projects'] as $project_name => $project_details) {
         $project_details['version'] = $this->getCore() . '-' . $project_details['version'];
         $project = new Project($project_name, $this->getCore(), $project_details['version']);
         $project->setDetails($project_details);
         $this->projects[$project_name] = $project;
     }
     // Todo: wrap libraries into objects.
 }
Exemplo n.º 5
0
 /**
  * @param Project $project
  * @param bool|false $reset
  */
 public function prepare(Project $project, $reset = false)
 {
     $cid_parts = array('release_history', $project->getProject(), $project->getCore());
     $cid = implode(':', $cid_parts);
     $data = false;
     if ($this->cache && !$reset) {
         $data = $this->cache->fetch($cid);
     }
     // If not in cache, load from remote.
     if ($data === false) {
         $url = $project->getStatusUrl() . '/' . $project->getProject() . '/' . $project->getCore();
         // Todo: use guzzle library.
         $content = file_get_contents($url);
         $data = $this->parseUpdateXml($content);
         // If data, store into cache.
         if ($this->cache && !empty($data)) {
             $this->cache->save($cid, $data, 1800);
         }
     }
     $data += array('project_status' => '', 'default_major' => '', 'recommended_major' => '', 'supported_majors' => '');
     // Hydrate release objects.
     if (isset($data['releases']) && is_array($data['releases'])) {
         foreach ($data['releases'] as $key => $value) {
             $data['releases'][$key] = new Release($value);
         }
         $project->setReleases($data['releases']);
     } else {
         $data['releases'] = array();
     }
     if (!empty($data['type'])) {
         $project->setProjectType($data['type']);
     } else {
         $project->setProjectType(Project::TYPE_UNKNOWN);
     }
     $this->data = (array) $data;
 }
Exemplo n.º 6
0
 /**
  * @param Project $project
  * @param ReleaseHistory $release_history
  * @param boolean $flat
  * @return array
  */
 protected function generateReport(Project $project, ReleaseHistory $release_history, $flat = false)
 {
     $report = array('project' => $project->getProject(), 'type' => $project->getProjectType(), 'version' => $project->getVersion(), 'version_date' => $project->getDatestamp(), 'recommended' => null, 'dev' => null, 'also_available' => array(), 'status' => $project->getStatus(), 'status_label' => ReleaseHistory::getStatusLabel($project->getStatus()), 'reason' => '');
     if ($flat) {
         $report['recommended'] = $project->getRecommended();
         $report['dev'] = $project->getDevVersion();
         $report['also_available'] = implode(',', $project->getAlsoAvailable());
     } else {
         if ($release = $release_history->getRelease($project->getRecommended())) {
             $report['recommended'] = $this->getReportFromRelease($release);
         }
         if ($release = $release_history->getRelease($project->getDevVersion())) {
             $report['dev'] = $this->getReportFromRelease($release);
         }
         foreach ($project->getAlsoAvailable() as $version) {
             if ($release = $project->getRelease($version)) {
                 $report['also_available'][] = $this->getReportFromRelease($release);
             }
         }
     }
     if ($reason = $project->getReason()) {
         $report['reason'] = $reason;
     }
     return $report;
 }