本文整理匯總了PHP中fORM::isClassMappedToTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP fORM::isClassMappedToTable方法的具體用法?PHP fORM::isClassMappedToTable怎麽用?PHP fORM::isClassMappedToTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fORM
的用法示例。
在下文中一共展示了fORM::isClassMappedToTable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: determineSubject
/**
* Takes information from a method call and determines the subject, route and if subject was plural
*
* @param string $class The class the method was called on
* @param string $subject An underscore_notation subject - either a singular or plural class name
* @param string $route The route to the subject
* @return array An array with the structure: array(0 => $subject, 1 => $route, 2 => $plural)
*/
private static function determineSubject($class, $subject, $route)
{
$schema = fORMSchema::retrieve($class);
$table = fORM::tablize($class);
$type = '*-to-many';
$plural = FALSE;
// one-to-many relationships need to use plural forms
$singular_form = fGrammar::singularize($subject, TRUE);
if ($singular_form && fORM::isClassMappedToTable($singular_form)) {
$subject = $singular_form;
$plural = TRUE;
} elseif (!fORM::isClassMappedToTable($subject) && in_array(fGrammar::underscorize($subject), $schema->getTables())) {
$subject = fGrammar::singularize($subject);
$plural = TRUE;
}
$related_table = fORM::tablize($subject);
$one_to_one = fORMSchema::isOneToOne($schema, $table, $related_table, $route);
if ($one_to_one) {
$type = 'one-to-one';
}
if ($one_to_one && $plural || !$plural && !$one_to_one) {
throw new fProgrammerException('The table %1$s is not in a %2$srelationship with the table %3$s', $table, $type, $related_table);
}
$route = fORMSchema::getRouteName($schema, $table, $related_table, $route, $type);
return array($subject, $route, $plural);
}