Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpkernelrest.php
Go to the documentation of this file.
1 <?php
11 class ezpKernelRest implements ezpKernelHandler
12 {
18 protected $isInitialized = false;
19
25 protected $settings;
26
32 protected $access;
33
37 protected $uri;
38
47 private $responseWriterClass;
48
49 private static $response;
50
55 public function __construct( array $settings = array(), $responseWriterClass = null )
56 {
57 $this->responseWriterClass = $responseWriterClass;
58
59 if ( isset( $settings['injected-settings'] ) )
60 {
61 $injectedSettings = array();
62 foreach ( $settings['injected-settings'] as $keySetting => $injectedSetting )
63 {
64 list( $file, $section, $setting ) = explode( '/', $keySetting );
65 $injectedSettings[$file][$section][$setting] = $injectedSetting;
66 }
67 // Those settings override anything else in local .ini files and their overrides
68 eZINI::injectSettings( $injectedSettings );
69 }
70 if ( isset( $settings['injected-merge-settings'] ) )
71 {
72 $injectedSettings = array();
73 foreach ( $settings['injected-merge-settings'] as $keySetting => $injectedSetting )
74 {
75 list( $file, $section, $setting ) = explode( '/', $keySetting );
76 $injectedSettings[$file][$section][$setting] = $injectedSetting;
77 }
78 // Those settings override anything else in local .ini files and their overrides
79 eZINI::injectMergeSettings( $injectedSettings );
80 }
81 $this->settings = $settings + array(
82 'use-cache-headers' => true,
83 'max-age' => 86400,
84 'siteaccess' => null,
85 'use-exceptions' => false
86 );
87 unset( $settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting );
88
89 // lazy loaded database driver
90 include __DIR__ . '/lazy.php';
91
92 $this->setUseExceptions( $this->settings['use-exceptions'] );
93
94 // Tweaks ini filetime checks if not defined!
95 // This makes ini system not check modified time so
96 // that index_treemenu.php can assume that index.php does
97 // this regular enough, set in config.php to override.
98 if ( !defined( 'EZP_INI_FILEMTIME_CHECK' ) )
99 {
100 define( 'EZP_INI_FILEMTIME_CHECK', false );
101 }
102
103 eZExecution::addFatalErrorHandler(
104 function ()
105 {
106 if ( !headers_sent() )
107 {
108 header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error' );
109 }
110 }
111 );
112 eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP );
113
114 // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
115 $_SERVER['SCRIPT_FILENAME'] = str_replace( '/index_rest.php', '/index.php', $_SERVER['SCRIPT_FILENAME'] );
116 $_SERVER['PHP_SELF'] = str_replace( '/index_rest.php', '/index.php', $_SERVER['PHP_SELF'] );
117
118 $ini = eZINI::instance();
119 $timezone = $ini->variable( 'TimeZoneSettings', 'TimeZone' );
120 if ( $timezone )
121 {
122 putenv( "TZ=$timezone" );
123 }
124
125 eZDebug::setHandleType( eZDebug::HANDLE_NONE );
126 $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' );
127 $ini = eZINI::instance();
128 eZSys::init( 'index_rest.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) == 'true' );
129 $uri = eZURI::instance( eZSys::requestURI() );
130 $GLOBALS['eZRequestedURI'] = $uri;
131
132 // load extensions
133 eZExtension::activateExtensions( 'default' );
134
135 require_once __DIR__ . '/restkernel_functions.php';
136
137 // set siteaccess from X-Siteaccess header if given and exists
138 if ( isset( $_SERVER['HTTP_X_SITEACCESS'] ) && eZSiteAccess::exists( $_SERVER['HTTP_X_SITEACCESS'] ) )
139 {
140 $access = array( 'name' => $_SERVER['HTTP_X_SITEACCESS'], 'type' => eZSiteAccess::TYPE_STATIC );
141 }
142 else
143 {
144 $access = eZSiteAccess::match( $uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile() );
145 }
146
147 eZSiteAccess::change( $access );
148
149 // load siteaccess extensions
150 eZExtension::activateExtensions( 'access' );
151
152 // Now that all extensions are activated and siteaccess has been changed, reset
153 // all eZINI instances as they may not take into account siteaccess specific settings.
154 eZINI::resetAllInstances( false );
155
156 if( ezpRestDebug::isDebugEnabled() )
157 {
158 $debug = ezpRestDebug::getInstance();
159 $debug->updateDebugSettings();
160 }
161 }
162
166 public static function getResponse()
167 {
168 return self::$response;
169 }
170
174 public static function setResponse( $response )
175 {
176 self::$response = $response;
177 }
178
185 public function run()
186 {
187 $mvcConfig = new ezpMvcConfiguration( $this->responseWriterClass );
188 $frontController = new ezpMvcConfigurableDispatcher( $mvcConfig );
189 $result = $frontController->run();
190 $this->shutdown();
191 return $result;
192 }
193
199 public function runCallback( \Closure $callback, $postReinitialize = true )
200 {
201 throw new \RuntimeException( 'runCallback() method is not supported by ezpKernelRest' );
202 }
203
209 public function setUseExceptions( $useExceptions )
210 {
211 eZModule::$useExceptions = (bool)$useExceptions;
212 }
213
219 public function reInitialize()
220 {
221 $this->isInitialized = false;
222 }
223
227 protected function shutdown( $reInitialize = true )
228 {
229 eZExecution::cleanup();
230 eZExecution::setCleanExit();
231 eZExpiryHandler::shutdown();
232 if ( $reInitialize )
233 $this->isInitialized = false;
234 }
235
242 public function hasServiceContainer()
243 {
244 return false;
245 }
246
253 public function getServiceContainer()
254 {
255 return;
256 }
257 }
eZDebug\HANDLE_FROM_PHP
const HANDLE_FROM_PHP
Definition: ezdebug.php:76
eZDebug\setHandleType
static setHandleType( $type)
Definition: ezdebug.php:248
eZDebug\HANDLE_NONE
const HANDLE_NONE
Definition: ezdebug.php:75
eZExecution\setCleanExit
static setCleanExit( $hasCleanExit=true)
Definition: ezexecution.php:29
eZExecution\cleanup
static cleanup()
Definition: ezexecution.php:37
eZExecution\addFatalErrorHandler
static addFatalErrorHandler( $handler)
Definition: ezexecution.php:75
eZExtension\activateExtensions
static activateExtensions( $extensionType='default', eZINI $siteINI=null)
Definition: ezextension.php:188
eZModule\$useExceptions
static $useExceptions
Definition: ezmodule.php:258
eZSiteAccess\match
static match(eZURI $uri, $host, $port=80, $file='/index.php')
Definition: ezsiteaccess.php:104
eZSiteAccess\change
static change(array $access, eZINI $siteINI=null)
Definition: ezsiteaccess.php:504
eZSiteAccess\TYPE_STATIC
const TYPE_STATIC
Definition: ezsiteaccess.php:29
eZSiteAccess\exists
static exists( $siteAccessName)
Definition: ezsiteaccess.php:723
eZSys\serverVariable
static serverVariable( $variableName, $quiet=false)
Definition: ezsys.php:857
eZSys\serverPort
static serverPort()
Definition: ezsys.php:824
eZSys\requestURI
static requestURI()
Definition: ezsys.php:1263
eZSys\hostname
static hostname()
Definition: ezsys.php:677
eZSys\init
static init( $index='index.php', $forceVirtualHost=null)
Definition: ezsys.php:1104
eZSys\indexFile
static indexFile( $withAccessPath=true)
Definition: ezsys.php:619
eZURI\instance
static instance( $uri=false)
Definition: ezuri.php:575
$ini
$ini
Definition: classes/admin/linklist.php:64
ezpKernelRest
Definition: ezpkernelrest.php:12
ezpKernelRest\run
run()
Definition: ezpkernelrest.php:185
ezpKernelRest\hasServiceContainer
hasServiceContainer()
Definition: ezpkernelrest.php:242
ezpKernelRest\$access
$access
Definition: ezpkernelrest.php:32
ezpKernelRest\getServiceContainer
getServiceContainer()
Definition: ezpkernelrest.php:253
ezpKernelRest\setUseExceptions
setUseExceptions( $useExceptions)
Definition: ezpkernelrest.php:209
ezpKernelRest\$responseWriterClass
$responseWriterClass
Definition: ezpkernelrest.php:47
ezpKernelRest\$isInitialized
$isInitialized
Definition: ezpkernelrest.php:18
ezpKernelRest\getResponse
static getResponse()
Definition: ezpkernelrest.php:166
ezpKernelRest\$uri
$uri
Definition: ezpkernelrest.php:37
ezpKernelRest\$settings
$settings
Definition: ezpkernelrest.php:25
ezpKernelRest\runCallback
runCallback(\Closure $callback, $postReinitialize=true)
Definition: ezpkernelrest.php:199
ezpKernelRest\$response
static $response
Definition: ezpkernelrest.php:49
ezpKernelRest\__construct
__construct(array $settings=array(), $responseWriterClass=null)
Definition: ezpkernelrest.php:55
ezpKernelRest\setResponse
static setResponse( $response)
Definition: ezpkernelrest.php:174
ezpKernelRest\reInitialize
reInitialize()
Definition: ezpkernelrest.php:219
ezpKernelRest\shutdown
shutdown( $reInitialize=true)
Definition: ezpkernelrest.php:227
ezpMvcConfigurableDispatcher
Definition: dispatcher.php:13
ezpMvcConfiguration
Definition: mvc_configuration.php:12
ezpRestDebug\getInstance
static getInstance()
Definition: debug.php:50
ezpRestDebug\isDebugEnabled
static isDebugEnabled()
Definition: debug.php:64
$result
$result
Definition: companysearch.php:94
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$debug
$debug
Definition: ezstats/admin/cron.php:36
ezpKernelHandler
Definition: ezpkernelhandler.php:15
$response
while(!feof($socket)) $response
Definition: paypalnotify.php:196
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.