/** * A helper function for getting/prompting for the site create options. * * @param [array] $assoc_args Arguments from command * @return [array] */ static function getSiteCreateOptions($assoc_args) { $options = array(); $options['label'] = Input::string($assoc_args, 'label', 'Human-readable label for the site'); $suggested_name = Utils\sanitizeName($options['label']); if (array_key_exists('name', $assoc_args)) { // Deprecated but kept for backwards compatibility $options['name'] = $assoc_args['name']; } elseif (array_key_exists('site', $assoc_args)) { $options['name'] = $assoc_args['site']; } elseif (isset($_SERVER['TERMINUS_SITE'])) { $options['name'] = $_SERVER['TERMINUS_SITE']; } else { $options['name'] = Input::string($assoc_args, 'site', "Machine name of the site; used as part of the default URL (if left blank will be {$suggested_name})", $suggested_name); } if (isset($assoc_args['org'])) { $options['organization_id'] = Input::orgid($assoc_args, 'org', false); } return $options; }
/** * A helper function for getting/prompting for the site create options. * * @param array $assoc_args Arguments from command * @return array */ private function getSiteCreateOptions($assoc_args) { $options = array(); $options['label'] = $this->input()->string(array('args' => $assoc_args, 'key' => 'label', 'message' => 'Human-readable label for the site')); $suggested_name = Utils\sanitizeName($options['label']); if (array_key_exists('name', $assoc_args)) { // Deprecated but kept for backwards compatibility $options['name'] = $assoc_args['name']; } elseif (array_key_exists('site', $assoc_args)) { $options['name'] = $assoc_args['site']; } elseif (isset($_SERVER['TERMINUS_SITE'])) { $options['name'] = $_SERVER['TERMINUS_SITE']; } else { $message = 'Machine name of the site; used as part of the default URL'; $message .= " (if left blank will be {$suggested_name})"; $options['name'] = $this->input()->string(array('args' => $assoc_args, 'key' => 'site', 'message' => $message, 'deafult' => $suggested_name)); } if (isset($assoc_args['org'])) { $options['organization_id'] = $this->input()->orgId(array('args' => $assoc_args, 'default' => false)); } return $options; }
public function testSanitizeName() { $name = '~My Test Site~'; $sanitized_name = Utils\sanitizeName($name); $this->assertEquals('my-test-site', $sanitized_name); $name = "Pantheon's The Best!"; $sanitized_name = Utils\sanitizeName($name); $this->assertEquals('pantheons-the-best', $sanitized_name); }