Horde_Form::getType PHP 메소드

getType() 공개 메소드

public getType ( $type, $params = [] )
    function getType($type, $params = array())
    {
        if (strpos($type, ':') !== false) {
            list($app, $type) = explode(':', $type);
            $type_class = $app . '_Form_Type_' . $type;
        } else {
            $type_class = 'Horde_Form_Type_' . $type;
        }
        if (!class_exists($type_class)) {
            throw new Horde_Exception(sprintf('Nonexistant class "%s" for field type "%s"', $type_class, $type));
        }
        $type_ob = new $type_class();
        if (!$params) {
            $params = array();
        }
        call_user_func_array(array($type_ob, 'init'), $params);
        return $type_ob;
    }

Usage Example

예제 #1
0
파일: Table.php 프로젝트: jubinpatel/horde
 /**
  * Return the metadata for the table.
  *
  * @return array  An array of the table metadata.
  * @throws Hermes_Exception
  */
 public function getMetaData()
 {
     if (is_null($this->_metaData)) {
         list($app, $name) = explode('/', $this->_config['name']);
         $args = array($name, $this->_config['params']);
         $this->_metaData = $GLOBALS['registry']->callByPackage($app, 'getTableMetaData', $args);
         // We need to make vars for the columns.
         foreach ($this->_metaData['sections'] as $secname => $section) {
             foreach ($section['columns'] as $col) {
                 $title = isset($col['title']) ? $col['title'] : '';
                 $typename = isset($col['type']) ? $col['type'] : 'text';
                 $params = isset($col['params']) ? $col['params'] : array();
                 // Column types which begin with % are pseudo-types handled
                 // directly.
                 if (substr($typename, 0, 1) != '%') {
                     // This type needs to be assigned by reference!
                     $type =& Horde_Form::getType($typename, $params);
                     $var = new Horde_Form_Variable($title, $col['name'], $type, false, true, '');
                     $this->_formVars[$secname][$col['name']] = $var;
                 }
             }
         }
     }
     return $this->_metaData;
 }
All Usage Examples Of Horde_Form::getType