"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "public_html/lists/base/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/FormFieldRegistry.php" between
phplist-3.4.5.tgz and phplist-3.4.6.tgz

About: phpList is a one-way email announcement delivery system for newsletters, publicity lists, notifications, and many other uses (requires PHP and MySQL).

FormFieldRegistry.php  (phplist-3.4.5.tgz):FormFieldRegistry.php  (phplist-3.4.6.tgz)
skipping to change at line 60 skipping to change at line 60
* Removes a field and its children from the registry. * Removes a field and its children from the registry.
* *
* @param string $name The fully qualified name of the base field * @param string $name The fully qualified name of the base field
*/ */
public function remove($name) public function remove($name)
{ {
$segments = $this->getSegments($name); $segments = $this->getSegments($name);
$target = &$this->fields; $target = &$this->fields;
while (\count($segments) > 1) { while (\count($segments) > 1) {
$path = array_shift($segments); $path = array_shift($segments);
if (!\array_key_exists($path, $target)) { if (!\is_array($target) || !\array_key_exists($path, $target)) {
return; return;
} }
$target = &$target[$path]; $target = &$target[$path];
} }
unset($target[array_shift($segments)]); unset($target[array_shift($segments)]);
} }
/** /**
* Returns the value of the field and its children. * Returns the value of the field and its children.
* *
skipping to change at line 83 skipping to change at line 83
* @return mixed The value of the field * @return mixed The value of the field
* *
* @throws \InvalidArgumentException if the field does not exist * @throws \InvalidArgumentException if the field does not exist
*/ */
public function &get($name) public function &get($name)
{ {
$segments = $this->getSegments($name); $segments = $this->getSegments($name);
$target = &$this->fields; $target = &$this->fields;
while ($segments) { while ($segments) {
$path = array_shift($segments); $path = array_shift($segments);
if (!\array_key_exists($path, $target)) { if (!\is_array($target) || !\array_key_exists($path, $target)) {
throw new \InvalidArgumentException(sprintf('Unreachable field " %s"', $path)); throw new \InvalidArgumentException(sprintf('Unreachable field " %s"', $path));
} }
$target = &$target[$path]; $target = &$target[$path];
} }
return $target; return $target;
} }
/** /**
* Tests whether the form has the given field. * Tests whether the form has the given field.
skipping to change at line 124 skipping to change at line 124
* @param mixed $value The value * @param mixed $value The value
* *
* @throws \InvalidArgumentException if the field does not exist * @throws \InvalidArgumentException if the field does not exist
*/ */
public function set($name, $value) public function set($name, $value)
{ {
$target = &$this->get($name); $target = &$this->get($name);
if ((!\is_array($value) && $target instanceof Field\FormField) || $targe t instanceof Field\ChoiceFormField) { if ((!\is_array($value) && $target instanceof Field\FormField) || $targe t instanceof Field\ChoiceFormField) {
$target->setValue($value); $target->setValue($value);
} elseif (\is_array($value)) { } elseif (\is_array($value)) {
$fields = self::create($name, $value); $registry = new static();
foreach ($fields->all() as $k => $v) { $registry->base = $name;
$registry->fields = $value;
foreach ($registry->all() as $k => $v) {
$this->set($k, $v); $this->set($k, $v);
} }
} else { } else {
throw new \InvalidArgumentException(sprintf('Cannot set value on a c ompound field "%s".', $name)); throw new \InvalidArgumentException(sprintf('Cannot set value on a c ompound field "%s".', $name));
} }
} }
/** /**
* Returns the list of field with their value. * Returns the list of field with their value.
* *
* @return FormField[] The list of fields as [string] Fully qualified name = > (mixed) value) * @return FormField[] The list of fields as [string] Fully qualified name = > (mixed) value)
*/ */
public function all() public function all()
{ {
return $this->walk($this->fields, $this->base); return $this->walk($this->fields, $this->base);
} }
/** /**
* Creates an instance of the class.
*
* This function is made private because it allows overriding the $base and
* the $values properties without any type checking.
*
* @param string $base The fully qualified name of the base field
* @param array $values The values of the fields
*
* @return static
*/
private static function create($base, array $values)
{
$registry = new static();
$registry->base = $base;
$registry->fields = $values;
return $registry;
}
/**
* Transforms a PHP array in a list of fully qualified name / value. * Transforms a PHP array in a list of fully qualified name / value.
* *
* @param array $array The PHP array * @param array $array The PHP array
* @param string $base The name of the base field * @param string $base The name of the base field
* @param array $output The initial values * @param array $output The initial values
* *
* @return array The list of fields as [string] Fully qualified name => (mix ed) value) * @return array The list of fields as [string] Fully qualified name => (mix ed) value)
*/ */
private function walk(array $array, $base = '', array &$output = []) private function walk(array $array, $base = '', array &$output = [])
{ {
 End of changes. 4 change blocks. 
24 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)