本文整理汇总了PHP中fORM::callInspectCallbacks方法的典型用法代码示例。如果您正苦于以下问题:PHP fORM::callInspectCallbacks方法的具体用法?PHP fORM::callInspectCallbacks怎么用?PHP fORM::callInspectCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fORM
的用法示例。
在下文中一共展示了fORM::callInspectCallbacks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: inspect
/**
* Returns the metadata about a column including features added by this class
*
* @internal
*
* @param fActiveRecord $object The fActiveRecord instance
* @param array &$values The current values
* @param array &$old_values The old values
* @param array &$related_records Any records related to this record
* @param array &$cache The cache array for the record
* @param string $method_name The method that was called
* @param array $parameters The parameters passed to the method
* @return mixed The metadata array or element specified
*/
public static function inspect($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters)
{
list($action, $subject) = fORM::parseMethod($method_name);
$column = fGrammar::underscorize($subject);
$class = get_class($object);
$table = fORM::tablize($class);
$db = fORMDatabase::retrieve($class, 'read');
$schema = fORMSchema::retrieve($class);
$info = $schema->getColumnInfo($table, $column);
$element = isset($parameters[0]) ? $parameters[0] : NULL;
$other_columns = self::$ordering_columns[$class][$column];
// Retrieve the current max ordering index from the database
$params = array("SELECT MAX(%r) FROM %r", $column, $table);
if ($other_columns) {
$params[0] .= " WHERE ";
$params = self::addOtherFieldsWhereParams($schema, $params, $table, $other_columns, $values);
}
$max_value = (int) call_user_func_array($db->translatedQuery, $params)->fetchScalar();
// If this is a new record, or in a new set, we need one more space in the ordering index
if (self::isInNewSet($column, $other_columns, $values, $old_values)) {
$max_value += 1;
}
$info['max_ordering_value'] = $max_value;
$info['feature'] = 'ordering';
fORM::callInspectCallbacks($class, $column, $info);
if ($element) {
return isset($info[$element]) ? $info[$element] : NULL;
}
return $info;
}
示例2: inspect
/**
* Retrieves information about a column
*
* @param string $column The name of the column to inspect
* @param string $element The metadata element to retrieve
* @return mixed The metadata array for the column, or the metadata element specified
*/
protected function inspect($column, $element = NULL)
{
if (!array_key_exists($column, $this->values)) {
throw new fProgrammerException('The column specified, %s, does not exist', $column);
}
$class = get_class($this);
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve($class);
$info = $schema->getColumnInfo($table, $column);
if (!in_array($info['type'], array('varchar', 'char', 'text'))) {
unset($info['valid_values']);
unset($info['max_length']);
}
if ($info['type'] != 'float') {
unset($info['decimal_places']);
}
if ($info['type'] != 'integer') {
unset($info['auto_increment']);
}
if (!in_array($info['type'], array('integer', 'float'))) {
unset($info['min_value']);
unset($info['max_value']);
}
$info['feature'] = NULL;
fORM::callInspectCallbacks(get_class($this), $column, $info);
if ($element) {
if (!isset($info[$element]) && !array_key_exists($element, $info)) {
throw new fProgrammerException('The element specified, %1$s, is invalid. Must be one of: %2$s.', $element, join(', ', array_keys($info)));
}
return $info[$element];
}
return $info;
}
示例3: inspect
/**
* Returns the metadata about a column including features added by this class
*
* @internal
*
* @param fActiveRecord $object The fActiveRecord instance
* @param array &$values The current values
* @param array &$old_values The old values
* @param array &$related_records Any records related to this record
* @param array &$cache The cache array for the record
* @param string $method_name The method that was called
* @param array $parameters The parameters passed to the method
* @return mixed The metadata array or element specified
*/
public static function inspect($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters)
{
list($action, $column) = fORM::parseMethod($method_name);
$class = get_class($object);
$table = fORM::tablize($class);
$info = fORMSchema::retrieve()->getColumnInfo($table, $column);
$element = isset($parameters[0]) ? $parameters[0] : NULL;
$column = self::$ordering_columns[$class]['column'];
$other_columns = self::$ordering_columns[$class]['other_columns'];
// Retrieve the current max ordering index from the database
$sql = "SELECT max(" . $column . ") FROM " . $table;
if ($other_columns) {
$sql .= " WHERE " . self::createOtherFieldsWhereClause($table, $other_columns, $values);
}
$max_value = (int) fORMDatabase::retrieve()->translatedQuery($sql)->fetchScalar();
// If this is a new record, or in a new set, we need one more space in the ordering index
if (self::isInNewSet($column, $other_columns, $values, $old_values)) {
$max_value += 1;
}
$info['max_ordering_value'] = $max_value;
$info['feature'] = 'ordering';
fORM::callInspectCallbacks($class, $column, $info);
if ($element) {
return isset($info[$element]) ? $info[$element] : NULL;
}
return $info;
}