idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
17,400
public function setFileLock ( $ file_lock ) { if ( empty ( $ file_lock ) && $ file_lock !== false ) { throw new PageCacheException ( __CLASS__ . ' file lock can not be empty. To disable set to boolean false.' ) ; } $ this -> file_lock = $ file_lock ; }
Set file locking logic
17,401
public function setFilePath ( $ filepath ) { if ( ! isset ( $ filepath ) || empty ( $ filepath ) ) { throw new PageCacheException ( __CLASS__ . ' file path not set or empty' ) ; } $ this -> filepath = $ filepath ; }
Set filepath of the cache file .
17,402
private function randomizeExpirationTime ( CacheItemInterface $ item ) { $ expiresAtTimestamp = $ item -> getExpiresAt ( ) ? $ item -> getExpiresAt ( ) -> getTimestamp ( ) : null ; $ expiresAtTimestamp = $ expiresAtTimestamp ? : ( $ item -> getCreatedAt ( ) -> getTimestamp ( ) + $ this -> cacheExpiresIn ) ; $ offset = ...
Calculate and returns item s expiration time .
17,403
public static function set ( $ key , $ value ) { if ( ! isset ( self :: $ config [ 'settings' ] ) ) { self :: $ config [ 'settings' ] = array ( ) ; } self :: $ config [ 'settings' ] [ $ key ] = $ value ; }
Adds a custom setting .
17,404
public static function build ( ) { try { self :: init ( ) ; self :: dependencies ( ) ; $ route = self :: canRoute ( ) ; if ( $ route !== false ) { $ actionContext = self :: actionContext ( $ route ) ; if ( $ actionContext !== null && ! self :: cached ( $ actionContext ) ) { self :: filters ( $ actionContext ) ; self ::...
Processes the current HTTP request .
17,405
private static function headers ( ) { if ( empty ( self :: $ config [ 'httpHeaders' ] ) ) { return ; } $ response = self :: $ config [ 'httpContext' ] -> getResponse ( ) ; $ response -> setHeaders ( self :: $ config [ 'httpHeaders' ] ) ; }
Adds headers .
17,406
private static function canRoute ( ) { $ httpContext = self :: $ config [ 'httpContext' ] ; if ( $ httpContext -> isIgnoredRoute ( ) ) { $ request = $ httpContext -> getRequest ( ) ; $ response = $ httpContext -> getResponse ( ) ; $ response -> clear ( ) ; if ( ! file_exists ( $ request -> documentRoot ( ) . $ request ...
Looks for a suitable route and checks whether the request can be executed .
17,407
private static function cached ( $ actionContext ) { $ httpContext = $ actionContext -> getHttpContext ( ) ; $ request = $ httpContext -> getRequest ( ) ; if ( $ request -> isPost ( ) ) { return false ; } $ cacheSettings = InternalHelper :: getStaticPropertyValue ( '\\PhpMvc\\OutputCache' , 'settings' ) ; $ actionName ...
Checks the cache and outputs the result if there is data in the cache for the current request .
17,408
private static function caching ( $ actionContext ) { $ cacheKey = InternalHelper :: getPropertyValue ( $ actionContext , 'cacheKey' ) ; if ( empty ( $ cacheKey ) ) { return ; } $ cacheSettings = InternalHelper :: getStaticPropertyValue ( '\\PhpMvc\\OutputCache' , 'settings' ) ; $ actionName = $ actionContext -> getAct...
Caches the response if possible .
17,409
private static function cachingPartial ( $ actionContext , $ eventArgs ) { $ cacheKey = InternalHelper :: getPropertyValue ( $ actionContext , 'cacheKey' ) ; if ( empty ( $ cacheKey ) ) { return ; } $ cache = $ httpContext -> getCache ( ) ; $ cachePartSeq = $ cache -> get ( $ cacheKey . '_part_seq' ) ; if ( ! isset ( $...
Caches the output in parts .
17,410
private static function cachingClient ( $ actionContext ) { $ cacheSettings = InternalHelper :: getStaticPropertyValue ( '\\PhpMvc\\OutputCache' , 'settings' ) ; $ actionName = $ actionContext -> getActionName ( ) ; if ( ! empty ( $ cacheSettings [ $ actionName ] [ 'location' ] ) ) { $ location = intval ( $ cacheSettin...
Sends the cache headers .
17,411
private static function getCacheParams ( $ actionContext , $ cacheSettings , $ parameterName , $ value = null ) { $ actionName = $ actionContext -> getActionName ( ) ; $ params = array ( ) ; if ( $ parameterName != 'varyByCustom' ) { ksort ( $ value ) ; if ( ! empty ( $ cacheSettings [ $ actionName ] [ $ parameterName ...
Builds an array of parameters for the cache entry key .
17,412
private static function filters ( $ actionContext ) { $ allFilters = InternalHelper :: getStaticPropertyValue ( '\\PhpMvc\\Filter' , 'filters' ) ; $ allFiltersInstance = array ( ) ; foreach ( $ allFilters as $ actionName => $ filters ) { foreach ( $ filters as $ filterName ) { $ className = $ filterName ; if ( ! class_...
Initializes the filters .
17,413
private static function validation ( ) { if ( isset ( self :: $ config [ 'validators' ] ) ) { $ validators = self :: $ config [ 'validators' ] ; } else { $ validators = true ; } if ( $ validators === true || ( ! isset ( $ validators [ 'actionName' ] ) || $ validators [ 'actionName' ] === true ) ) { if ( substr ( PHPMVC...
Checks the request and throws an exception if the request contains dangerous data .
17,414
private static function render ( $ actionContext ) { $ controller = $ actionContext -> getController ( ) ; $ modelState = $ actionContext -> getModelState ( ) ; self :: annotateAndValidateModel ( $ modelState ) ; $ actionExecutingContext = self :: actionExecutingFilters ( $ actionContext ) ; if ( ( $ actionResult = $ a...
Generates and renders the final result .
17,415
private static function executeAction ( $ actionContext ) { $ controller = $ actionContext -> getController ( ) ; $ actionName = $ actionContext -> getActionName ( ) ; $ action = new \ ReflectionMethod ( $ controller , $ actionName ) ; if ( ! $ action -> isPublic ( ) ) { throw new \ Exception ( 'Action methods must hav...
Calls the action method and returns the result .
17,416
private static function actionExecutingFilters ( $ actionContext ) { $ context = new ActionExecutingContext ( $ actionContext ) ; $ filters = $ actionContext -> getFilters ( ) ; foreach ( $ filters as $ filter ) { $ filter -> actionExecuting ( $ context ) ; } return $ context ; }
Calls the actionExecuting methods .
17,417
private static function actionExecutedFilters ( $ actionContext , $ actionResult , $ exceptionContext = null ) { $ context = new ActionExecutedContext ( $ actionContext , $ actionResult , $ exceptionContext ) ; $ filters = $ actionContext -> getFilters ( ) ; foreach ( $ filters as $ filter ) { $ filter -> actionExecute...
Calls the actionExecuted methods .
17,418
private static function exceptionFilters ( $ actionContext , $ exception ) { $ context = new ExceptionContext ( $ actionContext , $ exception ) ; $ filters = $ actionContext -> getFilters ( ) ; foreach ( $ filters as $ filter ) { $ filter -> exception ( $ context ) ; } return $ context ; }
Calls the exception methods .
17,419
public static function set ( $ actionName , $ modelType ) { if ( empty ( $ actionName ) ) { throw new \ Exception ( '$actionName must not be empty.' ) ; } if ( empty ( $ modelType ) ) { throw new \ Exception ( '$modelType must not be empty.' ) ; } $ canUse = false ; if ( $ actionName !== '.' ) { if ( ! is_array ( $ act...
Specifies the model type for the action .
17,420
public static function required ( $ modelType , $ propertyName , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } self :: makeDataAnnotation ( $ propertyName ) ; self :: $ annotations [ ...
Marks the specified property with the attribute requred and it is expected that the property value must be specified .
17,421
public static function compare ( $ modelType , $ propertyName , $ compareWith , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } if ( empty ( $ compareWith ) ) { throw new \ Exception ( ...
Sets a property whose value needs to be compared to the value of the specified property .
17,422
public static function stringLength ( $ modelType , $ propertyName , $ maxLength , $ minLength = null , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } self :: makeDataAnnotation ( $ pr...
Specifies the minimum and maximum length of characters that are allowed in a data field .
17,423
public static function range ( $ modelType , $ propertyName , $ min , $ max , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } if ( ( int ) $ min > ( int ) $ max ) { throw new \ Exceptio...
Specifies the numeric range constraints for the value of a data field .
17,424
public static function validation ( $ modelType , $ propertyName , $ callback , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } if ( ! is_callable ( $ callback ) ) { throw new \ Excepti...
Specifies a custom validation method that is used to validate the property .
17,425
public static function display ( $ modelType , $ propertyName , $ name , $ text = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } self :: makeDataAnnotation ( $ propertyName ) ; self :: $ annotations [ ...
Sets a values that is used for display in the UI .
17,426
public function strategy ( ) { $ session_str = SessionHandler :: process ( ) ; $ uri = empty ( $ _SERVER [ 'REQUEST_URI' ] ) ? 'uri' : $ _SERVER [ 'REQUEST_URI' ] ; $ query = empty ( $ _SERVER [ 'QUERY_STRING' ] ) ? 'query' : $ _SERVER [ 'QUERY_STRING' ] ; return md5 ( $ uri . $ _SERVER [ 'SCRIPT_NAME' ] . $ query . $ ...
Generate cache filename
17,427
public static function setPropertyValue ( $ class , $ name , $ value ) { $ property = new \ ReflectionProperty ( $ class , $ name ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ class , $ value ) ; return $ property ; }
Sets the value to the specified property of class instance . If the property is unavailable makes it available .
17,428
public static function getPropertyValueOfParentClass ( $ instance , $ name ) { $ class = new \ ReflectionClass ( $ instance ) ; $ parent = $ class -> getParentClass ( ) ; $ property = $ parent -> getProperty ( $ name ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ instance ) ; }
Gets the property value of the base class . If the property is unavailable makes it available .
17,429
public static function getStaticPropertyValue ( $ class , $ name ) { $ property = new \ ReflectionProperty ( $ class , $ name ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( null ) ; }
Gets the property value of the static class . If the property is unavailable makes it available .
17,430
public static function setStaticPropertyValue ( $ class , $ name , $ value ) { $ property = new \ ReflectionProperty ( $ class , $ name ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( null , $ value ) ; return $ property ; }
Sets the value to the specified property of static class . If the property is unavailable makes it available .
17,431
public static function invokeMethod ( $ class , $ name ) { $ property = new \ ReflectionMethod ( $ class , $ name ) ; $ property -> setAccessible ( true ) ; return $ property -> invoke ( $ class ) ; }
Calls the specified method . If the method is protected this restriction is ignored .
17,432
public static function getViewContent ( $ path ) { if ( $ path === false ) { throw new \ Exception ( 'The view file is not specified. Probably the correct path to the file was not found. Make sure that all paths are specified correctly, the files exists and is available.' ) ; } ob_start ( ) ; require ( $ path ) ; $ res...
Gets the content of the view .
17,433
public static function getSingleKeyOrAll ( $ array , $ key , $ default = null , $ nullIfEmpty = false ) { if ( $ key !== null ) { if ( $ nullIfEmpty === true ) { return ( isset ( $ array [ $ key ] ) ) && ! empty ( $ array [ $ key ] ) ? $ array [ $ key ] : $ default ; } else { return ( isset ( $ array [ $ key ] ) ) ? $ ...
Gets single key from array or all keys if key is null .
17,434
private static function setViewContext ( $ parentActionViewContext , $ viewContext ) { InternalHelper :: setStaticPropertyValue ( '\\PhpMvc\\View' , 'viewContext' , $ viewContext ) ; InternalHelper :: setStaticPropertyValue ( '\\PhpMvc\\Html' , 'viewContext' , $ viewContext ) ; InternalHelper :: setStaticPropertyValue ...
Sets view context to static classes .
17,435
function rule ( $ accept , $ route , $ subjects = '' ) { if ( ! is_array ( $ subjects ) ) $ subjects = explode ( ',' , $ subjects ) ; list ( $ verbs , $ path ) = $ this -> parseRoute ( $ route ) ; foreach ( $ subjects as $ subject ) foreach ( $ verbs as $ verb ) $ this -> rules [ $ subject ? : '*' ] [ $ verb ] [ $ path...
Define an access rule to a route
17,436
public function url ( ) { if ( $ this -> url === null ) { $ this -> url = parse_url ( 'http' . ( isset ( $ serverVariables [ 'HTTPS' ] ) ? 's' : '' ) . '://' . $ serverVariables [ 'HTTP_HOST' ] . $ serverVariables [ 'REQUEST_URI' ] ) ; } return $ this -> url ; }
Returns URL components .
17,437
public function documentRoot ( ) { if ( $ this -> documentRoot == null ) { $ this -> documentRoot = isset ( $ this -> serverVariables [ 'DOCUMENT_ROOT' ] ) ? $ this -> serverVariables [ 'DOCUMENT_ROOT' ] : substr ( PHPMVC_ROOT_PATH , 0 , - 1 ) ; } return $ this -> documentRoot ; }
Gets the document root directory under which the current script is executing as defined in the server s configuration file .
17,438
public function server ( $ key = null , $ default = null , $ nullIfEmpty = false ) { return InternalHelper :: getSingleKeyOrAll ( $ this -> serverVariables , $ key , $ default , $ nullIfEmpty ) ; }
Returns server variables .
17,439
public function cookies ( $ key = null , $ default = null , $ nullIfEmpty = false ) { return InternalHelper :: getSingleKeyOrAll ( $ this -> cookies , $ key , $ default , $ nullIfEmpty ) ; }
Returns cookies .
17,440
public function get ( $ key = null , $ default = null , $ nullIfEmpty = false ) { return InternalHelper :: getSingleKeyOrAll ( $ this -> get , $ key , $ default , $ nullIfEmpty ) ; }
Returns GET data .
17,441
public function post ( $ key = null , $ default = null , $ nullIfEmpty = false ) { return InternalHelper :: getSingleKeyOrAll ( $ this -> post , $ key , $ default , $ nullIfEmpty ) ; }
Returns POST data .
17,442
public function files ( $ key = null , $ default = null , $ nullIfEmpty = false ) { return InternalHelper :: getSingleKeyOrAll ( $ this -> files , $ key , $ default , $ nullIfEmpty ) ; }
Returns posted files .
17,443
public function userLanguages ( ) { if ( isset ( $ this -> serverVariables [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { preg_match_all ( '/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i' , $ this -> serverVariables [ 'HTTP_ACCEPT_LANGUAGE' ] , $ matches ) ; if ( count ( $ matches [ 1 ] ) ) { $ result = array_combine (...
Gets a sorted string array of client language preferences .
17,444
public function contentType ( ) { $ headers = array ( 'CONTENT_TYPE' , 'HTTP_CONTENT_TYPE' ) ; foreach ( $ headers as $ header ) { if ( ! empty ( $ this -> serverVariables [ $ header ] ) ) { return $ this -> serverVariables [ $ header ] ; } } return '' ; }
Returns Content - Type of the request or empty string .
17,445
public function headers ( $ key = null , $ default = null , $ nullIfEmpty = false ) { if ( $ this -> headers === null ) { $ result = array ( ) ; foreach ( $ this -> serverVariables as $ k => $ v ) { if ( substr ( $ k , 0 , 5 ) == 'HTTP_' ) { $ headerName = str_replace ( ' ' , '-' , ucwords ( strtolower ( str_replace ( ...
Returns HTTP headers of the request .
17,446
public static function set ( $ actionName = null , $ enable ) { $ actionName = ( $ actionName === null ? '.' : $ actionName ) ; if ( $ actionName != '.' && ! self :: $ actionContext -> actionNameEquals ( $ actionName ) ) { return ; } self :: $ enable = $ enable ; }
Sets verification mode for the specified action .
17,447
public static function set ( $ actionName , $ duration , $ location , $ varyByParam = null , $ varyByHeader = null , $ varyByCustom = null ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'duration' ] = $ duration ; self :: $ settings [ $ actionName ] [ 'location' ] = $ ...
Sets the cache settings .
17,448
public static function setDuration ( $ actionName , $ value ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'duration' ] = $ value ; }
Sets the cache duration in seconds .
17,449
public static function setLocation ( $ actionName , $ value ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'location' ] = $ value ; }
Sets the location . See OutputCacheLocation class for a list of possible values .
17,450
public static function setVaryByParam ( $ actionName , $ value ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'varyByParam' ] = $ value ; }
Sets the vary - by - param value .
17,451
public static function setVaryByHeader ( $ actionName , $ value ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'varyByHeader' ] = $ value ; }
Sets the vary - by - header value .
17,452
public static function setVaryByCustom ( $ actionName , $ value ) { if ( ! self :: canCache ( $ actionName ) ) { return ; } self :: $ settings [ $ actionName ] [ 'varyByCustom' ] = function ( $ actionContext ) use ( $ value ) { return $ value ( $ actionContext ) ; } ; }
Sets the vary - by - custom .
17,453
public static function injectModel ( & $ model ) { $ actionResult = self :: $ viewContext -> actionResult ; if ( ! empty ( $ actionResult ) ) { if ( $ actionResult instanceof ViewResult && ! empty ( $ actionResult -> model ) ) { $ model = $ actionResult -> model ; } else { $ model = null ; } } }
Injects model to state .
17,454
public static function getData ( $ key = null ) { if ( ! isset ( $ key ) ) { return self :: $ viewContext -> viewData ; } else { return isset ( self :: $ viewContext -> viewData [ $ key ] ) ? self :: $ viewContext -> viewData [ $ key ] : null ; } }
Gets the data with the specified key . If the specified key does not exist function returns null . If no key is specified returns all data .
17,455
private function validateRoute ( $ route ) { if ( ! $ route instanceof Route ) { throw new \ Exception ( 'A type of Route or a derivative is expected.' ) ; } if ( $ route -> ignore !== true && empty ( $ route -> name ) ) { throw new \ Exception ( 'The name of the route is expected. The value must not be empty.' ) ; } i...
Verifies that the data in the route instance is correct .
17,456
private function isUniqueRouteName ( $ name ) { foreach ( $ this -> routes as $ route ) { if ( mb_strtolower ( $ route -> name ) == mb_strtolower ( $ name ) ) { return false ; } } return true ; }
Checks the uniqueness of the route name .
17,457
private function getDirectoryPathByHash ( $ filename ) { $ val1 = ord ( $ filename [ 1 ] ) ; $ val2 = ord ( $ filename [ 3 ] ) ; $ val1 %= 99 ; $ val2 %= 99 ; return $ val1 . '/' . $ val2 . '/' ; }
Get a path with 2 directories based on filename hash
17,458
public function clearDirectory ( $ dir ) { if ( empty ( $ dir ) || ! @ is_dir ( $ dir ) ) { return false ; } $ iterator = new \ RecursiveDirectoryIterator ( $ dir ) ; $ filter = new \ RecursiveCallbackFilterIterator ( $ iterator , function ( $ current ) { $ filename = $ current -> getBasename ( ) ; return ! ( $ filenam...
Removes all files and directories inside a directory . Used for deleting all cache content .
17,459
public function init ( ) { if ( $ this -> config ( ) -> isDryRunMode ( ) ) { $ this -> log ( 'Dry run mode is on. Live content is displayed, no cached output.' ) ; } $ this -> log ( __METHOD__ . ' uri:' . $ _SERVER [ 'REQUEST_URI' ] . '; script:' . $ _SERVER [ 'SCRIPT_NAME' ] . '; query:' . $ _SERVER [ 'QUERY_STRING' ]...
Initialize cache . If you need to set configuration options do so before calling this method .
17,460
private function getDefaultCacheAdapter ( ) { return new FileSystemCacheAdapter ( $ this -> config -> getCachePath ( ) , $ this -> config -> getFileLock ( ) , $ this -> config -> getMinCacheFileSize ( ) ) ; }
Get Default Cache Adapter
17,461
public function getCurrentKey ( ) { if ( ! $ this -> currentKey ) { $ this -> currentKey = $ this -> getStrategy ( ) -> strategy ( ) ; } return $ this -> currentKey ; }
Get current key
17,462
private function displayItem ( CacheItemInterface $ item ) { $ isDryRun = $ this -> config ( ) -> isDryRunMode ( ) ; $ itemContent = $ item -> getContent ( ) ; if ( empty ( $ itemContent ) ) { $ this -> log ( __METHOD__ . ' Empty cache item found, skipping cache.' , print_r ( $ item , true ) ) ; return ; } $ this -> ht...
Display cache item send headers if necessary .
17,463
private function storePageContent ( $ content ) { $ key = $ this -> getCurrentKey ( ) ; $ item = new CacheItem ( $ key ) ; $ isHeadersForwardingEnabled = $ this -> config -> isSendHeaders ( ) && $ this -> config -> isForwardHeaders ( ) ; $ this -> log ( __METHOD__ . ' Header forwarding is ' . ( $ isHeadersForwardingEna...
Write page to cache and display it . When write is unsuccessful string content is returned .
17,464
public function getPageCache ( ) { $ key = $ this -> getCurrentKey ( ) ; $ item = $ this -> getItemStorage ( ) -> get ( $ key ) ; return $ item ? $ item -> getContent ( ) : false ; }
Return current page cache as a string or false on error if this page was cached before .
17,465
public function isCached ( CacheItemInterface $ item = null ) { if ( ! $ item ) { $ key = $ this -> getCurrentKey ( ) ; $ item = $ this -> getItemStorage ( ) -> get ( $ key ) ; } return $ item ? true : false ; }
Checks if current page is in cache .
17,466
private function log ( $ msg , $ exception = null ) { if ( ! $ this -> config -> isEnableLog ( ) ) { return false ; } if ( empty ( $ this -> logger ) && ! empty ( $ this -> config -> getLogFilePath ( ) ) ) { $ this -> logger = new DefaultLogger ( $ this -> config -> getLogFilePath ( ) ) ; } if ( $ exception ) { $ this ...
Log message using PSR Logger or error_log . Works only when logging was enabled and log file path was define . Attempts to create default logger if no logger exists .
17,467
private function setHeader ( $ name , $ value = null , $ httpResponseCode = null ) { header ( $ name . ( $ value ? ': ' . $ value : '' ) , true , $ httpResponseCode ) ; }
Sends HTTP Header
17,468
private function getIfModifiedSinceTimestamp ( ) { if ( ! empty ( $ _SERVER [ self :: HTTP_IF_MODIFIED_SINCE ] ) ) { $ modifiedSinceString = $ _SERVER [ self :: HTTP_IF_MODIFIED_SINCE ] ; } elseif ( ! empty ( $ _ENV [ self :: HTTP_IF_MODIFIED_SINCE ] ) ) { $ modifiedSinceString = $ _ENV [ self :: HTTP_IF_MODIFIED_SINCE...
Get timestamp value from If - Modified - Since request header
17,469
private function getResponseHeaders ( ) { if ( ! $ this -> responseHeaders ) { foreach ( $ this -> getSentHeaders ( ) as $ item ) { list ( $ key , $ value ) = explode ( ':' , $ item , 2 ) ; $ this -> responseHeaders [ $ key ] = trim ( $ value ) ; } } return $ this -> responseHeaders ; }
Get headers and populate local responseHeaders variable
17,470
public function setFlushHandler ( $ value ) { if ( $ value !== null && ! is_callable ( $ value ) ) { throw new \ Exception ( 'A function is expected, or null.' ) ; } $ this -> flushHandler = $ value ; }
Sets the event handler when calling the flush method .
17,471
public function setPreSendHandler ( $ value ) { if ( $ value !== null && ! is_callable ( $ value ) ) { throw new \ Exception ( 'A function is expected, or null.' ) ; } $ this -> preSendHandler = $ value ; }
Sets the event handler when calling the preSend method .
17,472
public function setEndHandler ( $ value ) { if ( $ value !== null && ! is_callable ( $ value ) ) { throw new \ Exception ( 'A function is expected, or null.' ) ; } $ this -> endHandler = $ value ; }
Sets the event handler when calling the end method .
17,473
public function addHeader ( $ name , $ value = null ) { if ( $ this -> canSetHeaders ( ) ) { if ( $ value === null ) { $ value = trim ( substr ( $ name , strpos ( $ name , ':' ) + 1 ) ) ; $ name = trim ( substr ( $ name , 0 , strpos ( $ name , ':' ) ) ) ; } $ this -> headers [ $ name ] = $ value ; } }
Adds an HTTP header to the current response .
17,474
public function addCookie ( $ name , $ value = '' , $ expire = 0 , $ path = '' , $ domain = '' , $ secure = false , $ httponly = false ) { if ( $ this -> canSetHeaders ( ) ) { $ this -> cookies [ ] = func_get_args ( ) ; } }
Adds cookie to send to the client .
17,475
public function write ( $ value , $ glue = "\n" ) { if ( is_array ( $ value ) ) { $ this -> output .= implode ( chr ( 10 ) , $ value ) ; } else { $ this -> output .= $ value ; } }
Writes the specified string to the HTTP response output stream .
17,476
public function writeFile ( $ path ) { if ( is_array ( $ path ) ) { $ this -> files = array_merge ( $ this -> files , $ path ) ; } elseif ( ! empty ( $ path ) ) { $ this -> files [ ] = $ path ; } }
Writes the contents of the specified file to the HTTP response output stream .
17,477
public function clear ( ) { $ this -> header = array ( ) ; $ this -> cookies = array ( ) ; $ this -> files = array ( ) ; $ this -> statusCode = null ; $ this -> statusDescription = null ; $ this -> output = '' ; if ( ob_get_length ( ) > 0 ) { ob_clean ( ) ; } }
Clears all headers and content output from the current response .
17,478
public function flush ( ) { $ this -> outputStarted = true ; $ files = $ this -> files ; $ output = $ this -> output ; $ this -> files = array ( ) ; $ this -> output = '' ; if ( $ this -> flushHandler !== null ) { call_user_func ( $ this -> flushHandler , array ( 'files' => $ files , 'output' => $ output ) ) ; } }
Sends all currently buffered output to the client .
17,479
public function getRoute ( ) { if ( $ this -> route === null && $ this -> isIgnoredRoute ( ) === false ) { $ this -> route = $ this -> routes -> matchRoute ( $ this ) ; } return $ this -> route ; }
Returns a route that is comparable to the current request context .
17,480
public function isIgnoredRoute ( ) { if ( $ this -> ignoreRoute === null ) { $ this -> ignoreRoute = ( $ this -> route = $ this -> routes -> matchIgnore ( $ this ) ) !== null ; } return $ this -> ignoreRoute ; }
Returns TRUE if the current route is to be ignored .
17,481
public static function displayName ( $ propertyName ) { $ propertyName = ( is_array ( $ propertyName ) ? implode ( '_' , $ propertyName ) : $ propertyName ) ; if ( ( $ dataAnnotation = self :: $ viewContext -> getModelDataAnnotation ( $ propertyName ) ) !== null ) { return htmlspecialchars ( $ dataAnnotation -> display...
Gets display name for the specified field .
17,482
public static function validationMessage ( $ propertyName , $ validationMessage = null , $ tag = 'span' , $ htmlAttributes = array ( ) ) { $ propertyName = ( is_array ( $ propertyName ) ? implode ( '_' , $ propertyName ) : $ propertyName ) ; $ htmlAttributes = ( $ htmlAttributes === null ? array ( ) : $ htmlAttributes ...
Gets a validation message if an error exists for the specified field .
17,483
public static function view ( $ path , $ model = null ) { if ( ( $ viewPath = PathUtility :: getViewFilePath ( $ path ) ) !== false ) { $ viewResult = new ViewResult ( $ viewPath , $ model ) ; $ viewContext = InternalHelper :: makeViewContext ( $ viewPath , self :: $ viewContext , $ viewResult , $ model , null , self :...
Returns the specified view as an HTML - encoded string .
17,484
public static function action ( $ actionName , $ controllerName = null , $ routeValues = null , $ fragment = null , $ schema = null , $ host = null ) { return UrlHelper :: action ( self :: $ viewContext , $ actionName , $ controllerName , $ routeValues , $ fragment , $ schema , $ host ) ; }
Returns the path to action .
17,485
private static function buildAttributes ( $ htmlAttributes , $ ignore = array ( ) ) { if ( empty ( $ htmlAttributes ) ) { return '' ; } if ( $ ignore === null ) { $ ignore = array ( ) ; } $ filtered = array_filter ( $ htmlAttributes , function ( $ key ) use ( $ ignore ) { return ! in_array ( $ key , $ ignore ) ; } , \ ...
Generates HTML - attributes string .
17,486
private static function encodeHtmlAttributeString ( $ value ) { if ( $ value === null ) { return '' ; } $ result = $ value ; $ result = str_replace ( '&' , '&amp;' , $ result ) ; $ result = str_replace ( '<' , '&lt;' , $ result ) ; $ result = str_replace ( '"' , '&quot;' , $ result ) ; $ result = str_replace ( '\'' , '...
Escapes special characters in the specified value for its use as the value of an HTML - attribute .
17,487
private function getKeyPath ( $ key ) { $ this -> validateKey ( $ key ) ; $ file = sha1 ( $ key ) ; $ this -> hashDirectory -> processFile ( $ file ) ; return $ this -> hashDirectory -> getFileStoragePath ( ) ; }
Make full cache file path for provided key
17,488
private function normalizeTtl ( $ ttl ) { if ( $ ttl === null ) { return self :: DEFAULT_TTL ; } if ( \ is_int ( $ ttl ) ) { return $ ttl ; } if ( $ ttl instanceof DateInterval ) { $ currentDateTime = new \ DateTimeImmutable ( ) ; $ ttlDateTime = $ currentDateTime -> add ( $ ttl ) ; return $ ttlDateTime -> getTimestamp...
Convert TTL to seconds
17,489
public static function mapPath ( $ virtualPath = null ) { if ( empty ( $ virtualPath ) ) { return PHPMVC_ROOT_PATH ; } if ( $ virtualPath [ 0 ] == '~' || $ virtualPath [ 0 ] == '/' ) { $ result = PHPMVC_ROOT_PATH ; $ result .= trim ( substr ( $ virtualPath , 1 , strlen ( $ virtualPath ) - 1 ) , '\\/' ) ; } elseif ( $ v...
Converts a virtual path to an physical path .
17,490
public static function isRelativePath ( $ path ) { if ( $ path [ 0 ] == '~' || $ path [ 0 ] == '.' ) { return true ; } if ( $ path [ 0 ] == '/' && ! is_file ( $ path ) && ! is_dir ( $ path ) ) { return true ; } return false ; }
Checks whether the specified path is relative or not .
17,491
public static function getFilePath ( $ path ) { if ( empty ( $ path ) ) { return false ; } if ( is_file ( $ path ) ) { return $ path ; } if ( is_file ( $ result = self :: mapPath ( $ path ) ) ) { return $ result ; } if ( ( $ result = self :: appendPhpExtension ( $ path ) ) !== false ) { return self :: getFilePath ( $ r...
Returns the physical path to an existing file . If no path is found returns FALSE .
17,492
public static function getViewFilePath ( $ path ) { if ( empty ( $ path ) ) { return false ; } if ( ( strpos ( $ path , '/' ) !== false || strpos ( $ path , '\\' ) !== false ) && is_file ( $ result = $ path ) ) { return $ result ; } if ( self :: isRelativePath ( $ path ) && is_file ( $ result = self :: mapPath ( $ path...
Searches for a file with a specified name and returns the correct path . If the file is not found returns FALSE .
17,493
protected function view ( $ viewOrModel = null , $ model = null , $ layout = null ) { return new ViewResult ( $ viewOrModel , $ model , $ layout ) ; }
Creates a ViewResult object that renders a view to the response .
17,494
protected function file ( $ path , $ contentType = null , $ downloadName = null ) { return new FileResult ( $ path , $ contentType , $ downloadName ) ; }
Creates a FileResult object by using the file contents and file type .
17,495
public function setConfig ( $ configOrKey , $ config = null ) { if ( $ config !== null ) { $ this -> config [ $ configOrKey ] = $ config ; } else { $ this -> config = ( $ configOrKey !== null ? $ configOrKey : array ( ) ) ; } }
Sets config .
17,496
public function add ( $ eventName , $ eventHandler , $ key = null ) { if ( ! is_callable ( $ eventHandler ) ) { throw new \ Exception ( 'Function is expected.' ) ; } if ( $ key !== null ) { $ this -> { $ eventName } [ $ key ] = $ eventHandler ; } else { $ this -> { $ eventName } [ ] = $ eventHandler ; } }
Adds a handler .
17,497
private function setConfigValues ( ) { if ( isset ( $ this -> config [ 'min_cache_file_size' ] ) && is_numeric ( $ this -> config [ 'min_cache_file_size' ] ) ) { $ this -> setMinCacheFileSize ( $ this -> config [ 'min_cache_file_size' ] ) ; } if ( isset ( $ this -> config [ 'enable_log' ] ) && $ this -> isBool ( $ this...
Reads config array and assigns config values
17,498
public function setLogFilePath ( $ logFilePath ) { if ( ! $ this -> isParentDirectoryExists ( $ logFilePath ) ) { throw new PageCacheException ( 'Log file directory does not exist for the path provided ' . $ logFilePath ) ; } $ this -> logFilePath = $ logFilePath ; return $ this ; }
Set path for internal log file
17,499
public function setCachePath ( $ cachePath ) { if ( empty ( $ cachePath ) || ! is_writable ( $ cachePath ) ) { throw new PageCacheException ( __METHOD__ . ' - Cache path not writable: ' . $ cachePath ) ; } if ( substr ( $ cachePath , - 1 ) !== '/' ) { throw new PageCacheException ( __METHOD__ . ' - / trailing slash is ...
Set cache path directory