Skip to content

Commit 916c014

Browse files
committed
Use UTF-8 as default output encoding
1 parent 4ca1c19 commit 916c014

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Simplified BSD License
22

33
Copyright (c) 2011-2014 Knut Ahlers <[email protected]>
4-
Copyright (c) 2013-2014 Sebastian Michaelsen <[email protected]>
4+
Copyright (c) 2013-2015 Sebastian Michaelsen <[email protected]>
55
All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without

classes/Bootstrap.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use AppZap\PHPFramework\Configuration\Configuration;
55
use AppZap\PHPFramework\Configuration\DefaultConfiguration;
66
use AppZap\PHPFramework\Configuration\Parser\IniParser;
7+
use AppZap\PHPFramework\Mvc\AbstractController;
78
use AppZap\PHPFramework\Mvc\ApplicationPartMissingException;
89
use AppZap\PHPFramework\Mvc\Dispatcher;
910
use AppZap\PHPFramework\SignalSlot\Dispatcher as SignalSlotDispatcher;
@@ -59,11 +60,12 @@ protected static function loadPlugins() {
5960
*
6061
*/
6162
protected static function registerCoreSlots() {
63+
SignalSlotDispatcher::registerSlot(AbstractController::SIGNAL_INIT_RESPONSE, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'contentTypeHeader']);
6264
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_CONSTRUCT, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'invokeDatabaseMigrator']);
63-
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_START_DISPATCHING, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'readOutputFromCache']);
6465
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_OUTPUT_READY, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'writeOutputToCache']);
6566
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_OUTPUT_READY, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'addFrameworkSignatureToOutput']);
6667
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_OUTPUT_READY, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'echoOutput']);
68+
SignalSlotDispatcher::registerSlot(Dispatcher::SIGNAL_START_DISPATCHING, ['AppZap\PHPFramework\SignalSlot\CoreSlots', 'readOutputFromCache']);
6769
}
6870

6971
/**

classes/Configuration/DefaultConfiguration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public static function initialize($application) {
1818
throw new ApplicationPartMissingException('Application folder ' . htmlspecialchars($applicationDirectoryPath) . ' not found', 1410538265);
1919
}
2020
$applicationDirectory .= '/';
21-
Configuration::set('phpframework', 'project_root', $projectRoot);
2221
Configuration::set('phpframework', 'db.migrator.directory', $applicationDirectory . '_sql/');
22+
Configuration::set('phpframework', 'project_root', $projectRoot);
2323
Configuration::set('application', 'application', $application);
2424
Configuration::set('application', 'application_directory', $applicationDirectory);
2525
Configuration::set('application', 'routes_file', $applicationDirectory . 'routes.php');

classes/SignalSlot/CoreSlots.php

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use AppZap\PHPFramework\Cache\Cache;
55
use AppZap\PHPFramework\Cache\CacheFactory;
66
use AppZap\PHPFramework\Configuration\Configuration;
7+
use AppZap\PHPFramework\Mvc\View\AbstractView;
78
use AppZap\PHPFramework\Persistence\DatabaseMigrator;
89

910
class CoreSlots {
@@ -61,4 +62,16 @@ public static function echoOutput($output) {
6162
}
6263
}
6364

65+
/**
66+
* @param AbstractView $response
67+
*/
68+
public static function contentTypeHeader(AbstractView $response) {
69+
$contentType = 'text/html';
70+
$charset = Configuration::get('phpframework', 'output_charset', 'utf-8');
71+
if ($charset) {
72+
$contentType .= '; charset=' . trim($charset);
73+
}
74+
$response->header('Content-Type', $contentType);
75+
}
76+
6477
}

0 commit comments

Comments
 (0)