示例#1
0
 /**
  * Run related method of the CPT object
  *
  * @param string $method camelCase method name
  * @param array $args Arguments to send function
  *
  * @return result of CPT::{{method}}()
  *
  * @see CPT
  */
 public function __call($method, $args)
 {
     // Make CPT method name
     $method = Inflector::camel2id($method, '_');
     // Return result of the method
     return call_user_func_array([$this->_cpt, $method], $args);
 }
示例#2
0
 /**
  * Get meta name
  * The name that integrates the field in server and client
  * Server using : Get meta name and set element value
  * Client using : Html element name, id, label assign
  * 
  * @param string $fieldName The name of the field
  *
  * @return string The binding name
  *
  * @throws Exception if the name of the field is invalid
  * @throws Exception if the field not found in the meta box
  */
 public function getMetaName($field)
 {
     if (!is_string($field)) {
         // Throw Exception if the field is not a string
         throw new Exception("First argument must be the name of the field", 1);
     }
     // Check field name existing
     if (!isset($this->fields[$field])) {
         // Throw Exception if the field not found in the meta box
         throw new Exception("{$field} not found in the meta box : {$this->name}", 1);
     }
     // If the meta name not set in the field
     if (!isset($this->fields[$field]['metaName'])) {
         // Binding names start with the name of the box
         $metaName = Inflector::camelize($this->name);
         // Append the field name to the binding name
         $metaName .= Inflector::camelize($field);
         // Use (_) seperator insetead of camelCase
         $this->fields[$field]['metaName'] = Inflector::camel2id($metaName, '_');
     }
     return $this->fields[$field]['metaName'];
 }