Open Source Content Management System

PHP midgard_collector constructor

  1. Example

object midgard_collector(string 'classname', string 'domain', mixed value);

midgard_collector constructor takes three parameters:

  • classname, name of the class for which collector should be initialized
  • domain, name of property which should be used as collector's domain
  • value, value of domain property

Derived classes' names may be used as classname parameter too. In such case base schema classname is determined internally by midgard-php extension and used by midgard-core's reflection property object.

Constructor returns FALSE:

  • classname is not registered as MgdSchema class , or classname is the name of class which doesn't extend one of MgdSchema class.
  • midgard-core couldn't instatiate new object

More details about fail on object instantiation can be found in midgard-core docs.

Domain property and its value is used to limit resultset returned by query.

Example

<?php

$person_id = 123; 
$mc = new midgard_collector('midgard_event', 'owner', $person_id);
$mc->set_key_property('title');
$mc->add_value_property('extra'); 
?>

Midgard Collector will query only those properties of an object for which owner is equal to $person_id. Title property is internally set as key , on PHP level is a key of associative array. Extra property is set as key of associative array assigned as key's value.

<?php 

/* We expect that there is event with 'holiday meeting' title. 
 * And we would like to know value of the extra property. */

$ret_array = $mc->get('holiday meeting');

echo $ret_array['extra'];
?>

In above example, value of extra property is returned for this object which owner is set as $person_id and title of this object is equal to 'holiday meeting'.

Designed by Nemein, hosted by Anykey