/** * Process revision submission steps. * * @return array Returns array in form of * array( * 'error' => array(), * 'notice' => array(), * 'complete' => (bool), * 'allow_continue' => (bool), * ) */ protected function process_steps() { $id = $this->request->variable('revision_id', 0); $steps = $this->contrib->type->upload_steps; if (!check_form_key('postform')) { return $this->get_result(array('error' => array($this->user->lang['FORM_INVALID'])), $steps, -1); } // If not id is provided, then we're just starting the submission process. if (!$id) { return $this->get_result($this->create(), $steps, -1); } $this->load_revision($id); // We use the validation_date field during the submission process // to store the current step in order to ensure that the user does not // skip any steps. $step_num = $this->revision->validation_date; if (empty($steps[$step_num])) { return $this->get_result(array(), $steps, $step_num); } $step = $steps[$step_num]; if ($this->attachment) { if (!$this->package->get_source()) { $this->set_package_paths(); } } $hash = $this->package->get_md5_hash(); $result = $this->run_step($step['function']); $result = $this->get_result($result, $steps, $step_num); $this->package->cleanup(); $new_hash = $this->package->get_md5_hash(); if ($hash !== $new_hash) { $this->update_package_stats(); } if (!$result['allow_continue']) { $this->cancel(false); return $result; } $this->revision->validation_date = $step_num + 1; $this->revision->submit(); return $result; }
/** * Generate Composer package. * * @param string $composer_package Path to package destination */ protected function generate_composer_package($composer_package) { $package = new package(); $package->set_source($this->ext_config->upload_path . $this->file['physical_filename']); $package->set_temp_path($this->ext_config->contrib_temp_path, true); $ext_base_path = $package->find_directory(array('files' => array('required' => 'composer.json', 'optional' => 'ext.php')), 'vendor'); $package->restore_root($ext_base_path, $this->id); $filesystem = new Filesystem(); $filesystem->copy($package->get_source(), $this->ext_config->upload_path . $composer_package); $package->set_source($package->get_source() . '.composer'); $package->repack(true); $package->cleanup(); }