Skip to content

Commit

Permalink
Splitters now allow overriding of parser options.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed May 26, 2013
1 parent c16b7d4 commit 68db79e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
3.0.0-alpha4 (2013-05-??)
* Added: It's now possible to send parser options to the splitter classes.

3.0.0-alpha3 (2013-05-13)
* Changed: propertyMap, valueMap and componentMap are now static
properties.
Expand Down
10 changes: 6 additions & 4 deletions lib/Sabre/VObject/Parser/MimeDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ class MimeDir {
* Optionally, it's possible to parse the input stream here.
*
* @param resource|null|string $input
* @param int $options Any parser options (OPTION constants).
* @return void
*/
public function __construct($input = null) {
public function __construct($input = null, $options = 0) {

if (!is_null($input)) {
$this->setInput($input);
}
$this->options = $options;

}

Expand All @@ -81,10 +83,10 @@ public function __construct($input = null) {
* used.
*
* @param string|resource|null $input
* @param int $options
* @param int|null $options
* @return array
*/
public function parse($input = null, $options = 0) {
public function parse($input = null, $options = null) {

This comment has been minimized.

Copy link
@staabm

staabm May 26, 2013

Member

Why the different defaults in construct and here?

This comment has been minimized.

Copy link
@evert

evert May 26, 2013

Author Member

If 'null' is provided, I'll keep the existing options.. if '0' is provided, I'm overriding them :)

Not a huge fan of this though. Thinking of just removing both arguments from parse, and keep them in the constructor..


$this->root = null;
if (!is_null($input)) {
Expand All @@ -93,7 +95,7 @@ public function parse($input = null, $options = 0) {

}

$this->options = $options;
if (!is_null($options)) $this->options = $options;

$this->parseDocument();

Expand Down
5 changes: 3 additions & 2 deletions lib/Sabre/VObject/Splitter/ICalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ class ICalendar implements SplitterInterface {
* The splitter should receive an readable file stream as it's input.
*
* @param resource $input
* @param int $options Parser options, see the OPTIONS constants.
*/
public function __construct($input) {
public function __construct($input, $options = 0) {

$data = VObject\Reader::read($input);
$data = VObject\Reader::read($input, $options);
$vtimezones = array();
$components = array();

Expand Down
5 changes: 3 additions & 2 deletions lib/Sabre/VObject/Splitter/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ class VCard implements SplitterInterface {
* The splitter should receive an readable file stream as it's input.
*
* @param resource $input
* @param int $options Parser options, see the OPTIONS constants.
*/
public function __construct($input) {
public function __construct($input, $options = 0) {

$this->input = $input;
$this->parser = new MimeDir($input);
$this->parser = new MimeDir($input, $options);

}

Expand Down
2 changes: 1 addition & 1 deletion lib/Sabre/VObject/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class Version {
/**
* Full version number
*/
const VERSION = '3.0.0-alpha3';
const VERSION = '3.0.0-alpha4';

}

0 comments on commit 68db79e

Please sign in to comment.