Generates a handler for a specific Kolab object type.
public create ( string $format = 'Xml', string $type = '', array $params = [] ) : Horde_Kolab_Format | ||
$format | string | The format that the handler should work with. |
$type | string | The object type that should be handled. |
$params | array | Additional parameters.
'version' - The format version. |
Результат | Horde_Kolab_Format | The handler. |
private function _getHprefsV1() { $factory = new Horde_Kolab_Format_Factory(); return $factory->create('Xml', 'Hprefs', array('version' => 1)); }
public function testConstructorParams() { if (!class_exists('Horde_Support_Timer')) { $this->markTestSkipped('Horde_Support package missing!'); } $factory = new Horde_Kolab_Format_Factory(array('timelog' => true)); $this->assertInstanceOf('Horde_Kolab_Format_Decorator_Timed', $factory->create('Xml', 'contact')); }
<?php /** * A sample script for reading/writing an event using internal API version 2. * * PHP version 5 * * @category Kolab * @package Kolab_Format * @author Gunnar Wrobel <*****@*****.**> * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @link http://www.horde.org/libraries/Horde_Kolab_Format */ /** * The Autoloader allows us to omit "require/include" statements. */ require_once 'Horde/Autoloader/Default.php'; /** Create the factory */ $factory = new Horde_Kolab_Format_Factory(); /** Generate the format handler */ $format = $factory->create('Xml', 'Event'); $now = new DateTime(); /** Prepare a test object */ $object = array('uid' => 1, 'summary' => 'test event', 'start-date' => array('date' => $now), 'end-date' => array('date' => $now)); /** Save this test data array in Kolab XML format */ $xml = $format->save($object); var_dump($xml); /** Reload the object from the XML format */ $read_object = $format->load($xml); var_dump($read_object);
{ /** * Specific data fields for the prefs object * * @var Kolab */ protected $_fields_specific; /** * Constructor */ public function __construct($parser, $params = array()) { $this->_root_name = 'string'; /** Specific preferences fields, in kolab format specification order */ $this->_fields_specific = array('string' => array('type' => self::TYPE_STRING, 'value' => self::VALUE_MAYBE_MISSING)); parent::__construct($parser, $params); } } /** Create the factory */ $factory = new Horde_Kolab_Format_Factory(); /** Generate the format handler */ $format = $factory->create('Xml', 'String'); /** Prepare a test object */ $object = array('uid' => 1, 'string' => 'test string'); /** Save this test data array in Kolab XML format */ $xml = $format->save($object); var_dump($xml); /** Reload the object from the XML format */ $read_object = $format->load($xml); var_dump($read_object);
private function _getParser($type) { return $this->_factory->create('Xml', $type, $this->_params); }
public function testVersion() { $factory = new Horde_Kolab_Format_Factory(); $note = $factory->create('Xml', 'Note'); $this->assertEquals(2, $note->getVersion()); }
private function _getContact() { $factory = new Horde_Kolab_Format_Factory(); return $factory->create('Xml', 'Contact'); }
<?php /** * A sample script for reading/writing an event. * * PHP version 5 * * @category Kolab * @package Kolab_Format * @author Gunnar Wrobel <*****@*****.**> * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @link http://www.horde.org/libraries/Horde_Kolab_Format */ /** * The Autoloader allows us to omit "require/include" statements. */ require_once 'Horde/Autoloader/Default.php'; /** Create the factory */ $factory = new Horde_Kolab_Format_Factory(); /** Generate the format handler */ $format = $factory->create('Xml', 'Event', array('version' => 1)); /** Prepare a test object */ $object = array('uid' => 1, 'summary' => 'test event', 'start-date' => time(), 'end-date' => time() + 24 * 60 * 60); /** Save this test data array in Kolab XML format */ $xml = $format->save($object); var_dump($xml); /** Reload the object from the XML format */ $read_object = $format->load($xml); var_dump($read_object);
private function _getEnvelope() { $factory = new Horde_Kolab_Format_Factory(); return $factory->create('Xml', 'Envelope'); }