本文整理汇总了PHP中Parameter::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::getValue方法的具体用法?PHP Parameter::getValue怎么用?PHP Parameter::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate the provided value or list of values against the criterion.
*
* @since 0.4
*
* @param Parameter $parameter
* @param array $parameters
*
* @return CriterionValidationResult
*/
public function validate(Parameter $parameter, array $parameters)
{
$result = new CriterionValidationResult();
if (is_array($parameter->getValue())) {
foreach ($parameter->getValue() as $item) {
if (!$this->doValidation($item, $parameter, $parameters)) {
$result->addInvalidItem($item);
}
}
if ($result->hasInvalidItems()) {
$allInvalid = count($result->getInvalidItems()) == count($parameter->getValue());
// If the parameter is required and all items are invalid, it's fatal.
// Else it's high for required, and normal for non-required parameters.
if ($parameter->isRequired()) {
$severity = $allInvalid ? ValidationError::SEVERITY_FATAL : ValidationError::SEVERITY_HIGH;
} else {
$severity = $allInvalid ? ValidationError::SEVERITY_NORMAL : ValidationError::SEVERITY_LOW;
}
$result->addError(new ValidationError($this->getListErrorMessage($parameter, $result->getInvalidItems(), $allInvalid), $severity));
}
} else {
if (!$this->doValidation($parameter->getValue(), $parameter, $parameters)) {
$result->addError(new ValidationError($this->getItemErrorMessage($parameter), $parameter->isRequired() ? ValidationError::SEVERITY_FATAL : ValidationError::SEVERITY_NORMAL));
}
}
return $result;
}
示例2: manipulate
/**
* Validate a parameter against the criterion.
*
* @param Parameter $parameter
* @param array $parameters
*
* @since 0.4
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
if (is_array($parameter->getValue())) {
$value =& $parameter->getValue();
foreach ($value as &$item) {
$this->doManipulation($item, $parameter, $parameters);
}
} else {
$this->doManipulation($parameter->getValue(), $parameter, $parameters);
}
}
示例3: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 1.0.1
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
if (!in_array($parameters['type']->getValue(), $parameter->getValue())) {
if ($parameters['type']->wasSetToDefault()) {
if (count($parameter->getValue()) > 0) {
$types = $parameter->getValue();
$parameters['type']->setValue($types[0]);
}
} else {
array_unshift($parameter->getValue(), $parameters['type']->getValue());
}
}
}
示例4: validate
/**
* @see ParameterCriterion::validate
*/
public function validate(Parameter $parameter, array $parameters)
{
$count = count($parameter->getValue());
return ($this->upperBound === false || $count <= $this->upperBound) && ($this->lowerBound === false || $count >= $this->lowerBound);
}
示例5: setParameter
private function setParameter(Parameter $param)
{
$set_param_head = 'SET_PARAM ' . $param->getKey();
try {
if ($param->isRawValue()) {
$raw_value = self::BEGIN_RAW . "\n" . base64_encode($param->getValue()) . "\n" . self::END_RAW;
return $this->socket_client->request($set_param_head . ' ' . self::RAW_VALUE_ANNOUNCMENT . "\n" . $raw_value);
} else {
return $this->socket_client->request($set_param_head . ' ' . $param->getValue());
}
} catch (\Exception $e) {
throw $e;
}
}
示例6: testSetup
function testSetup()
{
$param = new Parameter('name', 'value');
$this->assertEquals('NAME', $param->name);
$this->assertEquals('value', $param->value);
$this->assertEquals('value', $param->getValue());
}
示例7: testSetupNameLess
function testSetupNameLess()
{
$card = new Component\VCard();
$param = new Parameter($card, null, 'URL');
$this->assertEquals('VALUE', $param->name);
$this->assertEquals('URL', $param->getValue());
$this->assertTrue($param->noName);
}
示例8: testIsImmutable
public function testIsImmutable()
{
$parameter = new Parameter('foo', [$std = new \stdClass()]);
// Mutate injected object
$std->foo = 'bar';
// Mutate retrieved object
$parameter->getValue()[0]->foo = 'baz';
$this->assertEquals(new Parameter('foo', [new \stdClass()]), $parameter);
}
示例9: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 0.7
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
global $egMapsOLLayerGroups, $egMapsOLAvailableLayers;
$layerDefs = array();
$layerNames = array();
foreach ($parameter->getValue() as $layerOrGroup) {
$lcLayerOrGroup = strtolower($layerOrGroup);
// Layer groups. Loop over all items and add them when not present yet.
if (array_key_exists($lcLayerOrGroup, $egMapsOLLayerGroups)) {
foreach ($egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName) {
if (!in_array($layerName, $layerNames)) {
if (is_array($egMapsOLAvailableLayers[$layerName])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName];
}
$layerNames[] = $layerName;
}
}
} elseif (array_key_exists($lcLayerOrGroup, $egMapsOLAvailableLayers)) {
if (!in_array($lcLayerOrGroup, $layerNames)) {
if (is_array($egMapsOLAvailableLayers[$lcLayerOrGroup])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup];
}
$layerNames[] = $lcLayerOrGroup;
}
} else {
$title = Title::newFromText($layerOrGroup, Maps_NS_LAYER);
if ($title->getNamespace() == Maps_NS_LAYER && $title->exists()) {
$layerPage = new MapsLayerPage($title);
if ($layerPage->hasValidDefinition('openlayers')) {
$layer = $layerPage->getLayer();
if (!in_array($layerOrGroup, $layerNames)) {
$layerDefs[] = $layer->getJavaScriptDefinition();
$layerNames[] = $layerOrGroup;
}
} else {
wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation.");
}
} else {
wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation.");
}
}
}
$parameter->setValue($layerDefs);
MapsMappingServices::getServiceInstance('openlayers')->addLayerDependencies($this->getDependencies($layerNames));
}
示例10: testParameter
public function testParameter()
{
$parameter = new Parameter('foo');
$this->assertSame('foo', $parameter->getValue());
$this->assertSame('foo', $parameter());
}
示例11: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 0.4
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
$parameter->setValue($this->wrapper . implode($this->wrapper . $this->delimiter . $this->wrapper, $parameter->getValue()) . $this->wrapper);
}
示例12: validate
/**
* @see ParameterCriterion::validate
*/
public function validate(Parameter $parameter, array $parameters)
{
return count($parameter->getValue()) == count(array_unique($this->careAboutCapitalization ? $parameter->getValue() : array_map('strtolower', $parameter->getValue())));
}
示例13: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 0.7
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
global $egMapsOLLayerGroups, $egMapsOLAvailableLayers;
$layerDefs = array();
$usedLayers = array();
foreach ($parameter->getValue() as $layerOrGroup) {
$lcLayerOrGroup = strtolower($layerOrGroup);
// Layer groups. Loop over all items and add them if not present yet.
if (array_key_exists($lcLayerOrGroup, $egMapsOLLayerGroups)) {
foreach ($egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName) {
if (!in_array($layerName, $usedLayers)) {
if (is_array($egMapsOLAvailableLayers[$layerName])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName];
}
$usedLayers[] = $layerName;
}
}
} elseif (array_key_exists($lcLayerOrGroup, $egMapsOLAvailableLayers)) {
if (!in_array($lcLayerOrGroup, $usedLayers)) {
if (is_array($egMapsOLAvailableLayers[$lcLayerOrGroup])) {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0];
} else {
$layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup];
}
$usedLayers[] = $lcLayerOrGroup;
}
} else {
$layerParts = explode($this->groupNameSep, $layerOrGroup, 2);
$layerGroup = $layerParts[0];
$layerName = count($layerParts) > 1 ? $layerParts[1] : null;
$title = Title::newFromText($layerGroup, Maps_NS_LAYER);
if ($title !== null && $title->getNamespace() == Maps_NS_LAYER) {
/**
* TODO/FIXME: This shouldn't be here and using $wgParser, instead it should
* be somewhere around MapsBaseMap::renderMap. But since we do a lot more than
* 'parameter manipulation' in here, we already diminish the information needed
* for this which will never arrive there. Perhaps the whole
* MapsLayer::getJavaScriptDefinition() shouldn't be done here.
*/
global $wgParser;
// add dependency to the layer page so if the layer definition gets updated,
// the page where it is used will be updated as well:
$rev = Revision::newFromTitle($title);
$wgParser->getOutput()->addTemplate($title, $title->getArticleID(), $rev->getId());
// if the whole layer group is not yet loaded into the map and the group exists:
if (!in_array($layerGroup, $usedLayers) && $title->exists()) {
$layerPage = new MapsLayerPage($title);
if ($layerName !== null) {
// load specific layer with name:
$layer = MapsLayers::loadLayer($title, $layerName);
$layers = new MapsLayerGroup($layer);
$usedLayer = $layerOrGroup;
} else {
// load all layers from group:
$layers = MapsLayers::loadLayerGroup($title);
$usedLayer = $layerGroup;
}
foreach ($layers->getLayers() as $layer) {
if (($layer->getName() === null || !in_array($layerGroup . $this->groupNameSep . $layer->getName(), $usedLayers)) && $layer->isOk()) {
$layerDefs[] = $layer->getJavaScriptDefinition();
}
}
$usedLayers[] = $usedLayer;
// have to add this after loop of course!
}
} else {
wfWarn("Invalid layer ({$layerOrGroup}) encountered after validation.");
}
}
}
$parameter->setValue($layerDefs);
MapsMappingServices::getServiceInstance('openlayers')->addLayerDependencies($this->getDependencies($usedLayers));
}
示例14: testSetAndGetValue
/**
* @covers phpDocumentor\Transformer\Template\Parameter::getValue
* @covers phpDocumentor\Transformer\Template\Parameter::setValue
*/
public function testSetAndGetValue()
{
$this->assertSame(null, $this->fixture->getValue());
$this->fixture->setValue('value');
$this->assertSame('value', $this->fixture->getValue());
}
示例15: getFullListErrorMessage
/**
* @see ItemParameterCriterion::getFullListErrorMessage
*/
protected function getFullListErrorMessage( Parameter $parameter ) {
global $wgLang;
$originalCount = count( $this->allowedValues );
if ( $originalCount > 15 ) {
$allowedValues = array_slice( $this->allowedValues, 0, 13 );
$omitCount = $originalCount - count( $allowedValues );
return wfMsgExt(
'validator-list-error-accepts-only-omitted',
'parsemag',
$parameter->getOriginalName(),
$wgLang->listToText( $allowedValues ),
count( $allowedValues ),
$wgLang->formatNum( $omitCount )
);
}
else {
return wfMsgExt(
'validator-list-error-accepts-only',
'parsemag',
$parameter->getOriginalName(),
$wgLang->listToText( $this->allowedValues ),
count( $this->allowedValues ),
$parameter->getValue()
);
}
}