ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\VObject\Document Class Reference

Document. More...

+ Inheritance diagram for Sabre\VObject\Document:
+ Collaboration diagram for Sabre\VObject\Document:

Public Member Functions

 __construct ()
 Creates a new document. More...
 
 getDocumentType ()
 Returns the current document type. More...
 
 create ($name)
 Creates a new component or property. More...
 
 createComponent ($name, array $children=null, $defaults=true)
 Creates a new component. More...
 
 createProperty ($name, $value=null, array $parameters=null, $valueType=null)
 Factory method for creating new properties. More...
 
 getClassNameForPropertyValue ($valueParam)
 This method returns a full class-name for a value parameter. More...
 
 getClassNameForPropertyName ($propertyName)
 Returns the default class for a property name. More...
 
- Public Member Functions inherited from Sabre\VObject\Component
 __construct (Document $root, $name, array $children=[], $defaults=true)
 Creates a new component. More...
 
 add ()
 Adds a new property or component, and returns the new item. More...
 
 remove ($item)
 This method removes a component or property from this component. More...
 
 children ()
 Returns a flat list of all the properties and components in this component. More...
 
 getComponents ()
 This method only returns a list of sub-components. More...
 
 select ($name)
 Returns an array with elements that match the specified name. More...
 
 serialize ()
 Turns the object back into a serialized blob. More...
 
 jsonSerialize ()
 This method returns an array, with the representation as it should be encoded in JSON. More...
 
 xmlSerialize (Xml\Writer $writer)
 This method serializes the data into XML. More...
 
 __isset ($name)
 This method checks if a sub-element with the specified name exists. More...
 
 __set ($name, $value)
 Using the setter method you can add properties or subcomponents. More...
 
 __unset ($name)
 Removes all properties and components within this component with the specified name. More...
 
 __clone ()
 This method is automatically called when the object is cloned. More...
 
 getValidationRules ()
 
 validate ($options=0)
 Validates the node for correctness. More...
 
 destroy ()
 Call this method on a document if you're done using it. More...
 
- Public Member Functions inherited from Sabre\VObject\Node
 serialize ()
 Serializes the node into a mimedir format. More...
 
 jsonSerialize ()
 This method returns an array, with the representation as it should be encoded in JSON. More...
 
 xmlSerialize (Xml\Writer $writer)
 This method serializes the data into XML. More...
 
 destroy ()
 Call this method on a document if you're done using it. More...
 
 getIterator ()
 Returns the iterator for this object. More...
 
 setIterator (ElementList $iterator)
 Sets the overridden iterator. More...
 
 validate ($options=0)
 Validates the node for correctness. More...
 
 count ()
 Returns the number of elements. More...
 
 offsetExists ($offset)
 Checks if an item exists through ArrayAccess. More...
 
 offsetGet ($offset)
 Gets an item through ArrayAccess. More...
 
 offsetSet ($offset, $value)
 Sets an item through ArrayAccess. More...
 
 offsetUnset ($offset)
 Sets an item through ArrayAccess. More...
 
- Public Member Functions inherited from Sabre\Xml\XmlSerializable
 xmlSerialize (Writer $writer)
 The xmlSerialize method is called during xml writing. More...
 

Data Fields

const UNKNOWN = 1
 Unknown document type. More...
 
const VCALENDAR10 = 2
 vCalendar 1.0. More...
 
const ICALENDAR20 = 3
 iCalendar 2.0. More...
 
const VCARD21 = 4
 vCard 2.1. More...
 
const VCARD30 = 5
 vCard 3.0. More...
 
const VCARD40 = 6
 vCard 4.0. More...
 
- Data Fields inherited from Sabre\VObject\Component
 $name
 
- Data Fields inherited from Sabre\VObject\Node
const REPAIR = 1
 The following constants are used by the validate() method. More...
 
const PROFILE_CARDDAV = 2
 If this option is set, the validator will operate on the vcards on the assumption that the vcards need to be valid for CardDAV. More...
 
