コード例 #1
0
ファイル: Exception.php プロジェクト: wave-framework/wave
 public static function handle($e, $send_response = true)
 {
     try {
         Hook::triggerAction('exception.handle', array(&$e));
         $log_message = sprintf('%-4s %s', "({$e->getCode()})", $e->getMessage());
         // get the channel manually so the introspection works properly.
         $level = Log::ERROR;
         if ($e instanceof ErrorException && isset(self::$levels[$e->getSeverity()])) {
             $level = self::$levels[$e->getSeverity()];
         }
         Log::getChannel('exception')->addRecord($level, $log_message, array('exception' => $e));
         $request = static::$request;
         if ($request === null) {
             $request = Request::createFromGlobals();
         }
         $action = Action::getDefaultAction(self::$_controller);
         $action->setRespondsWith(array('*'), false);
         $response = Controller::invoke($action, $request, array('exception' => $e));
         $response->prepare($request);
         if ($send_response) {
             $response->send();
         }
         return $response;
     } catch (\Exception $_e) {
         $response = new Response();
         $response->setStatusCode(500);
         if (Core::$_MODE === Core::MODE_PRODUCTION) {
             $response->setContent("Internal server error");
         } else {
             $response->setContent($e->__toString() . "\n\n\nAdditionally, the following exception occurred while trying to handle the error:\n\n" . $_e->__toString());
         }
         return $response;
     }
 }
コード例 #2
0
ファイル: Cli.php プロジェクト: wave-framework/wave
 public static function createChannel($channel, AbstractHandler $handler = null)
 {
     $cli_handler = new CliHandler();
     $cli_handler->setFormatter(new LineFormatter(CliHandler::LINE_FORMAT));
     $channel_handler = parent::createChannel($channel, $handler);
     $channel_handler->pushHandler($cli_handler);
     static::setChannel($channel, $channel_handler);
     return $channel_handler;
 }
コード例 #3
0
ファイル: MySQL.php プロジェクト: wave-framework/wave
 public static function getRelations(DB\Table $table)
 {
     //using namespace for the table identifier as there might be same name DBs on different servers
     $namespace = $table->getDatabase()->getNamespace();
     $relation_cache = self::_getRelationCache($table);
     $relations = array();
     //may not be any constraints
     if ($relation_cache !== null) {
         foreach ($relation_cache as $cached_row) {
             //--- check both ends of the relation can be built.
             $local_db = DB::getByDatabaseName($cached_row['TABLE_SCHEMA']);
             if ($local_db === null) {
                 Wave\Log::write('mysql_driver', sprintf('Database [%s] is not referenced in the configuration - skipping building relations.', $cached_row['TABLE_SCHEMA']), Wave\Log::WARNING);
                 continue;
             }
             $local_column = $local_db->getColumn($cached_row['TABLE_NAME'], $cached_row['COLUMN_NAME']);
             //skip if there's no referenced schema.  This is because primary keys will be in the relation cache (no ref schema)
             if ($cached_row['REFERENCED_TABLE_SCHEMA'] === null) {
                 continue;
             }
             $referenced_db = DB::getByDatabaseName($cached_row['REFERENCED_TABLE_SCHEMA']);
             if ($referenced_db === null) {
                 Wave\Log::write('mysql_driver', sprintf('Database [%s] is not referenced in the configuration - skipping building relations.', $cached_row['REFERENCED_TABLE_SCHEMA']), Wave\Log::WARNING);
                 continue;
             }
             $referenced_column = $referenced_db->getColumn($cached_row['REFERENCED_TABLE_NAME'], $cached_row['REFERENCED_COLUMN_NAME']);
             if ($referenced_column === null) {
                 Wave\Log::write('mysql_driver', sprintf('Column [%s] is not referenced in the configuration - skipping building relations.', $cached_row['REFERENCED_COLUMN_NAME']), Wave\Log::WARNING);
                 continue;
             }
             //-----
             if ($cached_row['REFERENCED_TABLE_SCHEMA'] != $cached_row['TABLE_SCHEMA']) {
                 //print_r($cached_row);
                 //exit;
             }
             $relation = DB\Relation::create($local_column, $referenced_column, $cached_row['CONSTRAINT_NAME'], isset($cached_row['REVERSE']));
             if ($relation !== null) {
                 $relations[$relation->getIdentifyingName()] = $relation;
             } else {
                 Wave\Log::write('mysql_driver', sprintf('[%s.%s.%s] has duplicate relations.', $cached_row['TABLE_SCHEMA'], $cached_row['TABLE_NAME'], $cached_row['COLUMN_NAME']), Wave\Log::WARNING);
             }
         }
     }
     return $relations;
 }
コード例 #4
0
ファイル: Postgresql.php プロジェクト: wave-framework/wave
 public static function getRelations(DB\Table $table)
 {
     //using namespace for the table identifier as there might be same name DBs on different servers
     $namespace = $table->getDatabase()->getNamespace();
     $relation_cache = self::_getRelationCache($table);
     $relations = array();
     //may not be any constraints
     if ($relation_cache !== null) {
         foreach ($relation_cache as $cached_row) {
             //--- check both ends of the relation can be built.
             $local_db = DB::getByConfig(array('database' => $cached_row['table_catalog'], 'schema' => $cached_row['table_schema']));
             if ($local_db === null) {
                 Log::write('pgsql_driver', sprintf('Database [%s] is not referenced in the configuration - skipping building relations.', $cached_row['table_catalog']), Log::WARNING);
                 continue;
             }
             $local_column = $local_db->getColumn($cached_row['table_name'], $cached_row['column_name']);
             //skip if there's no referenced schema.  This is because primary keys will be in the relation cache (no ref schema)
             if ($cached_row['referenced_table_schema'] === null) {
                 continue;
             }
             $referenced_db = DB::getByConfig(array('database' => $cached_row['referenced_table_catalog'], 'schema' => $cached_row['referenced_table_schema']));
             if ($referenced_db === null) {
                 Log::write('pgsql_driver', sprintf('Database [%s] is not referenced in the configuration - skipping building relations.', $cached_row['referenced_table_schema']), Log::WARNING);
                 continue;
             }
             $referenced_column = $referenced_db->getColumn($cached_row['referenced_table_name'], $cached_row['referenced_column_name']);
             //-----
             $relation = DB\Relation::create($local_column, $referenced_column, $cached_row['constraint_name'], isset($cached_row['reverse']));
             if ($relation !== null) {
                 $relations[$relation->getIdentifyingName()] = $relation;
             } else {
                 Log::write('mysql_driver', sprintf('[%s.%s.%s] has duplicate relations.', $cached_row['table_schema'], $cached_row['table_name'], $cached_row['column_name']), Log::WARNING);
             }
         }
     }
     return $relations;
 }