本文整理汇总了PHP中Parameter::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::getName方法的具体用法?PHP Parameter::getName怎么用?PHP Parameter::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addParameter
/**
* @param \hergot\databroker\DataAdapter\Parameter $parameter
* @throws \InvalidArgumentException
*/
public function addParameter(Parameter $parameter)
{
if (isset($this->parameters[$parameter->getName()])) {
throw new \InvalidArgumentException('Parameter with name "' . $parameter->getName() . '" already defined');
}
$this->parameters[$parameter->getName()] = $parameter;
}
示例2: addParameter
public function addParameter(Parameter $parameter, $in = true)
{
if ($in) {
$this->inputParameters[$parameter->getName()] = $parameter;
} else {
$this->outputParameters[$parameter->getName()] = $parameter;
}
}
示例3: addParameter
/**
* Adds a parameter to the widget
*
* @param Parameter $new_parameter
* @return void
*/
public function addParameter($new_parameter)
{
if (!$new_parameter instanceof Parameter) {
throw new \MWException('Method addParameter() of widget ' . static::GetName() . ' requires an argument of type "Parameter".');
}
$new_parameter_name = $new_parameter->getName();
if (array_key_exists($new_parameter_name, $this->parameters)) {
throw new \MWException('Cannot add parameter "' . $new_parameter_name . '". Each parameter needs a disctinct name.');
}
$this->parameters[$new_parameter_name] = $new_parameter;
}
示例4: removeParameter
public function removeParameter(Parameter $parameter)
{
if (array_key_exists($parameter->getName(), $this->parameters)) {
unset($this->parameters[$parameter->getName()]);
}
}
示例5: addParameter
private function addParameter(Parameter $parameter)
{
$validLocations = ['path', 'header', 'query', 'body'];
if (!in_array($parameter->getLocation(), $validLocations)) {
throw new \InvalidArgumentException($parameter->getLocation() . ' is not a valid parameter location');
}
$this->parameters[$parameter->getName()] = $parameter;
}
示例6: getDescriptionRow
/**
* Returns the wikitext for a table row describing a single parameter.
*
* @since 1.0
*
* @param Parameter $parameter
*
* @return string
*/
protected function getDescriptionRow(Parameter $parameter)
{
$description = $parameter->getMessage();
if ($description === false) {
$description = $parameter->getDescription();
if ($description === false) {
$description = '-';
}
} else {
$description = $this->msg($description);
}
$type = $parameter->getTypeMessage();
$default = $parameter->isRequired() ? "''" . $this->msg('validator-describe-required') . "''" : $parameter->getDefault();
if (is_array($default)) {
$default = implode(', ', $default);
} elseif (is_bool($default)) {
$default = $default ? 'yes' : 'no';
}
if ($default === '') {
$default = "''" . $this->msg('validator-describe-empty') . "''";
}
return <<<EOT
| {$parameter->getName()}
| {$type}
| {$default}
| {$description}
EOT;
}
示例7: parameterNameGetsRecognizedCorrectly
/**
* @test
*/
public function parameterNameGetsRecognizedCorrectly()
{
$parameter = new Parameter(['value' => ['name' => 'myParam']]);
self::assertSame('myParam', $parameter->getName());
}
示例8: __construct
/**
* Constructor.
*
* @since 0.4.6
*
* @param Parameter $param
* @param mixed $currentValue
*/
public function __construct(Parameter $param, $currentValue = false)
{
$this->param = $param;
$this->currentValue = $currentValue;
$this->inputName = $param->getName();
}
示例9: validateValue
/**
* Run the value through the configured validator
*
* @param mixed $value
* @param Parameter $definition
* @access protected
*
* @throw Exception
*
* @return mixed
*/
protected function validateValue($value, $definition)
{
try {
return $definition->getValidator()->validate($value);
} catch (\Exception $e) {
throw new \Exception(sprintf('[%s] %s', $definition->getName(), $e->getMessage()));
}
}
示例10: getDescriptionRow
/**
* Returns the wikitext for a table row describing a single parameter.
*
* @since 1.6
*
* @param Parameter $parameter
* @param boolean $hasAliases
*
* @return string
*/
protected function getDescriptionRow(Parameter $parameter, $hasAliases)
{
if ($hasAliases) {
$aliases = $parameter->getAliases();
$aliases = count($aliases) > 0 ? implode(', ', $aliases) : '-';
}
$description = $parameter->getMessage();
if ($description === false) {
$description = $parameter->getDescription();
if ($description === false) {
$description = '-';
}
} else {
$description = $this->msg($description);
}
$type = $parameter->getTypeMessage();
$default = $parameter->isRequired() ? "''" . $this->msg('validator-describe-required') . "''" : $parameter->getDefault();
if (is_array($default)) {
$default = implode(', ', $default);
} elseif (is_bool($default)) {
$default = $default ? 'yes' : 'no';
}
if ($default === '') {
$default = "''" . $this->msg('validator-describe-empty') . "''";
}
return "| {$parameter->getName()}\n" . ($hasAliases ? '| ' . $aliases . "\n" : '') . <<<EOT
| {$type}
| {$default}
| {$description}
EOT;
}
示例11: newFromParameter
/**
* @deprecated Compatibility helper, will be removed in 0.7.
* @since 0.5
*
* @param Parameter $parameter
*
* @return IParamDefinition
*/
public static function newFromParameter(Parameter $parameter)
{
$def = self::newFromType($parameter->getType(), $parameter->getName(), $parameter->getDefault(), $parameter->getMessage() === false ? 'validator-message-nodesc' : $parameter->getMessage(), $parameter->isList());
$def->addAliases($parameter->getAliases());
$def->addCriteria($parameter->getCriteria());
$def->addManipulations($parameter->getManipulations());
$def->addDependencies($parameter->getDependencies());
$def->setDoManipulationOfDefault($parameter->applyManipulationsToDefault);
if ($parameter->isList()) {
$def->setDelimiter($parameter->getDelimiter());
}
$def->trimValue = $parameter->trimValue;
return $def;
}
示例12: __construct
public function __construct(Parameter $parameter)
{
parent::__construct($parameter->getName(), $parameter->isRequired());
$this->parameter = $parameter;
}
示例13: showFormatOption
/**
* Get the HTML for a single parameter input.
*
* @param Parameter $parameter
* @param mixed $currentValue
*
* @return string
*/
protected function showFormatOption(Parameter $parameter, $currentValue)
{
$input = new ParameterInput($parameter);
$input->setInputName('p[' . $parameter->getName() . ']');
if ($currentValue !== false) {
$input->setCurrentValue($currentValue);
}
return $input->getHtml();
}
示例14: prepare
/**
* Configures wrapped formatter class with any attributes on this element.
*/
public function prepare()
{
if (!$this->formatter) {
throw new BuildException("No formatter specified (use type or classname attribute)", $this->getLocation());
}
$out = $this->getOutputWriter();
print "Setting output writer to: " . get_class($out) . "\n";
$this->formatter->setOutput($out);
if ($this->formatter instanceof PlainPDOResultFormatter) {
// set any options that apply to the plain formatter
$this->formatter->setShowheaders($this->showheaders);
$this->formatter->setRowdelim($this->rowdelimiter);
$this->formatter->setColdelim($this->coldelimiter);
} elseif ($this->formatter instanceof XMLPDOResultFormatter) {
// set any options that apply to the xml formatter
$this->formatter->setEncoding($this->encoding);
$this->formatter->setFormatOutput($this->formatoutput);
}
foreach ($this->formatterParams as $param) {
$param = new Parameter();
$method = 'set' . $param->getName();
if (!method_exists($this->formatter, $param->getName())) {
throw new BuildException("Formatter " . get_class($this->formatter) . " does not have a {$method} method.", $this->getLocation());
}
call_user_func(array($this->formatter, $method), $param->getValue());
}
}
示例15: attemptToSetUserValue
/**
* Tries to find a matching user provided value and, when found, assigns it
* to the parameter, and removes it from the raw values. Returns a boolean
* indicating if there was any user value set or not.
*
* @since 0.4
*
* @return boolean
*/
protected function attemptToSetUserValue(Parameter $parameter)
{
if (array_key_exists($parameter->getName(), $this->rawParameters)) {
$parameter->setUserValue($parameter->getName(), $this->rawParameters[$parameter->getName()]);
unset($this->rawParameters[$parameter->getName()]);
return true;
} else {
foreach ($parameter->getAliases() as $alias) {
if (array_key_exists($alias, $this->rawParameters)) {
$parameter->setUserValue($alias, $this->rawParameters[$alias]);
unset($this->rawParameters[$alias]);
return true;
}
}
}
return false;
}