const PROFILE_CALDAV = 4
 If this option is set, the validator will operate on iCalendar objects on the assumption that the vcards need to be valid for CalDAV. More...
 
 $parent
 

Static Public Attributes

static $defaultName
 
static $propertyMap = []
 
static $componentMap = []
 
static $valueMap = []
 

Additional Inherited Members

- Protected Member Functions inherited from Sabre\VObject\Component
 getDefaults ()
 This method should return a list of default property values. More...
 
- Protected Attributes inherited from Sabre\VObject\Component
 $children = []
 
- Protected Attributes inherited from Sabre\VObject\Node
 $iterator = null
 
 $root
 

Detailed Description

Document.

A document is just like a component, except that it's also the top level element.

Both a VCALENDAR and a VCARD are considered documents.

This class also provides a registry for document types.

Author
Evert Pot (http://evertpot.com/) http://sabre.io/license/ Modified BSD License

Definition at line 19 of file Document.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\VObject\Document::__construct ( )

Creates a new document.

We're changing the default behavior slightly here. First, we don't want to have to specify a name (we already know it), and we want to allow children to be specified in the first argument.

But, the default behavior also works.

So the two sigs:

new Document(array $children = [], $defaults = true); new Document(string $name, array $children = [], $defaults = true)

Returns
void

Definition at line 97 of file Document.php.

References Sabre\VObject\Node\count().

97  {
98 
99  $args = func_get_args();
100  if (count($args) === 0 || is_array($args[0])) {
101  array_unshift($args, $this, static::$defaultName);
102  call_user_func_array(['parent', '__construct'], $args);
103  } else {
104  array_unshift($args, $this);
105  call_user_func_array(['parent', '__construct'], $args);
106  }
107 
108  }
count()
Returns the number of elements.
Definition: Node.php:177
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

Sabre\VObject\Document::create (   $name)

Creates a new component or property.

If it's a known component, we will automatically call createComponent. otherwise, we'll assume it's a property and call createProperty instead.

Parameters
string$name
string$arg1,...Unlimited number of args
Returns
mixed

Definition at line 132 of file Document.php.

References Sabre\VObject\Component\$name.

132  {
133 
134  if (isset(static::$componentMap[strtoupper($name)])) {
135 
136  return call_user_func_array([$this, 'createComponent'], func_get_args());
137 
138  } else {
139 
140  return call_user_func_array([$this, 'createProperty'], func_get_args());
141 
142  }
143 
144  }

◆ createComponent()

Sabre\VObject\Document::createComponent (   $name,
array  $children = null,
  $defaults = true 
)

Creates a new component.

This method automatically searches for the correct component class, based on its name.

You can specify the children either in key=>value syntax, in which case properties will automatically be created, or you can just pass a list of Component and Property object.

By default, a set of sensible values will be added to the component. For an iCalendar object, this may be something like CALSCALE:GREGORIAN. To ensure that this does not happen, set $defaults to false.

Parameters
string$name
array$children
bool$defaults
Returns
Component

Definition at line 166 of file Document.php.

References Sabre\VObject\Component\$children, and Sabre\VObject\Component\$name.

166  {
167 
168  $name = strtoupper($name);
169  $class = 'Sabre\\VObject\\Component';
170 
171  if (isset(static::$componentMap[$name])) {
172  $class = static::$componentMap[$name];
173  }
174  if (is_null($children)) $children = [];
175  return new $class($this, $name, $children, $defaults);
176 
177  }

◆ createProperty()

Sabre\VObject\Document::createProperty (   $name,
  $value = null,
array  $parameters = null,
  $valueType = null 
)

Factory method for creating new properties.

This method automatically searches for the correct property class, based on its name.

You can specify the parameters either in key=>value syntax, in which case parameters will automatically be created, or you can just pass a list of Parameter objects.

Parameters
string$name
mixed$value
array$parameters
string$valueTypeForce a specific valuetype, such as URI or TEXT
Returns
Property

Definition at line 196 of file Document.php.

References $i, Sabre\VObject\Component\$name, Sabre\VObject\Document\getClassNameForPropertyName(), and Sabre\VObject\Document\getClassNameForPropertyValue().

196  {
197 
198  // If there's a . in the name, it means it's prefixed by a groupname.
199  if (($i = strpos($name, '.')) !== false) {
200  $group = substr($name, 0, $i);
201  $name = strtoupper(substr($name, $i + 1));
202  } else {
203  $name = strtoupper($name);
204  $group = null;
205  }
206 
207  $class = null;
208 
209  if ($valueType) {
210  // The valueType argument comes first to figure out the correct
211  // class.
212  $class = $this->getClassNameForPropertyValue($valueType);
213  }
214 
215  if (is_null($class)) {
216  // If a VALUE parameter is supplied, we should use that.
217  if (isset($parameters['VALUE'])) {
218  $class = $this->getClassNameForPropertyValue($parameters['VALUE']);
219  if (is_null($class)) {
220  throw new InvalidDataException('Unsupported VALUE parameter for ' . $name . ' property. You supplied "' . $parameters['VALUE'] . '"');
221  }
222  }
223  else {
224  $class = $this->getClassNameForPropertyName($name);
225  }
226  }
227  if (is_null($parameters)) $parameters = [];
228 
229  return new $class($this, $name, $value, $parameters, $group);
230 
231  }
getClassNameForPropertyName($propertyName)
Returns the default class for a property name.
Definition: Document.php:260
getClassNameForPropertyValue($valueParam)
This method returns a full class-name for a value parameter.
Definition: Document.php:244
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ getClassNameForPropertyName()

Sabre\VObject\Document::getClassNameForPropertyName (   $propertyName)

Returns the default class for a property name.

Parameters
string$propertyName
Returns
string

Definition at line 260 of file Document.php.

Referenced by Sabre\VObject\Document\createProperty().

260  {
261 
262  if (isset(static::$propertyMap[$propertyName])) {
263  return static::$propertyMap[$propertyName];
264  } else {
265  return 'Sabre\\VObject\\Property\\Unknown';
266  }
267 
268  }
+ Here is the caller graph for this function:

◆ getClassNameForPropertyValue()

Sabre\VObject\Document::getClassNameForPropertyValue (   $valueParam)

This method returns a full class-name for a value parameter.

For instance, DTSTART may have VALUE=DATE. In that case we will look in our valueMap table and return the appropriate class name.

This method returns null if we don't have a specialized class.

Parameters
string$valueParam
Returns
string|null

Definition at line 244 of file Document.php.

Referenced by Sabre\VObject\Document\createProperty().

244  {
245 
246  $valueParam = strtoupper($valueParam);
247  if (isset(static::$valueMap[$valueParam])) {
248  return static::$valueMap[$valueParam];
249  }
250 
251  }
+ Here is the caller graph for this function:

◆ getDocumentType()

Sabre\VObject\Document::getDocumentType ( )

Returns the current document type.

Returns
int

Definition at line 115 of file Document.php.

115  {
116 
117  return self::UNKNOWN;
118 
119  }

Field Documentation

◆ $componentMap

Sabre\VObject\Document::$componentMap = []
static

Definition at line 72 of file Document.php.

◆ $defaultName

Sabre\VObject\Document::$defaultName
static

Definition at line 58 of file Document.php.

◆ $propertyMap

Sabre\VObject\Document::$propertyMap = []
static

Definition at line 65 of file Document.php.

◆ $valueMap

Sabre\VObject\Document::$valueMap = []
static

Definition at line 79 of file Document.php.

◆ ICALENDAR20

const Sabre\VObject\Document::ICALENDAR20 = 3

◆ UNKNOWN

const Sabre\VObject\Document::UNKNOWN = 1

◆ VCALENDAR10

const Sabre\VObject\Document::VCALENDAR10 = 2

vCalendar 1.0.

Definition at line 29 of file Document.php.

◆ VCARD21

◆ VCARD30

◆ VCARD40


The documentation for this class was generated from the following file: