* * 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:----RAaVdM8uhg8SrnqKTMX2WE6Q3op/SmRwdifG3YhFhrqFNJfP7DglZVLEP4FIBj7vSPKijT/wF8wPrD/FnMTHnuqnlMR1M5KFPRBCyQWXfLaj7dFjH+VTKLPgpBKYy/xEjgVdh+BBFzcjx3nPSgdZEJyrIYnuYWhsR5dtYkS84sVn8NGNfqnG6XOr/8XrXoFkBrhpp8cbpBSv01TIJVwE8r6ACceVeZtVh2l5QSirjTgeJlbMfTyse+anzBAGxXa1tgzEs9m/Zz2HS7Q1KTHPB6JqQUDLv7ilpVDdPUlPIjxu0EiHngYTxXHRrkjCOz80t0hKAFnbM+mu71xrB6l43l8s6Azue8RsV1JWyq8djEN6J9rp0tBoQ7xvdcAy0lbghR4cvYVklFi88ZUvuxBcpHSMY/Yoa+6bHaEOq7+IlmD7zX56jT5GSQTiRIsonO0NsNSy5N2+PTVUXa+cMhbs+1aUq1jvbdBocbfsA1Pr5eilgDcuWxfFNna0O/xxwVQl0Q+2ecNP/gQZIsF6LDx5JANGY0PMq/FLqWb5XrKcZaCHiO9XVgG5eln1SpmxPO7dYfXY71BoZq1uZ9FOJXitmjmpYEWkrsrjOCWkTFZHZBK8rf6FX8+7XF+lWGD9qECE5Dk/riOMcCWxvQhxGnFtni2rY1lQrbqylu9HS5klmRA=----ATTACHMENT:----NTQ5NTcxNDQzMTM1Mzc5MCAzOTc2OTE3NTQ5MDAxNzM5IDQwMjU2MzIzNTQ2NDc4NzY=