idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
6,500
|
public function getRows ( $ query ) { try { $ stmt = $ this -> db -> query ( $ query ) ; return $ stmt -> fetchAll ( PDO :: FETCH_ASSOC ) ; } catch ( Exception $ e ) { return [ ] ; } }
|
Get rows of data by query
|
6,501
|
protected function prepareRepository ( ) { $ config = $ this -> container [ 'config' ] ; $ this -> builder -> clean ( $ config [ 'build.directory' ] ) ; $ workingCopy = $ this -> git -> workingCopy ( $ config [ 'build.directory' ] ) ; $ this -> doGitInit ( $ workingCopy , $ config [ 'deploy.git.url' ] , $ config [ 'deploy.git.branch' ] ) ; $ this -> builder -> clean ( $ config [ 'build.directory' ] , true ) ; return $ workingCopy ; }
|
Prepare the build directory as a git repository .
|
6,502
|
protected function doGitInit ( GitWorkingCopy $ workingCopy , $ url , $ branch ) { $ workingCopy -> init ( ) ; $ workingCopy -> remote ( 'add' , 'origin' , $ url ) ; try { $ this -> output -> writeln ( "Attempting to fetch <path>origin/{$branch}</path>" , OutputInterface :: VERBOSITY_VERBOSE ) ; $ workingCopy -> fetch ( 'origin' , $ branch ) -> checkout ( '-f' , $ branch ) ; } catch ( GitException $ exception ) { $ this -> output -> writeln ( "Fetch failed, creating new branch instead" , OutputInterface :: VERBOSITY_VERBOSE ) ; $ workingCopy -> checkout ( '--orphan' , $ branch ) -> run ( [ 'commit' , '--allow-empty' , '-m' , "Branch created by steak" ] ) -> push ( '-u' , 'origin' , $ branch ) ; } return $ workingCopy -> clearOutput ( ) ; }
|
Set up the git repository for our build .
|
6,503
|
protected function rebuild ( ) { $ command = $ this -> getApplication ( ) -> find ( 'build' ) ; $ input = new ArrayInput ( [ '--no-clean' => true , ] ) ; return $ command -> run ( $ input , $ this -> output ) === 0 ; }
|
Delegate to the build command to rebuild the site .
|
6,504
|
protected function deployWithGit ( GitWorkingCopy $ workingCopy ) { if ( ! $ workingCopy -> hasChanges ( ) ) { return $ this -> output -> writeln ( '<comment>No changes to deploy!</comment>' ) ; } $ this -> output -> writeln ( '<info>Ready to deploy changes:</info>' ) ; $ this -> output -> write ( $ workingCopy -> getStatus ( ) ) ; if ( ! $ this -> input -> getOption ( 'force' ) ) { if ( ! $ this -> askForChangesConfirmation ( $ workingCopy ) ) { return $ this -> output -> writeln ( '<error>Aborted!</error>' ) ; } } $ this -> output -> writeln ( '<info>Deploying...</info>' ) ; $ this -> output -> write ( $ workingCopy -> add ( '.' ) -> commit ( $ this -> getCommitMessage ( ) ) -> push ( ) -> getOutput ( ) , OutputInterface :: VERBOSITY_VERBOSE ) ; }
|
Deploy the current contents of our working copy .
|
6,505
|
protected function askForChangesConfirmation ( GitWorkingCopy $ workingCopy ) { $ deployTo = "{$this->container['config']['deploy.git.url']}#{$this->container['config']['deploy.git.branch']}" ; $ confirm = new ConfirmationQuestion ( "<comment>Commit all and push to <path>{$deployTo}</path>?</comment> [Yn] " ) ; return $ this -> getHelper ( 'question' ) -> ask ( $ this -> input , $ this -> output , $ confirm ) ; }
|
Ask user to confirm changes listed by git status .
|
6,506
|
private function hasSession ( ) { if ( DI :: getDefault ( ) -> has ( 'session' ) === true ) { $ this -> session = DI :: getDefault ( ) -> getSession ( ) ; if ( $ this -> session -> getId ( ) === '' ) { $ this -> session -> start ( ) ; } return true ; } return false ; }
|
Check if \ Phalcon \ Di has session service
|
6,507
|
public function render ( array $ params = [ ] ) { return trim ( String :: insert ( $ this -> getStatement ( ) , $ params + $ this -> getParams ( ) , [ 'escape' => false ] ) ) . ';' ; }
|
Render the statement by injecting custom parameters . Merge with the default parameters to fill in any missing keys .
|
6,508
|
private function setFallbackValues ( ) { $ hash = md5 ( null ) ; $ this -> currentPage [ $ hash ] = 0 ; $ this -> itemsPerPage [ $ hash ] = 10 ; $ this -> maxPagerItems [ $ hash ] = 3 ; $ this -> totalItems [ $ hash ] = 0 ; }
|
Sets default values
|
6,509
|
public function getTotalItems ( $ id = null ) { $ hash = md5 ( $ id ) ; return isset ( $ this -> totalItems [ $ hash ] ) ? $ this -> totalItems [ $ hash ] : 0 ; }
|
Get the total items in the non - paginated version of the query
|
6,510
|
public function getLastPage ( $ id = null ) { $ totalItems = ( $ this -> getTotalItems ( $ id ) > 0 ) ? $ this -> getTotalItems ( $ id ) : 1 ; return ( int ) ceil ( $ totalItems / $ this -> getItemsPerPage ( $ id ) ) ; }
|
Gets the last page number
|
6,511
|
public static function default_data_provider ( ) { return array ( 'last_active' => time ( ) , 'current_lang' => \ CCLang :: current ( ) , 'client_agent' => \ CCServer :: client ( 'agent' ) , 'client_ip' => \ CCServer :: client ( 'ip' ) , 'client_port' => \ CCServer :: client ( 'port' ) , 'client_lang' => \ CCServer :: client ( 'language' ) , ) ; }
|
Some default values for our session
|
6,512
|
public function valid_fingerprint ( $ fingerprint = null ) { if ( is_null ( $ fingerprint ) ) { $ fingerprint = \ CCIn :: get ( \ ClanCats :: $ config -> get ( 'session.default_fingerprint_parameter' ) , false ) ; } return $ this -> fingerprint === $ fingerprint ; }
|
Does the current session fingerprint match a parameter
|
6,513
|
public function once ( $ key , $ default = null ) { $ value = \ CCArr :: get ( $ key , $ this -> _data , $ default ) ; \ CCArr :: delete ( $ key , $ this -> _data ) ; return $ value ; }
|
Get a value from data and remove it afterwards
|
6,514
|
public function read ( ) { if ( $ this -> id ) { if ( ! $ this -> _data = $ this -> _driver -> read ( $ this -> id ) ) { $ this -> regenerate ( ) ; $ this -> _data = array ( ) ; } if ( ! is_array ( $ this -> _data ) ) { $ this -> _data = array ( ) ; } $ this -> _data = array_merge ( $ this -> _data , $ this -> default_data ( ) ) ; } else { $ this -> regenerate ( ) ; $ this -> _data = $ this -> default_data ( ) ; } }
|
Read data from the session driver . This overwrite s any changes made on runtime .
|
6,515
|
public function write ( ) { $ this -> _driver -> write ( $ this -> id , $ this -> _data ) ; \ CCCookie :: set ( $ this -> cookie_name ( ) , $ this -> id , \ CCArr :: get ( 'lifetime' , $ this -> _config , \ CCDate :: minutes ( 5 ) ) ) ; }
|
Write the session to the driver
|
6,516
|
public function regenerate ( ) { do { $ id = \ CCStr :: random ( 32 ) ; } while ( $ this -> _driver -> has ( $ id ) ) ; $ this -> fingerprint = sha1 ( $ id ) ; return $ this -> id = $ id ; }
|
Generate a new session id and checks the dirver for dublicates .
|
6,517
|
public function gc ( ) { $ lifetime = \ CCArr :: get ( 'lifetime' , $ this -> _config , \ CCDate :: minutes ( 5 ) ) ; if ( $ lifetime < ( $ min_lifetime = \ CCArr :: get ( 'min_lifetime' , $ this -> _config , \ CCDate :: minutes ( 5 ) ) ) ) { $ lifetime = $ min_lifetime ; } $ this -> _driver -> gc ( $ lifetime ) ; }
|
Garbage collection delete all outdated sessions
|
6,518
|
public function generate ( ) { $ this -> printMessage ( '' ) ; $ this -> printMessage ( 'Creating Collection config' ) ; Files :: saveCollectionConfig ( ( new ConfigGenerator ( $ this -> config ) ) -> create ( ) ) ; $ this -> printMessage ( 'Creating Models, Controllers, Requests, Responses, and Exceptions' ) ; foreach ( $ this -> config -> versions as $ version => $ api ) { $ requests = [ ] ; $ this -> printMessage ( $ version . '...' ) ; foreach ( $ api as $ entityName => $ entity ) { $ entity = $ this -> vaidateEntityConfig ( $ entityName , $ entity ) ; Files :: initializeFolders ( $ version , $ entityName ) ; if ( isset ( $ entity -> model ) ) { $ columns = $ entity -> model -> columns ; Files :: saveModel ( new ModelGenerator ( $ version , $ entityName , $ columns ) ) ; foreach ( $ entity -> requests as $ requestMethod => $ actions ) { foreach ( $ actions as $ actionName => $ action ) { if ( empty ( $ action ) ) { continue ; } $ requests [ ] = Files :: saveRequest ( new RequestGenerator ( $ version , $ entityName , $ entity -> model , $ requestMethod , $ actionName , $ action ) ) ; } } Files :: saveResponse ( new ResponseGenerator ( $ version , $ entityName , $ columns ) ) ; } $ exceptions = $ this -> getExceptionsFromEntityConfig ( $ entity ) ; foreach ( $ exceptions as $ exception ) { Files :: saveException ( new ExceptionGenerator ( $ version , $ entityName , $ exception ) ) ; } Files :: saveController ( new ControllerGenerator ( $ version , $ entityName , $ entity ) ) ; } Files :: saveSDK ( new SDKGenerator ( $ version , $ this -> config -> name , $ requests ) ) ; } $ this -> printMessage ( "All done, Remember to add the files to VCS!" ) ; }
|
Generate the SDK
|
6,519
|
public function create ( TicketObject $ ticket ) { $ response = $ this -> client -> post ( 'tickets' , array ( 'ticket' => $ ticket ) ) ; return new TicketObject ( $ response ) ; }
|
Creates a ticket
|
6,520
|
public function update ( TicketObject $ ticket ) { return new TicketObject ( $ this -> client -> post ( 'tickets/' . $ ticket -> guid , array ( "ticket" => $ ticket ) ) ) ; }
|
Updates the ticket
|
6,521
|
public function check ( $ eventId , $ barcode , $ terminalId = null , Location $ location = null ) { return new TicketCheckIn ( $ this -> client -> post ( 'check' , [ 'event' => $ eventId , 'barcode' => $ barcode , 'terminalId' => $ terminalId , 'location' => $ location ] ) ) ; }
|
Check a ticket barcode for an event .
|
6,522
|
public function localPathAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ form = $ this -> createForm ( new ChoiceLocalPath ( ) , [ 'path' => $ request -> get ( 'path' ) ? : '' ] ) ; return $ this -> render ( 'AnimeDbAppBundle:Form:local_path.html.twig' , [ 'form' => $ form -> createView ( ) , ] , $ response ) ; }
|
Form field local path .
|
6,523
|
public function localPathFoldersAction ( Request $ request ) { $ form = $ this -> createForm ( new ChoiceLocalPath ( ) ) ; $ form -> handleRequest ( $ request ) ; $ path = $ form -> get ( 'path' ) -> getData ( ) ? : Filesystem :: getUserHomeDir ( ) ; if ( ( $ root = $ request -> get ( 'root' ) ) && strpos ( $ path , $ root ) !== 0 ) { $ path = $ root ; } $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( [ ( new \ DateTime ( ) ) -> setTimestamp ( filemtime ( $ path ) ) ] , - 1 , new JsonResponse ( ) ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } return $ response -> setData ( [ 'path' => $ path , 'folders' => Filesystem :: scandir ( $ path , Filesystem :: DIRECTORY ) , ] ) ; }
|
Return list folders for path .
|
6,524
|
public function imageAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } return $ this -> render ( 'AnimeDbAppBundle:Form:image.html.twig' , [ 'form' => $ this -> createForm ( new UploadImage ( ) ) -> createView ( ) , 'change' => ( bool ) $ request -> get ( 'change' , false ) , ] , $ response ) ; }
|
Form field image .
|
6,525
|
public static function parse ( $ lang ) { $ conf = ClanCats :: $ config -> language ; if ( isset ( $ lang ) && strlen ( $ lang ) > 1 ) { $ lang = explode ( ',' , strtolower ( $ lang ) ) ; $ lang = explode ( '-' , $ lang [ 0 ] ) ; if ( ! isset ( $ lang [ 1 ] ) ) { $ lang [ 1 ] = $ lang [ 0 ] ; } $ available = $ conf [ 'available' ] ; if ( array_key_exists ( $ lang [ 0 ] , $ available ) ) { if ( in_array ( $ lang [ 1 ] , $ available [ $ lang [ 0 ] ] ) ) { return $ lang [ 0 ] . '-' . $ lang [ 1 ] ; } else { $ locales = $ available [ $ lang [ 0 ] ] ; return $ lang [ 0 ] . '-' . $ locales [ key ( $ locales ) ] ; } } } return $ conf [ 'default' ] ; }
|
Match an language code with the aviable languages
|
6,526
|
public static function load ( $ path , $ overwrite = false ) { if ( array_key_exists ( $ path , static :: $ data [ static :: $ current_language ] ) && $ overwrite === false ) { return ; } $ file_path = CCPath :: get ( $ path , CCDIR_LANGUAGE . static :: $ current_language . '/' , EXT ) ; if ( ! file_exists ( $ file_path ) ) { if ( static :: $ current_language !== ( $ default_lang = ClanCats :: $ config -> get ( 'language.default' ) ) ) { $ file_path = CCPath :: get ( $ path , CCDIR_LANGUAGE . $ default_lang . '/' , EXT ) ; if ( ! file_exists ( $ file_path ) ) { throw new CCException ( "CCLang::load - could not find language file: " . $ file_path ) ; } } else { throw new CCException ( "CCLang::load - could not find language file: " . $ file_path ) ; } } static :: $ data [ static :: $ current_language ] [ $ path ] = require ( $ file_path ) ; }
|
Load a language file into the appliaction
|
6,527
|
public static function line ( $ key , $ params = array ( ) ) { $ path = substr ( $ key , 0 , strpos ( $ key , '.' ) ) ; $ key = substr ( $ key , strpos ( $ key , '.' ) + 1 ) ; if ( isset ( static :: $ aliases [ $ path ] ) ) { return static :: line ( static :: $ aliases [ $ path ] . '.' . $ key , $ params ) ; } if ( ! isset ( static :: $ data [ static :: $ current_language ] [ $ path ] ) ) { CCLang :: load ( $ path ) ; } if ( ! isset ( static :: $ data [ static :: $ current_language ] [ $ path ] [ $ key ] ) ) { CCLog :: add ( 'CCLang::line - No such line "' . $ key . '" (' . static :: $ current_language . ') in file: ' . $ path , 'warning' ) ; return $ key ; } $ line = static :: $ data [ static :: $ current_language ] [ $ path ] [ $ key ] ; foreach ( $ params as $ param => $ value ) { $ line = str_replace ( ':' . $ param , $ value , $ line ) ; } return $ line ; }
|
Recive a translated line
|
6,528
|
public function addCoverageValidatorPoolForCover ( $ coverToken ) { $ this -> addValidator ( new ValidatorClassNameMethodName ( $ coverToken ) ) ; $ this -> addValidator ( new ValidatorMethodName ( $ coverToken ) ) ; $ this -> addValidator ( new ValidatorClassName ( $ coverToken ) ) ; $ this -> addValidator ( new ValidatorClassNameMethodAccess ( $ coverToken ) ) ; }
|
init all available cover validator classes use incoming coverToken as parameter
|
6,529
|
public function analysePHPUnitFiles ( ) { $ testFiles = $ this -> scanFilesInPath ( $ this -> testSourcePath ) ; foreach ( $ testFiles as $ file ) { $ this -> analyseClassesInFile ( $ file ) ; } return $ this -> coverFishOutput -> writeResult ( $ this -> coverFishResult ) ; }
|
scan all unit - test files inside specific path
|
6,530
|
public function analyseCoverAnnotations ( $ phpDocBlock , CoverFishPHPUnitTest $ phpUnitTest ) { $ this -> validatorCollection -> clear ( ) ; $ phpUnitTest -> clearCoverMappings ( ) ; $ phpUnitTest -> clearCoverAnnotation ( ) ; foreach ( $ phpDocBlock [ 'covers' ] as $ cover ) { $ phpUnitTest -> addCoverAnnotation ( $ cover ) ; $ this -> addCoverageValidatorPoolForCover ( $ cover ) ; } $ phpUnitTest = $ this -> validateAndReturnMapping ( $ phpUnitTest ) ; $ this -> phpUnitFile -> addTest ( $ phpUnitTest ) ; }
|
scan all annotations inside one single unit test file
|
6,531
|
public function analyseClassesInFile ( $ file ) { $ ts = new PHP_Token_Stream ( $ file ) ; $ this -> phpUnitFile = new CoverFishPHPUnitFile ( ) ; foreach ( $ ts -> getClasses ( ) as $ className => $ classData ) { $ fqnClass = sprintf ( '%s\\%s' , $ this -> coverFishHelper -> getAttributeByKey ( 'namespace' , $ classData [ 'package' ] ) , $ className ) ; if ( false === $ this -> coverFishHelper -> isValidTestClass ( $ fqnClass ) ) { continue ; } $ classData [ 'className' ] = $ className ; $ classData [ 'classFile' ] = $ file ; $ this -> analyseClass ( $ classData ) ; } }
|
scan all classes inside one defined unit test file
|
6,532
|
public function setKeyCode ( $ keyCode ) { $ this -> keyCode = ( int ) $ keyCode ; $ this -> keyName = null ; return $ this ; }
|
Set the key code
|
6,533
|
protected function getOnInitScriptText ( ) { $ scriptText = null ; if ( $ this -> control ) { $ controlId = Builder :: escapeText ( $ this -> control -> getId ( ) ) ; $ scriptText = "declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});" ; } else { $ scriptText = "declare ToggleInterfaceControl <=> Page.MainFrame;" ; } $ stateVariableName = $ this :: VAR_STATE ; return $ scriptText . "declare persistent {$stateVariableName} as CurrentState for LocalUser = True;ToggleInterfaceControl.Visible = CurrentState;" ; }
|
Get the on init script text
|
6,534
|
protected function getKeyPressScriptText ( ) { $ scriptText = null ; $ keyProperty = null ; $ keyValue = null ; if ( $ this -> keyName ) { $ keyProperty = "KeyName" ; $ keyValue = Builder :: getText ( $ this -> keyName ) ; } else if ( $ this -> keyCode ) { $ keyProperty = "KeyCode" ; $ keyValue = Builder :: getInteger ( $ this -> keyCode ) ; } $ scriptText = "if (Event.{$keyProperty} == {$keyValue}) {" ; if ( $ this -> control ) { $ controlId = Builder :: escapeText ( $ this -> control -> getId ( ) ) ; $ scriptText .= " declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});" ; } else { $ scriptText .= " declare ToggleInterfaceControl <=> Page.MainFrame;" ; } $ scriptText .= " ToggleInterfaceControl.Visible = !ToggleInterfaceControl.Visible;" ; if ( $ this -> rememberState ) { $ stateVariableName = static :: VAR_STATE ; $ scriptText .= " declare persistent {$stateVariableName} as CurrentState for LocalUser = True; CurrentState = ToggleInterfaceControl.Visible;" ; } return $ scriptText . "}" ; }
|
Get the key press script text
|
6,535
|
public static function clear ( $ event , $ what = null ) { if ( is_null ( $ what ) ) { unset ( static :: $ events [ $ event ] ) ; return ; } if ( array_key_exists ( $ what , static :: $ events [ $ event ] [ $ what ] ) ) { unset ( static :: $ events [ $ event ] [ $ what ] ) ; } }
|
clear an event
|
6,536
|
public static function ready ( $ event , $ params = array ( ) ) { $ responses = static :: fire ( $ event , $ params ) ; foreach ( static :: pack ( $ responses ) as $ response ) { if ( $ response !== true ) { return false ; } } return true ; }
|
also fires an event but returns a bool positiv only if all responses where positiv like all system ready YESS!
|
6,537
|
public static function fire ( $ event , $ params = array ( ) ) { if ( ! array_key_exists ( $ event , static :: $ events ) ) { return ; } $ event = static :: $ events [ $ event ] ; $ return = array ( ) ; if ( array_key_exists ( 'before' , $ event ) ) { $ return [ 'before' ] = static :: call ( $ event [ 'before' ] , $ params ) ; } if ( array_key_exists ( 'callbacks' , $ event ) ) { $ return [ 'main' ] = static :: call ( $ event [ 'callbacks' ] , $ params ) ; } if ( array_key_exists ( 'after' , $ event ) ) { $ return [ 'after' ] = static :: call ( $ event [ 'after' ] , $ params ) ; } return static :: pack ( $ return ) ; }
|
fire an event
|
6,538
|
public static function pass ( $ event , $ param = null ) { if ( ! array_key_exists ( $ event , static :: $ events ) ) { return $ param ; } $ event = static :: $ events [ $ event ] ; if ( array_key_exists ( 'before' , $ event ) ) { $ param = static :: call ( $ event [ 'before' ] , $ param , true ) ; } if ( array_key_exists ( 'callbacks' , $ event ) ) { $ param = static :: call ( $ event [ 'callbacks' ] , $ param , true ) ; } if ( array_key_exists ( 'after' , $ event ) ) { $ param = static :: call ( $ event [ 'after' ] , $ param , true ) ; } return $ param ; }
|
pass an var to an event the diffrence to fire is that the param gets modified by each event
|
6,539
|
protected static function call ( $ callbacks , $ params , $ pass = false ) { $ response = array ( ) ; if ( $ pass ) { $ response = $ params ; } foreach ( $ callbacks as $ callback ) { if ( $ pass ) { $ response = call_user_func_array ( $ callback , array ( $ response ) ) ; } else { $ response [ ] = call_user_func_array ( $ callback , $ params ) ; } } return $ response ; }
|
call an callback array
|
6,540
|
protected static function pack ( $ responses ) { return array_merge ( CCArr :: get ( 'before' , $ responses , array ( ) ) , CCArr :: get ( 'main' , $ responses , array ( ) ) , CCArr :: get ( 'after' , $ responses , array ( ) ) ) ; }
|
packs all responses into one array
|
6,541
|
public function preSave ( Event $ event , Query $ query , $ id , array & $ data ) { $ data [ $ this -> getConfig ( $ query -> getType ( ) === Query :: UPDATE ? 'updateField' : 'createField' ) ] = time ( ) ; return true ; }
|
Append the current timestamp to the data .
|
6,542
|
public function getSQLFilter ( $ radius , $ scale = 'km' ) { GeoFunctions :: $ Latitude = $ this -> name . 'Latitude' ; GeoFunctions :: $ Longditude = $ this -> name . 'Longditude' ; return GeoFunctions :: getSQLSquare ( $ this -> getLatitude ( ) , $ this -> getLongditude ( ) , $ radius , $ scale ) ; }
|
return a SQL Bounce for WHERE Clause
|
6,543
|
public function getDistanceFromLocation ( Location $ location , $ scale = 'km' ) { return GeoFunctions :: getDistance ( $ this -> getLatitude ( ) , $ this -> getLongditude ( ) , $ location -> getLatitude ( ) , $ location -> getLongditude ( ) , $ scale ) ; }
|
return the Distance to the given location
|
6,544
|
public static function is_callable ( $ key ) { if ( is_callable ( $ key ) ) { return true ; } if ( array_key_exists ( $ key , static :: $ _container ) ) { return true ; } return false ; }
|
Is this callable
|
6,545
|
public static function call ( ) { $ arguments = func_get_args ( ) ; $ key = array_shift ( $ arguments ) ; if ( is_string ( $ key ) && array_key_exists ( $ key , static :: $ _container ) && is_callable ( static :: $ _container [ $ key ] ) ) { return call_user_func_array ( static :: $ _container [ $ key ] , $ arguments ) ; } if ( ! is_callable ( $ key ) ) { throw new CCException ( "CCContainer::call - Cannot call '" . $ key . "' invalid callback." ) ; } return call_user_func_array ( $ key , $ arguments ) ; }
|
call a container
|
6,546
|
protected function buildGraph ( & $ graph , $ distanceComputeCallback , array $ objects ) { $ graph = new Helpers \ Graph ( ) ; while ( $ object = array_shift ( $ objects ) ) { $ graph -> addNode ( $ object , $ this -> computeDistances ( $ object , $ objects , $ distanceComputeCallback ) ) ; } }
|
Create a graph where each ready player is a node
|
6,547
|
private function computeDistances ( $ object , $ followers , $ distanceComputeCallback ) { $ distances = array ( ) ; foreach ( $ followers as $ follower ) { if ( $ follower == $ object ) continue ; $ distances [ $ follower -> id ] = call_user_func ( $ distanceComputeCallback , $ object -> data , $ follower -> data ) ; } return $ distances ; }
|
Compute distance for a player with all his followers
|
6,548
|
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ next ) : ResponseInterface { $ path = $ request -> getUri ( ) -> getPath ( ) ; if ( ! empty ( $ this -> basePath ) && 0 === strpos ( $ path , $ this -> basePath ) ) { $ cleanPath = substr ( $ path , strlen ( $ this -> basePath ) ) ; if ( $ cleanPath === false ) { $ cleanPath = '' ; } $ request = $ request -> withUri ( $ request -> getUri ( ) -> withPath ( $ cleanPath ) ) ; } return $ next -> handle ( $ request ) ; }
|
strip away the basePath
|
6,549
|
public function setCache ( $ file ) { if ( ! empty ( $ file ) ) { $ this -> cache = new AccessTokenCache ( $ file ) ; $ this -> setAccessToken ( $ this -> cache -> get ( ) ) ; } }
|
sets the cache file when possible
|
6,550
|
public function send ( $ messageText , callable $ callable = null ) { $ message = new Message ( $ messageText ) ; $ response = $ this -> connection -> sendMessage ( $ message ) -> getBody ( ) ; if ( $ callable ) { $ response = call_user_func ( $ callable , $ response ) ; } return $ response ; }
|
Send text to the server .
|
6,551
|
public function send ( Request $ request , $ async = false ) : \ Psr \ Http \ Message \ StreamInterface { $ this -> currentUri = $ request -> fullUrl ( ) ; $ options = [ ] ; if ( $ request -> method ( ) === 'POST' || $ request -> method ( ) === 'PUT' ) { $ options [ 'json' ] = $ request -> request -> all ( ) ; } $ client = new Client ( ) ; $ requestType = $ async ? 'requestAsync' : 'request' ; $ response = $ client -> { $ requestType } ( $ request -> method ( ) , $ this -> currentUri , $ options ) ; return $ response -> getBody ( ) ; }
|
Send the given request through the application . This method allows you to fully customize the entire Request object .
|
6,552
|
public function delete ( $ key ) { try { $ this -> get ( $ key ) ; } catch ( KeyNotFoundException $ e ) { return false ; } unset ( $ this -> store [ $ key ] ) ; return true ; }
|
Removes a key .
|
6,553
|
public function setPassword ( $ p1 , $ p2 = null , $ login = false ) { $ this -> password = $ this -> integration -> setPassword ( $ p1 , $ p2 , $ login , $ this ) ; return $ this ; }
|
Set the password if the passwords match .
|
6,554
|
public static function checkDomain ( $ domain_name ) { if ( $ domain_name [ 0 ] == '.' ) $ domain_name = substr ( $ domain_name , 1 ) ; return ( preg_match ( "/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i" , $ domain_name ) && preg_match ( "/^.{1,253}$/" , $ domain_name ) && preg_match ( "/^[^\.]{1,63}(\.[^\.]{1,63})*$/" , $ domain_name ) ) ; }
|
Check if domain is valid
|
6,555
|
protected function buildStructuredHeaders ( ) : void { $ this -> structuredHeaders = array ( ) ; $ headers = $ this -> entry [ PoTokens :: TRANSLATED ] ; $ headers = ( $ headers === null ) ? array ( ) : $ headers ; $ full = implode ( '' , $ headers ) ; $ headers = explode ( "\n" , $ full ) ; $ pattern = '/([a-z0-9\-]+):\s*(.*)/i' ; foreach ( $ headers as $ h ) { if ( preg_match ( $ pattern , trim ( $ h ) , $ matches ) ) { $ this -> structuredHeaders [ strtolower ( $ matches [ 1 ] ) ] = array ( 'key' => $ matches [ 1 ] , 'value' => $ matches [ 2 ] , ) ; } } }
|
Populate the internal structuredHeaders property with contents of this entry s msgstr value .
|
6,556
|
protected function storeStructuredHeader ( ) : bool { if ( is_null ( $ this -> structuredHeaders ) ) { return false ; } $ headers = array ( "" ) ; foreach ( $ this -> structuredHeaders as $ h ) { $ headers [ ] = $ h [ 'key' ] . ': ' . $ h [ 'value' ] . "\n" ; } $ this -> entry [ PoTokens :: TRANSLATED ] = $ headers ; return true ; }
|
Rebuild the this entry s msgstr value using contents of the internal structuredHeaders property .
|
6,557
|
public function getHeader ( string $ key ) : ? string { $ this -> buildStructuredHeaders ( ) ; $ lkey = strtolower ( $ key ) ; $ header = null ; if ( isset ( $ this -> structuredHeaders [ $ lkey ] [ 'value' ] ) ) { $ header = $ this -> structuredHeaders [ $ lkey ] [ 'value' ] ; } return $ header ; }
|
Get a header value string by key
|
6,558
|
public function setHeader ( string $ key , string $ value ) : void { $ this -> buildStructuredHeaders ( ) ; $ lkey = strtolower ( $ key ) ; if ( isset ( $ this -> structuredHeaders [ $ lkey ] ) ) { $ this -> structuredHeaders [ $ lkey ] [ 'value' ] = $ value ; } else { $ newHeader = array ( 'key' => $ key , 'value' => $ value ) ; $ this -> structuredHeaders [ $ lkey ] = $ newHeader ; } $ this -> storeStructuredHeader ( ) ; }
|
Set the value of a header string for a key .
|
6,559
|
public function setCreateDate ( ? int $ time = null ) : void { $ this -> setHeader ( 'POT-Creation-Date' , $ this -> formatTimestamp ( $ time ) ) ; }
|
Set the POT - Creation - Date header
|
6,560
|
public function setRevisionDate ( ? int $ time = null ) : void { $ this -> setHeader ( 'PO-Revision-Date' , $ this -> formatTimestamp ( $ time ) ) ; }
|
Set the PO - Revision - Date header
|
6,561
|
protected function formatTimestamp ( ? int $ time = null ) : string { if ( empty ( $ time ) ) { $ time = time ( ) ; } return gmdate ( 'Y-m-d H:iO' , $ time ) ; }
|
Format a timestamp following PO file conventions
|
6,562
|
public function buildDefaultHeader ( ) : void { $ this -> set ( PoTokens :: MESSAGE , "" ) ; $ this -> set ( PoTokens :: TRANSLATOR_COMMENTS , 'SOME DESCRIPTIVE TITLE' ) ; $ this -> add ( PoTokens :: TRANSLATOR_COMMENTS , 'Copyright (C) YEAR HOLDER' ) ; $ this -> add ( PoTokens :: TRANSLATOR_COMMENTS , 'LICENSE' ) ; $ this -> add ( PoTokens :: TRANSLATOR_COMMENTS , 'FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.' ) ; $ this -> add ( PoTokens :: TRANSLATOR_COMMENTS , '' ) ; $ this -> set ( PoTokens :: FLAG , 'fuzzy' ) ; $ this -> setHeader ( 'Project-Id-Version' , 'PACKAGE VERSION' ) ; $ this -> setHeader ( 'Report-Msgid-Bugs-To' , 'FULL NAME <EMAIL@ADDRESS>' ) ; $ this -> setCreateDate ( ) ; $ this -> setHeader ( 'PO-Revision-Date' , 'YEAR-MO-DA HO:MI+ZONE' ) ; $ this -> setHeader ( 'Last-Translator' , 'FULL NAME <EMAIL@ADDRESS>' ) ; $ this -> setHeader ( 'Language-Team' , 'LANGUAGE <EMAIL@ADDRESS>' ) ; $ this -> setHeader ( 'MIME-Version' , '1.0' ) ; $ this -> setHeader ( 'Content-Type' , 'text/plain; charset=UTF-8' ) ; $ this -> setHeader ( 'Content-Transfer-Encoding' , '8bit' ) ; $ this -> setHeader ( 'Plural-Forms' , 'nplurals=INTEGER; plural=EXPRESSION;' ) ; $ this -> setHeader ( 'X-Generator' , 'geekwright/po' ) ; }
|
Create a default header entry
|
6,563
|
public static function callObjectMethod ( $ object , $ name , Array $ args = NULL ) { $ args = ( array ) $ args ; switch ( count ( $ args ) ) { case 0 : return $ object -> $ name ( ) ; case 1 : return $ object -> $ name ( $ args [ 0 ] ) ; case 2 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] ) ; case 3 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] ) ; case 4 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] , $ args [ 3 ] ) ; case 5 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] , $ args [ 3 ] , $ args [ 4 ] ) ; case 6 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] , $ args [ 3 ] , $ args [ 4 ] , $ args [ 5 ] ) ; case 7 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] , $ args [ 3 ] , $ args [ 4 ] , $ args [ 5 ] , $ args [ 6 ] ) ; case 8 : return $ object -> $ name ( $ args [ 0 ] , $ args [ 1 ] , $ args [ 2 ] , $ args [ 3 ] , $ args [ 4 ] , $ args [ 5 ] , $ args [ 6 ] , $ args [ 7 ] ) ; default : return call_user_func_array ( array ( $ object , $ name ) , $ args ) ; } }
|
Ruft eine Methode auf einem Objekt auf
|
6,564
|
public function confirmationValidate ( $ attribute ) { if ( ! $ this -> hasErrors ( ) ) { if ( $ this -> user !== null ) { $ confirmationRequired = Yii :: $ app -> settings -> get ( 'enableConfirmation' , 'user' ) && ! Yii :: $ app -> settings -> get ( 'enableUnconfirmedLogin' , 'user' ) ; if ( $ confirmationRequired && ! $ this -> user -> isEmailConfirmed ) { $ this -> addError ( $ attribute , Yii :: t ( 'yuncms' , 'You need to confirm your email address.' ) ) ; } if ( $ this -> user -> isBlocked ) { $ this -> addError ( $ attribute , Yii :: t ( 'yuncms' , 'Your account has been blocked.' ) ) ; } } } }
|
Validates the confirmation . This method serves as the inline validation for password .
|
6,565
|
public function setUserAction ( $ link , $ label = null ) { if ( $ label ) { $ this -> userAction = [ 'link' => $ link , 'label' => $ label , ] ; } else { $ this -> userAction = $ link ; } }
|
set a user facing link as continue action
|
6,566
|
public static function clean_paths ( $ string ) { $ string = str_replace ( ROOT_DIR , '' , $ string ) ; $ string = str_replace ( '.php' , '' , $ string ) ; return $ string ; }
|
cleans file paths from redundant information i . e . ROOT_DIR and . php is removed
|
6,567
|
protected function _compile_regex ( $ route ) { $ pattern = '`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`' ; if ( preg_match_all ( $ pattern , $ route , $ matches , PREG_SET_ORDER ) ) { $ match_types = array ( 'i' => '[0-9]++' , 'a' => '[0-9A-Za-z]++' , 'h' => '[0-9A-Fa-f]++' , '*' => '.+?' , '' => '[^/]++' ) ; foreach ( $ matches as $ match ) { list ( $ block , $ pre , $ type , $ param , $ optional ) = $ match ; if ( isset ( $ match_types [ $ type ] ) ) { $ type = $ match_types [ $ type ] ; } if ( $ param ) { $ param = "?<{$param}>" ; } if ( $ optional ) { $ optional = '?' ; } $ replaced = "(?:{$pre}({$param}{$type})){$optional}" ; $ route = str_replace ( $ block , $ replaced , $ route ) ; } } if ( substr ( $ route , strlen ( $ route ) - 1 ) != '/' ) { $ route .= '/?' ; } return "`^{$route}$`" ; }
|
Compiles the regex necessary to capture all match types within a route .
|
6,568
|
private function validate ( $ name ) { if ( ! is_string ( $ name ) ) { throw new InvalidNameException ( 'Migration name must be a string, got ' . gettype ( $ name ) ) ; } if ( strlen ( $ name ) === 0 ) { throw new InvalidNameException ( 'Migration name must not be empty' ) ; } $ validCharsRegex = '/^[' . self :: NAME_VALID_CHARS_REGEX . ']+$/' ; if ( preg_match ( $ validCharsRegex , $ name ) === 0 ) { $ invalidChars = preg_replace ( '/[' . self :: NAME_VALID_CHARS_REGEX . ']/' , '' , $ name ) ; throw new InvalidNameException ( 'Migration name contains invalid characters: ' . $ invalidChars ) ; } if ( strlen ( $ name ) > self :: MAX_NAME_LENGTH ) { throw new InvalidNameException ( sprintf ( 'Migration name cannot exceed %d characters, is %d: %s' , self :: MAX_NAME_LENGTH , strlen ( $ name ) , $ name ) ) ; } }
|
Ensure the migration name is acceptable .
|
6,569
|
protected function setupContainer ( ) { $ container = Registry :: init ( ) ; $ container -> add ( 'app' , $ this ) ; $ container -> add ( 'registry' , $ container ) ; $ container -> add ( 'config' , function ( ) { return new Config ( $ this -> getConfigPath ( ) , 'prod' ) ; } ) ; $ this -> config = $ container -> make ( 'config' ) ; $ container -> add ( 'routes' , function ( ) { return new Collection ( ) ; } ) ; $ this -> container = $ container ; }
|
Registers container and some classes
|
6,570
|
protected function configure ( ) { $ config = $ this -> config -> get ( 'app' ) ; $ this -> charset = $ config [ 'charset' ] ; mb_internal_encoding ( $ this -> charset ) ; date_default_timezone_set ( $ config [ 'timezone' ] ) ; }
|
Sets up basic application configurations
|
6,571
|
protected function registerServices ( ) { $ services = array_filter ( $ this -> config -> get ( 'app.services' ) , function ( $ service ) { return class_exists ( $ service ) ; } ) ; foreach ( $ services as $ service ) { $ obj = new $ service ( $ this -> container ) ; $ obj -> services ( ) ; $ this -> services [ ] = $ obj ; } }
|
Registers all defined services
|
6,572
|
public function get ( int $ entityId ) { $ response = $ this -> infakt -> get ( $ this -> getServiceName ( ) . '/' . $ entityId . '.json' ) ; if ( 2 != substr ( ( string ) $ response -> getStatusCode ( ) , 0 , 1 ) ) { return null ; } return $ this -> getMapper ( ) -> map ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) -> getContents ( ) , true ) ) ; }
|
Get entity by ID .
|
6,573
|
protected function getModelClass ( ) : string { $ class = substr ( get_class ( $ this ) , strrpos ( get_class ( $ this ) , '\\' ) + 1 ) ; $ class = substr ( $ class , 0 , strlen ( $ class ) - strlen ( 'Repository' ) ) ; return 'Infakt\\Model\\' . $ class ; }
|
Get fully - qualified class name of a model .
|
6,574
|
protected function getMapperClass ( ) : string { $ class = substr ( get_class ( $ this ) , strrpos ( get_class ( $ this ) , '\\' ) + 1 ) ; $ class = substr ( $ class , 0 , strlen ( $ class ) - strlen ( 'Repository' ) ) ; return 'Infakt\\Mapper\\' . $ class . 'Mapper' ; }
|
Get fully - qualified class name of a mapper .
|
6,575
|
public function withExistingProxy ( HlsProxy $ hlsProxy ) { if ( is_null ( $ this -> proxies ) ) { $ this -> proxies = [ ] ; } array_push ( $ this -> proxies , $ hlsProxy ) ; return $ this ; }
|
Fluent setter for the property proxies
|
6,576
|
public function toArray ( ) { return [ 'message' => $ this -> getMessageException ( ) , 'errors' => $ this -> getErrors ( ) , 'debugCode' => $ this -> getDebugCode ( ) , 'details' => $ this -> getDetails ( ) , 'routeBack' => redirect ( ) -> back ( ) -> getTargetUrl ( ) ] ; }
|
convierte el Objeto en un array
|
6,577
|
public function fetchToken ( Request $ request ) { foreach ( $ this -> config -> getOperators ( ) as $ name ) { $ operator = $ this -> getOperator ( $ name ) ; if ( $ operator -> hasToken ( $ request ) ) { return $ operator -> fetchToken ( $ request ) ; } } return null ; }
|
Fetch authorization token from request if any .
|
6,578
|
public function isMigrationApplied ( Name $ name ) { $ this -> ensureMigrationExists ( $ name ) ; $ collection = $ this -> getAppliedCollection ( ) ; $ criteria = [ 'className' => ( string ) $ name ] ; $ record = $ collection -> find ( $ criteria ) -> getSingleResult ( ) ; if ( $ record === null ) { return false ; } else { return ( bool ) $ record [ 'isApplied' ] ; } }
|
Check if a migration has been applied .
|
6,579
|
public function migrate ( Name $ name , Direction $ direction , OutputInterface $ output ) { $ migration = $ this -> createMigrationInstance ( $ name , $ output ) ; $ output -> writeln ( '<info>Migrating ' . $ direction . '...</info> <comment>' . $ name . '</comment>' ) ; if ( $ direction -> isUp ( ) ) { $ migration -> up ( $ this -> getDatabase ( ) ) ; $ this -> setMigrationApplied ( $ name , true ) ; } else { $ migration -> down ( $ this -> getDatabase ( ) ) ; $ this -> setMigrationApplied ( $ name , false ) ; } $ output -> writeln ( '<info>Migrated ' . $ direction . '</info>' ) ; }
|
Migrate up or down .
|
6,580
|
public function getAllMigrations ( ) { $ iterator = new \ DirectoryIterator ( $ this -> configuration -> getMigrationsDirectory ( ) ) ; $ migrations = [ ] ; foreach ( $ iterator as $ file ) { $ fileName = ( string ) $ file ; if ( $ fileName === '.' || $ fileName === '..' ) { continue ; } if ( ! is_dir ( $ file -> getPathname ( ) ) ) { continue ; } $ name = new Name ( $ fileName ) ; $ isApplied = $ this -> isMigrationApplied ( $ name ) ; $ migrations [ ] = new Migration ( $ name , $ isApplied ) ; } usort ( $ migrations , function ( Migration $ a , Migration $ b ) { return strcmp ( $ a -> getName ( ) , $ b -> getName ( ) ) ; } ) ; return $ migrations ; }
|
Get a list of all migrations sorted alphabetically .
|
6,581
|
public function getMigrationsNotApplied ( ) { $ migrationsNotApplied = [ ] ; $ migrations = $ this -> getAllMigrations ( ) ; foreach ( $ migrations as $ migration ) { if ( ! $ migration -> isApplied ( ) ) { $ migrationsNotApplied [ ] = $ migration ; } } return $ migrationsNotApplied ; }
|
Return array with all migrations that were note applied .
|
6,582
|
private function setMigrationApplied ( Name $ name , $ isApplied ) { $ collection = $ this -> getAppliedCollection ( ) ; $ criteria = [ 'className' => ( string ) $ name ] ; $ newObj = [ '$set' => [ 'className' => ( string ) $ name , 'isApplied' => $ isApplied ] ] ; $ collection -> upsert ( $ criteria , $ newObj ) ; }
|
Update the database to record whether or not the migration has been applied .
|
6,583
|
public function getBroadcastFactory ( ) : ? Factory { if ( ! $ this -> hasBroadcastFactory ( ) ) { $ this -> setBroadcastFactory ( $ this -> getDefaultBroadcastFactory ( ) ) ; } return $ this -> broadcastFactory ; }
|
Get broadcast factory
|
6,584
|
public function setItem ( Control $ item ) { $ item -> checkId ( ) ; if ( $ item instanceof Scriptable ) { $ item -> setScriptEvents ( true ) ; } $ this -> item = $ item ; return $ this ; }
|
Set the Item Control
|
6,585
|
public function validateMapping ( CoverFishMapping $ coverMapping ) { $ coverFishResult = new CoverFishResult ( ) ; $ coverFishResult = $ this -> prepareCoverFishResult ( $ coverFishResult ) ; $ coverFishResult = $ this -> validateDefaultCoverClassMapping ( $ coverMapping , $ coverFishResult ) ; $ coverFishResult = $ this -> validateClassFQNMapping ( $ coverMapping , $ coverFishResult ) ; $ coverFishResult = $ this -> validateClassAccessorVisibility ( $ coverMapping , $ coverFishResult ) ; $ coverFishResult = $ this -> validateClassMethod ( $ coverMapping , $ coverFishResult ) ; return $ coverFishResult ; }
|
main validator mapping engine if any of our cover validator checks will fail return corresponding result immediately ...
|
6,586
|
final function createLabel ( $ message , $ login = null , $ countdown = null , $ isAnimated = false , $ hideOnF6 = true , $ showBackgroud = false ) { $ this -> removeLabel ( $ login ) ; $ ui = Windows \ Label :: Create ( $ login ) ; $ ui -> setPosition ( 0 , 40 ) ; $ ui -> setMessage ( $ message , $ countdown ) ; $ ui -> animated = $ isAnimated ; $ ui -> hideOnF6 = $ hideOnF6 ; $ ui -> showBackground = $ showBackgroud ; $ ui -> show ( ) ; }
|
Display a text message in the center of the player s screen If countdown is set the message will be refresh every second the end of the countdown
|
6,587
|
final function updateLobbyWindow ( $ serverName , $ playersCount , $ playingPlayersCount , $ averageTime ) { $ lobbyWindow = Windows \ LobbyWindow :: Create ( ) ; Windows \ LobbyWindow :: setServerName ( $ serverName ) ; Windows \ LobbyWindow :: setAverageWaitingTime ( $ averageTime == - 1 ? - 1 : ceil ( $ averageTime / 60 ) ) ; Windows \ LobbyWindow :: setPlayingPlayerCount ( $ playingPlayersCount ) ; Windows \ LobbyWindow :: setReadyPlayerCount ( $ playersCount ) ; $ lobbyWindow -> show ( ) ; }
|
Display the lobby Window on the right of the screen
|
6,588
|
final function removePlayerFromPlayerList ( $ login ) { Windows \ PlayerList :: Erase ( $ login ) ; $ playerLists = Windows \ PlayerList :: GetAll ( ) ; foreach ( $ playerLists as $ playerList ) { $ playerList -> removePlayer ( $ login ) ; } Windows \ PlayerList :: RedrawAll ( ) ; }
|
Remove a player from the playerlist and destroy his list
|
6,589
|
public final function transactionCommit ( ) { if ( 1 == $ this -> intTransactionDepth ) { $ this -> executeTransactionCommit ( ) ; } if ( $ this -> intTransactionDepth <= 0 ) { throw new Caller ( "The transaction commit call is called before the transaction begin was called." ) ; } $ this -> intTransactionDepth -- ; }
|
This function commits the database transaction .
|
6,590
|
public function escapeIdentifiers ( $ mixIdentifiers ) { if ( is_array ( $ mixIdentifiers ) ) { return array_map ( array ( $ this , 'EscapeIdentifier' ) , $ mixIdentifiers ) ; } else { return $ this -> escapeIdentifier ( $ mixIdentifiers ) ; } }
|
Given an array of identifiers this method returns array of escaped identifiers For corner case handling if a single identifier is supplied a single escaped identifier is returned
|
6,591
|
public function escapeIdentifiersAndValues ( $ mixColumnsAndValuesArray ) { $ result = array ( ) ; foreach ( $ mixColumnsAndValuesArray as $ strColumn => $ mixValue ) { $ result [ $ this -> escapeIdentifier ( $ strColumn ) ] = $ this -> sqlVariable ( $ mixValue ) ; } return $ result ; }
|
Escapes both column and values when supplied as an array
|
6,592
|
public function insertOrUpdate ( $ strTable , $ mixColumnsAndValuesArray , $ strPKNames = null ) { $ strEscapedArray = $ this -> escapeIdentifiersAndValues ( $ mixColumnsAndValuesArray ) ; $ strColumns = array_keys ( $ strEscapedArray ) ; $ strUpdateStatement = '' ; foreach ( $ strEscapedArray as $ strColumn => $ strValue ) { if ( $ strUpdateStatement ) { $ strUpdateStatement .= ', ' ; } $ strUpdateStatement .= $ strColumn . ' = ' . $ strValue ; } if ( is_null ( $ strPKNames ) ) { $ strMatchCondition = 'target_.' . $ strColumns [ 0 ] . ' = source_.' . $ strColumns [ 0 ] ; } else { if ( is_array ( $ strPKNames ) ) { $ strMatchCondition = '' ; foreach ( $ strPKNames as $ strPKName ) { if ( $ strMatchCondition ) { $ strMatchCondition .= ' AND ' ; } $ strMatchCondition .= 'target_.' . $ this -> escapeIdentifier ( $ strPKName ) . ' = source_.' . $ this -> escapeIdentifier ( $ strPKName ) ; } } else { $ strMatchCondition = 'target_.' . $ this -> escapeIdentifier ( $ strPKNames ) . ' = source_.' . $ this -> escapeIdentifier ( $ strPKNames ) ; } } $ strTable = $ this -> EscapeIdentifierBegin . $ strTable . $ this -> EscapeIdentifierEnd ; $ strSql = sprintf ( 'MERGE INTO %s AS target_ USING %s AS source_ ON %s WHEN MATCHED THEN UPDATE SET %s WHEN NOT MATCHED THEN INSERT (%s) VALUES (%s)' , $ strTable , $ strTable , $ strMatchCondition , $ strUpdateStatement , implode ( ', ' , $ strColumns ) , implode ( ', ' , array_values ( $ strEscapedArray ) ) ) ; $ this -> executeNonQuery ( $ strSql ) ; }
|
INSERTs or UPDATEs a table
|
6,593
|
public final function query ( $ strQuery ) { $ timerName = null ; if ( ! $ this -> blnConnectedFlag ) { $ this -> connect ( ) ; } if ( $ this -> blnEnableProfiling ) { $ timerName = 'queryExec' . mt_rand ( ) ; Timer :: start ( $ timerName ) ; } $ result = $ this -> executeQuery ( $ strQuery ) ; if ( $ this -> blnEnableProfiling ) { $ dblQueryTime = Timer :: stop ( $ timerName ) ; Timer :: reset ( $ timerName ) ; $ this -> logQuery ( $ strQuery , $ dblQueryTime ) ; } return $ result ; }
|
Sends the SELECT query to the database and returns the result
|
6,594
|
private function logQuery ( $ strQuery , $ dblQueryTime ) { if ( $ this -> blnEnableProfiling ) { $ objDebugBacktrace = debug_backtrace ( ) ; if ( ( count ( $ objDebugBacktrace ) > 3 ) && ( array_key_exists ( 'function' , $ objDebugBacktrace [ 2 ] ) ) && ( ( $ objDebugBacktrace [ 2 ] [ 'function' ] == 'QueryArray' ) || ( $ objDebugBacktrace [ 2 ] [ 'function' ] == 'QuerySingle' ) || ( $ objDebugBacktrace [ 2 ] [ 'function' ] == 'QueryCount' ) ) ) { $ objBacktrace = $ objDebugBacktrace [ 3 ] ; } else { if ( isset ( $ objDebugBacktrace [ 2 ] ) ) { $ objBacktrace = $ objDebugBacktrace [ 2 ] ; } else { $ objBacktrace = $ objDebugBacktrace [ 1 ] ; } } if ( isset ( $ objBacktrace [ 'object' ] ) ) { $ objBacktrace [ 'object' ] = null ; } for ( $ intIndex = 0 , $ intMax = count ( $ objBacktrace [ 'args' ] ) ; $ intIndex < $ intMax ; $ intIndex ++ ) { $ obj = $ objBacktrace [ 'args' ] [ $ intIndex ] ; if ( is_null ( $ obj ) ) { $ obj = 'null' ; } else { if ( gettype ( $ obj ) == 'integer' ) { } else { if ( gettype ( $ obj ) == 'object' ) { $ obj = 'Object: ' . get_class ( $ obj ) ; if ( method_exists ( $ obj , '__toString' ) ) { $ obj .= '- ' . $ obj ; } } else { if ( is_array ( $ obj ) ) { $ obj = 'Array' ; } else { $ obj = sprintf ( "'%s'" , $ obj ) ; } } } } $ objBacktrace [ 'args' ] [ $ intIndex ] = $ obj ; } $ arrProfile = array ( 'objBacktrace' => $ objBacktrace , 'strQuery' => $ strQuery , 'dblTimeInfo' => $ dblQueryTime ) ; array_push ( $ this -> strProfileArray , $ arrProfile ) ; } }
|
If EnableProfiling is on then log the query to the profile array
|
6,595
|
public function outputProfiling ( $ blnPrintOutput = true ) { $ strPath = isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : $ _SERVER [ 'PHP_SELF' ] ; $ strOut = '<div class="qDbProfile">' ; if ( $ this -> blnEnableProfiling ) { $ strOut .= sprintf ( '<form method="post" id="frmDbProfile%s" action="%s/profile.php"><div>' , $ this -> intDatabaseIndex , QCUBED_PHP_URL ) ; $ strOut .= sprintf ( '<input type="hidden" name="strProfileData" value="%s" />' , base64_encode ( serialize ( $ this -> strProfileArray ) ) ) ; $ strOut .= sprintf ( '<input type="hidden" name="intDatabaseIndex" value="%s" />' , $ this -> intDatabaseIndex ) ; $ strOut .= sprintf ( '<input type="hidden" name="strReferrer" value="%s" /></div></form>' , htmlentities ( $ strPath ) ) ; $ intCount = round ( count ( $ this -> strProfileArray ) ) ; if ( $ intCount == 0 ) { $ strQueryString = 'No queries' ; } else { if ( $ intCount == 1 ) { $ strQueryString = '1 query' ; } else { $ strQueryString = $ intCount . ' queries' ; } } $ strOut .= sprintf ( '<b>PROFILING INFORMATION FOR DATABASE CONNECTION #%s</b>: %s performed. Please <a href="#" onclick="var frmDbProfile = document.getElementById(\'frmDbProfile%s\'); frmDbProfile.target = \'_blank\'; frmDbProfile.submit(); return false;">click here to view profiling detail</a><br />' , $ this -> intDatabaseIndex , $ strQueryString , $ this -> intDatabaseIndex ) ; } else { $ strOut .= '<form></form><b>Profiling was not enabled for this database connection (#' . $ this -> intDatabaseIndex . ').</b> To enable, ensure that ENABLE_PROFILING is set to TRUE.' ; } $ strOut .= '</div>' ; $ strOut .= '<script>$j(function() {$j(".qDbProfile").draggable();});</script>' ; if ( $ blnPrintOutput ) { print ( $ strOut ) ; return null ; } else { return $ strOut ; } }
|
Displays the OutputProfiling results plus a link which will popup the details of the profiling .
|
6,596
|
public static function extractCommentOptions ( $ strComment ) { $ ret [ 0 ] = null ; $ ret [ 1 ] = null ; if ( ( $ strComment ) && ( $ pos1 = strpos ( $ strComment , '{' ) ) !== false && ( $ pos2 = strrpos ( $ strComment , '}' , $ pos1 ) ) ) { $ strJson = substr ( $ strComment , $ pos1 , $ pos2 - $ pos1 + 1 ) ; $ a = json_decode ( $ strJson , true ) ; if ( $ a ) { $ ret [ 0 ] = substr ( $ strComment , 0 , $ pos1 ) . substr ( $ strComment , $ pos2 + 1 ) ; $ ret [ 1 ] = $ a ; } else { $ ret [ 0 ] = $ strComment ; } } return $ ret ; }
|
Utility function to extract the json embedded options structure from the comments .
|
6,597
|
protected function get_custom_routes ( ) { $ routes = [ ] ; $ routes [ 'GET' ] [ 'foo' ] = 'bar' ; $ accept = fem \ request :: get_primary_accept ( ) ; $ routes [ 'GET' ] [ 'foo' ] = 'bar->' . $ accept ; $ routes [ 'GET' ] [ 'foo' ] = 'bar::' . $ accept ; $ routes [ 'GET' ] [ 'foo' ] = function ( $ url , $ method ) { } ; $ routes [ 'GET' ] [ 'foo' ] = function ( $ url , $ method , $ arguments ) { echo 'baz' ; } ; return $ routes ; }
|
user defined mapping url to handler
|
6,598
|
public function getDelegate ( $ packageType ) { if ( ! isset ( $ this -> _instances [ $ packageType ] ) ) { if ( isset ( $ this -> _delegates [ $ packageType ] ) ) { $ classname = $ this -> _delegates [ $ packageType ] ; $ instance = new $ classname ( $ this -> io , $ this -> composer , 'nooku-framework' ) ; $ this -> _instances [ $ packageType ] = $ instance ; } else throw new \ InvalidArgumentException ( 'Unknown package type `' . $ packageType . '`.' ) ; } return $ this -> _instances [ $ packageType ] ; }
|
Returns a specialized LibraryInstaller subclass to deal with the given package type .
|
6,599
|
public function setDirectory ( $ directory ) { if ( strpos ( $ directory , '/' ) !== 0 ) { throw new Exception \ InvalidArgumentException ( 'Directory name must be an absolute path.' ) ; } if ( ! is_dir ( $ directory ) ) { throw new Exception \ LogicException ( 'Template directory does not exist.' ) ; } $ this -> directory = realpath ( $ directory ) ; }
|
Template resolution is restricted to the paths under the template directory .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.