protected static function generateResponse($response) { if ($response === null) { $method_name = strtolower(preg_replace('/([a-z])([A-Z])/e', "'\\1_'.strtolower('\\2')", self::$status['current_method'])); $controller_name = strtolower(preg_replace('/([a-z])([A-Z])/e', "'\\1_'.strtolower('\\2')", self::$status['current_controller'])); $try_one = self::getDefaultViewDirectory() . $controller_name . '/' . $method_name . '.php'; $try_two = self::getDefaultViewDirectory() . PicoraSupport::pluralize($controller_name) . '/' . $method_name . '.php'; if (file_exists($try_one)) { $response = PicoraController::render($try_one); } elseif (file_exists($try_two)) { $response = PicoraController::render($try_two); } else { throw new Exception(self::$status['current_controller'] . 'Controller->' . self::$status['current_method'] . '() returned null, and no matching view was found.'); } } return self::getRequestMethod() == 'ajax' ? $response : call_user_func(self::$layout_handler, $response instanceof PicoraView ? $response->display() : $response, self::getCurrentController()); }
/** * @param string $class_name * @return string */ public static final function tableNameFromClassName($class_name) { if (!isset(self::$__table_names__[$class_name])) { if (!class_exists($class_name)) { $table_name = $class_name; } else { $table_name = defined($class_name . '::TABLE_NAME') ? constant($class_name . '::TABLE_NAME') : null; if ($table_name === null) { $table_name = PicoraSupport::pluralize(strtolower(preg_replace('/([a-z])([A-Z])/e', "'\\1_'.strtolower('\\2')", str_replace('ActiveRecord', '', $class_name)))); } } self::$__table_names__[$class_name] = $table_name; } return self::$__table_names__[$class_name]; }