idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
2,400
public function post ( $ resource , $ content ) { $ url = $ this -> baseUrl . $ resource ; $ headers = array ( 'Content-Type' => 'application/json' , 'Authorization' => $ this -> auth -> getCredential ( ) ) ; try { $ response = $ this -> browser -> post ( $ url , $ headers , json_encode ( $ content ) ) ; } catch ( \ Bu...
Common post request for all API calls
2,401
protected function filter ( $ value ) { if ( ! is_scalar ( $ value ) ) { return $ value ; } $ value = ( string ) $ value ; if ( ! $ this -> hasPcreUnicodeSupport ( ) ) { return preg_replace ( '/[^0-9]/' , '' , $ value ) ; } if ( extension_loaded ( 'mbstring' ) ) { return preg_replace ( '/[^[:digit:]]/' , '' , $ value )...
Lifted entirely from the Zend framework so that we don t have to include the Zend \ Filter package and all its dependencies .
2,402
public function getNewToken ( ) { $ post = array ( 'auth' => array ( 'username' => $ this -> username , 'password' => $ this -> password , ) , ) ; return $ this -> http -> call ( HttpMethod :: POST , $ this -> host . '/auth' , $ post ) -> token ; }
Get a new auth token from server
2,403
public function setSaveOptions ( $ file_name = null , $ directory = null , $ suffix = null ) { if ( $ directory ) { $ this -> _save_dir = rtrim ( $ directory , DIRECTORY_SEPARATOR ) ; } else if ( ! $ this -> _save_dir ) { $ this -> _save_dir = $ this -> _image_info [ 'dirname' ] ; } if ( ! is_dir ( $ directory ) ) { mk...
Set Saving Options
2,404
public function setOutputFormat ( $ format = null , $ quality = null , $ filters = null ) { if ( $ format ) { $ format = strtolower ( $ format ) ; if ( in_array ( $ format , static :: $ _allowed_formates ) ) { $ this -> _output_format = $ format ; if ( $ this -> _save_path ) { $ this -> _save_name = preg_replace ( '/(?...
Setting Output Format
2,405
public function exportImage ( $ keep_resource = false ) { array_unshift ( $ this -> _output_options , $ this -> _image_resource , $ this -> _save_path ) ; switch ( $ this -> _output_format ) { case 'jpeg' : case 'jpg' : if ( ! $ this -> _save_path ) { header ( 'content-type: image/jpeg' ) ; } $ result = call_user_func_...
Save Or Output Current Image Resource
2,406
public function embed ( $ keep_resource = false ) { ob_start ( ) ; switch ( $ this -> _output_format ) { case 'jpeg' : case 'jpg' : imagejpeg ( $ this -> _image_resource ) ; break ; case 'png' : imagepng ( $ this -> _image_resource ) ; break ; case 'gif' : imagegif ( $ this -> _image_resource ) ; break ; } $ str = ob_g...
Get Image as embeded code
2,407
public function reset ( ) { if ( ! $ this -> _image_resource_backup ) { throw new ImageException ( 'Cannot restore, no backup has been taken for image resource' ) ; } $ cloned = $ this -> cloneResource ( $ this -> _image_resource_backup ) ; $ this -> _image_resource = $ cloned [ 'resource' ] ; $ this -> updateImageInfo...
Restore Image resource from backup
2,408
private function updateImageInfo ( $ width , $ height ) { $ this -> _image_info [ 0 ] = $ width ; $ this -> _image_info [ 1 ] = $ height ; $ this -> _image_info [ 3 ] = 'width="' . $ width . '" height="' . $ height . '"' ; $ this -> _image_info [ 'aspect' ] = $ width / $ height ; }
Update Image Resource Info
2,409
protected function getRGBFromRange ( $ r , $ g , $ b , $ range ) { if ( ! $ range ) { return array ( $ r , $ g , $ b ) ; } $ range = round ( $ range / 2 ) ; $ color = array ( ) ; $ min = $ r - $ range ; $ max = $ r + $ range ; if ( $ min < 0 ) { $ min = 0 ; } if ( $ max > 255 ) { $ max = 255 ; } $ color [ 'r' ] = $ col...
Get Random RGB Values on a specific range
2,410
private function cloneResource ( $ resource ) { $ w = imagesx ( $ resource ) ; $ h = imagesy ( $ resource ) ; $ trans = imagecolortransparent ( $ resource ) ; if ( imageistruecolor ( $ resource ) ) { $ clone = imagecreatetruecolor ( $ w , $ h ) ; imagealphablending ( $ clone , false ) ; imagesavealpha ( $ clone , true ...
Clone Image Resource
2,411
public function composer ( $ views , $ callback ) { foreach ( ( array ) $ views as $ view ) { if ( $ callback instanceof Closure === false ) { $ callback = function ( ) use ( $ callback ) { return $ callback ; } ; } if ( $ view === '*' ) { $ this -> composers [ '*' ] [ ] = $ callback ; continue ; } $ view = $ this -> v...
Register preprocess with views .
2,412
protected function extension ( $ view ) { $ extensions = $ this -> extensions ( ) ; $ ext_reg = '/(' . implode ( '|' , $ extensions ) . ')+$/' ; if ( preg_match ( $ ext_reg , $ view ) ) { return $ template ; } return substr ( $ view , - strlen ( $ extensions [ 0 ] ) ) === $ extensions [ 0 ] ? $ view : $ view . $ extens...
Add extension to the view string if it don t exists .
2,413
public function create_data ( $ data = [ ] ) { if ( is_object ( $ data ) && method_exists ( $ data , 'to_array' ) ) { return $ data -> to_array ( ) ; } return is_array ( $ data ) ? $ data : [ ] ; }
Create view data .
2,414
public function get_composer ( View $ view ) { $ view_name = $ view -> get_name ( ) ; if ( isset ( $ this -> composers [ $ view_name ] ) ) { return $ this -> composers [ $ view_name ] ; } return [ ] ; }
Call composer .
2,415
protected function view ( $ view ) { if ( preg_match ( '/\.\w+$/' , $ view , $ matches ) && in_array ( $ matches [ 0 ] , $ this -> extensions ( ) ) ) { return str_replace ( '.' , '/' , preg_replace ( '/' . $ matches [ 0 ] . '$/' , '' , $ view ) ) . $ matches [ 0 ] ; } return $ this -> extension ( str_replace ( '.' , '/...
Get the right view string from dot view or view that missing extension .
2,416
protected function reset_composer ( View $ view ) { $ view_name = $ view -> get_name ( ) ; if ( isset ( $ this -> composers [ $ view_name ] ) ) { unset ( $ this -> composers [ $ view_name ] ) ; } }
Reset view composer .
2,417
public static function getControlCapabilities ( ) { $ caps = array ( ) ; foreach ( array_keys ( self :: $ virtualCapabilities ) as $ capabilityName ) { $ caps [ ] = self :: PREFIX_CONTROL . $ capabilityName ; } return $ caps ; }
Returns an array of all the control capabilities
2,418
static function sql_exec ( $ db , $ bindings , $ sql = null ) { if ( $ sql === null ) { $ sql = $ bindings ; } $ stmt = $ db -> prepare ( $ sql ) ; if ( is_array ( $ bindings ) ) { for ( $ i = 0 , $ ien = count ( $ bindings ) ; $ i < $ ien ; $ i ++ ) { $ binding = $ bindings [ $ i ] ; $ stmt -> bindValue ( $ binding [ ...
Execute an SQL query on the database
2,419
static function pluck ( $ a , $ prop ) { $ out = array ( ) ; for ( $ i = 0 , $ len = count ( $ a ) ; $ i < $ len ; $ i ++ ) { $ out [ ] = $ a [ $ i ] [ $ prop ] ; } return $ out ; }
Pull a particular property from each assoc . array in a numeric array returning and array of the property values from each item .
2,420
public function parse ( $ configFile = '' ) { $ defaultConfigFile = $ this -> getConfigFile ( $ configFile , 'default' ) ; $ defaultConfigArray = parent :: parse ( $ defaultConfigFile ) ? : [ ] ; $ envConfigFile = $ this -> getConfigFile ( $ configFile , $ this -> app -> getEnvironment ( ) ) ; $ envConfigArray = parent...
Parse the configuration file and get the configuration array .
2,421
private function getConfigFile ( $ configFile , $ environment = 'default' ) { $ configFile = $ configFile ? : 'config' ; $ envConfigFile = $ this -> app -> getConfigPath ( ) . DIRECTORY_SEPARATOR . $ configFile . '-' . $ environment . '.php' ; if ( ! is_file ( $ envConfigFile ) ) { $ envConfigFile = $ this -> app -> ge...
Get the configuration file according to the given environment if any .
2,422
public function init ( Parser $ parser , Lexer $ lexer ) { $ parser -> setStartRule ( $ this -> startRule ) ; foreach ( $ this -> rules as $ rule ) { $ parser -> addRule ( $ rule ) ; } $ parser -> setLexer ( $ lexer ) ; $ lexer -> setParser ( $ parser ) ; return $ this ; }
Set start rule and add set s rules to parser
2,423
protected function addRule ( AbstractRule $ rule , $ category = self :: CATEGORY_NONE ) { $ rule -> setRuleSet ( $ this ) ; $ this -> rules [ ] = $ rule ; $ this -> categories [ $ category ] [ ] = $ rule ; return $ this ; }
Add new rule to set
2,424
protected function getListeners ( string $ eventName ) : array { if ( ! isset ( $ this -> listeners [ $ eventName ] ) ) { return [ ] ; } if ( ! isset ( $ this -> sortedListeners [ $ eventName ] ) ) { $ this -> sortedListeners [ $ eventName ] = $ this -> sortEventListeners ( $ eventName ) ; } return $ this -> sortedList...
Returns array of event listeners .
2,425
protected function sortEventListeners ( string $ eventName ) : array { $ listeners = $ this -> listeners [ $ eventName ] ; $ normalised = [ ] ; ksort ( $ listeners ) ; foreach ( $ listeners as $ priorityListeners ) { foreach ( $ priorityListeners as $ listener ) { $ normalised [ ] = $ listener ; } } return $ normalised...
Merges all event listeners for particular event .
2,426
public function cssClass ( $ type ) { $ framework = $ this -> getFramework ( ) ; $ classes = $ this -> getClasses ( $ framework ) ; if ( property_exists ( $ classes , $ type ) ) { return $ classes -> $ type ; } return '' ; }
Get the css class for a given object type .
2,427
public function columns ( $ xs , $ sm , $ md , $ lg ) { $ framework = $ this -> getFramework ( ) ; switch ( $ framework ) { case 'bs3' : case 'bs4' : $ xsC = $ this -> cssClass ( 'column_extra_small' ) . $ xs ; $ smC = $ this -> cssClass ( 'column_small' ) . $ sm ; $ mdC = $ this -> cssClass ( 'column_medium' ) . $ md ...
Create framework column class .
2,428
public function getClasses ( $ framework ) { switch ( $ framework ) { case 'bs3' : $ classes = $ this -> json -> bs3 ; break ; case 'bs4' : $ classes = $ this -> json -> bs4 ; break ; case 'f6' : $ classes = $ this -> json -> f6 ; break ; case '' : default : return '' ; } return $ classes ; }
Get the css class matrix for the given framework .
2,429
public function send ( $ to , $ subject , $ body ) { if ( \ Sifo \ Domains :: getInstance ( ) -> getDebugMode ( ) ) { $ this -> _dispatchMailController ( $ to , $ subject , $ body ) ; } return parent :: send ( $ to , $ subject , $ body ) ; }
Send an email whith debug interruption .
2,430
protected function selectChoice ( ) { $ index = array_search ( $ this -> choices [ $ this -> cursor -> getPosition ( ) ] , $ this -> answers ) ; if ( false !== $ index ) { unset ( $ this -> answers [ $ index ] ) ; } else { $ this -> answers [ ] = $ this -> choices [ $ this -> cursor -> getPosition ( ) ] ; } $ this -> a...
Allows selecting multiple choices
2,431
public function sanitize ( $ var ) { global $ smcFunc ; if ( is_array ( $ var ) ) { foreach ( $ var as $ k => $ v ) $ var [ $ k ] = $ this -> sanitize ( $ v ) ; return $ var ; } else { $ var = ( string ) $ smcFunc [ 'htmltrim' ] ( $ smcFunc [ 'htmlspecialchars' ] ( $ var ) , ENT_QUOTES ) ; if ( ctype_digit ( $ var ) ) ...
Sanitizes a var . Recursive . Treats any var as a string and cast it as an integer if necessary .
2,432
public function getStdClass ( $ formatAble = false ) { $ object = new stdClass ( ) ; $ object -> testProperty = 'test' ; $ object -> nullProperty = null ; $ object -> arrayProperty = [ 'level1' => [ 'level2a' => null , 'level2' => [ 'level3' => 'value' , 'level3b' => null , ] , ] , ] ; if ( $ formatAble ) { $ object = ...
Get stdClass dummy data .
2,433
public function getStdClassWithArray ( $ formatAble = false ) { $ object = new stdClass ( ) ; $ object -> array = [ [ 'key' => 'value' , 'key2' => 'value2' , ] , ] ; if ( $ formatAble ) { $ object = Manager :: formatAble ( $ object ) ; } return $ object ; }
Get stdClass dummy data with array .
2,434
public function getPost ( $ formatAble = false ) { $ post = Post :: published ( ) -> first ( ) ; $ post = self :: fix ( $ post ) ; if ( $ formatAble ) { $ post = Manager :: formatAble ( $ post ) ; } return $ post ; }
Get WordPress dummy data .
2,435
public function getMultiplePosts ( $ formatAble = false ) { $ posts = Post :: published ( ) -> get ( ) ; foreach ( $ posts as $ key => $ post ) { $ posts [ $ key ] = self :: fix ( $ post ) ; if ( $ formatAble ) { $ posts [ $ key ] = Manager :: formatAble ( $ posts [ $ key ] ) ; } } return $ posts ; }
Get multiple WordPress data .
2,436
final public function offsetSet ( $ index , $ value ) : void { if ( is_null ( $ index ) ) { throw CannotAlterCollection :: byAddingTo ( $ this ) ; } throw CannotAlterCollection :: byOverWriting ( $ this , $ index ) ; }
Disallows use of the offsetSet method .
2,437
public function get ( $ key , $ locale , $ package = 'default' , $ default = null ) { if ( empty ( $ key ) ) { return $ default ; } $ package = ( $ package ? : 'default' ) ; try { $ this -> loadTranslations ( $ locale , $ package ) ; $ array = ( static :: $ translations [ $ locale ] ? : [ ] ) ; $ value = ArrayHelper ::...
Get a translation value . If the default value is null and no translation is found it throws Exception .
2,438
public static function create ( $ field ) : RowFieldNormalizerInterface { switch ( $ field ) { case Quotation :: ACTIVE : return new ActiveNormalizer ( ) ; case Quotation :: ASSISTS_MAGIC_POINTS : return new AssistsMagicPointsNormalizer ( ) ; case Quotation :: ASSISTS : return new AssistsNormalizer ( ) ; case Quotation...
Returns an implementation of RowFieldNormalizerInterface
2,439
public function available ( $ id , $ start , $ end ) { $ param = array ( 'start' => date ( "Y-m-d\TH:i:s\Z" , $ start ) , 'end' => date ( "Y-m-d\TH:i:s\Z" , $ end ) ) ; return $ this -> get ( 'metrics/definitions/' . urlencode ( $ id ) , $ param ) ; }
Get available metrics
2,440
public function metrics ( $ id , $ filter , $ start , $ end ) { $ param = array ( 'start' => date ( "Y-m-d\TH:i:s\Z" , $ start ) , 'end' => date ( "Y-m-d\TH:i:s\Z" , $ end ) , 'filter' => $ filter ) ; $ param = $ this -> makeJsonReady ( $ param ) ; return $ this -> get ( 'metrics/graphs/' . urlencode ( $ id ) , $ param...
Get actual metrics
2,441
public function dynamicMetrics ( $ filter , $ start , $ end , $ inventoryFilter = Null ) { $ urlencoded = '' ; $ query = array ( ) ; if ( isset ( $ inventoryFilter ) ) { $ query [ 'inventoryFilter' ] = $ inventoryFilter ; } if ( ! empty ( $ query ) ) { $ urlencoded = '?' . http_build_query ( $ query ) ; } $ param = arr...
Get dynamic metrics
2,442
protected function executePayload ( $ payload , $ args ) { array_unshift ( $ args , $ this -> wrapped ) ; if ( $ payload instanceof Mutator ) { $ this -> wrapped = call_user_func_array ( $ payload , $ args ) ; return $ this ; } else { return call_user_func_array ( $ payload , $ args ) ; } }
Payload is either Mutator or Accessor . Both are supposed to be callable .
2,443
public function getElseSet ( string $ key , int $ ttl , callable $ callable ) { if ( $ this -> exists ( $ key ) ) { return $ this -> get ( $ key ) ; } try { $ callable_data = call_user_func ( $ callable ) ; } catch ( Exception $ e ) { } $ this -> set ( $ key , $ callable_data ) ; $ this -> expireAt ( $ key , time ( ) +...
Get the cache key . If it does not exist execute the callable and set the cache key .
2,444
public function findByAuth ( $ provider , $ identifier ) { $ user = null ; $ login = $ this -> repository -> findByAuth ( $ provider , $ identifier ) ; if ( $ login !== null ) $ user = $ login -> getUser ( ) ; return $ user ; }
Attempt to find a UserInterface by given login credentials returns the UserInterface or null on error
2,445
public static function instance ( ) { if ( ! isset ( self :: $ instance ) ) { self :: $ instance = new self ; self :: $ instance -> boot ( ) ; self :: $ instance -> setup_actions ( ) ; } return self :: $ instance ; }
Get Plugin boilerplate loader instance .
2,446
public static function config ( $ key , $ value = null ) { return self :: factory ( ) -> engine ( ) -> config ( $ key , $ value ) ; }
Get or set configuration value .
2,447
public function load_extensions ( ) { $ extensions = [ new \ Frozzare \ Digster \ Extensions \ Filter_Extensions ( ) , new \ Frozzare \ Digster \ Extensions \ Function_Extensions ( ) , new \ Frozzare \ Digster \ Extensions \ Global_Extensions ( ) , new \ Frozzare \ Digster \ Extensions \ I18n_Extensions ( ) ] ; $ exten...
Load Digster extensions .
2,448
public static function view ( $ view = null , array $ data = [ ] ) { if ( func_num_args ( ) === 0 ) { return self :: factory ( ) ; } return self :: factory ( ) -> make ( $ view , $ data ) ; }
Get the view class .
2,449
public static function resolveClass ( $ resource , $ id = null ) { $ class = 'IXF\\' . $ resource ; if ( class_exists ( $ class ) ) return new $ class ( $ id ) ; return new IXF \ ApiResource ( $ id ) ; }
If a class exists for the given resource return an instance of it else return an instance of the generic ApiResouce class .
2,450
public static function retrieve ( $ resource , $ id ) { $ instance = self :: resolveClass ( $ resource , $ id ) ; $ instance -> refresh ( $ resource ) ; return $ instance ; }
Retrieve an object by ID
2,451
public function refresh ( $ resource ) { $ url = $ url = '/' . $ resource . '/' . $ this -> id ; $ requestor = new ApiRequestor ( ) ; $ response = $ requestor -> request ( 'get' , $ url , $ this -> _retrieveOptions ) ; $ this -> refreshFrom ( $ response [ 0 ] ) ; return $ this ; }
Refresh the current object from the API service
2,452
public static function all ( $ resource , $ params = null ) { self :: _validateCall ( 'all' , $ params ) ; $ requestor = new ApiRequestor ( ) ; $ url = '/' . $ resource ; $ response = $ requestor -> request ( 'get' , $ url , $ params ) ; return Util :: convertToIxfObject ( $ response ) ; }
Get all objects of a given resource
2,453
public function save ( ) { $ requestor = new ApiRequestor ( ) ; $ params = $ this -> serializeParameters ( ) ; self :: _validateCall ( 'save' , $ params ) ; unset ( $ params [ 'id' ] ) ; if ( count ( $ params ) > 0 ) { $ url = '/' . $ this -> getType ( ) . '/' . $ this -> id ; return $ requestor -> request ( 'put' , $ ...
Save an object
2,454
public function toString ( ) { $ email = '<' . Mime :: encodeEmail ( $ this -> email ( ) ) . '>' ; $ name = $ this -> name ( ) ; return $ name ? Mime :: encodeValue ( $ name ) . ' ' . $ email : $ email ; }
Return the encoded representation of the address
2,455
private function encodeCollection ( CollectionInterface $ action_result , ResponseInterface $ response ) { $ response = $ response -> write ( json_encode ( $ action_result ) ) -> withStatus ( 200 ) ; if ( $ action_result -> canBeEtagged ( ) ) { if ( $ action_result -> getApplicationIdentifier ( ) != $ this -> app_ident...
Encode DataObject collection .
2,456
private function encodeSingle ( ObjectInterface $ action_result , ResponseInterface $ response ) { $ result = [ 'single' => $ action_result ] ; foreach ( $ action_result -> jsonSerializeDetails ( ) as $ k => $ v ) { if ( $ k == 'single' ) { throw new LogicException ( "JSON serialize details can't overwrite 'single' pro...
Encode individual DataObject object .
2,457
protected function encodeJsonSerializable ( JsonSerializable $ action_result , ResponseInterface $ response , $ status = 200 ) { return $ response -> write ( json_encode ( $ action_result ) ) -> withStatus ( $ status ) ; }
Encode JsonSerializable instance response with status 200 .
2,458
private function encodeUserSessionResponse ( UserSessionResponseInterface $ action_result , ServerRequestInterface $ request , ResponseInterface $ response ) { if ( $ action_result -> getAuthenticatedWith ( ) instanceof SessionInterface ) { $ response = $ this -> getCookiesProvider ( ) -> set ( $ request , $ response ,...
Encode user session action results and return properly populated response .
2,459
private function encodeUserSessionTerminatedResponse ( UserSessionTerminateResponseInterface $ action_result , ServerRequestInterface $ request , ResponseInterface $ response ) { $ response = $ this -> getCookiesProvider ( ) -> remove ( $ request , $ response , $ this -> getUserSessionIdCookieName ( ) ) [ 1 ] ; return ...
Encode user session terminated action results and return properly populated response .
2,460
private function _getFileContent ( ) { if ( ! isset ( $ this -> _index_file_content ) ) { if ( ! ( $ this -> _index_file_content = file_get_contents ( $ this -> _root_page_path ) ) ) { trigger_error ( "Root file not found. Please, validate the path." , E_USER_ERROR ) ; } } return $ this -> _index_file_content ; }
Return the platform index file content .
2,461
private function _enablePage ( ) { if ( $ this -> test ) { return true ; } $ enabled_source = $ this -> _getEnablingCode ( ) . $ this -> _getFileContent ( ) ; return file_put_contents ( $ this -> _root_page_path , $ enabled_source ) ; }
Enable the replacement page .
2,462
private function _disablePage ( ) { if ( $ this -> test ) { return true ; } $ disabled_source = str_replace ( $ this -> _getEnablingCode ( ) , '' , $ this -> _getFileContent ( ) ) ; return file_put_contents ( $ this -> _root_page_path , $ disabled_source ) ; ; }
Disable the replacement page . Normal page is enabled .
2,463
public function getAllStations ( DWDHourlyParameters $ hourlyParameters , bool $ active = false ) { $ services = $ this -> createServices ( $ hourlyParameters ) ; $ crawler = new DWDHourlyCrawler ( $ services ) ; return $ crawler -> getAllStations ( $ active ) ; }
Retrieve all stations for the parameters
2,464
private function createServices ( DWDHourlyParameters $ variables ) : array { $ conf = DWDConfiguration :: getHourlyConfiguration ( ) -> parameters ; $ controllers = array ( ) ; if ( ! empty ( $ variables -> getVariables ( ) ) ) { foreach ( $ variables -> getVariables ( ) as $ var ) { switch ( $ var ) { case $ conf -> ...
Create a new instance of the appropriate controller .
2,465
protected function bootMiddleWares ( ) { if ( isset ( $ this -> middleWares [ 'boot' ] ) && count ( $ this -> middleWares [ 'boot' ] ) ) { foreach ( $ this -> middleWares [ 'boot' ] as $ middleware => $ handler ) { $ this -> container -> call ( [ $ this -> container -> make ( $ middleware ) , $ handler ] ) ; } return [...
Resolve application boot middleware .
2,466
protected function resolveDependencies ( array $ dependencies ) { foreach ( $ dependencies as $ dependency => $ type ) { call_user_func_array ( [ $ this , $ type ] , [ $ dependency ] ) ; } }
Application dependency binding to container .
2,467
private function expandShorthandDefinitions ( ) { foreach ( $ this -> mapping as $ key => $ settings ) { if ( is_string ( $ key ) && is_string ( $ settings ) ) { $ this -> mapping [ $ key ] = [ 'type' => 'column' , 'mapping' => [ 'destination' => $ settings ] ] ; } } }
Expands shorthand definitions to theirs full definition
2,468
public function getCsvFiles ( ) { $ childResults = [ ] ; foreach ( $ this -> parsers as $ type => $ parser ) { $ childResults += $ parser -> getCsvFiles ( ) ; } $ results = array_merge ( [ $ this -> type => $ this -> result ] , $ childResults ) ; return $ results ; }
Return own result and all children
2,469
public function isValid ( ) { if ( $ this -> isValid === null ) $ this -> isValid = $ this -> validate ( ) ; return $ this -> isValid ; }
Returns true if this length unit is valid .
2,470
public function compareTo ( $ l ) { if ( $ l === false ) return false ; if ( $ l -> unit !== $ this -> unit ) { $ converter = new HTMLPurifier_UnitConverter ( ) ; $ l = $ converter -> convert ( $ l , $ this -> unit ) ; if ( $ l === false ) return false ; } return $ this -> n - $ l -> n ; }
Compares two lengths and returns 1 if greater - 1 if less and 0 if equal .
2,471
public function sortAscending ( array $ prefList ) { $ comparator = new MatchedPreferenceComparator ( ) ; usort ( $ prefList , function ( MatchedPreferenceInterface $ lValue , MatchedPreferenceInterface $ rValue ) use ( $ comparator ) { return - 1 * $ comparator -> compare ( $ lValue , $ rValue ) ; } ) ; return $ prefL...
Sort the array of MatchedPreference instances in ascending order .
2,472
public static function fromDefaults ( ) { $ handler = new HandlerLDAP ( config ( 'ldap.host' ) , config ( 'ldap.basedn' ) , config ( 'ldap.dn' ) , config ( 'ldap.password' ) , config ( 'ldap.search_user_id' ) , config ( 'ldap.search_username' ) , config ( 'ldap.search_user_mail' ) , config ( 'ldap.search_user_mail_arra...
Returns a HandlerLDAP instance based on the default configuration .
2,473
protected function addMessage ( $ instance ) { $ message = \ Sifo \ FilterPost :: getInstance ( ) -> getString ( 'msgid' ) ; $ translator_model = new I18nTranslatorModel ( ) ; $ instance_domains = $ this -> getConfig ( 'domains' , $ instance ) ; $ instance_inheritance = array ( ) ; if ( isset ( $ instance_domains [ 'in...
Add message .
2,474
protected function customizeTranslation ( ) { $ message = \ Sifo \ FilterPost :: getInstance ( ) -> getString ( 'msgid' ) ; $ id_message = null ; if ( is_numeric ( $ message ) ) { $ id_message = $ message ; } $ instance = $ this -> getParsedParam ( 'instance' ) ; $ translator_model = new I18nTranslatorModel ( ) ; $ id_...
Customize translation .
2,475
public function handleError ( HTTPInputRequest $ request , HTTPOutputResponse $ response , \ Throwable $ e ) : void { if ( $ e instanceof HTTPError ) { $ e -> generateErrorResponse ( ) ; } throw $ e ; }
Handle HTTP error or other \ Throwable instance throwed under HTTP access .
2,476
public function indexAction ( ) { $ view = new ViewModel ( ) ; $ service = $ this -> getThemeService ( ) ; $ view -> registeredThemes = $ service -> getRegisteredThemes ( ) ; $ view -> options = $ this -> getModuleOptions ( ) ; $ flashMessenger = $ this -> flashMessenger ( ) ; if ( $ flashMessenger -> hasMessages ( ) )...
Show list of themes .
2,477
public function enableAction ( ) { $ themeName = $ this -> params ( ) -> fromRoute ( 'theme' ) ; if ( ! $ themeName ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'Theme was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/theme' ) -> setStatusCode ( 303 ) ; } $ servi...
Enable theme .
2,478
public function disableAction ( ) { $ themeName = $ this -> params ( ) -> fromRoute ( 'theme' ) ; if ( ! $ themeName ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'Theme was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/theme' ) -> setStatusCode ( 303 ) ; } $ serv...
Disable theme .
2,479
public function defaultAction ( ) { $ themeName = $ this -> params ( ) -> fromRoute ( 'theme' ) ; if ( ! $ themeName ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'Theme was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/theme' ) -> setStatusCode ( 303 ) ; } $ side...
Set the default theme .
2,480
public static function self ( array $ option = array ( ) ) { if ( ! self :: $ self ) { self :: $ self = new self ( $ option ) ; } return self :: $ self ; }
Instance for current process
2,481
public function parallel ( $ closure , $ options = array ( ) , $ start = true ) { if ( is_bool ( $ options ) ) { $ start = $ options ; $ options = array ( ) ; } if ( $ closure instanceof Process ) { $ child = $ closure ; $ closure = $ child -> runner ; $ options = $ child -> options ; } else { $ child = new Process ( $...
Run the closure in parallel space
2,482
public function daemonize ( ) { $ pid = pcntl_fork ( ) ; if ( $ pid === - 1 ) { throw new \ RuntimeException ( 'Unable to fork child process.' ) ; } else if ( $ pid ) { exit ; } posix_setsid ( ) ; if ( $ pid === - 1 ) { throw new \ RuntimeException ( 'Unable to fork child process.' ) ; } else if ( $ pid ) { exit ; } $ ...
Make the process daemonize
2,483
public function listen ( ) { if ( ! $ this -> queue ) { $ this -> queue = msg_get_queue ( $ this -> pid ) ; $ this -> emit ( 'listen' ) ; } return $ this ; }
Register message listener
2,484
protected function childInitialize ( array $ options = array ( ) ) { $ this -> prepared = false ; $ this -> removeAllListeners ( ) ; $ this -> master = false ; $ pid = posix_getpid ( ) ; $ this -> ppid = $ this -> pid ; $ this -> pid = $ pid ; $ this -> queue = null ; $ this -> process = new Process ( $ this , $ this -...
Init child process
2,485
protected function childProcessOptions ( $ options ) { if ( $ options [ 'cwd' ] ) { chdir ( $ options [ 'cwd' ] ) ; } if ( $ options [ 'user' ] ) { $ this -> childChangeUser ( $ options [ 'user' ] ) ; } if ( $ options [ 'env' ] ) { $ this -> childChangeEnv ( $ options [ 'env' ] ) ; } if ( $ options [ 'timeout' ] ) { $ ...
Process options in child
2,486
protected function tryChangeUser ( $ user ) { $ changed_user = false ; if ( $ user && posix_getuid ( ) > 0 ) { throw new \ RuntimeException ( 'Only root can change user to spawn the process' ) ; } if ( $ user && ! ( $ changed_user = posix_getpwnam ( $ user ) ) ) { throw new \ RuntimeException ( 'Can not look up user: '...
Try to change user
2,487
protected function childSetTimeout ( $ timeout ) { $ start_time = time ( ) ; $ self = $ this ; $ this -> on ( 'tick' , function ( ) use ( $ timeout , $ start_time , $ self ) { if ( $ start_time + $ timeout < time ( ) ) $ self -> shutdown ( 1 ) ; } ) ; }
Try to set timeout
2,488
protected function childChangeUser ( $ user ) { if ( is_array ( $ user ) || ( $ user = $ this -> tryChangeUser ( $ user ) ) ) { posix_setgid ( $ user [ 'gid' ] ) ; posix_setuid ( $ user [ 'uid' ] ) ; } }
Process change user
2,489
protected function signalHandlerDefault ( $ signal ) { switch ( $ signal ) { case SIGTERM : case SIGINT : while ( $ this -> children ) { foreach ( $ this -> children as $ child ) { $ ok = $ child -> kill ( SIGINT ) ; if ( posix_get_last_error ( ) == 1 ) $ ok = false ; if ( $ ok ) { $ child -> emit ( 'abort' , $ signal ...
Default signal handler
2,490
public function shutdown ( $ status = 0 , $ info = null ) { if ( ! $ this -> process -> isExit ( ) ) { $ this -> process -> status = $ status ; $ this -> emit ( 'exit' , $ status , $ info ) ; $ this -> process -> emit ( 'exit' , $ status , $ info ) ; } }
Shutdown with status
2,491
protected function registerTickHandlers ( ) { $ self = $ this ; register_tick_function ( function ( ) use ( $ self ) { if ( ! $ self -> prepared ) { return ; } if ( $ self -> master ) { while ( $ pid = pcntl_wait ( $ status , WNOHANG ) ) { if ( $ pid === - 1 ) { pcntl_signal_dispatch ( ) ; break ; } if ( empty ( $ self...
Register tick handlers
2,492
static function getDataFromZip ( $ zipFile , $ extractionPrefix ) { $ zip = new ZipArchive ; self :: log ( self :: class , "zip=" . $ zipFile ) ; if ( $ zip -> open ( $ zipFile ) ) { for ( $ i = 0 ; $ i < $ zip -> numFiles ; $ i ++ ) { $ stat = $ zip -> statIndex ( $ i ) ; if ( substr ( $ stat [ 'name' ] , 0 , strlen (...
Extract the single file we need to use to get the data .
2,493
public function datetime ( $ name , $ value = null , $ options = [ ] ) { $ value = $ this -> getValueAttribute ( $ name , $ value ) ; $ timeValue = $ dateValue = null ; if ( $ value instanceof \ DateTime ) { $ dateValue = $ value -> format ( 'Y-m-d' ) ; $ timeValue = $ value -> format ( 'H:i' ) ; } return $ this -> dat...
Create a date and a time input field .
2,494
public function validateSweetcaptcha ( $ attribute , $ value , $ parameters ) { if ( Input :: has ( 'scvalue' ) ) { $ sweetcaptcha = app ( ) -> make ( 'SweetCaptcha' ) ; return $ sweetcaptcha -> check ( array ( 'sckey' => $ value , 'scvalue' => Input :: get ( 'scvalue' ) ) ) == "true" ; } else return false ; }
Validation method for the Sweet Captcha input values .
2,495
public static function setClient ( $ input = null ) { self :: $ client = ( $ input instanceof Google_client ) ? $ input : new Google_Client ( ) ; if ( is_array ( $ input ) ) { foreach ( $ input as $ key => $ value ) { $ method = "set" . ucfirst ( $ key ) ; if ( ! method_exists ( self :: $ client , $ method ) ) { throw ...
New a Google_Client with config or set Google_Client by giving
2,496
public static function verifyAccessToken ( $ accessToken = null ) { if ( null === $ accessToken ) { $ token = self :: getClient ( ) -> getAccessToken ( ) ; if ( ! isset ( $ token [ 'access_token' ] ) ) { throw new Exception ( 'access_token must be passed in or set as part of setAccessToken' ) ; } $ accessToken = $ toke...
Verify an access_token . This method will verify the current access_token by Google API if one isn t provided .
2,497
public static function verifyScopes ( $ scopes , $ accessToken = null ) { if ( ! $ tokenInfo = self :: verifyAccessToken ( $ accessToken ) ) return false ; $ scopeString = $ tokenInfo [ 'scope' ] ; foreach ( $ scopes as $ key => $ scope ) { if ( stripos ( $ scopeString , $ scope ) === false ) return false ; } return tr...
Verify scopes of tokenInfo by access_token . This method will verify the current access_token by Google API if one isn t provided .
2,498
public function setId ( Schema $ schema , $ id ) { $ reset_unique_field = ( $ schema -> getUniqueFieldId ( ) === $ this -> _id ) ; $ schema -> removeField ( $ this -> _id ) ; $ this -> _id = $ id ; $ schema -> attachField ( $ this ) ; if ( $ reset_unique_field ) { $ schema -> setUniqueField ( $ id ) ; } return $ this ;...
Resets the unique identifier of the field .
2,499
public function setName ( Schema $ schema , $ name ) { $ schema -> removeField ( $ this -> _id ) ; $ this -> _name = $ name ; $ schema -> attachField ( $ this ) ; return $ this ; }
Sets the name of the field as stored in the index .