idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
22,200 | public function findFile ( $ class , array $ prefixPaths , array $ basePaths = [ ] , $ useIncludePath = false ) { if ( $ file = $ this -> searchNamespaces ( $ prefixPaths , $ class , true ) ) { return $ file ; } $ class = preg_replace ( '/_(?=[^\\\\]*$)/' , '\\' , $ class ) ; if ( $ file = $ this -> searchNamespaces ( $ basePaths , $ class , false ) ) { return $ file ; } elseif ( $ useIncludePath ) { return $ this -> searchDirectories ( explode ( PATH_SEPARATOR , get_include_path ( ) ) , $ class ) ; } return false ; } | Attempts to find a file for the given class from given paths . |
22,201 | private function searchNamespaces ( $ paths , $ class , $ truncate ) { foreach ( $ paths as $ namespace => $ directories ) { $ canonized = $ this -> canonizeClass ( $ namespace , $ class , $ truncate ) ; if ( $ canonized && $ file = $ this -> searchDirectories ( $ directories , $ canonized ) ) { return $ file ; } } return false ; } | Searches for the class file from the namespaces that apply to the class . |
22,202 | private function canonizeClass ( $ namespace , $ class , $ truncate ) { $ class = ltrim ( $ class , '\\' ) ; $ namespace = ( string ) $ namespace ; $ namespace = $ namespace === '' ? '' : trim ( $ namespace , '\\' ) . '\\' ; if ( strncmp ( $ class , $ namespace , strlen ( $ namespace ) ) !== 0 ) { return false ; } return $ truncate ? substr ( $ class , strlen ( $ namespace ) ) : $ class ; } | Matches the class against the namespace and canonizes the name as needed . |
22,203 | private function searchDirectories ( array $ directories , $ class ) { foreach ( $ directories as $ directory ) { $ directory = trim ( $ directory ) ; $ path = preg_replace ( '/[\\/\\\\]+/' , DIRECTORY_SEPARATOR , $ directory . '/' . $ class ) ; if ( $ directory && $ file = $ this -> searchExtensions ( $ path ) ) { return $ file ; } } return false ; } | Searches for the class file in the list of directories . |
22,204 | private function searchExtensions ( $ path ) { foreach ( $ this -> fileExtensions as $ ext ) { if ( file_exists ( $ path . $ ext ) ) { return $ path . $ ext ; } } return false ; } | Searches for the class file using known file extensions . |
22,205 | public function getBuildPath ( ) { $ path = pathinfo ( $ this -> relativePath ) ; $ fingerprint = md5 ( $ this -> filters -> map ( function ( $ f ) { return $ f -> getFilter ( ) ; } ) -> toJson ( ) . $ this -> getLastModified ( ) ) ; return "{$path['dirname']}/{$path['filename']}-{$fingerprint}.{$this->getBuildExtension()}" ; } | Get the build path to the asset . |
22,206 | public function getLastModified ( ) { if ( $ this -> lastModified ) { return $ this -> lastModified ; } return $ this -> lastModified = $ this -> isRemote ( ) ? null : $ this -> files -> lastModified ( $ this -> absolutePath ) ; } | Get the last modified time of the asset . |
22,207 | public function getGroup ( ) { if ( $ this -> group ) { return $ this -> group ; } return $ this -> group = $ this -> detectGroupFromExtension ( ) ? : $ this -> detectGroupFromContentType ( ) ; } | Get the assets group . |
22,208 | protected function detectGroupFromContentType ( ) { if ( extension_loaded ( 'curl' ) ) { $ this -> getLogger ( ) -> warning ( 'Attempting to determine asset group using cURL. This may have a considerable effect on application speed.' ) ; $ handler = curl_init ( $ this -> absolutePath ) ; curl_setopt ( $ handler , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ handler , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ handler , CURLOPT_HEADER , true ) ; curl_setopt ( $ handler , CURLOPT_NOBODY , true ) ; curl_setopt ( $ handler , CURLOPT_SSL_VERIFYPEER , false ) ; curl_exec ( $ handler ) ; if ( ! curl_errno ( $ handler ) ) { $ contentType = curl_getinfo ( $ handler , CURLINFO_CONTENT_TYPE ) ; return starts_with ( $ contentType , 'text/css' ) ? 'stylesheets' : 'javascripts' ; } } } | Detect the group from the content type using cURL . |
22,209 | protected function detectGroupFromExtension ( ) { $ extension = pathinfo ( $ this -> absolutePath , PATHINFO_EXTENSION ) ; foreach ( array ( 'stylesheets' , 'javascripts' ) as $ group ) { if ( in_array ( $ extension , $ this -> allowedExtensions [ $ group ] ) ) { return $ group ; } } } | Detect group from the assets extension . |
22,210 | public function rawOnEnvironment ( ) { $ environments = array_flatten ( func_get_args ( ) ) ; if ( in_array ( $ this -> appEnvironment , $ environments ) ) { return $ this -> raw ( ) ; } return $ this ; } | Sets the asset to be served raw when the application is running in a given environment . |
22,211 | public function build ( $ production = false ) { $ filters = $ this -> prepareFilters ( $ production ) ; $ asset = new StringAsset ( $ this -> getContent ( ) , $ filters -> all ( ) , dirname ( $ this -> absolutePath ) , basename ( $ this -> absolutePath ) ) ; return $ asset -> dump ( ) ; } | Build the asset . |
22,212 | public function prepareFilters ( $ production = false ) { $ filters = $ this -> filters -> map ( function ( $ filter ) use ( $ production ) { $ filter -> setProduction ( $ production ) ; return $ filter -> getInstance ( ) ; } ) ; return $ filters -> filter ( function ( $ filter ) { return $ filter instanceof FilterInterface ; } ) ; } | Prepare the filters applied to the asset . |
22,213 | protected function initCli ( ) { $ this -> phpSapi = php_sapi_name ( ) ; $ phpSapiCHasCli = FALSE ; if ( substr ( $ this -> phpSapi , 0 , 3 ) === 'cli' ) { $ this -> phpSapi = 'cli' ; $ phpSapiCHasCli = TRUE ; } $ this -> cli = FALSE ; if ( $ phpSapiCHasCli && ! isset ( $ this -> globalServer [ 'REQUEST_URI' ] ) ) { $ this -> cli = TRUE ; $ hostName = gethostname ( ) ; $ this -> scheme = 'file:' ; $ this -> secure = FALSE ; $ this -> hostName = $ hostName ; $ this -> host = $ hostName ; $ this -> port = '' ; $ this -> path = '' ; $ this -> query = '' ; $ this -> fragment = '' ; $ this -> ajax = FALSE ; $ this -> basePath = '' ; $ this -> requestPath = '' ; $ this -> domainUrl = '' ; $ this -> baseUrl = '' ; $ this -> requestUrl = '' ; $ this -> fullUrl = '' ; $ this -> referer = '' ; $ this -> serverIp = '127.0.0.1' ; $ this -> clientIp = $ this -> serverIp ; $ this -> contentLength = 0 ; $ this -> headers = [ ] ; $ this -> params = [ ] ; $ this -> appRequest = FALSE ; $ this -> method = 'GET' ; $ backtraceItems = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; $ indexFilePath = str_replace ( '\\' , '/' , $ backtraceItems [ count ( $ backtraceItems ) - 1 ] [ 'file' ] ) ; $ lastSlashPos = mb_strrpos ( $ indexFilePath , '/' ) ; $ this -> appRoot = mb_substr ( $ indexFilePath , 0 , $ lastSlashPos ) ; $ this -> scriptName = mb_substr ( $ indexFilePath , $ lastSlashPos ) ; $ args = $ this -> globalServer [ 'argv' ] ; array_shift ( $ args ) ; $ params = [ ] ; if ( $ args ) { foreach ( $ args as $ arg ) { parse_str ( $ arg , $ paramsLocal ) ; if ( ! $ paramsLocal ) continue ; foreach ( $ paramsLocal as $ paramName => $ paramValue ) { if ( is_array ( $ paramValue ) ) { $ params = array_merge ( $ params , [ $ paramName => array_merge ( $ params [ $ paramName ] ? : [ ] , $ paramValue ) ] ) ; } else { $ params [ $ paramName ] = $ paramValue ; } } } } $ this -> params = $ params ; $ this -> globalGet = $ params ; } } | If request is processed via CLI initialize most of request properties with empty values and parse CLI params into params array . |
22,214 | protected function getSidebarPostId ( ) { $ post_id = intval ( get_the_ID ( ) ) ; if ( $ this -> isBlog ( ) ) { $ post_id = intval ( get_option ( 'page_for_posts' ) ) ; } $ post_id = intval ( apply_filters ( 'app_sidebar_context_post_id' , $ post_id ) ) ; return $ post_id ; } | Get the post id that should be checked for a custom sidebar for the current request . |
22,215 | public function getCurrentSidebarId ( $ default = 'default-sidebar' , $ meta_key = '_app_custom_sidebar' ) { $ post_id = $ this -> getSidebarPostId ( ) ; $ sidebar = $ default ; if ( $ post_id ) { $ sidebar = get_post_meta ( $ post_id , $ meta_key , true ) ; } if ( empty ( $ sidebar ) ) { $ sidebar = $ default ; } return $ sidebar ; } | Get the current sidebar id . |
22,216 | public function getPageChildren ( $ idPage , $ publishedOnly = 0 ) { if ( empty ( $ idPage ) ) return null ; $ tablePageTree = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageTree' ) ; $ datasPage = $ tablePageTree -> getPageChildrenByidPage ( $ idPage , $ publishedOnly ) ; return $ datasPage ; } | This service gets the children pages of a specific page |
22,217 | public function getPageFather ( $ idPage , $ type = 'published' ) { if ( empty ( $ idPage ) ) return null ; $ cacheKey = 'getPageFather_' . $ idPage ; $ cacheConfig = 'engine_page_services' ; $ melisEngineCacheSystem = $ this -> serviceLocator -> get ( 'MelisEngineCacheSystem' ) ; $ results = $ melisEngineCacheSystem -> getCacheByKey ( $ cacheKey , $ cacheConfig ) ; if ( ! empty ( $ results ) ) return $ results ; $ tablePageTree = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageTree' ) ; $ datasPage = $ tablePageTree -> getFatherPageById ( $ idPage , $ type ) ; $ melisEngineCacheSystem -> setCacheByKey ( $ cacheKey , $ cacheConfig , $ datasPage ) ; return $ datasPage ; } | Gets the father page of a specific page |
22,218 | public function getPageBreadcrumb ( $ idPage , $ typeLinkOnly = 1 , $ allPages = true ) { if ( empty ( $ idPage ) ) return null ; $ cacheKey = 'getPageBreadcrumb_' . $ idPage . '_' . $ typeLinkOnly . '_' . $ allPages ; $ cacheConfig = 'engine_page_services' ; $ melisEngineCacheSystem = $ this -> serviceLocator -> get ( 'MelisEngineCacheSystem' ) ; $ results = $ melisEngineCacheSystem -> getCacheByKey ( $ cacheKey , $ cacheConfig ) ; if ( ! empty ( $ results ) ) return $ results ; $ results = array ( ) ; $ tmp = $ idPage ; $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasPageRes = $ melisPage -> getDatasPage ( $ idPage ) ; $ datasPageTreeRes = $ datasPageRes -> getMelisPageTree ( ) ; if ( ! empty ( $ datasPageTreeRes ) ) { if ( $ datasPageTreeRes -> page_status == 1 || $ allPages ) { if ( $ typeLinkOnly && $ datasPageTreeRes -> page_menu != 'NONE' ) array_push ( $ results , $ datasPageTreeRes ) ; if ( ! $ typeLinkOnly ) array_push ( $ results , $ datasPageTreeRes ) ; } } else return array ( ) ; while ( $ tmp != - 1 ) { $ datasPageFatherRes = $ this -> getPageFather ( $ tmp ) ; $ datas = $ datasPageFatherRes -> current ( ) ; if ( ! empty ( $ datas ) ) { $ tmp = $ datas -> tree_father_page_id ; unset ( $ datas -> tree_page_id ) ; unset ( $ datas -> tree_father_page_id ) ; unset ( $ datas -> tree_page_order ) ; $ datas -> tree_page_id = $ tmp ; if ( $ datasPageTreeRes -> page_status == 1 || $ allPages ) { if ( $ typeLinkOnly && $ datas -> page_menu != 'NONE' ) array_push ( $ results , $ datas ) ; if ( ! $ typeLinkOnly ) array_push ( $ results , $ datas ) ; } } else break ; } krsort ( $ results ) ; $ melisEngineCacheSystem -> setCacheByKey ( $ cacheKey , $ cacheConfig , $ results ) ; return $ results ; } | Gets the breadcromb of pages as an array |
22,219 | public function cleanLink ( $ link ) { $ link = strtolower ( preg_replace ( array ( '#[\\s-]+#' , '#[^A-Za-z0-9/ -]+#' ) , array ( '-' , '' ) , $ this -> cleanString ( urldecode ( $ link ) ) ) ) ; $ link = preg_replace ( '/\/+/' , '/' , $ link ) ; $ link = preg_replace ( '/-+/' , '-' , $ link ) ; return $ link ; } | Cleans a link to allow only good characters |
22,220 | public function getDomainByPageId ( $ idPage ) { if ( empty ( $ idPage ) ) return null ; $ cacheKey = 'getDomainByPageId_' . $ idPage ; $ cacheConfig = 'engine_page_services' ; $ melisEngineCacheSystem = $ this -> serviceLocator -> get ( 'MelisEngineCacheSystem' ) ; $ results = $ melisEngineCacheSystem -> getCacheByKey ( $ cacheKey , $ cacheConfig ) ; if ( ! empty ( $ results ) ) return $ results ; $ domainStr = '' ; $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasPage = $ melisPage -> getDatasPage ( $ idPage ) ; $ datasTemplate = $ datasPage -> getMelisTemplate ( ) ; if ( ! empty ( $ datasTemplate ) && ! empty ( $ datasTemplate -> tpl_site_id ) ) { $ melisEngineTableSite = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ datasSite = $ melisEngineTableSite -> getSiteById ( $ datasTemplate -> tpl_site_id , getenv ( 'MELIS_PLATFORM' ) ) ; if ( $ datasSite ) { $ datasSite = $ datasSite -> current ( ) ; if ( ! empty ( $ datasSite ) ) { $ scheme = 'http' ; if ( ! empty ( $ datasSite -> sdom_scheme ) ) $ scheme = $ datasSite -> sdom_scheme ; $ domain = $ datasSite -> sdom_domain ; if ( $ domain != '' ) $ domainStr = $ scheme . '://' . $ domain ; } } } $ melisEngineCacheSystem -> setCacheByKey ( $ cacheKey , $ cacheConfig , $ domainStr ) ; return $ domainStr ; } | Gets the domain as define in site table for a page id |
22,221 | public function getSiteByPageId ( $ idPage ) { if ( empty ( $ idPage ) ) return null ; $ cacheKey = 'getSiteByPageId_' . $ idPage ; $ cacheConfig = 'engine_page_services' ; $ melisEngineCacheSystem = $ this -> serviceLocator -> get ( 'MelisEngineCacheSystem' ) ; $ results = $ melisEngineCacheSystem -> getCacheByKey ( $ cacheKey , $ cacheConfig ) ; if ( ! empty ( $ results ) ) return $ results ; $ datasSite = null ; $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasPage = $ melisPage -> getDatasPage ( $ idPage ) ; $ datasTemplate = $ datasPage -> getMelisTemplate ( ) ; if ( ! empty ( $ datasTemplate ) && ! empty ( $ datasTemplate -> tpl_site_id ) ) { $ melisEngineTableSite = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ datasSite = $ melisEngineTableSite -> getSiteById ( $ datasTemplate -> tpl_site_id , getenv ( 'MELIS_PLATFORM' ) ) ; if ( $ datasSite ) { $ datasSite = $ datasSite -> current ( ) ; } } $ melisEngineCacheSystem -> setCacheByKey ( $ cacheKey , $ cacheConfig , $ datasSite ) ; return $ datasSite ; } | Gets the site object of a page id |
22,222 | public function getPrevNextPage ( $ idPage , $ publishedOnly = 1 ) { $ output = array ( 'prev' => null , 'next' => null ) ; $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasPagePublished = $ melisPage -> getDatasPage ( $ idPage , 'published' ) ; $ datasPagePublishedTree = $ datasPagePublished -> getMelisPageTree ( ) ; $ melisTree = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTree' ) ; $ sisters = $ melisTree -> getPageChildren ( $ datasPagePublishedTree -> tree_father_page_id , $ publishedOnly ) ; $ sisters = $ sisters -> toArray ( ) ; if ( ! empty ( $ sisters ) ) { foreach ( $ sisters as $ key => $ row ) { $ order [ $ key ] = $ row [ 'tree_page_order' ] ; } array_multisort ( $ order , SORT_ASC , $ sisters ) ; $ posInArray = false ; foreach ( $ sisters as $ key => $ uneSister ) { if ( $ uneSister [ 'tree_page_id' ] == $ datasPagePublishedTree -> tree_page_id ) $ posInArray = $ key ; } if ( $ posInArray !== false ) { $ posPrevPage = ( ( $ posInArray - 1 ) >= 0 ) ? ( $ posInArray - 1 ) : null ; $ posNextPage = ( ( $ posInArray + 1 ) && array_key_exists ( $ posInArray + 1 , $ sisters ) ) ? ( $ posInArray + 1 ) : null ; if ( ! is_null ( $ posPrevPage ) ) { $ prevItem = $ sisters [ $ posPrevPage ] ; $ prevLink = $ melisTree -> getPageLink ( $ sisters [ $ posPrevPage ] [ 'tree_page_id' ] ) ; if ( ! empty ( $ prevItem [ 'page_name' ] ) && ! empty ( $ prevLink ) ) { $ output [ 'prev' ] = $ prevItem ; $ output [ 'prev' ] [ 'link' ] = $ prevLink ; } } if ( ! is_null ( $ posNextPage ) ) { $ nextItem = $ sisters [ $ posNextPage ] ; $ nextLink = $ melisTree -> getPageLink ( $ sisters [ $ posNextPage ] [ 'tree_page_id' ] ) ; if ( ! empty ( $ nextItem [ 'page_name' ] ) && ! empty ( $ nextLink ) ) { $ output [ 'next' ] = $ nextItem ; $ output [ 'next' ] [ 'link' ] = $ nextLink ; } } } } return $ output ; } | Gets the previous and next page for a specific page in the treeview |
22,223 | public function addHeader ( string $ name , string $ value ) { $ key = strtolower ( $ name ) ; $ this -> headerNames [ $ key ] = $ name ; $ this -> headers [ $ key ] [ ] = $ value ; return $ this ; } | Adds a new header with the given value . |
22,224 | public function getHeader ( string $ name ) : string { $ lines = $ this -> getHeaderLines ( $ name ) ; return implode ( ',' , $ lines ) ; } | Retrieves a header by the given case - insensitive name as a string . |
22,225 | public function getHeaders ( ) : array { $ result = [ ] ; foreach ( $ this -> headers as $ key => $ lines ) { $ name = $ this -> headerNames [ $ key ] ; $ result [ $ name ] = $ lines ; } return $ result ; } | Retrieves all message headers . |
22,226 | private function parseHeaders ( $ headers ) : array { if ( is_string ( $ headers ) ) { $ headers = explode ( "\r\n" , $ headers ) ; } if ( empty ( $ headers ) ) { return [ ] ; } $ result = [ ] ; foreach ( $ headers as $ key => $ line ) { if ( is_numeric ( $ key ) ) { if ( strpos ( $ line , 'HTTP/' ) === 0 ) { $ result = [ ] ; continue ; } elseif ( strstr ( $ line , ': ' ) ) { list ( $ key , $ line ) = explode ( ': ' , $ line ) ; } else { continue ; } } if ( is_array ( $ line ) ) { $ result [ $ key ] = array_merge ( $ result [ $ key ] ?? [ ] , $ line ) ; } else { $ result [ $ key ] [ ] = $ line ; } } return $ result ; } | Parse the http response headers from a response . |
22,227 | public function setHeader ( string $ name , $ value ) { $ key = strtolower ( $ name ) ; if ( $ value === null ) { unset ( $ this -> headerNames [ $ key ] , $ this -> headers [ $ key ] ) ; } else { $ this -> headerNames [ $ key ] = $ name ; $ this -> headers [ $ key ] = ( array ) $ value ; } return $ this ; } | Set a header by case - insensitive name . Setting a header will overwrite the current value for the header . |
22,228 | public static function isGdFile ( $ filename ) { if ( ! is_file ( $ filename ) || ! is_readable ( $ filename ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" Is Not A Readable File' , $ filename ) ) ; } $ result = false ; $ f = null ; if ( ( $ f = @ fopen ( $ filename , 'r' ) ) ) { if ( ( $ id = @ fread ( $ f , 3 ) ) ) { $ result = ( 'gd2' === strtolower ( $ id ) ) ? true : false ; } } @ fclose ( $ f ) ; return $ result ; } | Check if the given file is gd file |
22,229 | public function partFromFile ( $ file , Box $ box ) { $ this -> isValidFile ( $ file ) ; $ this -> assertGdFile ( $ file ) ; $ x = $ box -> getX ( ) ; $ y = $ box -> getY ( ) ; $ width = $ box -> getWidth ( ) ; $ height = $ box -> getHeight ( ) ; $ result = @ imagecreatefromgd2part ( $ file , $ x , $ y , $ width , $ height ) ; if ( false == $ result ) { throw new CanvasCreationException ( sprintf ( 'Faild To Create The Part "%s" Of The Gd Canvas From The File "%s"' , $ file , ( string ) $ box ) ) ; } $ this -> setHandler ( $ result ) ; return $ this ; } | Load Part Of gd canvas from file |
22,230 | public function getDataBySiteIdAndEnv ( $ siteId , $ siteEnv ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ select -> where ( array ( "sdom_site_id" => $ siteId , 'sdom_env' => $ siteEnv ) ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Gets the domain by the site id and the environment platform |
22,231 | public function getDataByEnv ( $ siteEnv ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ select -> group ( 'melis_cms_site_domain.sdom_env' ) ; $ select -> where ( array ( 'sdom_env' => $ siteEnv ) ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Get the domain of the site per its environement |
22,232 | public function __isset ( $ name ) { $ store = & $ this -> __protected [ 'store' ] ; if ( array_key_exists ( $ name , $ store ) ) return TRUE ; if ( $ controllerType = $ this -> getReflectionClass ( 'controller' ) ) { if ( $ controllerType -> hasProperty ( $ name ) ) { $ property = $ controllerType -> getProperty ( $ name ) ; if ( ! $ property -> isStatic ( ) ) { if ( ! $ property -> isPublic ( ) ) $ property -> setAccessible ( TRUE ) ; $ value = $ property -> getValue ( $ this -> controller ) ; $ store [ $ name ] = & $ value ; return TRUE ; } } } return FALSE ; } | Get TRUE if any value by given name exists in local view store or in local controller instance . |
22,233 | public function getVerifiedEmails ( ) { $ emails = array ( ) ; try { $ user = $ this -> api ( '/me' ) ; if ( isset ( $ user [ 'emails' ] ) && is_array ( $ user [ 'emails' ] ) && count ( $ user [ 'emails' ] ) > 0 ) { foreach ( $ user [ 'emails' ] as $ key => $ value ) { if ( isset ( $ value [ 'verified' ] ) && $ value [ 'verified' ] == true ) { $ emails [ ] = $ value [ 'value' ] ; } } } } catch ( VGS_Client_Exception $ e ) { self :: errorLog ( 'Exception thrown when getting logged in user:' . $ e -> getMessage ( ) ) ; } return $ emails ; } | Get all verified emails for the logged in user . |
22,234 | public function isEmailVerified ( $ email ) { try { $ user = $ this -> api ( '/user/' . $ email ) ; if ( isset ( $ user [ 'emails' ] ) && is_array ( $ user [ 'emails' ] ) && count ( $ user [ 'emails' ] ) > 0 ) { foreach ( $ user [ 'emails' ] as $ key => $ value ) { if ( isset ( $ value [ 'verified' ] ) && $ value [ 'verified' ] == true && $ value [ 'value' ] == $ email ) { return true ; } } } } catch ( VGS_Client_Exception $ e ) { self :: errorLog ( 'Exception thrown when getting logged in user:' . $ e -> getMessage ( ) ) ; } return false ; } | Check if email is verified |
22,235 | public function refreshAccessToken ( $ refresh_token = null ) { $ return = array ( ) ; if ( $ refresh_token ) { $ params [ 'client_id' ] = $ this -> getClientID ( ) ; $ params [ 'client_secret' ] = $ this -> getClientSecret ( ) ; $ params [ 'redirect_uri' ] = $ this -> getRedirectUri ( ) ; $ params [ 'grant_type' ] = 'refresh_token' ; $ params [ 'scope' ] = '' ; $ params [ 'state' ] = '' ; $ params [ 'refresh_token' ] = $ refresh_token ; $ return = ( array ) json_decode ( $ this -> makeRequest ( $ this -> getTokenURL ( ) , $ params ) ) ; } if ( is_array ( $ return ) && isset ( $ return [ 'access_token' ] ) ) { $ this -> session = $ return ; if ( isset ( $ return [ 'access_token' ] ) ) { $ this -> setAccessToken ( $ return [ 'access_token' ] ) ; } if ( isset ( $ return [ 'refresh_token' ] ) ) { $ this -> setRefreshToken ( $ return [ 'refresh_token' ] ) ; } } else { $ this -> setAccessToken ( $ this -> getClientID ( ) ) ; } return $ this -> getAccessToken ( ) ; } | Gets a Fresh OAuth access token based on a refresh token |
22,236 | public function getFlowURI ( $ flow_name , array $ params = array ( ) ) { if ( empty ( $ flow_name ) ) { throw new VGS_Client_Exception ( "Unspecified flow name" ) ; } $ default_params = array ( 'client_id' => $ this -> getClientID ( ) , 'response_type' => 'code' , 'redirect_uri' => $ this -> getCurrentURI ( ) , ) ; if ( $ this -> xiti ) { $ default_params [ 'xiti_json' ] = $ this -> getXitiConfiguration ( ) ; } $ default_params [ 'v' ] = self :: VERSION ; $ parameters = array_merge ( $ default_params , $ params ) ; return $ this -> getUrl ( 'flow' , $ flow_name , $ parameters ) ; } | Get an URI to any flow url in SPiD |
22,237 | public function getPurchaseHistoryURI ( $ params = array ( ) ) { $ default_params = array ( 'client_id' => $ this -> getClientID ( ) , 'response_type' => 'code' , 'redirect_uri' => $ this -> getCurrentURI ( ) , ) ; if ( $ this -> xiti ) { $ default_params [ 'xiti_json' ] = $ this -> getXitiConfiguration ( ) ; } $ default_params [ 'v' ] = self :: VERSION ; return $ this -> getUrl ( 'www' , 'account/purchasehistory' , array_merge ( $ default_params , $ params ) ) ; } | Get the URI for redirecting the user to purchase history page |
22,238 | public function getApiURI ( $ path = '' , $ params = array ( ) ) { if ( ! $ path ) { throw new Exception ( 'Missing argument' ) ; } return $ this -> getUrl ( 'api' , $ path , array_merge ( array ( 'oauth_token' => $ this -> getAccessToken ( ) ) , $ params ) ) ; } | Get the API URI |
22,239 | public function getLogoutURI ( $ params = array ( ) ) { $ default_params = array ( 'redirect_uri' => $ this -> getCurrentURI ( ) , 'oauth_token' => $ this -> getAccessToken ( ) ) ; if ( $ this -> xiti ) { $ default_params [ 'xiti_json' ] = $ this -> getXitiConfiguration ( ) ; } $ default_params [ 'v' ] = self :: VERSION ; return $ this -> getUrl ( 'www' , 'logout' , array_merge ( $ default_params , $ params ) ) ; } | Get a Logout URI suitable for use with redirects . |
22,240 | public function getLoginStatusUrl ( $ params = array ( ) ) { return $ this -> getUrl ( 'www' , 'login_status' , array_merge ( array ( 'client_id' => $ this -> getClientID ( ) , 'no_session' => $ this -> getCurrentURI ( ) , 'no_user' => $ this -> getCurrentURI ( ) , 'ok_session' => $ this -> getCurrentURI ( ) , 'session_version' => 1 ) , $ params ) ) ; } | Get a login status URI to fetch the status from SPiD . |
22,241 | protected function _restserver ( $ path , $ method = 'GET' , $ params = array ( ) , $ getParams = array ( ) ) { $ this -> container = null ; if ( $ this -> debug ) { $ start = microtime ( true ) ; } if ( is_array ( $ method ) && empty ( $ params ) ) { $ params = $ method ; $ method = 'GET' ; } $ getParams [ 'method' ] = $ method ; $ uri = $ this -> getUrl ( 'api' , $ path ) ; $ result = $ this -> _oauthRequest ( $ uri , $ params , $ getParams ) ; if ( floatval ( $ this -> api_version ) >= 2 ) { $ container = json_decode ( $ result , true ) ; if ( $ container && array_key_exists ( 'name' , $ container ) && $ container [ 'name' ] == 'SPP Container' ) { $ this -> container = $ container ; } } preg_match ( "/\.(json|jsonp|html|xml|serialize|php|csv|tgz)$/" , $ path , $ matches ) ; if ( $ matches ) { switch ( $ matches [ 1 ] ) { case 'json' : $ result = json_decode ( $ result , true ) ; break ; default : if ( $ this -> debug ) { $ this -> timer [ __FUNCTION__ ] [ 'elapsed' ] [ ] = microtime ( true ) - $ start ; } return $ result ; break ; } } else $ result = json_decode ( $ result , true ) ; if ( is_array ( $ result ) && isset ( $ result [ 'error' ] ) && $ result [ 'error' ] ) { $ e = new VGS_Client_Exception ( $ result , $ this -> raw ) ; switch ( $ e -> getType ( ) ) { case 'ApiException' : break ; case 'OAuthException' : case 'invalid_token' : $ this -> setSession ( null ) ; } throw $ e ; } if ( floatval ( $ this -> api_version ) >= 2 && $ result && is_array ( $ result ) && array_key_exists ( 'name' , $ result ) && $ result [ 'name' ] == 'SPP Container' ) { if ( isset ( $ result [ 'sig' ] ) && isset ( $ result [ 'algorithm' ] ) ) { $ result = $ this -> validateAndDecodeSignedRequest ( $ result [ 'sig' ] , $ result [ 'data' ] , $ result [ 'algorithm' ] ) ; } else { $ result = $ result [ 'data' ] ; } } if ( $ this -> debug ) { $ this -> timer [ __FUNCTION__ ] [ 'elapsed' ] [ ] = microtime ( true ) - $ start ; } return $ result ; } | Invoke the REST API . |
22,242 | protected function _oauthRequest ( $ uri , $ params , $ getParams = array ( ) ) { if ( $ this -> debug ) { $ start = microtime ( true ) ; } if ( ! isset ( $ getParams [ 'oauth_token' ] ) && isset ( $ params [ 'oauth_token' ] ) ) { $ getParams [ 'oauth_token' ] = $ params [ 'oauth_token' ] ; } if ( ! isset ( $ getParams [ 'oauth_token' ] ) ) { $ getParams [ 'oauth_token' ] = $ this -> getAccessToken ( ) ; } foreach ( ( array ) $ params as $ key => $ value ) { if ( ! is_string ( $ value ) ) { $ params [ $ key ] = json_encode ( $ value ) ; } } if ( $ this -> debug ) { $ this -> timer [ __FUNCTION__ ] [ 'elapsed' ] [ ] = microtime ( true ) - $ start ; } return $ this -> makeRequest ( $ uri , $ params , null , $ getParams ) ; } | Make a OAuth Request |
22,243 | private function recursiveHash ( $ data ) { if ( ! is_array ( $ data ) ) { return $ data ; } $ ret = "" ; uksort ( $ data , 'strnatcmp' ) ; foreach ( $ data as $ v ) { $ ret .= $ this -> recursiveHash ( $ v ) ; } return $ ret ; } | Used to create outgoing POST data hashes not for API response signature |
22,244 | public function createHash ( $ data ) { $ string = $ this -> recursiveHash ( $ data ) ; $ secret = $ this -> getClientSignSecret ( ) ; return self :: base64UrlEncode ( hash_hmac ( "sha256" , $ string , $ secret , true ) ) ; } | Creates a post data array hash that must be added to outgoing API requests that require it . |
22,245 | public function validateAndDecodeSignedRequest ( $ encoded_signature , $ payload , $ algorithm = 'HMAC-SHA256' ) { $ sig = self :: base64UrlDecode ( $ encoded_signature ) ; switch ( $ algorithm ) { case 'HMAC-SHA256' : $ expected_sig = hash_hmac ( 'sha256' , $ payload , $ this -> getClientSignSecret ( ) , true ) ; if ( ! hash_equals ( $ sig , $ expected_sig ) ) { self :: errorLog ( 'Bad Signed JSON signature!' ) ; return null ; } return json_decode ( self :: base64UrlDecode ( $ payload ) , true ) ; break ; default : self :: errorLog ( 'Unknown algorithm. Expected HMAC-SHA256' ) ; break ; } return null ; } | Validate and decode Signed API Request responses |
22,246 | protected function getUrl ( $ name , $ path = '' , $ params = array ( ) ) { $ uri = self :: getBaseURL ( $ name ) ; if ( $ path ) { if ( $ path [ 0 ] === '/' ) { $ path = substr ( $ path , 1 ) ; } $ uri .= $ path ; } if ( $ params ) { $ uri .= '?' . http_build_query ( $ params , null , $ this -> argSeparator ) ; } return $ uri ; } | Build the URI for given domain alias path and parameters . |
22,247 | public function getCurrentURI ( $ extra_params = array ( ) , $ drop_params = array ( ) ) { $ drop_params = array_merge ( self :: $ DROP_QUERY_PARAMS , $ drop_params ) ; $ server_https = $ this -> _getServerParam ( 'HTTPS' ) ; $ server_http_host = $ this -> _getServerParam ( 'HTTP_HOST' ) ? : '' ; $ server_request_uri = $ this -> _getServerParam ( 'REQUEST_URI' ) ? : '' ; $ protocol = isset ( $ server_https ) && $ server_https == 'on' ? 'https://' : 'http://' ; $ currentUrl = $ protocol . $ server_http_host . $ server_request_uri ; $ parts = parse_url ( $ currentUrl ) ; $ query = '' ; if ( ! empty ( $ parts [ 'query' ] ) ) { $ params = array ( ) ; parse_str ( $ parts [ 'query' ] , $ params ) ; $ params = array_merge ( $ params , $ extra_params ) ; foreach ( $ drop_params as $ key ) { unset ( $ params [ $ key ] ) ; } if ( ! empty ( $ params ) ) { $ query = '?' . http_build_query ( $ params , null , $ this -> argSeparator ) ; } } elseif ( ! empty ( $ extra_params ) ) { $ query = '?' . http_build_query ( $ extra_params , null , $ this -> argSeparator ) ; } $ port = isset ( $ parts [ 'port' ] ) && ( ( $ protocol === 'http://' && $ parts [ 'port' ] !== 80 ) || ( $ protocol === 'https://' && $ parts [ 'port' ] !== 443 ) ) ? ':' . $ parts [ 'port' ] : '' ; return $ protocol . ( isset ( $ parts [ 'host' ] ) ? $ parts [ 'host' ] : '' ) . $ port . ( isset ( $ parts [ 'path' ] ) ? $ parts [ 'path' ] : '' ) . $ query ; } | Returns the Current URI stripping it of known parameters that should not persist . |
22,248 | public function set ( $ id , \ Closure $ value ) { $ this -> definitions [ $ id ] = function ( $ container ) use ( $ value ) { static $ object ; if ( is_null ( $ object ) ) { $ object = $ value ( $ container ) ; } return $ object ; } ; } | Adds an entry to the container . |
22,249 | public function RenderError ( $ exceptionMessage = '' ) { if ( $ this -> application -> IsErrorDispatched ( ) ) return ; throw new \ ErrorException ( $ exceptionMessage ? $ exceptionMessage : "Server error: `" . htmlspecialchars ( $ this -> request -> GetFullUrl ( ) ) . "`." , 500 ) ; } | Render error controller and error action for any dispatch exception or error as rendered html response or as plain text response . |
22,250 | protected function renderGetViewScriptPath ( $ controllerOrActionNameDashed = NULL , $ actionNameDashed = NULL ) { $ currentCtrlIsTopMostParent = $ this -> parentController === NULL ; if ( $ this -> viewScriptsPath !== NULL ) { $ resultPathItems = [ $ this -> viewScriptsPath ] ; if ( $ controllerOrActionNameDashed !== NULL ) $ resultPathItems [ ] = $ controllerOrActionNameDashed ; if ( $ actionNameDashed !== NULL ) $ resultPathItems [ ] = $ actionNameDashed ; return str_replace ( [ '_' , '\\' ] , '/' , implode ( '/' , $ resultPathItems ) ) ; } if ( $ actionNameDashed !== NULL ) { $ controllerNameDashed = $ controllerOrActionNameDashed ; } else { $ toolClass = '' ; if ( $ currentCtrlIsTopMostParent ) { $ controllerNameDashed = $ this -> controllerName ; } else { $ ctrlsDefaultNamespace = $ this -> application -> GetAppDir ( ) . '\\' . $ this -> application -> GetControllersDir ( ) ; $ currentCtrlClassName = get_class ( $ this ) ; if ( mb_strpos ( $ currentCtrlClassName , $ ctrlsDefaultNamespace ) === 0 ) $ currentCtrlClassName = mb_substr ( $ currentCtrlClassName , mb_strlen ( $ ctrlsDefaultNamespace ) + 1 ) ; $ currentCtrlClassName = str_replace ( '\\' , '/' , $ currentCtrlClassName ) ; $ toolClass = $ this -> application -> GetToolClass ( ) ; $ controllerNameDashed = $ toolClass :: GetDashedFromPascalCase ( $ currentCtrlClassName ) ; } if ( $ controllerOrActionNameDashed !== NULL ) { $ actionNameDashed = $ controllerOrActionNameDashed ; } else { if ( $ currentCtrlIsTopMostParent ) { $ actionNameDashed = $ this -> actionName ; } else { $ defaultCtrlAction = $ this -> application -> GetDefaultControllerAndActionNames ( ) ; $ actionNameDashed = $ toolClass :: GetDashedFromPascalCase ( $ defaultCtrlAction [ 1 ] ) ; } } } $ controllerPath = str_replace ( [ '_' , '\\' ] , '/' , $ controllerNameDashed ) ; return implode ( '/' , [ $ controllerPath , $ actionNameDashed ] ) ; } | Complete view script path by given controller and action or only by given action rendering arguments . |
22,251 | protected function registerBladeExtensions ( ) : void { $ blade = $ this -> app [ 'view' ] -> getEngineResolver ( ) -> resolve ( 'blade' ) -> getCompiler ( ) ; $ blade -> directive ( 'javascripts' , function ( $ value ) { return "<?php echo basset_javascripts($value); ?>" ; } ) ; $ blade -> directive ( 'stylesheets' , function ( $ value ) { return "<?php echo basset_stylesheets($value); ?>" ; } ) ; $ blade -> directive ( 'assets' , function ( $ value ) { return "<?php echo basset_assets($value); ?>" ; } ) ; } | Register the Blade extensions with the compiler . |
22,252 | protected function registerAssetFinder ( ) : void { $ this -> app -> singleton ( 'basset.finder' , function ( $ app ) { return new AssetFinder ( $ app [ 'files' ] , $ app [ 'config' ] , base_path ( ) . '/resources/assets' ) ; } ) ; } | Register the asset finder . |
22,253 | protected function registerLogger ( ) : void { $ this -> app -> singleton ( 'basset.log' , function ( $ app ) { return new Logger ( new \ Monolog \ Logger ( 'basset' ) , $ app [ 'events' ] ) ; } ) ; } | Register the logger . |
22,254 | protected function registerBuilder ( ) : void { $ this -> app -> singleton ( 'basset.builder' , function ( $ app ) { return new Builder ( $ app [ 'files' ] , $ app [ 'basset.manifest' ] , $ app [ 'basset.path.build' ] ) ; } ) ; $ this -> app -> singleton ( 'basset.builder.cleaner' , function ( $ app ) { return new FilesystemCleaner ( $ app [ 'basset' ] , $ app [ 'basset.manifest' ] , $ app [ 'files' ] , $ app [ 'basset.path.build' ] ) ; } ) ; } | Register the collection builder . |
22,255 | protected function redirect ( $ url , $ code = 301 ) { $ app = \ MvcCore \ Application :: GetInstance ( ) ; $ app -> GetResponse ( ) -> SetCode ( $ code ) -> SetHeader ( 'Location' , $ url ) ; $ app -> Terminate ( ) ; } | Redirect request to given URL with optional code and terminate application . |
22,256 | public function filterDump ( AssetInterface $ asset ) { $ this -> assetDirectory = $ this -> realPath ( $ asset -> getSourceRoot ( ) ) ; $ content = $ asset -> getContent ( ) ; foreach ( $ this -> symlinks as $ link => $ target ) { unset ( $ this -> symlinks [ $ link ] ) ; if ( $ link == '//' ) { $ link = $ this -> documentRoot ; } else { $ link = str_replace ( '//' , $ this -> documentRoot . '/' , $ link ) ; } $ link = strtr ( $ link , '/' , DIRECTORY_SEPARATOR ) ; $ this -> symlinks [ $ link ] = $ this -> realPath ( $ target ) ; } $ content = $ this -> trimUrls ( $ content ) ; $ content = preg_replace_callback ( '/@import\\s+([\'"])(.*?)[\'"]/' , array ( $ this , 'processUriCallback' ) , $ content ) ; $ content = preg_replace_callback ( '/url\\(\\s*([^\\)\\s]+)\\s*\\)/' , array ( $ this , 'processUriCallback' ) , $ content ) ; $ asset -> setContent ( $ content ) ; } | Apply a filter on file dump . |
22,257 | public static function Init ( $ forceDevelopmentMode = NULL ) { if ( static :: $ debugging !== NULL ) return ; if ( self :: $ strictExceptionsMode === NULL ) self :: initStrictExceptionsMode ( self :: $ strictExceptionsMode ) ; $ app = static :: $ app ? : ( static :: $ app = & \ MvcCore \ Application :: GetInstance ( ) ) ; static :: $ requestBegin = $ app -> GetRequest ( ) -> GetMicrotime ( ) ; if ( gettype ( $ forceDevelopmentMode ) == 'boolean' ) { static :: $ debugging = $ forceDevelopmentMode ; } else { $ configClass = $ app -> GetConfigClass ( ) ; static :: $ debugging = $ configClass :: IsDevelopment ( TRUE ) || $ configClass :: IsAlpha ( TRUE ) ; } $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; static :: $ originalDebugClass = ltrim ( $ app -> GetDebugClass ( ) , '\\' ) == $ selfClass ; static :: initHandlers ( ) ; $ initGlobalShortHandsHandler = static :: $ InitGlobalShortHands ; $ initGlobalShortHandsHandler ( static :: $ debugging ) ; } | Initialize debugging and logging once only . |
22,258 | protected static function initStrictExceptionsMode ( $ strictExceptionsMode ) { $ errorLevelsToExceptions = [ ] ; if ( $ strictExceptionsMode !== FALSE ) { $ sysCfgDebug = static :: getSystemCfgDebugSection ( ) ; if ( isset ( $ sysCfgDebug [ 'strictExceptions' ] ) ) { $ rawStrictExceptions = $ sysCfgDebug [ 'strictExceptions' ] ; $ rawStrictExceptions = is_array ( $ rawStrictExceptions ) ? $ rawStrictExceptions : explode ( ',' , trim ( $ rawStrictExceptions , '[]' ) ) ; $ errorLevelsToExceptions = array_map ( function ( $ rawErrorLevel ) { $ rawErrorLevel = trim ( $ rawErrorLevel ) ; if ( is_numeric ( $ rawErrorLevel ) ) return intval ( $ rawErrorLevel ) ; return constant ( $ rawErrorLevel ) ; } , $ rawStrictExceptions ) ; } else { $ errorLevelsToExceptions = self :: $ strictExceptionsModeDefaultLevels ; } } return self :: SetStrictExceptionsMode ( $ strictExceptionsMode , $ errorLevelsToExceptions ) ; } | Initialize strict exceptions mode in default levels or in customized levels from system config . |
22,259 | protected static function initHandlers ( ) { $ className = version_compare ( PHP_VERSION , '5.5' , '>' ) ? static :: class : get_called_class ( ) ; foreach ( static :: $ handlers as $ key => $ value ) { static :: $ handlers [ $ key ] = [ $ className , $ value ] ; } register_shutdown_function ( static :: $ handlers [ 'shutdownHandler' ] ) ; } | Initialize debugging and logging handlers . |
22,260 | protected static function initLogDirectory ( ) { $ sysCfgDebug = static :: getSystemCfgDebugSection ( ) ; $ logDirConfiguredPath = isset ( $ sysCfgDebug [ 'logDirectory' ] ) ? $ sysCfgDebug [ 'logDirectory' ] : static :: $ LogDirectory ; if ( mb_substr ( $ logDirConfiguredPath , 0 , 1 ) === '~' ) { $ app = static :: $ app ? : ( static :: $ app = & \ MvcCore \ Application :: GetInstance ( ) ) ; $ logDirAbsPath = $ app -> GetRequest ( ) -> GetAppRoot ( ) . '/' . ltrim ( mb_substr ( $ logDirConfiguredPath , 1 ) , '/' ) ; } else { $ logDirAbsPath = $ logDirConfiguredPath ; } static :: $ LogDirectory = $ logDirAbsPath ; try { if ( ! is_dir ( $ logDirAbsPath ) ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; if ( ! mkdir ( $ logDirAbsPath , 0777 , TRUE ) ) throw new \ RuntimeException ( '[' . $ selfClass . "] It was not possible to create log directory: `" . $ logDirAbsPath . "`." ) ; if ( ! is_writable ( $ logDirAbsPath ) ) if ( ! chmod ( $ logDirAbsPath , 0777 ) ) throw new \ RuntimeException ( '[' . $ selfClass . "] It was not possible to setup privileges to log directory: `" . $ logDirAbsPath . "` to writeable mode 0777." ) ; } } catch ( \ Exception $ e ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; die ( '[' . $ selfClass . '] ' . $ e -> getMessage ( ) ) ; } static :: $ logDirectoryInitialized = TRUE ; return $ logDirAbsPath ; } | If log directory doesn t exist create new directory - relative from app root . |
22,261 | public function & InitAll ( ) { $ this -> GetScriptName ( ) ; $ this -> GetAppRoot ( ) ; $ this -> GetMethod ( ) ; $ this -> GetBasePath ( ) ; $ this -> GetScheme ( ) ; $ this -> IsSecure ( ) ; $ this -> GetHostName ( ) ; $ this -> GetHost ( ) ; $ this -> GetRequestPath ( ) ; $ this -> GetFullUrl ( ) ; $ this -> GetReferer ( ) ; $ this -> GetMicrotime ( ) ; $ this -> IsAjax ( ) ; if ( $ this -> port === NULL ) $ this -> initUrlSegments ( ) ; if ( $ this -> headers === NULL ) $ this -> initHeaders ( ) ; if ( $ this -> params === NULL ) $ this -> initParams ( ) ; $ this -> GetServerIp ( ) ; $ this -> GetClientIp ( ) ; $ this -> GetContentLength ( ) ; return $ this ; } | Initialize all possible protected values from all global variables including all http headers all params and application inputs . This method is not recommended to use in production mode it s designed mostly for development purposes to see in one moment what could be inside request after calling any getter method . |
22,262 | public function createResolver ( ) { $ resolver = $ this -> getResolver ( ) ; if ( isset ( $ resolver ) ) { $ resolver_class = get_class ( $ resolver ) ; $ retriever = $ resolver -> getUriRetriever ( ) ; if ( isset ( $ retriever ) ) { $ retriever_class = get_class ( $ retriever ) ; $ new_retriever = new $ retriever_class ( ) ; } else { $ new_retriever = new UriRetriever ( ) ; } $ max_depth = $ resolver :: $ maxDepth ; $ new_resolver = new $ resolver_class ( $ new_retriever ) ; $ new_resolver :: $ maxDepth = $ max_depth ; } else { $ new_retriever = new UriRetriever ( ) ; $ new_resolver = new RefResolver ( $ new_retriever ) ; } return $ new_resolver ; } | Create a resolver with the same classes as the initialized resolver . |
22,263 | public function handle ( LogManager $ logger ) : void { $ db = \ resolve ( 'db' ) ; $ callback = $ this -> buildQueryCallback ( $ logger ) ; foreach ( $ db -> getQueryLog ( ) as $ query ) { $ callback ( new QueryExecuted ( $ query [ 'query' ] , $ query [ 'bindings' ] , $ query [ 'time' ] , $ db ) ) ; } \ resolve ( Dispatcher :: class ) -> listen ( QueryExecuted :: class , $ callback ) ; } | Handle the listener . |
22,264 | protected function buildQueryCallback ( LogManager $ logger ) : callable { return function ( QueryExecuted $ query ) use ( $ logger ) { $ sql = Str :: replaceArray ( '?' , $ query -> connection -> prepareBindings ( $ query -> bindings ) , $ query -> sql ) ; $ logger -> info ( "<comment>{$sql} [{$query->time}ms]</comment>" ) ; } ; } | BUild Query Callback . |
22,265 | public function storeIsActive ( $ storeViewCode ) { if ( isset ( $ this -> stores [ $ storeViewCode ] ) ) { return 1 === ( integer ) $ this -> stores [ $ storeViewCode ] [ MemberNames :: IS_ACTIVE ] ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Found invalid store view code %s' , $ storeViewCode ) ) ) ; } | Return s TRUE if the store with the passed code is active else FALSE . |
22,266 | protected function initReverseParamsGetGreedyInfo ( & $ reverseSectionsInfo , & $ constraints , & $ paramName , & $ sectionIndex , & $ greedyCaught ) { $ greedyFlag = mb_strpos ( $ paramName , '*' ) !== FALSE ; $ sectionIsLast = NULL ; if ( $ greedyFlag ) { if ( $ greedyFlag && $ greedyCaught ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ InvalidArgumentException ( "[" . $ selfClass . "] Route pattern definition can have only one greedy `<param_name*>` " . " with star (to include everything - all characters and slashes . `.*`) ($this)." ) ; } $ reverseSectionsCount = count ( $ reverseSectionsInfo ) ; $ sectionIndexPlusOne = $ sectionIndex + 1 ; if ( $ sectionIndexPlusOne < $ reverseSectionsCount && ! ( $ reverseSectionsInfo [ $ sectionIndexPlusOne ] -> fixed ) ) { $ constraintDefined = isset ( $ constraints [ $ paramName ] ) ; $ constraint = $ constraintDefined ? $ constraints [ $ paramName ] : NULL ; $ greedyReal = ! $ constraintDefined || ( $ constraintDefined && ( mb_strpos ( $ constraint , '.*' ) !== FALSE || mb_strpos ( $ constraint , '.+' ) !== FALSE ) ) ; if ( $ greedyReal ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ InvalidArgumentException ( "[" . $ selfClass . "] Route pattern definition can not have greedy `<param_name*>` with star " . "(to include everything - all characters and slashes . `.*`) immediately before optional " . "section ($this)." ) ; } } $ greedyCaught = TRUE ; $ paramName = str_replace ( '*' , '' , $ paramName ) ; $ sectionIsLast = $ sectionIndexPlusOne === $ reverseSectionsCount ; } return [ $ greedyFlag , $ sectionIsLast ] ; } | Get if founded param place is greedy or not . If it s greedy check if it is only one greedy param in whole pattern string and if it is the last param between other params . Get also if given section index belongs to the last section info in line . |
22,267 | protected function initFlagsByPatternOrReverse ( $ pattern ) { $ scheme = static :: FLAG_SCHEME_NO ; if ( mb_strpos ( $ pattern , '//' ) === 0 ) { $ scheme = static :: FLAG_SCHEME_ANY ; } else if ( mb_strpos ( $ pattern , 'http://' ) === 0 ) { $ scheme = static :: FLAG_SCHEME_HTTP ; } else if ( mb_strpos ( $ pattern , 'https://' ) === 0 ) { $ scheme = static :: FLAG_SCHEME_HTTPS ; } $ host = static :: FLAG_HOST_NO ; if ( $ scheme ) { if ( mb_strpos ( $ pattern , static :: PLACEHOLDER_HOST ) !== FALSE ) { $ host = static :: FLAG_HOST_HOST ; } else if ( mb_strpos ( $ pattern , static :: PLACEHOLDER_DOMAIN ) !== FALSE ) { $ host = static :: FLAG_HOST_DOMAIN ; } else { if ( mb_strpos ( $ pattern , static :: PLACEHOLDER_TLD ) !== FALSE ) $ host += static :: FLAG_HOST_TLD ; if ( mb_strpos ( $ pattern , static :: PLACEHOLDER_SLD ) !== FALSE ) $ host += static :: FLAG_HOST_SLD ; } if ( mb_strpos ( $ pattern , static :: PLACEHOLDER_BASEPATH ) !== FALSE ) $ host += static :: FLAG_HOST_BASEPATH ; } $ queryString = mb_strpos ( $ pattern , '?' ) !== FALSE ? static :: FLAG_QUERY_INCL : static :: FLAG_QUERY_NO ; $ this -> flags = [ $ scheme , $ host , $ queryString ] ; } | Initialize three route integer flags . About if and what scheme definition is contained in given pattern if and what domain parts are contained in given pattern and if given pattern contains any part of query string . Given pattern is reverse and if reverse is empty it s pattern prop . |
22,268 | protected function throwExceptionIfKeyPropertyIsMissing ( $ propsNames ) { $ propsNames = func_get_args ( ) ; $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ LogicException ( "[" . $ selfClass . "] Route configuration property/properties is/are" . " missing: `" . implode ( "`, `" , $ propsNames ) . "`, to parse and" . " complete key properties `match` and/or `reverse` to route" . " or build URL correctly ($this)." ) ; } | Thrown a logic exception about missing key property in route object to parse pattern or reverse . Those properties are necessary to complete correctly match property to route incoming request or to complete correctly reverse property to build URL address . |
22,269 | public function SetCookie ( $ name , $ value , $ lifetime = 0 , $ path = '/' , $ domain = NULL , $ secure = NULL , $ httpOnly = TRUE ) { if ( $ this -> IsSent ( ) ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ RuntimeException ( "[" . $ selfClass . "] Cannot set cookie after HTTP headers have been sent." ) ; } $ request = \ MvcCore \ Application :: GetInstance ( ) -> GetRequest ( ) ; return \ setcookie ( $ name , $ value , $ lifetime === 0 ? 0 : time ( ) + $ lifetime , $ path , $ domain === NULL ? $ request -> GetHostName ( ) : $ domain , $ secure === NULL ? $ request -> IsSecure ( ) : $ secure , $ httpOnly ) ; } | Send a cookie . |
22,270 | public function DeleteCookie ( $ name , $ path = '/' , $ domain = NULL , $ secure = NULL ) { return $ this -> SetCookie ( $ name , '' , 0 , $ path , $ domain , $ secure ) ; } | Delete cookie - set value to empty string and set expiration to until the browser is closed . |
22,271 | public function withAttribute ( $ key , $ value ) { $ newAttributes = $ this -> attributes -> withAttribute ( $ key , $ value ) ; $ that = clone ( $ this ) ; $ that -> attributes = $ newAttributes ; return $ that ; } | Returns a copy of the element with the attribute set . |
22,272 | public function withoutAttribute ( $ key ) { $ newAttributes = $ this -> attributes -> withoutAttribute ( $ key ) ; $ that = clone ( $ this ) ; $ that -> attributes = $ newAttributes ; return $ that ; } | Returns a copy of the element with the attribute removed . |
22,273 | protected function createCurl ( ) { $ ch = curl_init ( ) ; $ body = '' ; if ( $ this -> method === self :: METHOD_HEAD ) { curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; } elseif ( $ this -> method !== self :: METHOD_GET ) { curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ this -> method ) ; $ body = $ this -> makeCurlBody ( ) ; if ( $ body ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ body ) ; } } $ headers = [ ] ; foreach ( $ this -> getHeaders ( ) as $ key => $ values ) { foreach ( $ values as $ line ) { $ headers [ ] = "$key: $line" ; } } if ( is_string ( $ body ) && ! $ this -> hasHeader ( 'Content-Length' ) ) { $ headers [ ] = 'Content-Length: ' . strlen ( $ body ) ; } if ( ! $ this -> hasHeader ( 'Expect' ) ) { $ headers [ ] = 'Expect:' ; } curl_setopt ( $ ch , CURLOPT_HTTP_VERSION , $ this -> getProtocolVersion ( ) == '1.0' ? CURL_HTTP_VERSION_1_0 : CURL_HTTP_VERSION_1_1 ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this -> getTimeout ( ) ) ; curl_setopt ( $ ch , CURLOPT_MAXREDIRS , 10 ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> verifyPeer ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , $ this -> verifyPeer ? 2 : 0 ) ; curl_setopt ( $ ch , CURLOPT_ENCODING , '' ) ; curl_setopt ( $ ch , CURLOPT_PROTOCOLS , CURLPROTO_HTTP | CURLPROTO_HTTPS ) ; if ( ! empty ( $ this -> auth ) ) { curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> auth [ 0 ] . ":" . ( ( empty ( $ this -> auth [ 1 ] ) ) ? "" : $ this -> auth [ 1 ] ) ) ; } return $ ch ; } | Create the cURL resource that represents this request . |
22,274 | protected function makeCurlBody ( ) { $ body = $ this -> body ; if ( is_string ( $ body ) ) { return ( string ) $ body ; } $ contentType = $ this -> getHeader ( 'Content-Type' ) ; if ( stripos ( $ contentType , 'application/json' ) === 0 ) { $ body = json_encode ( $ body ) ; } return $ body ; } | Convert the request body into a format suitable to be passed to curl . |
22,275 | protected function execCurl ( $ ch ) { curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; $ response = curl_exec ( $ ch ) ; $ info = curl_getinfo ( $ ch ) ; $ code = $ info [ "http_code" ] ; if ( $ response ) { $ header_size = $ info [ "header_size" ] ; $ rawHeaders = substr ( $ response , 0 , $ header_size ) ; $ status = null ; $ rawBody = substr ( $ response , $ header_size ) ; } else { $ status = $ code ; $ rawHeaders = [ ] ; $ rawBody = curl_error ( $ ch ) ; } $ result = new HttpResponse ( $ status , $ rawHeaders , $ rawBody ) ; $ result -> setRequest ( $ this ) ; return $ result ; } | Execute a curl handle and return the response . |
22,276 | public function isValidChannelValue ( $ value , $ channel ) { if ( ! in_array ( $ channel , self :: $ channels ) ) { throw new \ InvalidArgumentException ( 'Invalid Channel Name' ) ; } if ( $ channel == self :: CHANNEL_ALPHA ) { if ( $ value >= 0 && $ value <= 127 ) { return true ; } } else { if ( $ value >= 0 && $ value <= 255 ) { return true ; } } return false ; } | Check if the given value is valid for the given channel name |
22,277 | public function setAlpha ( $ alpha ) { $ this -> assertChannelValue ( $ alpha , self :: CHANNEL_ALPHA ) ; $ this -> alpha = $ alpha ; return $ this ; } | set alpha value |
22,278 | public function setRed ( $ value ) { $ this -> assertChannelValue ( $ value , self :: CHANNEL_RED ) ; $ this -> red = $ value ; return $ this ; } | Set red value |
22,279 | public function setGreen ( $ value ) { $ this -> assertChannelValue ( $ value , self :: CHANNEL_GREEN ) ; $ this -> green = $ value ; return $ this ; } | Set green value |
22,280 | public function setBlue ( $ value ) { $ this -> assertChannelValue ( $ value , self :: CHANNEL_BLUE ) ; $ this -> blue = $ value ; return $ this ; } | Set blue value |
22,281 | public function getValue ( ) { return ( ( ( int ) $ this -> getRed ( ) & 0xFF ) << 16 ) | ( ( ( int ) $ this -> getGreen ( ) & 0xFF ) << 8 ) | ( ( ( int ) $ this -> getBlue ( ) & 0xFF ) ) | ( ( ( int ) $ this -> getAlpha ( ) & 0xFF ) << 24 ) ; } | Get color value |
22,282 | public function setFromRGBColor ( RGBColor $ color ) { return $ this -> setRed ( $ color -> getRed ( ) ) -> setGreen ( $ color -> getGreen ( ) ) -> setBlue ( $ color -> getBlue ( ) ) -> setAlpha ( $ color -> getAlpha ( ) ) ; } | Set color from another color object |
22,283 | public function setFromArray ( array $ color ) { return $ this -> setRed ( $ color [ 0 ] ) -> setGreen ( $ color [ 1 ] ) -> setBlue ( $ color [ 2 ] ) -> setAlpha ( $ color [ 3 ] ) ; } | Set color from array |
22,284 | public function setFromValue ( $ rgb , $ hasalpha = true ) { $ r = ( $ rgb >> 16 ) & 0xFF ; $ g = ( $ rgb >> 8 ) & 0xFF ; $ b = ( $ rgb >> 0 ) & 0xFF ; if ( $ hasalpha ) { $ a = ( $ rgb >> 24 ) & 0xff ; return $ this -> setRed ( $ r ) -> setGreen ( $ g ) -> setBlue ( $ b ) -> setAlpha ( $ a ) ; } return $ this -> setRed ( $ r ) -> setGreen ( $ g ) -> setBlue ( $ b ) ; } | Set color from rgb integer |
22,285 | public function setFromHex ( $ hex , $ alpha = 0 ) { if ( ! preg_match ( self :: $ HexRegex , $ hex ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Inavlid Hex Color "%s"' , $ hex ) ) ; } $ ehex = ltrim ( $ hex , '#' ) ; if ( strlen ( $ ehex ) === 3 ) { $ ehex = $ ehex [ 0 ] . $ ehex [ 0 ] . $ ehex [ 1 ] . $ ehex [ 1 ] . $ ehex [ 2 ] . $ ehex [ 2 ] ; } $ color = array_map ( 'hexdec' , str_split ( $ ehex , 2 ) ) ; return $ this -> setRed ( $ color [ 0 ] ) -> setGreen ( $ color [ 1 ] ) -> setBlue ( $ color [ 2 ] ) -> setAlpha ( $ alpha ) ; } | Set color from hex string |
22,286 | public function getRGBColor ( ) { return new self ( $ this -> getRed ( ) , $ this -> getGreen ( ) , $ this -> getBlue ( ) , $ this -> getAlpha ( ) ) ; } | Get new color object which is equal to the current one |
22,287 | public function brighter ( $ shade = 0.7 ) { $ r = $ this -> getRed ( ) ; $ g = $ this -> getGreen ( ) ; $ b = $ this -> getBlue ( ) ; $ alpha = $ this -> getAlpha ( ) ; $ i = ( integer ) ( 1.0 / ( 1.0 - $ shade ) ) ; if ( $ r == 0 && $ g == 0 && $ b == 0 ) { return new self ( $ i , $ i , $ i , $ alpha ) ; } if ( $ r > 0 && $ r < $ i ) $ r = $ i ; if ( $ g > 0 && $ g < $ i ) $ g = $ i ; if ( $ b > 0 && $ b < $ i ) $ b = $ i ; return $ this -> setFromArray ( array ( min ( array ( ( integer ) ( $ r / $ shade ) , 255 ) ) , min ( array ( ( integer ) ( $ g / $ shade ) , 255 ) ) , min ( array ( ( integer ) ( $ b / $ shade ) , 255 ) ) , $ alpha ) ) ; } | Create Brighter version of the current color using the specified number of shades |
22,288 | public function darker ( $ shade = 0.7 ) { return $ this -> setFromArray ( array ( max ( array ( ( integer ) $ this -> getRed ( ) * $ shade , 0 ) ) , max ( array ( ( integer ) $ this -> getGreen ( ) * $ shade , 0 ) ) , max ( array ( ( integer ) $ this -> getBlue ( ) * $ shade , 0 ) ) , $ this -> getAlpha ( ) ) ) ; } | Create darker version of the current color using the specified number of shades |
22,289 | public function blend ( RGBColor $ color , $ amount ) { return $ this -> setFromArray ( array ( min ( 255 , min ( $ this -> getRed ( ) , $ color -> getRed ( ) ) + round ( abs ( $ color -> getRed ( ) - $ this -> getRed ( ) ) * $ amount ) ) , min ( 255 , min ( $ this -> getGreen ( ) , $ color -> getGreen ( ) ) + round ( abs ( $ color -> getGreen ( ) - $ this -> getGreen ( ) ) * $ amount ) ) , min ( 255 , min ( $ this -> getBlue ( ) , $ color -> getBlue ( ) ) + round ( abs ( $ color -> getBlue ( ) - $ this -> getBlue ( ) ) * $ amount ) ) , min ( 100 , min ( $ this -> getAlpha ( ) , $ color -> getAlpha ( ) ) + round ( abs ( $ color -> getAlpha ( ) - $ this -> getAlpha ( ) ) * $ amount ) ) ) ) ; } | Blend current color with the given new color and the amount |
22,290 | public function grayscale ( ) { $ gray = min ( 255 , round ( 0.299 * $ this -> getRed ( ) + 0.587 * $ this -> getGreen ( ) + 0.114 * $ this -> getBlue ( ) ) ) ; return $ this -> setFromArray ( array ( $ gray , $ gray , $ gray , $ this -> getAlpha ( ) ) ) ; } | Gray current color |
22,291 | protected function assertChannelValue ( $ value , $ channel ) { if ( ! $ this -> isValidChannelValue ( $ value , $ channel ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Value "%s" For The %s Channel' , $ value , ucfirst ( $ value ) ) ) ; } return $ this ; } | Assert that the given value for the given channel name is valid |
22,292 | private function buildCommand ( $ attribute , array $ propertyData ) { if ( $ attribute -> get ( 'check_listview' ) == 1 ) { $ commandName = 'listviewtoggle_' . $ attribute -> getColName ( ) ; } else { $ commandName = 'publishtoggle_' . $ attribute -> getColName ( ) ; } $ toggle = new ToggleCommand ( ) ; $ toggle -> setName ( $ commandName ) ; $ toggle -> setLabel ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'metamodelattribute_checkbox' ] [ 'toggle' ] [ 0 ] ) ; $ toggle -> setDescription ( \ sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'metamodelattribute_checkbox' ] [ 'toggle' ] [ 1 ] , $ attribute -> getName ( ) ) ) ; $ extra = $ toggle -> getExtra ( ) ; $ extra [ 'icon' ] = 'visible.svg' ; $ objIconEnabled = FilesModel :: findByUuid ( $ attribute -> get ( 'check_listviewicon' ) ) ; $ objIconDisabled = FilesModel :: findByUuid ( $ attribute -> get ( 'check_listviewicondisabled' ) ) ; if ( $ attribute -> get ( 'check_listview' ) == 1 && $ objIconEnabled -> path && $ objIconDisabled -> path ) { $ extra [ 'icon' ] = $ objIconEnabled -> path ; $ extra [ 'icon_disabled' ] = $ objIconDisabled -> path ; } else { $ extra [ 'icon' ] = 'visible.svg' ; } $ toggle -> setToggleProperty ( $ attribute -> getColName ( ) ) ; if ( $ attribute -> get ( 'check_inverse' ) == 1 ) { $ toggle -> setInverse ( true ) ; } if ( ! empty ( $ propertyData [ 'eval' ] [ 'readonly' ] ) ) { $ toggle -> setDisabled ( true ) ; } return $ toggle ; } | Build a single toggle operation . |
22,293 | protected function createBackendViewDefinition ( $ container ) { if ( $ container -> hasDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ) { $ view = $ container -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ; } else { $ view = new Contao2BackendViewDefinition ( ) ; $ container -> setDefinition ( Contao2BackendViewDefinitionInterface :: NAME , $ view ) ; } return $ view ; } | Create the backend view definition . |
22,294 | public function handle ( BuildMetaModelOperationsEvent $ event ) { if ( ! $ this -> scopeMatcher -> currentScopeIsBackend ( ) ) { return ; } $ allProps = $ event -> getScreen ( ) [ 'properties' ] ; $ properties = \ array_map ( function ( $ property ) { return ( $ property [ 'col_name' ] ?? null ) ; } , $ allProps ) ; foreach ( $ event -> getMetaModel ( ) -> getAttributes ( ) as $ attribute ) { if ( ! $ this -> wantToAdd ( $ attribute , $ properties ) ) { continue ; } $ info = [ ] ; foreach ( $ allProps as $ prop ) { if ( $ prop [ 'col_name' ] === $ attribute -> getColName ( ) ) { $ info = $ prop ; } } $ toggle = $ this -> buildCommand ( $ attribute , $ info ) ; $ container = $ event -> getContainer ( ) ; $ view = $ this -> createBackendViewDefinition ( $ container ) ; $ commands = $ view -> getModelCommands ( ) ; if ( ! $ commands -> hasCommandNamed ( $ toggle -> getName ( ) ) ) { if ( $ commands -> hasCommandNamed ( 'show' ) ) { $ info = $ commands -> getCommandNamed ( 'show' ) ; } else { $ info = null ; } $ commands -> addCommand ( $ toggle , $ info ) ; } } } | Create the property conditions . |
22,295 | private function wantToAdd ( $ attribute , array $ properties ) : bool { return ( $ attribute instanceof Checkbox ) && ( ( $ attribute -> get ( 'check_publish' ) === '1' ) || ( $ attribute -> get ( 'check_listview' ) === '1' ) ) && ( \ in_array ( $ attribute -> getColName ( ) , $ properties , true ) ) ; } | Test if we want to add an operation for the attribute . |
22,296 | public function buildBoostedFields ( $ fields ) { if ( is_string ( $ fields ) ) { return $ fields ; } $ processed = array ( ) ; foreach ( $ fields as $ fieldName => $ boost ) { if ( ! is_array ( $ boost ) ) { $ processed [ ] = $ fieldName . '^' . $ boost ; } else { $ field = $ fieldName . '~' . $ boost [ 0 ] ; if ( isset ( $ boost [ 1 ] ) ) { $ field .= '^' . $ boost [ 1 ] ; } $ processed [ ] = $ field ; } } return join ( ',' , $ processed ) ; } | Helper function that turns associative arrays into boosted fields . |
22,297 | public function setBlockSize ( $ size ) { if ( $ size <= 1 ) { throw new \ InvalidArgumentException ( "Pixel Size Must Be Greater Than One" ) ; } $ this -> size = ( int ) abs ( $ size ) ; return $ this ; } | Set the block size |
22,298 | public function initialize ( ) { if ( $ this -> versionStorage -> hasVersioningNode ( ) ) { throw new MigratorException ( 'This repository has already been initialized. Will not re-initialize.' ) ; } foreach ( array_keys ( $ this -> versionCollection -> getAllVersions ( ) ) as $ timestamp ) { $ this -> versionStorage -> add ( $ timestamp ) ; } $ this -> session -> save ( ) ; } | Add all the migrations without running them . This should be executed on new database installations . |
22,299 | private function resolveTo ( $ to , $ from ) { if ( is_string ( $ to ) ) { $ to = strtolower ( $ to ) ; } if ( $ to === 'down' ) { $ to = $ this -> versionCollection -> getPreviousVersion ( $ from ) ; } if ( $ to === 'up' ) { $ to = $ this -> versionCollection -> getNextVersion ( $ from ) ; } if ( $ to === 'bottom' ) { $ to = 0 ; } if ( $ to === 'top' || null === $ to ) { $ to = $ this -> versionCollection -> getLatestVersion ( ) ; } if ( 0 !== $ to && false === strtotime ( $ to ) ) { throw new MigratorException ( sprintf ( 'Unknown migration action "%s". Known actions: "%s"' , $ to , implode ( '", "' , $ this -> actions ) ) ) ; } if ( 0 !== $ to && ! $ this -> versionCollection -> has ( $ to ) ) { throw new MigratorException ( sprintf ( 'Unknown version "%s"' , $ to ) ) ; } return $ to ; } | Resolve the to version . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.