Skip to content

Sabre VObject Component

Evert Pot edited this page Jun 6, 2013 · 5 revisions

Sabre\VObject\Component

Component

A component represents a group of properties, such as VCALENDAR, VEVENT, or VCARD.

Properties

$name

public string $name

Component name.

This will contain a string such as VEVENT, VTODO, VCALENDAR, VCARD.

  • Visibility: public

$children

public array $children = array()

A list of properties and/or sub-components.

  • Visibility: public

$parent

public \Sabre\VObject\Node $parent

Reference to the parent object, if this is not the top object.

$iterator

protected \Sabre\VObject\ElementList $iterator = null

Iterator override

$root

protected \Sabre\VObject\Component $root

The root document

Methods

__construct

void Sabre\VObject\Component::__construct(\Sabre\VObject\Document $root, string $name, array $children, bool $defaults)

Creates a new component.

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.

  • Visibility: public

Arguments

add

\Sabre\VObject\Node Sabre\VObject\Component::add($a1, $a2, $a3)

Adds a new property or component, and returns the new item.

This method has 3 possible signatures:

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.

  • Visibility: public

Arguments

  • $a1 mixed
  • $a2 mixed
  • $a3 mixed

remove

void Sabre\VObject\Component::remove(mixed $item)

This method removes a component or property from this component.

You can either specify the item by name (like DTSTART), in which case all properties/components with that name will be removed, or you can pass an instance of a property or component, in which case only that exact item will be removed.

The removed item will be returned. In case there were more than 1 items removed, only the last one will be returned.

  • Visibility: public

Arguments

  • $item mixed

children

array Sabre\VObject\Component::children()

Returns an iterable list of children

  • Visibility: public

getComponents

array Sabre\VObject\Component::getComponents()

This method only returns a list of sub-components.

Properties are ignored.

  • Visibility: public

select

array Sabre\VObject\Component::select(string $name)

Returns an array with elements that match the specified name.

This function is also aware of MIME-Directory groups (as they appear in vcards). This means that if a property is grouped as "HOME.EMAIL", it will also be returned when searching for just "EMAIL". If you want to search for a property in a specific group, you can select on the entire string ("HOME.EMAIL"). If you want to search on a specific property that has not been assigned a group, specify ".EMAIL".

Keys are retained from the 'children' array, which may be confusing in certain cases.

  • Visibility: public

Arguments

  • $name string

serialize

string Sabre\VObject\Component::serialize()

Turns the object back into a serialized blob.

  • Visibility: public

jsonSerialize

array Sabre\VObject\Component::jsonSerialize()

This method returns an array, with the representation as it should be encoded in json.

This is used to create jCard or jCal documents.

  • Visibility: public

getDefaults

array Sabre\VObject\Component::getDefaults()

This method should return a list of default property values.

  • Visibility: protected

__get

\Sabre\VObject\Property Sabre\VObject\Component::__get(string $name)

Using 'get' you will either get a property or component.

If there were no child-elements found with the specified name, null is returned.

To use this, this may look something like this:

$event = $calendar->VEVENT;

  • Visibility: public

Arguments

  • $name string

__isset

bool Sabre\VObject\Component::__isset(string $name)

This method checks if a sub-element with the specified name exists.

  • Visibility: public

Arguments

  • $name string

__set

void Sabre\VObject\Component::__set(string $name, mixed $value)

Using the setter method you can add properties or subcomponents

You can either pass a Component, Property object, or a string to automatically create a Property.

If the item already exists, it will be removed. If you want to add a new item with the same name, always use the add() method.

  • Visibility: public

Arguments

  • $name string
  • $value mixed

__unset

void Sabre\VObject\Component::__unset(string $name)

Removes all properties and components within this component with the specified name.

  • Visibility: public

Arguments

  • $name string

__clone

void Sabre\VObject\Component::__clone()

This method is automatically called when the object is cloned.

Specifically, this will ensure all child elements are also cloned.

  • Visibility: public

validate

array Sabre\VObject\Component::validate(int $options)

Validates the node for correctness.

The following options are supported: - Node::REPAIR - If something is broken, an automatic repair may be attempted.

An array is returned with warnings.

Every item in the array has the following properties: * level - (number between 1 and 3 with severity information) * message - (human readable message) * node - (reference to the offending node)

  • Visibility: public

Arguments

  • $options int

getIterator

\Sabre\VObject\ElementList Sabre\VObject\Node::getIterator()

Returns the iterator for this object

setIterator

void Sabre\VObject\Node::setIterator(\Sabre\VObject\ElementList $iterator)

Sets the overridden iterator

Note that this is not actually part of the iterator interface

Arguments

count

int Sabre\VObject\Node::count()

Returns the number of elements

offsetExists

bool Sabre\VObject\Node::offsetExists(int $offset)

Checks if an item exists through ArrayAccess.

This method just forwards the request to the inner iterator

Arguments

  • $offset int

offsetGet

mixed Sabre\VObject\Node::offsetGet(int $offset)

Gets an item through ArrayAccess.

This method just forwards the request to the inner iterator

Arguments

  • $offset int

offsetSet

void Sabre\VObject\Node::offsetSet(int $offset, mixed $value)

Sets an item through ArrayAccess.

This method just forwards the request to the inner iterator

Arguments

  • $offset int
  • $value mixed

offsetUnset

void Sabre\VObject\Node::offsetUnset(int $offset)

Sets an item through ArrayAccess.

This method just forwards the request to the inner iterator

Arguments

  • $offset int
Clone this wiki locally