Open Source Content Management Framework

midgard_reflection_property

  1. Creating a New midgard_reflection_property Instance
  2. Midgard Reflection Property Methods
  3. Usage Example:

The main purpose of midgard_reflection_property class is to let developers write "reflected" applications and provide as many information defined in MgdSchema files as possible.

midgard_reflection_property provides information defined in schema files as properties' attributes, such as: multilang, link, type.

Minimum version: 1.8alpha3 "Hot&Black"

Creating a New midgard_reflection_property Instance

The Midgard Reflection Property object is instantiated with a classname as parameter.

object midgard_reflection_property(string 'classname');

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

A Warning messag is logged and the constructor returns FALSE if the class's name used as constructor parameter is not the name of a registered MgdSchema class and if the class doesn't extend the base schema class.

<?php

$classname = "midgard_group";
if($mrp = new midgard_reflection_property($classname))
{
    echo "Reflection property class instance successfully created";
}
?>

Midgard Reflection Property Methods

Usage Example:

<?php

$article = new midgard_article();
$ref = new midgard_reflection_property(get_class($article));

foreach (get_object_vars($article) as $key => $val){

    print "\n Property $key :\n";
    $descr = $ref->description($key);
    print "\t '$descr' \n";
    if($ref->is_multilang($key))
            print "\t is multilang \n";
    else
            print "\t is not multilang\n";

    if($ref->is_link($key)) {
            $link = $ref->get_link_name($key);
            print "\t is a link to $link \n";
    }

    $type = $ref->get_midgard_type($key);
    if($type == MGD_TYPE_LONGTEXT)
            print "\t is editable text \n";

    if($type == MGD_TYPE_TIMESTAMP)
                    print "\t is setable date \n";

}
Tagged
midgard-1.8.0
mgdschema
multilang
Designed by Nemein, hosted by Anykey