Пример #1
0
 protected function validateType($value)
 {
     parent::validateType($value);
     if (!is_bool($value)) {
         throw new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), json_encode($value)));
     }
 }
Пример #2
0
 protected function configureScalarNode(ScalarNode $configNode, NodeBuilder $node)
 {
     if (null !== $node->normalization) {
         $configNode->setNormalizationClosures($this->buildExpressions($node->normalization->before));
     }
     if (null !== $node->merge) {
         $configNode->setAllowOverwrite($node->merge->allowOverwrite);
     }
     if (true === $node->default) {
         $configNode->setDefaultValue($node->defaultValue);
     }
     if (false === $node->allowEmptyValue) {
         $configNode->setAllowEmptyValue($node->allowEmptyValue);
     }
     $configNode->addEquivalentValue(null, $node->nullEquivalent);
     $configNode->addEquivalentValue(true, $node->trueEquivalent);
     $configNode->addEquivalentValue(false, $node->falseEquivalent);
 }