Class:SmartestParameterHolder

From The Smartest Wiki
(Redirected from SmartestParameterHolder)
Jump to: navigation, search

SmartestParameterHolder is one of Smartest's basic types, and is a very important class in Smartest. Unlike most of the other basic types, It is used both in the building of web pages and in much of Smartest's back-end functionality. Unlike the SmartestArray class, which is more for lists of like objects or values, it is used like an associative array. However, like SmartestArray, it has a number of features that an ordinary array does not have. For instance, it can be locked, or made read-only. Also, when accidentally printed or converted to a string, it gives its name, which is set when the object is instantiated, instead of 'Array'. It can easily convert itself to an array, a JSON string, or stdClass object, and can absorb PHP arrays, even recursively when some of their values are also arrays, creating further SmartestParameterHolder instances. It can be looped over like a normal PHP array, also has several 'magic' offsets for counting and checking values, and retrieving keys.

Offsets

  • _count
  • _first
  • _last
  • _json
  • _keys
  • _has
  • _debug

Note that the values stored in the SmartestParameterHolder are also available as offsets, since each most be named when it is added:

Create:

$ph = new SmartestParameterHolder('Essential Values');
$ph->setParameter('name', 'value');

Template:

<?sm:$myobject.name:?>