protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $errors = array(); # Access repository $forge = ForgeGitHubFactory::fetch($values['url']); try { $forge->initialize($values['url']); if ($forge->getReadme()) { $mdparser = new ForgeMDParser($forge->getReadme()); } if ($forge->getYaml()) { $yaml = new ForgeYamlParser($forge->getYaml()); } $values = $values + array('title' => $yaml->get('name'), 'username' => $yaml->get('author'), 'docsurl' => $yaml->get('docs'), 'demourl' => $yaml->get('demo'), 'githubuser' => $forge->getUser(), 'githubrepo' => $forge->getProject(), 'howtouse' => $mdparser->getSection('how-to-use'), 'screenshot' => $mdparser->getScreenshot(), 'description' => $mdparser->getDescription(), 'tags' => $yaml->get('tags'), 'category' => $yaml->get('category'), 'stabletag' => $yaml->get('current'), 'gitTags' => $forge->getTags(), 'arbitrarySections' => $mdparser->getArbitrarySections(), 'screenshots' => $mdparser->getScreenshots()); } catch (ForgeException $e) { $errors[] = new sfValidatorError($this, $e->getMessage()); } if (!empty($errors)) { throw new sfValidatorErrorSchema($this, $errors); } return $values; }
protected function doClean($values) { $forge = ForgeGitHubFactory::fetch($values[$this->getOption('url_field')]); if ($values[$this->getOption('tag_field')]) { if (!in_array($values[$this->getOption('tag_field')], $forge->getTags())) { throw new sfValidatorError($this, 'not_found', array('value' => $values[$this->getOption('tag_field')])); } } else { $tags = $forge->getTags(); if ($tags) { $values[$this->getOption('tag_field')] = end($tags); } else { $values[$this->getOption('tag_field')] = null; } } return $values; }
protected function doClean($values) { if (sfConfig::get('app_plugin_dev_loose_mode') && sfConfig::get('sf_environment') == 'dev') { return $values; } $forge = ForgeGitHubFactory::fetch($values[$this->getOption('url_field')]); if (isset($values[$this->getOption('username_field')])) { if ($values[$this->getOption('username_field')]) { if (sfContext::getInstance()->getUser()->getUsername() != $values[$this->getOption('username_field')]) { throw new sfValidatorError($this, 'no_match', array('actual' => sfContext::getInstance()->getUser()->getUsername())); } } else { throw new sfValidatorError($this, 'not_found'); } } return $values; }