Class Object

(line 77)

Description


Located in File: /system.inc.php

Object is the ultimate ancestor of all objects and components.

Object encapsulates fundamental behavior common to objects by introducing methods that

create, maintain and destroy instances of the object by allocating, initializing, and freeing required memory.

respond when object instances are created or destroyed.

return class-type and instance information on an object and runtime type information (RTTI) about its published properties.

Use Object as an immediate base class when declaring simple objects that do not need to persist (are not saved and reloaded in the session) and that do not need to be assigned to other objects.

Much of the capability of objects is established by methods that Object introduces. Many of these methods are used internally by IDEs and are not intended for users to call directly. Others are overridden in descendant objects that have more complex behavior.

Although Object is the based object of a component framework, not all objects are components. All component classes are descended from Component.

To create a class that belongs to the class library, you must, at least, inherit from Object, which provides the basic methods to work.



Classes extended from Object:
Filer
A base class that reads/writes components from/to an xml stream
Collection
A class for storing and managing a list of objects. This class acts as a wrapper over a PHP array.
Persistent
A base class for persistent objects which are the ones which provide the required features to be serialized/unserialized easily.
Field
Encapsulates a table field
PropertyEditor
Base class for property editors
ComponentEditor
Base class for component editors

Properties

Summary:

[none]

Methods

Summary:
__construct Constructs an object and initializes its data before the object is first used.
className Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
classNameIs Determines whether an object is of a specific type.
classParent Returns the type of the immediate ancestor of a class.
inheritsFrom Determines the relationship of two object types.
methodExists Check if a method exists declared on this object instance.
__get To virtualize properties
__set To virtualize properties

Constructor __construct (line 98)

Object __construct( )

Constructs an object and initializes its data before the object is first used.

Create constructs an object. The purpose, size, and behavior of objects differ greatly. The Create constructor defined by Object allocates memory but does not initialize data.

Descendant objects usually define a constructor that creates the particular kind of object and initializes its data.

In Object, this constructor basically assigns the globa Input object to be available as a field for all objects.


Method className (line 130)

string className( )

Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).

Use ClassName to obtain the class name from an object instance. This is useful for differentiating object instances that are assigned to a variable that has the type of an ancestor class.

  1.  <?php
  2.          //Class definition
  3.          class Unit467 extends Page
  4.          {
  5.                 function Unit467BeforeShow($sender$params)
  6.                 {
  7.                  echo $this->className();
  8.                  //This will echo Unit467 on the browser
  9.                 }
  10.  
  11.          }
  12.  ?>

Info

  • return - Name of this object class

Method classNameIs (line 158)

boolean classNameIs( string $name)

Determines whether an object is of a specific type.

ClassNameIs determines whether an object instance has a class name that matches a specified string.

  1.  <?php
  2.          //Class definition
  3.          class Unit467 extends Page
  4.          {
  5.                 function Unit467BeforeShow($sender$params)
  6.                 {
  7.                   if ($this->classNameIs("Unit467")) echo "This is the right form!";
  8.                 }
  9.  
  10.          }
  11.  ?>

Parameters

  • string $name: Name to compare

Info

  • return - True if classname of this object is $name

Method classParent (line 213)

class classParent( )

Returns the type of the immediate ancestor of a class.

ClassParent returns the name of the parent class for an object instance. For Object, ClassParent returns false. Avoid using ClassParent in application code.

  1.  <?php
  2.          //Class definition
  3.          class Unit467 extends Page
  4.          {
  5.                 function Unit467BeforeShow($sender$params)
  6.                 {
  7.                    echo $this->classParent();
  8.                    //This will echo Page
  9.                 }
  10.  
  11.          }
  12.  ?>

Info

  • return - Class from which this object inherits

Method inheritsFrom (line 243)

boolean inheritsFrom( string $class)

Determines the relationship of two object types.

Use InheritsFrom to determine if a particular class type or object is an instance of a class or one of its descendants. InheritsFrom returns true if the object type specified in the class parameter is an ancestor of the object type or the type of the object itself. Otherwise, it returns false.

  1.  <?php
  2.          //Class definition
  3.          class Unit467 extends Page
  4.          {
  5.                 function Unit467BeforeShow($sender$params)
  6.                 {
  7.                    if ($this->inheritsFrom("Page")) echo "This is a page!";
  8.                 }
  9.  
  10.          }
  11.  ?>

Parameters

  • string $class: Class name to check

Info

  • return - True if this object inherits from $class

Method methodExists (line 184)

boolean methodExists( string $method)

Check if a method exists declared on this object instance.

  1.  <?php
  2.          //Class definition
  3.          class Unit467 extends Page
  4.          {
  5.                 function Unit467BeforeShow($sender$params)
  6.                 {
  7.                   if ($this->methodExists("Unit467BeforeShow")) echo "It exists!";
  8.                 }
  9.  
  10.          }
  11.  ?>

Parameters

  • string $method: Method name to check

Info

  • return - True if $method exists

Method __get (line 276)

mixed __get( string $nm)

To virtualize properties

This PHP magic method is used on the class library to allow you create property (public and published) so you can write setters and getters and use property names in your code.

Parameters

  • string $nm: Property name

Method __set (line 324)

void __set( string $nm, mixed $val)

To virtualize properties

This PHP magic method is used on the class library to allow you create property (public and published) so you can write setters and getters and use property names in your code.

Parameters

  • string $nm: Property name
  • mixed $val: Property value

Events

Summary:

[none]

Javascript Events

Summary:

[none]

Documentation generated on Fri, 26 Dec 2008 11:46:47 +0100 by phpDocumentor 1.4.0a2