/** * @test */ public function mergeShouldMergeTwoResults() { $notice1 = $this->getMockMessage('Notice'); $notice2 = $this->getMockMessage('Notice'); $notice3 = $this->getMockMessage('Notice'); $warning1 = $this->getMockMessage('Warning'); $warning2 = $this->getMockMessage('Warning'); $warning3 = $this->getMockMessage('Warning'); $error1 = $this->getMockMessage('Error'); $error2 = $this->getMockMessage('Error'); $error3 = $this->getMockMessage('Error'); $otherResult = new \TYPO3\CMS\Extbase\Error\Result(); $otherResult->addNotice($notice1); $otherResult->forProperty('foo.bar')->addNotice($notice2); $this->result->forProperty('foo')->addNotice($notice3); $otherResult->addWarning($warning1); $this->result->addWarning($warning2); $this->result->addWarning($warning3); $otherResult->forProperty('foo')->addError($error1); $otherResult->forProperty('foo')->addError($error2); $otherResult->addError($error3); $this->result->merge($otherResult); $this->assertSame(array($notice1), $this->result->getNotices(), 'Notices are not merged correctly without recursion'); $this->assertSame(array($notice3), $this->result->forProperty('foo')->getNotices(), 'Original sub-notices are overridden.'); $this->assertSame(array($notice2), $this->result->forProperty('foo')->forProperty('bar')->getNotices(), 'Sub-notices are not copied.'); $this->assertSame(array($warning2, $warning3, $warning1), $this->result->getWarnings()); $this->assertSame(array($error3), $this->result->getErrors()); $this->assertSame(array($error1, $error2), $this->result->forProperty('foo')->getErrors()); }
/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Property\Exception */ public function setValue($rawValue) { if ($rawValue === null) { $this->value = null; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } try { $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); } catch (TargetNotFoundException $e) { // for optional arguments no exeption is thrown. if ($this->isRequired()) { throw $e; } } $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== null) { // @todo Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; }
/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentValueException if the argument is not a valid object of type $dataType */ public function setValue($rawValue) { if ($rawValue === NULL) { $this->value = NULL; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== NULL) { // TODO: Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; }
/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentValueException if the argument is not a valid object of type $dataType */ public function setValue($rawValue) { if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { if ($rawValue === NULL) { $this->value = NULL; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== NULL) { // TODO: Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; } else { if ($rawValue === NULL || is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; } else { $this->value = $this->transformValue($rawValue); } return $this; } }
/** * Checks if the specified property of the given object is valid, and adds * found errors to the $messages object. * * @param mixed $value The value to be validated * @param array $validatorNames Contains an array with validator names * @param \TYPO3\CMS\Extbase\Error\Result $messages the result object to * which the validation errors should be added * * @return void */ protected function checkProperty($value, $validatorNames, \TYPO3\CMS\Extbase\Error\Result $messages) { foreach ($validatorNames as $validatorName) { $messages->merge($this->getValidator($validatorName)->validate($value)); } }
/** * Sets the value of this argument. * * @param mixed $rawValue The value of this argument * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument * @throws \TYPO3\CMS\Extbase\Property\Exception */ public function setValue($rawValue) { if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { if ($rawValue === NULL) { $this->value = NULL; return $this; } if (is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; return $this; } try { $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration); } catch (TargetNotFoundException $e) { // for optional arguments no exeption is thrown. if ($this->isRequired()) { throw $e; } } $this->validationResults = $this->propertyMapper->getMessages(); if ($this->validator !== NULL) { // TODO: Validation API has also changed!!! $validationMessages = $this->validator->validate($this->value); $this->validationResults->merge($validationMessages); } return $this; } else { if ($rawValue === NULL || is_object($rawValue) && $rawValue instanceof $this->dataType) { $this->value = $rawValue; } else { $this->value = $this->transformValue($rawValue); } return $this; } }