idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
9,200
public function updateUser ( array $ config = [ ] ) { $ result = $ this -> updateUserInternal ( $ config ) ; $ statusCode = ( int ) $ result [ 'statusCode' ] ; if ( $ statusCode === 200 ) { return $ this -> getResultAsArrayWithoutStatusCode ( $ result ) ; } $ this -> reportUnexpectedResponse ( $ result , 1490808841 ) ;...
Update the specified user with the given information .
9,201
private function assertTrustedBrokerIp ( ) { $ baseHost = parse_url ( $ this -> idBrokerUri , PHP_URL_HOST ) ; $ idBrokerIp = gethostbyname ( $ baseHost ) ; if ( ! $ this -> isTrustedIpAddress ( $ idBrokerIp ) ) { throw new Exception ( 'The Id Broker has an IP that is not trusted ... ' . $ idBrokerIp , 1494531300 ) ; }...
Determine whether any of the Id - broker s IPs are not in the trusted ranges
9,202
protected function initializeProductLink ( array $ attr ) { $ productId = $ attr [ MemberNames :: PRODUCT_ID ] ; $ linkTypeId = $ attr [ MemberNames :: LINK_TYPE_ID ] ; $ linkedProductId = $ attr [ MemberNames :: LINKED_PRODUCT_ID ] ; if ( $ entity = $ this -> loadProductLink ( $ productId , $ linkedProductId , $ linkT...
Initialize the product link with the passed attributes and returns an instance .
9,203
public function parse ( string $ input ) : Type { $ this -> lexer -> setInput ( $ input ) ; $ this -> lexer -> moveNext ( ) ; return $ this -> parseInternal ( ) ; }
Parse a type string .
9,204
private function match ( int $ type ) { if ( ! $ this -> lexer -> isNextToken ( $ type ) ) { $ this -> syntaxError ( ) ; } $ value = $ this -> lexer -> lookahead [ 'value' ] ; $ this -> lexer -> moveNext ( ) ; return $ value ; }
Match a token in the lexer .
9,205
private function parseInternal ( ) : Type { $ typeName = $ this -> match ( Lexer :: T_IDENTIFIER ) ; if ( ! $ this -> lexer -> isNextToken ( Lexer :: T_OPEN_BRACKET ) ) { return new Type ( $ typeName ) ; } $ this -> match ( Lexer :: T_OPEN_BRACKET ) ; $ params = [ ] ; do { if ( $ this -> lexer -> isNextToken ( Lexer ::...
Parse internal type string .
9,206
private function syntaxError ( ) : void { throw new SyntaxErrorException ( $ this -> lexer -> getInputUntilPosition ( PHP_INT_MAX ) , $ this -> lexer -> lookahead [ 'value' ] ? : 'end of string' , ( int ) $ this -> lexer -> lookahead [ 'position' ] ) ; }
Throw a syntax error exception .
9,207
public static function getInstance ( $ id = null , $ phpExecutable = 'php' , $ tmpPath = 'tmp/' ) { if ( is_null ( self :: $ _instance ) ) { self :: $ _phpExecutable = $ phpExecutable ; self :: $ _tmpPath = $ tmpPath ; $ jobRunner = new JobRunner ( $ id ) ; self :: $ _instance = $ jobRunner ; } return self :: $ _instan...
Get the job runner instance . Parameters are used only on first creation .
9,208
protected function _getJobDirectory ( Job $ job ) { $ jobDir = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . $ job -> getId ( ) ; $ this -> _prepareDirectory ( $ jobDir ) ; return $ jobDir ; }
Get the directory where a job will work .
9,209
public function start ( Job $ job ) { $ jobData = new JobData ( ) ; if ( $ this -> exec ) { $ jobDir = $ this -> _getJobDirectory ( $ job ) ; $ logFile = realpath ( $ this -> getDirectory ( ) ) . '/run.log' ; $ lockFile = $ this -> _lockJob ( $ jobDir ) ; if ( $ lockFile ) { $ jobData -> lockFile = $ lockFile ; $ jobDa...
Start the execution of a job .
9,210
protected function _getJobResult ( Job $ job ) { $ jobHash = spl_object_hash ( $ job ) ; if ( isset ( $ this -> runningJobs [ $ jobHash ] ) ) { $ jobDir = $ this -> _getJobDirectory ( $ job ) ; if ( file_exists ( "$jobDir/out.serialize" ) ) { $ data = unserialize ( file_get_contents ( "$jobDir/out.serialize" ) ) ; $ jo...
Check if a job is terminated handle the finish & return true or false if finished or not .
9,211
public function proccess ( ) { foreach ( $ this -> runningJobs as $ jobData ) { $ this -> isRunning ( $ jobData -> job ) ; } foreach ( $ this -> pendingJobs as $ job ) { $ this -> start ( $ job ) ; } }
Process all running jobs and check if they have finished .
9,212
public function waitForAll ( $ sleepTime = 1 ) { while ( ! empty ( $ this -> runningJobs ) ) { $ this -> proccess ( ) ; $ this -> sleep ( $ sleepTime ) ; } }
Wait for all the jobs to be terminated .
9,213
protected function buildDatetimepicker ( $ input , array $ options = [ ] ) { $ this -> Asset -> script ( [ '/vendor/moment/moment-with-locales.min' , 'MeTools.bootstrap-datetimepicker.min' , ] , [ 'block' => 'script_bottom' ] ) ; $ this -> Asset -> css ( '/vendor/bootstrap-datetimepicker/css/bootstrap-datetimepicker.mi...
Internal function to generate datepicker and timepicker .
9,214
public function beforeLayout ( Event $ event , $ layoutFile ) { if ( ! $ this -> output ) { return ; } $ output = array_map ( function ( $ v ) { return " " . $ v ; } , $ this -> output ) ; $ this -> Html -> scriptBlock ( sprintf ( '$(function() {%s});' , PHP_EOL . implode ( PHP_EOL , $ output ) . PHP_EOL ) , [ 'bloc...
Before layout callback . beforeLayout is called before the layout is rendered .
9,215
public function analytics ( $ id ) { return $ this -> getView ( ) -> getRequest ( ) -> is ( 'localhost' ) ? null : $ this -> Html -> scriptBlock ( sprintf ( '!function(e,a,t,n,c,o,s){e.GoogleAnalyticsObject=c,e[c]=e[c]||function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].l=1*new Date,o=a.createElement(t),s=a.getElemen...
Create a script block for Google Analytics
9,216
public function ckeditor ( $ jquery = false ) { is_readable_or_fail ( WWW_ROOT . 'ckeditor' . DS . 'ckeditor.js' ) ; $ scripts = [ '/ckeditor/ckeditor' ] ; if ( $ jquery && is_readable ( WWW_ROOT . 'ckeditor' . DS . 'adapters' . DS . 'jquery.js' ) ) { $ scripts [ ] = '/ckeditor/adapters/jquery' ; } if ( is_readable ( W...
Loads all CKEditor scripts .
9,217
public function fancybox ( ) { $ this -> Html -> css ( [ '/vendor/fancybox/jquery.fancybox' , '/vendor/fancybox/helpers/jquery.fancybox-buttons' , '/vendor/fancybox/helpers/jquery.fancybox-thumbs' , ] , [ 'block' => 'css_bottom' ] ) ; $ scripts = [ '/vendor/fancybox/jquery.fancybox.pack' , '/vendor/fancybox/helpers/jqu...
Loads all FancyBox scripts .
9,218
public function slugify ( $ sourceField = 'form #title' , $ targetField = 'form #slug' ) { $ this -> Asset -> script ( 'MeTools.slugify' , [ 'block' => 'script_bottom' ] ) ; $ this -> output [ ] = sprintf ( '$().slugify("%s", "%s");' , $ sourceField , $ targetField ) ; }
Through slugify . js it provides the slug of a field .
9,219
public function setWarningLevel ( $ level = self :: WARNING_LEVEL_DEFAULT ) { if ( ! in_array ( $ level , $ this -> availableWarningLevels ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'The warning level "%s" is not available.' , $ level ) ) ; } $ this -> warningLevel = ( string ) $ level ; return $ ...
Sets warning level
9,220
public function addLocalFile ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'The file "%s" does not exists.' , $ file ) ) ; } $ this -> addScript ( file_get_contents ( $ file ) ) ; return $ this ; }
Add local javascript file
9,221
public function addLocalDirectory ( $ directory , $ recursive = false ) { if ( ! file_exists ( $ directory ) || ! is_dir ( $ directory ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'The directory "%s" does not exists.' , $ directory ) ) ; } if ( $ recursive ) { $ iterator = new \ RecursiveIteratorIte...
Add local files contains in directory
9,222
public function addRemoteFile ( $ url ) { if ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'The url "%s" is not valid.' , $ url ) ) ; } $ this -> files [ ] = ( string ) $ url ; return $ this ; }
Add remote javascript file
9,223
public function getParams ( ) { $ params = array ( 'compilation_level' => $ this -> getMode ( ) , 'output_format' => 'xml' , 'warning_level' => $ this -> getWarningLevel ( ) , 'output_info_1' => 'compiled_code' , 'output_info_2' => 'statistics' , 'output_info_3' => 'warnings' , 'output_info_4' => 'errors' , ) ; $ forma...
Returns compiler params
9,224
public function getHash ( ) { return md5 ( implode ( '' , $ this -> scripts ) . implode ( '' , $ this -> files ) . $ this -> mode . $ this -> warningLevel . $ this -> getFormattingOptions ( ) -> getPrettyPrintEnabled ( ) . $ this -> getFormattingOptions ( ) -> getPrintInputDelimiterEnabled ( ) ) ; }
Returns compile hash
9,225
public function setOption ( $ name , $ value ) { $ methodName = 'set' . ucfirst ( $ name ) ; if ( ! method_exists ( $ this , $ methodName ) ) { throw new RuntimeException ( 'Method not exists: ' . $ methodName ) ; } return $ this -> $ methodName ( $ value ) ; }
Set option Fluent interface
9,226
public function attachDefaultHelper ( ) { $ this -> attachHelper ( 'checkbox' , new FormHelperChoiceCheckbox ( ) ) ; $ this -> attachHelper ( 'radio' , new FormHelperChoiceRadio ( ) ) ; $ this -> attachHelper ( 'select' , new FormHelperChoiceSelect ( ) ) ; $ this -> attachHelper ( 'error' , new FormHelperFieldError ( )...
attach default form helper
9,227
public function loadField ( Property $ property , $ helperName , array $ options = array ( ) ) { if ( $ this -> getHelper ( 'field' ) -> hasKey ( $ helperName ) ) { $ formHelper = $ this -> getHelper ( 'field' ) -> get ( $ helperName ) ; $ tmpFormHelper = clone $ formHelper ; $ tmpFormHelper -> setProperty ( $ property...
load and render form help field
9,228
public function loadChoice ( Property $ property , $ helperName , $ choiceValue , array $ options = array ( ) ) { if ( $ this -> getHelper ( 'choice' ) -> hasKey ( $ helperName ) ) { $ formHelper = $ this -> getHelper ( 'choice' ) -> get ( $ helperName ) ; $ tmpFormHelper = clone $ formHelper ; $ tmpFormHelper -> setPr...
load and render form help choice
9,229
public function loadTag ( FormInterface $ form , $ helperName , $ content = null , array $ options = array ( ) ) { if ( $ this -> getHelper ( 'tag' ) -> hasKey ( $ helperName ) ) { $ formHelper = $ this -> getHelper ( 'tag' ) -> get ( $ helperName ) ; $ tmpFormHelper = clone $ formHelper ; $ tmpFormHelper -> setForm ( ...
load and render form help tag
9,230
public function loadOption ( FormInterface $ form , $ helperName , $ optionValue , array $ options = array ( ) ) { if ( ! $ form instanceof FormCollectionInterface ) { throw new InvalidArgumentException ( sprintf ( 'loadOption requires a instance of Type "%s", "%s" was given.' , FormCollectionInterface :: class , get_c...
load and render form help option
9,231
public function getHelper ( $ helperType ) { if ( $ this -> isValidKey ( $ helperType ) ) { return $ this -> getHelperMap ( ) -> get ( $ helperType ) ; } else { throw new InvalidArgumentException ( 'Invalid form helper type given' ) ; } }
return registered form helper
9,232
public function getHelperCount ( $ helperType ) { if ( $ this -> isValidKey ( $ helperType ) ) { if ( ! is_null ( $ formHelperMap = $ this -> getHelperMap ( ) -> get ( $ helperType ) ) ) { return count ( $ formHelperMap ) ; } return 0 ; } else { throw new InvalidArgumentException ( 'Invalid form helper type given' ) ; ...
return count of registered form helper
9,233
public function hasHelper ( $ helperType ) { if ( $ this -> isValidKey ( $ helperType ) ) { if ( ! is_null ( $ formHelperMap = $ this -> getHelperMap ( ) -> get ( $ helperType ) ) && count ( $ formHelperMap ) > 0 ) { return true ; } } else { throw new InvalidArgumentException ( 'Invalid form helper type given' ) ; } re...
return if helper are registered
9,234
public function attachHelper ( $ helperName , FormHelperInterface $ formHelper ) { if ( $ this -> isValidKey ( $ helperName ) ) { if ( is_null ( $ formHelperType = $ this -> resolveHelperType ( $ formHelper ) ) ) { throw new InvalidArgumentException ( 'Unkown form helper instance given' ) ; } if ( $ this -> hasHelper (...
add form helper
9,235
public function detachHelper ( $ helperName , FormHelperInterface $ helper ) { if ( $ this -> isValidKey ( $ helperName ) ) { if ( is_null ( $ formHelperType = $ this -> resolveHelperType ( $ helper ) ) ) { throw new InvalidArgumentException ( 'Unkown form helper instance given' ) ; } if ( $ this -> hasHelper ( $ formH...
remove form helper
9,236
public function clean ( $ maxlifetime , $ next ) { global $ wpdb ; $ wpdb -> query ( $ wpdb -> prepare ( "DELETE FROM {$wpdb->prefix}sm_sessions WHERE session_expiry < %s LIMIT %d" , time ( ) , 1000 ) ) ; return $ next ( $ maxlifetime ) ; }
Update the database by removing any sessions that are no longer valid .
9,237
public function geocode ( $ address ) { $ query = $ this -> buildQuery ( 'address' , $ address ) ; $ response = $ this -> validateResponse ( $ this -> getResponse ( $ query ) ) ; return $ this -> buildResults ( $ response [ 'results' ] ) ; }
Geocodes the provided address
9,238
public function reverseByPlaceId ( $ placeId ) { $ query = $ this -> buildQuery ( 'place_id' , $ placeId ) ; $ response = $ this -> validateResponse ( $ this -> getResponse ( $ query ) ) ; return $ this -> buildResults ( $ response [ 'results' ] ) ; }
Reverse geocodes by the provided place id .
9,239
public function reverseByCoordinates ( $ latitude , $ longitude ) { $ query = $ this -> buildQuery ( 'address' , "{$latitude},{$longitude}" ) ; $ response = $ this -> validateResponse ( $ this -> getResponse ( $ query ) ) ; return $ this -> buildResults ( $ response [ 'results' ] ) ; }
Reverse geocodes by the provided coordinates .
9,240
private function addOptionalQueryParameters ( $ apiKey , $ language , $ region ) { if ( $ apiKey ) { $ this -> endpoint = $ this -> buildQuery ( 'key' , $ apiKey ) ; } if ( $ language ) { $ this -> endpoint = $ this -> buildQuery ( 'language' , $ language ) ; } if ( $ region ) { $ this -> endpoint = $ this -> buildQuer...
Adds any of the optional query parameters to the query .
9,241
private function validateResponse ( $ response ) { if ( ! isset ( $ response ) ) { throw new NoResult ( sprintf ( 'Could not execute query' ) ) ; } if ( 'REQUEST_DENIED' === $ response [ 'status' ] && 'The provided API key is invalid.' === $ response [ 'error_message' ] ) { throw new InvalidKey ( sprintf ( 'API key is ...
Makes sure the response does not contain any errors .
9,242
private function buildResults ( $ results ) { return array_map ( function ( $ result ) { $ coordinates = $ result [ 'geometry' ] [ 'location' ] ; $ data = [ 'address' => $ result [ 'formatted_address' ] , 'latitude' => $ coordinates [ 'lat' ] , 'longitude' => $ coordinates [ 'lng' ] , 'place_id' => $ result [ 'place_id...
Transform the response from Google into a result set .
9,243
public function setContent ( $ content , $ type = NULL ) { $ this -> content = $ content ; if ( ! empty ( $ type ) ) { $ this -> contentType = $ type ; } return $ this ; }
Set the content for this object .
9,244
protected function doRender ( FilterPreRenderEvent $ preEvent , MailInterface $ mail ) { $ variables = $ preEvent -> getVariables ( ) ; $ variables [ '_mail_type' ] = $ mail -> getType ( ) ; $ variables [ '_layout' ] = null !== $ mail -> getLayout ( ) ? $ mail -> getLayout ( ) -> getName ( ) : null ; $ subject = $ this...
Render the mail .
9,245
protected function getTranslatedMail ( $ template , $ type ) { $ mail = $ this -> loader -> load ( $ template , $ type ) ; return TranslationUtil :: translateMail ( $ mail , $ this -> getLocale ( ) , $ this -> translator ) ; }
Get the translated mail .
9,246
protected function getTranslatedLayout ( MailInterface $ mail ) { $ layout = $ mail -> getLayout ( ) ; if ( null !== $ layout ) { $ layout = TranslationUtil :: translateLayout ( $ layout , $ this -> getLocale ( ) , $ this -> translator ) ; } return $ layout ; }
Get the translated layout of mail .
9,247
private function generate ( string $ identifier , string $ method , string $ timestamp , string $ uri , string $ content ) : string { $ payload = [ 'id' => $ identifier , 'method' => strtoupper ( $ method ) , 'timestamp' => $ timestamp , 'uri' => rtrim ( $ uri , '/' ) ] ; if ( is_null ( json_decode ( $ content ) ) ) { ...
Generates a payload with the provided properties
9,248
protected function generateFromPsr7Request ( Psr7Request $ request ) : string { $ id = isset ( $ this -> request -> getHeader ( 'X-SIGNED-ID' ) [ 0 ] ) ? $ this -> request -> getHeader ( 'X-SIGNED-ID' ) [ 0 ] : '' ; $ timestamp = isset ( $ this -> request -> getHeader ( 'X-SIGNED-TIMESTAMP' ) [ 0 ] ) ? $ this -> reques...
Returns the payload from a guzzle request .
9,249
protected function generateFromIlluminateRequest ( IlluminateRequest $ request ) : string { $ id = $ this -> request -> headers -> get ( 'X-SIGNED-ID' , '' ) ; $ timestamp = $ this -> request -> headers -> get ( 'X-SIGNED-TIMESTAMP' , '' ) ; return $ this -> generate ( ( string ) $ id , ( string ) $ this -> request -> ...
Retruns the payload from an illuminate request .
9,250
public function findOneByEmailAndWebsiteId ( $ email , $ websiteId ) { $ params = array ( MemberNames :: EMAIL => $ email , MemberNames :: WEBSITE_ID => $ websiteId ) ; $ this -> customerByEmailAndWebsiteIdStmt -> execute ( $ params ) ; return $ this -> customerByEmailAndWebsiteIdStmt -> fetch ( \ PDO :: FETCH_ASSOC ) ...
Return s the customer with the passed email and website ID .
9,251
final function withServiceName ( $ serviceName = null ) { if ( false == $ this -> canCreate ( $ serviceName ) ) throw new \ Exception ( sprintf ( 'Can`t Create (%s).' , \ Poirot \ Std \ flatten ( $ serviceName ) ) ) ; $ new = clone $ this ; $ new -> currentService = $ serviceName ; return $ new ; }
Set Create Service Method Respond To This Service
9,252
public function getCoreModules ( $ excludeModulesOnReturn = [ ] ) { $ modules = [ 'melisdbdeploy' => 'MelisDbDeploy' , 'meliscomposerdeploy' => 'MelisComposerDeploy' , 'meliscore' => 'MelisCore' , 'melissites' => 'MelisSites' , 'melisassetmanager' => 'MelisAssetManager' , ] ; if ( $ excludeModulesOnReturn ) { foreach (...
Returns all the important modules
9,253
public function activateModule ( $ module , $ defaultModules = [ 'MelisAssetManager' , 'MelisComposerDeploy' , 'MelisDbDeploy' , 'MelisCore' ] , $ excludeModule = [ 'MelisModuleConfig' ] ) { $ activeModules = $ this -> getActiveModules ( $ defaultModules ) ; foreach ( $ activeModules as $ key => $ mod ) { if ( in_array...
This method activating a single module and store to the module . load . php of the platform
9,254
public function createModuleLoader ( $ pathToStore , $ modules = [ ] , $ topModules = [ 'melisdbdeploy' , 'meliscomposerdeploy' , 'meliscore' ] , $ bottomModules = [ 'MelisModuleConfig' ] ) { $ tmpFileName = 'melis.module.load.php.tmp' ; $ fileName = 'melis.module.load.php' ; if ( $ this -> checkDir ( $ pathToStore ) )...
Creates module loader file
9,255
public static function getType ( $ path , $ outputFormat = null , array $ imgInfo = null ) { $ imgInfo = $ imgInfo ? : self :: getSize ( $ path ) ; if ( $ outputFormat ) { switch ( $ outputFormat ) { case 'png' : $ type = ImageFile :: TYPE_PNG ; break ; case 'gif' : $ type = ImageFile :: TYPE_GIF ; break ; case 'wbmp' ...
Get image type based on given format or mime info
9,256
public static function get ( $ path , array $ info = null ) { $ info = $ info ? : self :: getSize ( $ path ) ; switch ( $ info [ 'mime' ] ) { case self :: TYPE_JPG : $ srcImg = imagecreatefromjpeg ( $ path ) ; break ; case self :: TYPE_PNG : $ srcImg = imagecreatefrompng ( $ path ) ; break ; case self :: TYPE_GIF : $ s...
Make and return an image resource from file
9,257
public static function save ( $ path , $ img , $ type = self :: TYPE_JPG , $ quality = null ) { $ dir = explode ( '/' , $ path ) ; unset ( $ dir [ count ( $ dir ) - 1 ] ) ; $ dir = implode ( '/' , $ dir ) ; if ( ! file_exists ( $ dir ) || ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } switch ( $ type ) { case...
Save image to given path from image resource
9,258
public static function newFromServiceCatalog ( $ catalog , $ token , $ region = CDN :: DEFAULT_REGION ) { $ c = count ( $ catalog ) ; for ( $ i = 0 ; $ i < $ c ; ++ $ i ) { if ( $ catalog [ $ i ] [ 'type' ] == self :: SERVICE_TYPE ) { foreach ( $ catalog [ $ i ] [ 'endpoints' ] as $ endpoint ) { if ( isset ( $ endpoint...
Create a new CDN object based on a service catalog .
9,259
public function containers ( $ enabledOnly = NULL ) { $ client = \ HPCloud \ Transport :: instance ( ) ; $ url = $ this -> url . '/?format=json' ; if ( $ enabledOnly ) { $ url .= '&enabled_only=true' ; } elseif ( $ enabledOnly === FALSE ) { $ url .= '&enabled_only=false' ; } $ headers = array ( 'X-Auth-Token' => $ this...
Get a list of containers that the CDN system knows of .
9,260
public function container ( $ name ) { $ containers = $ this -> containers ( ) ; foreach ( $ containers as $ container ) { if ( $ container [ 'name' ] == $ name ) { return $ container ; } } return FALSE ; }
Get a container by name .
9,261
public function enable ( $ name , $ ttl = NULL , & $ created = FALSE ) { $ headers = array ( ) ; if ( ! empty ( $ ttl ) ) { $ headers [ 'X-TTL' ] = ( int ) $ ttl ; } $ res = $ this -> modifyContainer ( $ name , 'PUT' , $ headers ) ; $ created = $ res -> status ( ) == 201 ; $ url = $ res -> header ( 'X-Cdn-Uri' , 'UNKNO...
Enable a container .
9,262
public function update ( $ name , $ attrs ) { $ headers = array ( ) ; foreach ( $ attrs as $ item => $ val ) { switch ( $ item ) { case 'ttl' : $ headers [ 'X-TTL' ] = ( int ) $ val ; break ; case 'enabled' : case 'cdn_enabled' : if ( isset ( $ val ) && $ val == FALSE ) { $ flag = 'False' ; } else { $ flag = 'True' ; }...
Set attributes on a CDN container .
9,263
protected function modifyContainer ( $ name , $ method , $ headers = array ( ) , $ qstring = '' ) { $ url = $ this -> url . '/' . rawurlencode ( $ name ) . $ qstring ; $ headers [ 'X-Auth-Token' ] = $ this -> token ; $ client = \ HPCloud \ Transport :: instance ( ) ; $ response = $ client -> doRequest ( $ url , $ metho...
Run the given method on the given container .
9,264
public static function array_merge_recursive_distinct ( array $ array1 , array $ array2 ) { $ result = $ array1 ; foreach ( $ array2 as $ key => $ val ) { if ( is_array ( $ array2 [ $ key ] ) ) { $ result [ $ key ] = is_array ( $ result [ $ key ] ) ? self :: array_merge_recursive_distinct ( $ result [ $ key ] , $ array...
Merge second array into first but only for keys present in first array
9,265
public static function time_ago ( $ date , $ granularity = 1 ) { $ periods = [ 'decade' => 315360000 , 'year' => 31536000 , 'month' => 2628000 , 'week' => 604800 , 'day' => 86400 , 'hour' => 3600 , 'minute' => 60 , 'second' => 1 ] ; $ date = strtotime ( $ date ) ; $ difference = time ( ) - $ date ; $ retval = '' ; if (...
DISPLAYS COMMENT POST TIME AS 1 year 1 week ago or 5 minutes 7 seconds ago etc ...
9,266
public function fulfillConditions ( $ entry = null ) { foreach ( $ this -> getConditions ( ) as $ condition ) { if ( $ condition -> getAttribute ( ) == MissionGameCondition :: NONE ) { continue ; } if ( $ condition -> getAttribute ( ) == MissionGameCondition :: VICTORY ) { if ( ! $ entry || ! $ entry -> getWinner ( ) )...
Are the conditions linked to this game fulfilled ?
9,267
public function createCachedConditionGenerator ( ConditionGenerator $ conditionGenerator , $ ttl = 0 ) : ConditionGenerator { if ( null === $ this -> cacheDriver ) { return $ conditionGenerator ; } return new CachedConditionGenerator ( $ conditionGenerator , $ this -> cacheDriver , $ ttl ) ; }
Creates a new CachedConditionGenerator instance for the given ConditionGenerator .
9,268
protected function getClaimOrNull ( $ claim ) { $ claim = $ this -> token -> getPayload ( ) -> findClaimByName ( $ claim ) ; return $ claim ? $ claim -> getValue ( ) : null ; }
Get a claim if we have one or return null
9,269
protected function isExpired ( ) { $ exp = \ DateTime :: createFromFormat ( 'U' , $ this -> getClaimOrNull ( self :: EXPIRY ) ) ; return ! $ exp || $ exp <= ( new DateTime ) ; }
Is this token expired
9,270
public static function isValid ( MailInterface $ mail , $ type ) { $ validTypes = static :: getValidTypes ( $ type ) ; return $ mail -> isEnabled ( ) && \ in_array ( $ mail -> getType ( ) , $ validTypes , true ) ; }
Check if the mail template is valid .
9,271
public static function getValidTypes ( $ type ) { if ( MailTypes :: TYPE_PRINT === $ type ) { return [ MailTypes :: TYPE_ALL , MailTypes :: TYPE_PRINT ] ; } if ( MailTypes :: TYPE_SCREEN === $ type ) { return [ MailTypes :: TYPE_ALL , MailTypes :: TYPE_SCREEN ] ; } return [ MailTypes :: TYPE_ALL , MailTypes :: TYPE_PRI...
Get the valid mail types .
9,272
private function startExecution ( int $ timestamp , string $ jobId ) : string { $ start = new \ DateTime ( 'now' , new \ DateTimeZone ( 'UTC' ) ) ; $ sendAt = new \ DateTime ( "@{$timestamp}" ) ; $ span = ( int ) $ start -> diff ( $ sendAt ) -> format ( '%a' ) ; $ input = [ 'job_id' => $ jobId ] ; if ( $ span < 365 ) {...
Starts the execution in the state machine and returns the generated executionArn from AWS .
9,273
private function stopExecution ( string $ jobId , string $ executionArn ) : void { try { $ this -> sfnClient -> stopExecution ( [ 'executionArn' => $ executionArn , 'cause' => 'canceled' , ] ) ; } catch ( \ Throwable $ t ) { $ this -> logger -> error ( 'Failed to stopExecution of [{execution_arn}] for [{job_id}].' , [ ...
I know you hurtin and worryin I can feel it on you but you oughta quit on it now . Because I want it over and done . I do . I m tired boss .
9,274
public static function formatConfig ( $ config ) { if ( \ is_string ( $ config ) ) { $ config = [ 'file' => $ config ] ; } if ( ! \ is_array ( $ config ) ) { throw new UnexpectedTypeException ( $ config , 'array' ) ; } if ( ! isset ( $ config [ 'file' ] ) ) { $ msg = 'The "file" attribute must be defined in config of l...
Format the string config to array config with file attribute .
9,275
public static function formatTranslationConfig ( $ config , KernelInterface $ kernel ) { $ config = static :: formatConfig ( $ config ) ; $ config [ 'file' ] = $ kernel -> locateResource ( $ config [ 'file' ] ) ; if ( isset ( $ config [ 'translations' ] ) && \ is_array ( $ config [ 'translations' ] ) ) { foreach ( $ co...
Format the string config to array config with file attribute and translations .
9,276
public static function escape ( $ string , $ flag = ENT_COMPAT , $ hardEscape = true ) { return htmlspecialchars ( $ string , $ flag , static :: ENCODING , ( bool ) $ hardEscape ) ; }
wrapper for htmlspecialchars with utf - 8 and ENT_COMPAT set as default
9,277
public static function secureCompare ( $ userInput , $ reference ) { if ( strlen ( $ userInput ) !== strlen ( $ reference ) ) { $ comparison = $ reference ^ $ reference ; $ result = 1 ; } else { $ comparison = $ userInput ^ $ reference ; $ result = 0 ; } $ len = strlen ( $ comparison ) ; for ( $ i = $ len - 1 ; $ i >= ...
Truly constant time string comparison for Timing Attack protection
9,278
public static function resolveRelative ( $ sourcePath , $ targetPath ) { if ( '.' == dirname ( $ sourcePath ) ) { $ path = str_repeat ( '../' , substr_count ( $ targetPath , '/' ) ) ; } elseif ( '.' == $ targetDir = dirname ( $ targetPath ) ) { $ path = dirname ( $ sourcePath ) . '/' ; } else { $ path = '' ; while ( 0 ...
Returns relative path to the source directory from the target path .
9,279
public static function resolveUrl ( AssetInterface $ asset , $ url ) { if ( false !== strpos ( $ url , '://' ) ) { return $ url ; } $ root = dirname ( $ asset -> getSourceRoot ( ) . '/' . $ asset -> getTargetPath ( ) ) ; $ path = dirname ( $ asset -> getTargetPath ( ) ) ; if ( '.' === $ path ) { $ image = $ url ; } els...
Resolves an URL from an asset .
9,280
public static function removeQueryString ( $ path ) { if ( false === $ pos = strpos ( $ path , '?' ) ) { return $ path ; } $ anchorPos = strpos ( $ path , '#' , $ pos ) ; $ end = false === $ anchorPos ? strlen ( $ path ) : $ anchorPos ; return substr ( $ path , 0 , $ pos ) . substr ( $ path , $ end ) ; }
Removes from ? position in string . If not found returns the original string .
9,281
protected function createLayout ( array $ config ) { $ layout = $ this -> newLayoutInstance ( ) ; $ layout -> setName ( ConfigUtil :: getValue ( $ config , 'name' ) ) ; $ layout -> setLabel ( ConfigUtil :: getValue ( $ config , 'label' ) ) ; $ layout -> setDescription ( ConfigUtil :: getValue ( $ config , 'description'...
Create the layout .
9,282
protected function createLayoutTranslation ( LayoutInterface $ layout , array $ config ) { $ translation = $ this -> newLayoutTranslationInstance ( $ layout ) ; $ translation -> setLocale ( ConfigUtil :: getValue ( $ config , 'locale' ) ) ; $ translation -> setLabel ( ConfigUtil :: getValue ( $ config , 'label' ) ) ; $...
Create a layout translation .
9,283
private function getDomDocumentType ( string $ data ) : string { $ startPos = $ endPos = \ stripos ( $ data , '<!doctype' ) ; $ braces = 0 ; do { $ char = $ data [ $ endPos ++ ] ; if ( '<' === $ char ) { ++ $ braces ; } if ( '>' === $ char ) { -- $ braces ; } } while ( $ braces > 0 ) ; $ internalSubset = \ substr ( $ d...
Retrieves internalSubset even in bugfixed php versions .
9,284
public function rankAdd ( ) { if ( ! $ this -> owner -> isNewRecord ) { return ; } if ( ! is_numeric ( $ this -> owner -> getAttribute ( $ this -> attribute ) ) ) { $ this -> owner -> setAttribute ( $ this -> attribute , $ this -> getSiblings ( ) -> count ( ) ) ; } }
Adds inserts rank into new model
9,285
public function rankRemove ( ) { $ owner = $ this -> owner ; $ query = $ this -> getSiblings ( ) -> andWhere ( [ '>' , $ this -> attribute , $ this -> owner -> getAttribute ( $ this -> attribute ) ] ) ; $ owner :: updateAllCounters ( [ $ this -> attribute => - 1 ] , $ query -> where ) ; }
Updates siblings ranks after owner model is deleted
9,286
public function rankSwitch ( $ to ) { $ owner = $ this -> owner ; $ this -> getSiblings ( ) -> andWhere ( [ $ this -> attribute => $ to ] ) -> one ( ) -> updateAttributes ( [ $ this -> attribute => $ this -> owner -> getAttribute ( $ this -> attribute ) ] ) ; $ owner -> updateAttributes ( [ $ this -> attribute => $ to ...
Switches rank position with another model .
9,287
public function initialize ( array $ get = [ ] , array $ post = [ ] , array $ cookie = [ ] , array $ files = [ ] , array $ server = [ ] , $ rawBody = null , array $ globals = [ ] ) { $ cookie = $ this -> removeSlashes ( $ cookie ) ; $ get = $ this -> removeSlashes ( $ get ) ; $ post = $ this -> removeSlashes ( $ post )...
Initializes request properties
9,288
protected function removeSlashes ( $ array ) { $ fnc = function ( $ value ) use ( & $ fnc ) { if ( is_array ( $ value ) ) { return array_map ( $ fnc , $ value ) ; } return stripslashes ( $ value ) ; } ; if ( version_compare ( phpversion ( ) , '6.0.0-dev' , '<' ) && get_magic_quotes_gpc ( ) ) { $ array = array_map ( $ f...
Removes slashes from array
9,289
protected function resolveInvalidRedirect ( ) { if ( empty ( $ this -> server [ 'REDIRECT_URL' ] ) ) { return false ; } $ nodes = substr ( $ this -> server [ 'SCRIPT_FILENAME' ] , strlen ( $ this -> server [ 'DOCUMENT_ROOT' ] ) ) ; $ nodes = str_replace ( '\\' , '/' , $ nodes ) ; $ nodes = substr ( $ nodes , 0 , strrpo...
Resolves invalid redirection path
9,290
protected function resolveBaseName ( ) { $ schema = $ this -> schema ( ) ; $ host = str_replace ( '//' , '/' , $ this -> host ( ) . $ this -> dir . '/' ) ; return $ schema . '://' . $ host ; }
Resolves base name
9,291
protected function resolveParameters ( array $ get = [ ] , array $ globals = [ ] ) { if ( $ this -> method ( ) != 'CLI' || ! isset ( $ globals [ 'argc' ] , $ globals [ 'argv' ] ) || $ globals [ 'argc' ] <= 1 ) { return $ get ; } $ cli = [ ] ; for ( $ i = 1 ; $ i < $ globals [ 'argc' ] ; $ i ++ ) { if ( preg_match_all (...
Resolves request parameters from passed array and CLI
9,292
public function isSecure ( ) { if ( $ proto = ( string ) $ this -> header -> get ( 'x_forwarded_proto' ) ) { return in_array ( strtolower ( current ( explode ( ',' , $ proto ) ) ) , [ 'https' , 'on' , 'ssl' , '1' ] ) ; } return strtolower ( $ this -> server -> get ( 'HTTPS' ) ) == 'on' || $ this -> server -> get ( 'HTT...
Returns true if request is made via SSL
9,293
public function path ( $ query = false ) { return $ this -> path . ( $ query && $ this -> query -> has ( ) ? '?' . http_build_query ( $ this -> query -> all ( ) , null , '&' ) : null ) ; }
Returns requested URL
9,294
public function uri ( $ query = false ) { return rtrim ( $ this -> baseName ( ) , '/' ) . '/' . ltrim ( $ this -> path ( $ query ) , '/' ) ; }
Returns requested URI
9,295
public function format ( $ format = null ) { if ( $ format !== null ) { $ this -> format = $ format ; } return $ this -> format ; }
Returns requested format
9,296
protected function getPrivateKey ( ) { try { $ privateKey = file_get_contents ( $ this -> privateKeyPath ) ; } catch ( \ Exception $ e ) { $ msg = 'Impossible to read the private key of the DKIM swiftmailer signer "%s"' ; throw new RuntimeException ( sprintf ( $ msg , $ this -> privateKeyPath ) ) ; } return $ privateKe...
Get the private key .
9,297
protected function & getArrayByReference ( & $ offset ) { $ offset = explode ( self :: SEPARATOR , $ offset ) ; if ( count ( $ offset ) > 1 ) { $ arr = & $ this -> getFromArray ( $ this -> storage , array_slice ( $ offset , 0 , - 1 ) , false ) ; } else { $ arr = & $ this -> storage ; } $ offset = array_slice ( $ offset...
Returns reference to sub array
9,298
protected function & getFromArray ( & $ array , $ keys , $ default = null ) { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ array [ $ key ] ) ) { return $ default ; } if ( empty ( $ keys ) ) { return $ array [ $ key ] ; } return $ this -> getFromArray ( $ array [ $ key ] , $ keys , $ default ) ; }
Returns array element matching key
9,299
protected function setIntoArray ( & $ array , $ keys , $ value ) { $ k = array_shift ( $ keys ) ; if ( is_scalar ( $ array ) ) { $ array = ( array ) $ array ; } if ( ! isset ( $ array [ $ k ] ) ) { $ array [ $ k ] = null ; } if ( empty ( $ keys ) ) { return $ array [ $ k ] = & $ value ; } return $ this -> setIntoArray ...
Sets array elements value