コード例 #1
0
ファイル: RestfulTrait.php プロジェクト: aleph-n/opencholar
 /**
  * @Given /^I create a new node of "([^"]*)" as "([^"]*)" with the settings:$/
  */
 public function iCreateANewNodeOfAsWithTheSettings($type, $account, TableNode $table)
 {
     list($values, $token, $path) = $this->getVariables($type, $account, $table, TRUE);
     $values['vsite'] = FeatureHelp::getNodeId($values['vsite']);
     foreach (['parent', 'software_project'] as $key) {
         if (!empty($values[$key])) {
             $values[$key] = FeatureHelp::getNodeId($values[$key]);
         }
     }
     if (!empty($values['professional_title'])) {
         $values['professional_title'] = array($values['professional_title']);
     }
     if (!empty($values['files'])) {
         $values['files'] = FeatureHelp::getFilesIDs(explode(',', $values['files']));
     }
     if (!empty($values['package'])) {
         $file = $this->getClient()->get($this->locatePath('os-package-file'))->json();
         if (empty($file['file']['fid'])) {
             throw new Exception('An error occured with the file. You ca the value above.');
         }
         $values['package'] = $file['file']['fid'];
     }
     $this->invokeRestRequest('post', $path, ['access_token' => $token], $values);
 }