Skip to content

Commit

Permalink
Few API tweaks, and marking a new release.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed May 31, 2013
1 parent 68db79e commit ea6fe81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
3.0.0-alpha4 (2013-05-??)
3.0.0-alpha4 (2013-05-31)
* Added: It's now possible to send parser options to the splitter classes.
* Added: A few tweaks to improve component and property creation.

3.0.0-alpha3 (2013-05-13)
* Changed: propertyMap, valueMap and componentMap are now static
Expand Down
5 changes: 3 additions & 2 deletions lib/Sabre/VObject/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public function __construct(Document $root, $name, array $children = array(), $d
* add(Component $comp) // Adds a new component
* add(Property $prop) // Adds a new property
* add($name, $value, array $parameters = array()) // Adds a new property
* add($name, array $children = array()) // Adds a new component
* by name.
*
* @return Node
*/
public function add($a1, $a2 = null, array $a3 = array()) {
public function add($a1, $a2 = null, $a3 = null) {

if ($a1 instanceof Node) {
if (!is_null($a2)) {
Expand Down Expand Up @@ -367,7 +368,7 @@ public function __set($name, $value) {
} else {
$this->children[] = $value;
}
} elseif (is_scalar($value) || is_array($value)) {
} elseif (is_scalar($value) || is_array($value) || is_null($value)) {
$property = $this->root->create($name,$value);
$property->parent = $this;
if (!is_null($overWrite)) {
Expand Down
6 changes: 4 additions & 2 deletions lib/Sabre/VObject/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,15 @@ public function create($name) {
* @param bool $defaults
* @return Component
*/
public function createComponent($name, array $children = array(), $defaults = true) {
public function createComponent($name, array $children = null, $defaults = true) {

$name = strtoupper($name);
$class = 'Sabre\\VObject\\Component';

if (isset(static::$componentMap[$name])) {
$class.='\\' . static::$componentMap[$name];
}
if (is_null($children)) $children = array();
return new $class($this, $name, $children, $defaults);

}
Expand All @@ -208,7 +209,7 @@ public function createComponent($name, array $children = array(), $defaults = tr
* @param array $parameters
* @return Property
*/
public function createProperty($name, $value = null, array $parameters = array()) {
public function createProperty($name, $value = null, array $parameters = null) {

// If there's a . in the name, it means it's prefixed by a groupname.
if (($i=strpos($name,'.'))!==false) {
Expand All @@ -231,6 +232,7 @@ public function createProperty($name, $value = null, array $parameters = array()
if (is_null($class)) {
$class='Sabre\\VObject\\Property\\Text';
}
if (is_null($parameters)) $parameters = array();

return new $class($this, $name, $value, $parameters, $group);

Expand Down

0 comments on commit ea6fe81

Please sign in to comment.