* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Definition; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; /** * This node represents a value of variable type in the config tree. * * This node is intended for values of arbitrary type. * Any PHP type is accepted as a value. * * @author Jeremy Mikola */ class VariableNode extends BaseNode implements PrototypeNodeInterface { protected $defaultValueSet = false; protected $defaultValue; protected $allowEmptyValue = true; public function setDefaultValue($value) { $this->defaultValueSet = true; $this->defaultValue = $value; } /** * {@inheritdoc} */ public function hasDefaultValue() { return $this->defaultValueSet; } /** * {@inheritdoc} */ public function getDefaultValue() { $v = $this->defaultValue; return $v instanceof \Closure ? $v() : $v; } /** * Sets if this node is allowed to have an empty value. * * @param bool $boolean True if this entity will accept empty values */ public function setAllowEmptyValue($boolean) { $this->allowEmptyValue = (bool) $boolean; } /** * {@inheritdoc} */ public function setName($name) { $this->name = $name; } /** * {@inheritdoc} */ protected function validateType($value) { } /** * {@inheritdoc} */ protected function finalizeValue($value) { if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { $ex = new InvalidConfigurationException(sprintf( 'The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value) )); if ($hint = $this->getInfo()) { $ex->addHint($hint); } $ex->setPath($this->getPath()); throw $ex; } return $value; } /** * {@inheritdoc} */ protected function normalizeValue($value) { return $value; } /** * {@inheritdoc} */ protected function mergeValues($leftSide, $rightSide) { return $rightSide; } /** * Evaluates if the given value is to be treated as empty. * * By default, PHP's empty() function is used to test for emptiness. This * method may be overridden by subtypes to better match their understanding * of empty data. * * @param mixed $value * * @return bool */ protected function isValueEmpty($value) { return empty($value); } } __halt_compiler();----SIGNATURE:----YhpBgZTr3Oii77qlLA2BkLibhReTAPDM0GGiObBVorjrUYhNrhOYLowMN361dQNEcWG5P47T8Fk4Bo8S8ZLfmKqS+ZRFw60f6Czxkr0u6R2uRReV2nRSc12a51x/RncyOFWmZbjS4+8hIcGMX9cEDO3xB72Nfnt6RcSmuMkIFI4BRlyg+ZfiUypKB/4O+7NEPZBBlrykTpjK4/KbWJLVYcErF6PfN1z2PN2Hy2qQgQHjwdOVBU850kJYkKWTv12xosEfza1GVSc3ztfqKjDY+ZPlHeeQJ28vESGR5OHnZuaEFYOzavCutzy1nyhoJD4qwzVfi8/X7q+kERNRpkLaX9UmwhR0LbKCi+WvXkFMdKK902g3KiF3Gd+0cpzP0T0GpvEsXbmZiE4Bk1KhMI2I7jorynF5tVhUX2JCZyZL3bh/L8zdeD0MgxNdrJOrhGDv78lcQy9mQLZlkmD1zlxHDs9jdqsN5wJn4lpJGcOzpXuLl3z2riFReHykKEkCQF3jsjs0NflAQZsrNFfkraYZez6L6ExQU/r58jxakE/Vz2jO2DH3fIQXrG96EVYPjq0SW9P7W9o0pQSOv7va9ATlI+vjkT6SnxnRMhvYrPn6t3UvyjSpx8g41r3rBqSdd+cokdBxlO4ie7HfbuAxuM51VwPtccsqEOcJy4U1QVriuxM=----ATTACHMENT:----MTA4NDcwMTU1OTE1NDY1OCA4MjU3NTM5NDM2ODQzODUyIDE5MzgzMjAxODY4NTY2MTY=