idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
17,100
public function decrement ( $ key , $ value , \ DatePeriod $ period = null ) { if ( is_null ( $ period ) ) { $ this -> repository -> decrement ( $ key , $ value ) ; } else { $ this -> decrementForPeriod ( $ key , $ value , $ period ) ; } }
Decrement value .
17,101
protected function decrementForPeriod ( $ key , $ value , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { foreach ( $ ranges as $ range ) { $ range instanceof DateRange ? $ this -> repository -> decrementForRange ( $ key , $ range -> getStartDate ( ) , $ range -> getEndDate ( ) , $ value ) : $ this -> repository -> decrementFor ( $ key , $ range , $ value ) ; } } }
Decrement value for a given period .
17,102
protected function removeForPeriod ( $ key , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { foreach ( $ ranges as $ range ) { $ range instanceof DateRange ? $ this -> repository -> removeForRange ( $ key , $ range -> getStartDate ( ) , $ range -> getEndDate ( ) ) : $ this -> repository -> removeFor ( $ key , $ range ) ; } } }
Remove value for a given period .
17,103
protected function getRanges ( \ DatePeriod $ period ) { $ ranges = array ( ) ; $ start = null ; $ end = null ; $ single = true ; foreach ( $ period as $ i => $ date ) { $ ranges [ $ i ] = $ date ; if ( $ i > 0 ) { $ ranges [ $ i - 1 ] = new DateRange ( $ ranges [ $ i - 1 ] , $ date ) ; $ single = false ; } } if ( ! $ single ) { array_pop ( $ ranges ) ; } return $ ranges ; }
Generate date ranges from given period .
17,104
public function prepareFileUploadRequest ( array $ files , $ relativePath = null , array $ data = [ ] , array $ query = [ ] ) { $ request = $ this -> prepareRequest ( 'POST' , $ relativePath , [ ] , $ query ) ; $ request -> getHeaders ( ) -> removeHeader ( $ request -> getHeaders ( ) -> get ( 'Content-Type' ) ) ; $ this -> httpClient -> setRequest ( $ request ) ; foreach ( $ files as $ formName => $ filePath ) { $ this -> httpClient -> setFileUpload ( $ filePath , $ formName ) ; if ( isset ( $ data [ $ formName ] ) ) { $ file = $ request -> getFiles ( ) -> get ( $ filePath , null ) ; if ( $ file ) { $ file [ 'filename' ] = $ data [ $ formName ] ; $ request -> getFiles ( ) -> set ( $ filePath , $ file ) ; } unset ( $ data [ $ formName ] ) ; } } $ request -> getPost ( ) -> fromArray ( $ data ) ; return $ request ; }
Prepare a POST request for uploading files
17,105
public function registerMiddleware ( Router $ router ) { foreach ( $ this -> middleware as $ module => $ middlewares ) { foreach ( $ middlewares as $ name => $ middleware ) { $ class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}" ; $ router -> middleware ( $ name , $ class ) ; } } }
Register the filters .
17,106
private function registerModulePermissions ( ) { foreach ( $ this -> app [ 'modules' ] -> enabled ( ) as $ module ) { if ( $ this -> app [ 'society.isInstalled' ] ) { $ permissionManager = new PermissionManager ( ) ; $ permissionManager -> registerDefault ( $ module ) ; } } }
Register the modules dependencies .
17,107
private function registerBindings ( ) { $ this -> app -> bind ( 'society.isInstalled' , function ( $ app ) { return file_exists ( base_path ( '.env' ) ) && file_exists ( storage_path ( 'app/installed' ) ) && Schema :: hasTable ( 'migrations' ) ; } ) ; }
Register general App - Bindings .
17,108
protected function unmarkedText ( $ text ) { $ newText = "" ; if ( $ this -> breaksEnabled ) { $ parts = mb_split ( '[ ]*\n' , $ text ) ; } else { $ parts = mb_split ( '(?:[ ][ ]+|[ ]*\\\\)\n' , $ text ) ; } foreach ( $ parts as $ index => & $ part ) { if ( $ index > 0 ) { $ newText .= "<br />\n" ; } $ part = mb_ereg_replace ( '/[ ]*\n/' , "\n" , $ part ) ; $ ltr = $ this -> getLtrStrLen ( $ part ) ; $ rtl = $ this -> getRtlStrLen ( $ part ) ; $ dir = null ; if ( $ this -> isLtr ( ) && $ rtl > 0 && $ rtl > $ ltr ) { $ dir = "rtl" ; } else if ( $ this -> isRtl ( ) && $ ltr > 0 && $ ltr > $ rtl ) { $ dir = "ltr" ; } if ( ! is_null ( $ dir ) ) { $ newText .= "<div dir=\"{$dir}\">{$part}</div>" ; } else { $ newText .= $ part ; } } return $ newText ; }
Inject span tags for each line to indicate direction .
17,109
public function scan ( $ count = 50 , $ min = 0 , $ max = 0 , $ rate = 0 ) { $ iterator = new QScanIterator ( $ this -> stream , $ this -> log ) ; $ iterator -> setCount ( $ count ) -> setMin ( $ min ) -> setMax ( $ max ) -> setRate ( $ rate ) ; return $ iterator ; }
Scan all existing queues .
17,110
static private function getTextBackTrace ( $ backtrace ) { $ str = '' ; foreach ( $ backtrace as $ step ) { if ( $ step [ 'function' ] != 'getTextBackTrace' && $ step [ 'function' ] != 'handle_error' ) { if ( isset ( $ step [ 'file' ] ) && isset ( $ step [ 'line' ] ) ) { $ str .= "In " . $ step [ 'file' ] . " at line " . $ step [ 'line' ] . ": " ; } if ( isset ( $ step [ 'class' ] ) && isset ( $ step [ 'type' ] ) && isset ( $ step [ 'function' ] ) ) { $ str .= $ step [ 'class' ] . $ step [ 'type' ] . $ step [ 'function' ] . '(' ; } if ( is_array ( $ step [ 'args' ] ) ) { $ drawn = false ; $ params = '' ; foreach ( $ step [ 'args' ] as $ param ) { $ params .= self :: getPhpVariableAsText ( $ param ) ; $ params .= ', ' ; $ drawn = true ; } $ str .= $ params ; if ( $ drawn == true ) $ str = substr ( $ str , 0 , strlen ( $ str ) - 2 ) ; } $ str .= ')' ; $ str .= "\n" ; } } return $ str ; }
Returns the Exception Backtrace as a text string .
17,111
private function add_to_po ( $ string ) { $ this -> strings [ $ string ] = '' ; $ current_strings = Util :: load ( Config :: $ po_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.po' ) ; $ untranslated = [ $ string => '' ] ; $ strings = array_merge ( $ untranslated , $ current_strings ) ; ksort ( $ strings ) ; Util :: save ( Config :: $ po_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.po' , $ this -> application_name , $ this -> language , $ strings ) ; }
Add a string to the po file
17,112
private function reload_po_file ( ) { $ po_files = [ ] ; $ po_files [ ] = Config :: $ po_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.po' ; $ packages = \ Skeleton \ Core \ Package :: get_all ( ) ; foreach ( $ packages as $ package ) { if ( file_exists ( Config :: $ po_directory . '/' . $ this -> language -> name_short . '/package/' . $ package -> name . '.po' ) ) { $ po_files [ ] = Config :: $ po_directory . '/' . $ this -> language -> name_short . '/package/' . $ package -> name . '.po' ; } } $ array_modified = 0 ; if ( file_exists ( Config :: $ cache_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.php' ) ) { $ array_modified = filemtime ( Config :: $ cache_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.php' ) ; } $ po_file_modified = null ; foreach ( $ po_files as $ po_file ) { if ( ! file_exists ( $ po_file ) ) { continue ; } if ( $ po_file_modified === null ) { $ po_file_modified = filemtime ( $ po_file ) ; } if ( filemtime ( $ po_file ) > $ po_file_modified ) { $ po_file_modified = filemtime ( $ po_file ) ; } } if ( $ array_modified >= $ po_file_modified ) { return ; } $ po_strings = [ ] ; foreach ( array_reverse ( $ po_files ) as $ po_file ) { $ strings = Util :: load ( $ po_file ) ; foreach ( $ strings as $ key => $ value ) { if ( ! isset ( $ po_strings [ $ key ] ) ) { $ po_strings [ $ key ] = $ value ; } elseif ( $ value != '' ) { $ po_strings [ $ key ] = $ value ; } else { continue ; } } } if ( ! file_exists ( Config :: $ cache_directory . '/' . $ this -> language -> name_short ) ) { mkdir ( Config :: $ cache_directory . '/' . $ this -> language -> name_short , 0755 , true ) ; } file_put_contents ( Config :: $ cache_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.php' , '<?php $strings = ' . var_export ( $ po_strings , true ) . ';' ) ; }
Read the po files
17,113
private function load_strings ( ) { if ( file_exists ( Config :: $ cache_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.php' ) ) { require Config :: $ cache_directory . '/' . $ this -> language -> name_short . '/' . $ this -> application_name . '.php' ; $ this -> strings = $ strings ; } }
Load the strings
17,114
public static function get ( LanguageInterface $ language = null , $ application_name = null ) { if ( ! isset ( self :: $ translation [ $ language -> name_short ] ) OR self :: $ translation [ $ language -> name_short ] -> application_name != $ application_name ) { self :: $ translation [ $ language -> name_short ] = new self ( $ language , $ application_name ) ; } return self :: $ translation [ $ language -> name_short ] ; }
Get a translation object
17,115
public static function translate_plural ( $ string , Translation $ translation = null ) { if ( $ translation !== null ) { $ translation = self :: get ( $ translation -> language , $ translation -> application_name ) ; } else { $ translation = self :: get ( ) ; } return $ translation -> translate_string ( $ string ) ; }
Translate a plural string
17,116
protected function setTranslationForMessageFromService ( $ selfEdit , $ msgInstanceName , $ key , $ label , $ language , $ delete ) { if ( $ delete ) { $ translationService = new InstanceProxy ( $ msgInstanceName , $ selfEdit ) ; return $ translationService -> deleteMessage ( $ key , $ language ) ; } else { $ translationService = new InstanceProxy ( $ msgInstanceName , $ selfEdit ) ; return $ translationService -> setMessage ( $ key , $ label , $ language ) ; } }
Saves the translation for one key and one language using CURL .
17,117
public function autoNewCol ( int $ nbColForThisCell = 1 , array $ classes = [ ] , array $ attrs = [ ] ) : string { ! $ this -> autoStarted && $ this -> autoStart ( ) ; $ src = '' ; $ this -> status === self :: STATUS_IN_CELL && $ src .= $ this -> endCell ( ) ; $ this -> status === self :: STATUS_OK && $ src .= $ this -> beginContainer ( $ this -> autoFluid , $ this -> autoContainer , $ this -> autoContainerClasses ) ; $ this -> status === self :: STATUS_IN_CONTAINER && $ src .= $ this -> beginRow ( ) ; if ( $ this -> status !== self :: STATUS_IN_ROW ) { Checkers :: notice ( 'Bad status, expected: ' . self :: STATUS_IN_ROW . ', detected: ' . $ this -> status ) ; } if ( $ this -> autoCurrentCol + $ nbColForThisCell > $ this -> autoCols ) { $ src .= $ this -> endRow ( ) -> beginRow ( ) ; $ this -> autoCurrentCol = 0 ; } $ src .= $ this -> callBeginCell ( $ this -> autoCols / $ nbColForThisCell , $ classes , $ attrs ) ; $ this -> autoCurrentCol += $ nbColForThisCell ; return $ src ; }
To call before each data cell
17,118
public function autoStop ( ) : string { $ src = '' ; $ this -> status === self :: STATUS_IN_CELL && $ src .= $ this -> endCell ( ) ; $ this -> status === self :: STATUS_IN_ROW && $ src .= $ this -> endRow ( ) ; $ this -> status === self :: STATUS_IN_CONTAINER && $ src .= $ this -> endContainer ( $ this -> autoContainer ) ; $ this -> autoCols = self :: DEFAULT_COLS ; $ this -> autoFluid = self :: DEFAULT_FLUID ; $ this -> autoCurrentCol = 0 ; $ this -> autoStarted = false ; return $ src ; }
To call at the end of your grid
17,119
public function auto ( array $ cellsData , int $ nbColsByRow = null , bool $ container = false , array $ classes = [ ] , array $ attrs = [ ] , array $ containerClasses = [ ] , bool $ fluid = true ) : string { $ nbColsByRow = $ nbColsByRow ?? count ( $ cellsData ) ; $ src = $ this -> autoStart ( $ nbColsByRow , $ container , $ fluid , $ containerClasses ) ; foreach ( $ cellsData as $ cell ) { $ src .= $ this -> autoNewCol ( 1 , $ classes , $ attrs ) ; $ src .= ( string ) $ cell ; } $ src .= $ this -> autoStop ( ) ; return $ src ; }
Decorate automatically an array of strings with a grid
17,120
public function addSMIME ( string $ certificate , string $ privateKey ) : void { $ signer = new SMIMESigner ( ) ; $ signer -> certificate = $ certificate ; $ signer -> privateKey = $ privateKey ; $ this -> set ( $ signer ) ; }
Add a SMIME signer .
17,121
public function addDKIM ( string $ privateKey , string $ domain , string $ selector ) : void { $ signer = new DKIMSigner ( ) ; $ signer -> privateKey = $ privateKey ; $ signer -> domain = $ domain ; $ signer -> selector = $ selector ; $ this -> set ( $ signer ) ; }
Add a DKIM signer .
17,122
public static function getStandard ( ) { if ( self :: $ standard === null ) { $ cn = self :: $ standardCN ; if ( ! class_exists ( $ cn , true ) ) { throw new \ LogicException ( 'The standard FS implementation not installed' ) ; } if ( ! is_subclass_of ( $ cn , self :: $ interface ) ) { throw new \ LogicException ( 'OMG, standard FS is fake' ) ; } self :: $ standard = new $ cn ; } return self :: $ standard ; }
Returns the standard implementation
17,123
public function arg ( string $ arg ) : ProcessBuilder { if ( $ arg === '' ) { return $ this ; } $ this -> arguments [ ] = $ arg ; return $ this ; }
Adds an argument
17,124
public function option ( string $ option , ? string $ value = null ) : ProcessBuilder { if ( $ option === '' ) { return $ this ; } if ( strpos ( $ option , '-' ) !== 0 ) { $ option = sprintf ( '--%s' , $ option ) ; } $ this -> arguments [ ] = $ option ; if ( $ value !== null ) { $ this -> arguments [ ] = $ value ; } return $ this ; }
Adds an option
17,125
public function input ( $ input ) : ProcessBuilder { if ( $ input === null ) { $ this -> input = null ; return $ this ; } if ( is_resource ( $ input ) ) { $ this -> input = $ input ; return $ this ; } if ( is_scalar ( $ input ) ) { $ this -> input = ( string ) $ input ; } return $ this ; }
Sets the input
17,126
public function timeout ( $ timeout ) : ProcessBuilder { if ( $ timeout === null ) { $ this -> timeout = null ; return $ this ; } $ timeout = ( float ) $ timeout ; if ( $ timeout < 0 ) { throw new DomainException ( 'Timeout must be a positive number' ) ; } $ this -> timeout = $ timeout ; return $ this ; }
Sets the timeout in seconds
17,127
public function setEnv ( string $ name , ? string $ value = null ) : ProcessBuilder { $ this -> environment [ $ name ] = $ value ; return $ this ; }
Sets an environment variable
17,128
public function getProcess ( ) : Process { if ( count ( $ this -> prefix ) === 0 && count ( $ this -> arguments ) === 0 ) { throw new MethodCallException ( 'You must add arguments before calling getProcess()' ) ; } $ arguments = array_merge ( $ this -> prefix , $ this -> arguments ) ; $ command = implode ( ' ' , array_map ( 'escapeshellarg' , $ arguments ) ) ; if ( $ this -> inheritEnv ) { $ env = array_replace ( $ _SERVER , $ this -> environment ) ; } else { $ env = $ this -> environment ; } $ process = new Process ( $ command , $ this -> directory , $ env , $ this -> input , $ this -> timeout , $ this -> stdout , $ this -> stderr ) ; if ( $ this -> outputDisabled ) { $ process -> disableOutput ( ) ; } return $ process ; }
Creates a Process instance
17,129
protected function fillAttributes ( $ resource , array $ attributes ) { foreach ( $ attributes as $ attribute => $ value ) { $ setter = "set" . ucfirst ( $ attribute ) ; if ( method_exists ( $ resource , $ setter ) ) { $ resource -> $ setter ( $ value ) ; } } }
Sets all the properties on the entity .
17,130
public function postSubmit ( FormEvent $ event ) { $ image = $ event -> getData ( ) ; if ( $ image && $ image -> hasFile ( ) ) { $ image -> setPath ( null ) ; } }
Post form submit listener
17,131
public function resolve ( & $ toResolve ) { if ( $ this -> config_resolver instanceof ReferenceInterface ) { $ this -> config_resolver -> deReferenceArray ( $ toResolve ) ; } return $ this ; }
Resolving use the parameter resolver
17,132
public function hasService ( $ id = '' ) { $ sid = $ this -> getSectionId ( $ id ) ; if ( $ this -> has ( $ sid ) ) { return true ; } if ( $ this -> autoClassName ( $ id ) ) { return true ; } if ( $ this -> serviceTranslation ( $ id ) ) { return true ; } return false ; }
Autowiring support added
17,133
protected function autoClassName ( $ id ) { if ( $ this -> auto && class_exists ( $ id ) && $ this -> isWritable ( ) ) { return $ this -> setService ( $ id , $ id ) ; } return false ; }
Returns true if
17,134
protected function getRawConfig ( $ id ) { $ this -> config_resolver -> enableDeReference ( false ) ; $ data = $ this -> config_resolver -> get ( $ id ) ; $ this -> config_resolver -> enableDeReference ( true ) ; return $ data ; }
Get not - dereferenced config from config_resolver
17,135
public function set ( $ name , $ value = null ) { is_null ( $ name ) or \ Arr :: set ( $ this -> data , $ name , $ value ) ; return $ this ; }
set session variables
17,136
public function get ( $ name , $ default = null ) { if ( is_null ( $ name ) ) { return $ this -> data ; } return \ Arr :: get ( $ this -> data , $ name , $ default ) ; }
get session variables
17,137
public function key ( $ name = 'session_id' ) { return isset ( $ this -> keys [ $ name ] ) ? $ this -> keys [ $ name ] : false ; }
get session key variables
17,138
public function rotate ( $ force = true ) { if ( ! empty ( $ this -> keys ) ) { if ( $ force or ( $ this -> config [ 'rotation_time' ] and $ this -> keys [ 'created' ] + $ this -> config [ 'rotation_time' ] <= $ this -> time -> get_timestamp ( ) ) ) { $ this -> keys [ 'previous_id' ] = $ this -> keys [ 'session_id' ] ; $ this -> keys [ 'session_id' ] = $ this -> _new_session_id ( ) ; $ this -> keys [ 'created' ] = $ this -> time -> get_timestamp ( ) ; $ this -> keys [ 'updated' ] = $ this -> keys [ 'created' ] ; } } return $ this ; }
force a session_id rotation
17,139
public function set_flash ( $ name , $ value ) { if ( strpos ( $ name , '.' ) !== false ) { $ keys = explode ( '.' , $ name , 2 ) ; $ name = array_shift ( $ keys ) ; } else { $ keys = false ; } if ( $ keys ) { if ( isset ( $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] [ 'value' ] ) ) { $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] [ 'state' ] = 'new' ; } else { $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] = array ( 'state' => 'new' , 'value' => array ( ) ) ; } \ Arr :: set ( $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] [ 'value' ] , $ keys [ 0 ] , $ value ) ; } else { $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] = array ( 'state' => 'new' , 'value' => $ value ) ; } return $ this ; }
set session flash variables
17,140
public function keep_flash ( $ name ) { if ( is_null ( $ name ) ) { foreach ( $ this -> flash as $ key => $ value ) { $ this -> flash [ $ key ] [ 'state' ] = 'new' ; } } elseif ( isset ( $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] ) ) { $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] [ 'state' ] = 'new' ; } return $ this ; }
keep session flash variables
17,141
public function delete_flash ( $ name ) { if ( is_null ( $ name ) ) { $ this -> flash = array ( ) ; } elseif ( isset ( $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] ) ) { unset ( $ this -> flash [ $ this -> config [ 'flash_id' ] . '::' . $ name ] ) ; } return $ this ; }
delete session flash variables
17,142
public function get_config ( $ name ) { return isset ( $ this -> config [ $ name ] ) ? $ this -> config [ $ name ] : null ; }
get a runtime config value
17,143
public function set_config ( $ name , $ value = null ) { if ( isset ( $ this -> config [ $ name ] ) ) $ this -> config [ $ name ] = $ value ; return $ this ; }
set a runtime config value
17,144
protected function _cleanup_flash ( ) { foreach ( $ this -> flash as $ key => $ value ) { if ( $ value [ 'state' ] === 'expire' ) { unset ( $ this -> flash [ $ key ] ) ; } } }
removes flash variables marked as old
17,145
protected function _new_session_id ( ) { $ session_id = '' ; while ( strlen ( $ session_id ) < 32 ) { $ session_id .= mt_rand ( 0 , mt_getrandmax ( ) ) ; } return md5 ( uniqid ( $ session_id , TRUE ) ) ; }
generate a new session id
17,146
protected function _set_cookie ( $ payload = array ( ) ) { if ( $ this -> config [ 'enable_cookie' ] ) { $ payload = $ this -> _serialize ( $ payload ) ; $ this -> config [ 'encrypt_cookie' ] and $ payload = \ Crypt :: encode ( $ payload ) ; if ( strlen ( $ payload ) > 4000 ) { throw new \ FuelException ( 'The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.' ) ; } if ( $ this -> config [ 'expire_on_close' ] ) { return \ Cookie :: set ( $ this -> config [ 'cookie_name' ] , $ payload , 0 , $ this -> config [ 'cookie_path' ] , $ this -> config [ 'cookie_domain' ] , null , $ this -> config [ 'cookie_http_only' ] ) ; } else { return \ Cookie :: set ( $ this -> config [ 'cookie_name' ] , $ payload , $ this -> config [ 'expiration_time' ] , $ this -> config [ 'cookie_path' ] , $ this -> config [ 'cookie_domain' ] , null , $ this -> config [ 'cookie_http_only' ] ) ; } } }
write a cookie
17,147
protected function _get_cookie ( ) { $ cookie = \ Input :: post ( $ this -> config [ 'post_cookie_name' ] , false ) ; if ( $ cookie === false ) { $ cookie = \ Cookie :: get ( $ this -> config [ 'cookie_name' ] , false ) ; } if ( $ cookie === false ) { $ cookie = \ Input :: headers ( $ this -> config [ 'http_header_name' ] , false ) ; } if ( $ cookie === false ) { $ cookie = \ Input :: get ( $ this -> config [ 'cookie_name' ] , false ) ; } if ( $ cookie !== false ) { $ this -> config [ 'encrypt_cookie' ] and $ cookie = \ Crypt :: decode ( $ cookie ) ; $ cookie = $ this -> _unserialize ( $ cookie ) ; if ( is_array ( $ cookie ) ) { if ( ( $ this -> config [ 'driver' ] === 'cookie' and ! is_array ( $ cookie [ 0 ] ) ) or ( $ this -> config [ 'driver' ] !== 'cookie' and ! is_string ( $ cookie [ 0 ] ) ) ) { logger ( 'DEBUG' , 'Error: Invalid session cookie specific format' ) ; $ cookie = false ; } } elseif ( is_string ( $ cookie ) and strlen ( $ cookie ) == 32 ) { $ cookie = array ( $ cookie ) ; } else { logger ( 'DEBUG' , 'Error: Invalid session cookie general format' ) ; $ cookie = false ; } } return $ cookie ; }
read a cookie
17,148
public function physicalClass ( $ translate = false ) { $ classes = $ this -> getSNMP ( ) -> walk1d ( self :: OID_ENTITY_PHYSICAL_CLASS ) ; if ( ! $ translate ) { return $ classes ; } return $ this -> getSNMP ( ) -> translate ( $ classes , self :: $ ENTITY_PHSYICAL_CLASS ) ; }
Returns an associate array of entPhysicalClass
17,149
public static function compare ( $ hash1 , $ hash2 ) : bool { if ( ! is_string ( $ hash1 ) ) { $ hash1 = ( string ) $ hash1 ; } if ( ! is_string ( $ hash2 ) ) { $ hash2 = ( string ) $ hash2 ; } return hash_equals ( $ hash1 , $ hash2 ) ; }
Compare to hashes . Minimize timing attacks .
17,150
public function scriptsMapAction ( ) { $ scriptsBuilder = $ this -> get ( 'phlexible_gui.asset.scripts_builder' ) ; $ asset = $ scriptsBuilder -> build ( ) ; return new BinaryFileResponse ( $ asset -> getMapAsset ( ) , 200 , array ( 'Content-Type' => 'application/json;charset=UTF-8' ) ) ; }
Output scripts map .
17,151
public function cssAction ( Request $ request ) { $ baseUrlContentFilter = $ this -> get ( 'phlexible_gui.asset.base_url_content_filter' ) ; $ baseUrlContentFilter -> setBasePath ( $ request -> getBasePath ( ) ) ; $ baseUrlContentFilter -> setBaseUrl ( $ request -> getBaseUrl ( ) ) ; $ cssBuilder = $ this -> get ( 'phlexible_gui.asset.css_builder' ) ; $ asset = $ cssBuilder -> build ( ) ; $ response = new BinaryFileResponse ( $ asset , 200 , array ( 'Content-Type' => 'text/css;charset=UTF-8' ) ) ; if ( $ asset -> getMapAsset ( ) ) { $ response -> headers -> set ( 'X-SourceMap' , $ this -> generateUrl ( 'asset_css_map' ) ) ; } return $ response ; }
Output css .
17,152
public function cssMapAction ( Request $ request ) { $ baseUrlContentFilter = $ this -> get ( 'phlexible_gui.asset.base_url_content_filter' ) ; $ baseUrlContentFilter -> setBasePath ( $ request -> getBasePath ( ) ) ; $ baseUrlContentFilter -> setBaseUrl ( $ request -> getBaseUrl ( ) ) ; $ cssBuilder = $ this -> get ( 'phlexible_gui.asset.css_builder' ) ; $ asset = $ cssBuilder -> build ( ) ; return new BinaryFileResponse ( $ asset -> getMapAsset ( ) , 200 , array ( 'Content-Type' => 'application/json;charset=UTF-8' ) ) ; }
Output css map .
17,153
public function iconsAction ( Request $ request ) { $ iconsBuilder = $ this -> get ( 'phlexible_gui.asset.icons_builder' ) ; $ asset = $ iconsBuilder -> build ( $ request -> getBasePath ( ) ) ; return new BinaryFileResponse ( $ asset , 200 , array ( 'Content-Type' => 'text/css;charset=UTF-8' ) ) ; }
Output icon styles .
17,154
public function translationsAction ( Request $ request , $ language ) { $ translationBuilder = $ this -> get ( 'phlexible_gui.asset.translations_builder' ) ; $ asset = $ translationBuilder -> build ( $ language ) ; return new BinaryFileResponse ( $ asset , 200 , array ( 'Content-Type' => 'text/javascript;charset=UTF-8' ) ) ; }
Output translations .
17,155
public function getMessage ( int $ code ) : string { return $ this -> statusExists ( $ code ) ? $ this -> statuses [ $ code ] : self :: UNDEFINED_STATUS_MESSAGE ; }
Returns relevant status message if status exists Undefined Status is returned otherwise
17,156
public function executeFormUpdateRequest ( WebRequest $ request , Response $ response , Form $ form ) { $ responseData = array ( 'csrf' => $ form -> generateCsrfToken ( $ request ) ) ; if ( ! $ request -> hasParam ( 'form-extended-entity-select-query' ) ) { $ responseData [ 'data' ] = array ( ) ; $ response -> setOutput ( json_encode ( $ responseData ) , true ) ; return ; } $ query = $ request -> getParam ( 'form-extended-entity-select-query' ) ; $ entities = $ this -> getAvailableValues ( $ query ) ; if ( $ entities === false ) { $ response -> setOutput ( json_encode ( array ( 'error' => true ) ) , true ) ; return ; } $ data = array ( ) ; foreach ( $ entities as $ entity ) { $ data [ ] = array ( 'id' => $ entity -> getId ( ) , 'name' => ( string ) $ entity ) ; } $ responseData [ 'data' ] = $ data ; $ response -> setOutput ( json_encode ( $ responseData ) , true ) ; }
Executes the form update request
17,157
public function indexAction ( ) { $ this -> layout ( 'jaztec-admin/layout' ) ; $ sm = $ this -> getServiceLocator ( ) ; $ bootstrap = $ sm -> get ( 'kjsencha.bootstrap' ) ; return $ bootstrap -> getViewModel ( ) ; }
Fires the ExtJs application .
17,158
public function & addControl ( $ control , $ name = '' , $ label = '' , $ value = '' , $ description = '' , $ unbound = false ) { $ string = new CamelCase ( $ control ) ; $ control = $ this -> factory -> create ( 'FormDesigner\Controls\\' . $ string -> camelize ( ) . 'Control' ) ; $ control -> setName ( $ name ) ; if ( $ unbound && method_exists ( $ control , 'setUnbound' ) ) { $ control -> setUnbound ( ) ; $ control -> removename ( ) ; } if ( ! empty ( $ label ) && method_exists ( $ control , 'setLabel' ) ) { $ control -> setLabel ( $ label ) ; } if ( ! empty ( $ value ) && method_exists ( $ control , 'setValue' ) ) { $ control -> setValue ( $ value ) ; } if ( ! empty ( $ description ) && method_exists ( $ control , 'setDescription' ) ) { $ control -> setDescription ( $ description ) ; } if ( $ control instanceof Button ) { $ control -> noLabel ( ) ; } $ this -> elementFactory ( 'control' , $ control ) ; return $ control ; }
Creates a formcontrol and adds it by it s name to the controls list .
17,159
public function & addElement ( $ element , $ args = [ ] ) { $ element = $ this -> factory -> create ( $ element , $ args ) ; $ this -> elementFactory ( 'factory' , $ element ) ; return $ element ; }
Create an new html object and adds it as new FormElement
17,160
public function & addGroup ( $ unshift = false ) { $ group = $ this -> factory -> create ( 'FormDesigner\FormGroup' ) ; $ this -> elementFactory ( 'group' , $ group , $ unshift ) ; $ group -> injectFormDesigner ( $ this -> fd ) ; $ group -> injectParentGroup ( $ this ) ; return $ group ; }
Creates a new FormGroup objects and adds it as new FormElement
17,161
private function elementFactory ( $ type , $ content , $ unshift = false ) { $ element = $ this -> factory -> create ( 'FormDesigner\FormElement' ) ; $ element -> setContent ( $ content ) ; if ( $ unshift == true ) { array_unshift ( $ this -> elements , $ element ) ; } else { $ this -> elements [ ] = $ element ; } return $ element ; }
Factory mehtod to create new FormElement object within this group object .
17,162
public function getGoogleTracking ( ) { $ trackingCode = $ this -> settingManager -> getParameter ( 'google.tracking_code' ) ; if ( ! $ this -> debug && 0 < strlen ( $ trackingCode -> getPropertyId ( ) ) ) { $ domain = $ trackingCode -> getDomain ( ) ; if ( 0 === strlen ( $ domain ) ) { $ domain = 'auto' ; } if ( in_array ( $ trackingCode -> getDomain ( ) , [ 'none' , 'auto' ] ) ) { $ domain = sprintf ( "'%s'" , $ domain ) ; } else { $ domain = sprintf ( "{'cookieDomain': '%s'}" , $ domain ) ; } return sprintf ( self :: GA_TRACKING_CODE , $ trackingCode -> getPropertyId ( ) , $ domain ) ; } return '' ; }
Renders the google analytics tracking code .
17,163
public function registerObject ( $ service , $ object ) { if ( ! is_object ( $ object ) ) { throw new ResolutionException ( "Service '$service' cannot be register as it's value is invalid" ) ; } $ this -> services [ $ service ] = function ( ) use ( $ object ) { return $ object ; } ; }
Registers an object with the container .
17,164
public function isValid ( $ value , Constraint $ constraint ) { $ document = $ this -> parseDocument ( $ value ) ; $ fields = $ this -> parseFields ( $ constraint -> fields ) ; $ caseInsensitive = $ this -> parseCaseInsensitive ( $ constraint -> caseInsensitive ) ; $ query = $ this -> createQuery ( $ document , $ fields , $ caseInsensitive ) ; $ numberResults = $ query -> count ( ) ; if ( 0 === $ numberResults ) { return true ; } if ( 1 === $ numberResults ) { $ result = $ query -> one ( ) ; if ( $ result === $ document ) { return true ; } } if ( $ this -> context ) { $ this -> addFieldViolation ( $ fields [ 0 ] , $ constraint -> message ) ; } return false ; }
Validates the document uniqueness .
17,165
public function findAll ( ) { $ repos = array ( ) ; foreach ( $ this -> getRows ( ) as $ row ) { $ repo = $ this -> createNew ( ) ; $ repo -> setId ( $ row [ 'id' ] ) ; $ repo -> setSlug ( $ row [ 'slug' ] ) ; $ repo -> setType ( $ row [ 'type' ] ) ; $ repo -> setQualityBadgeHash ( $ row [ 'qualityBadgeHash' ] ) ; $ repo -> setCoverageBadgeHash ( $ row [ 'coverageBadgeHash' ] ) ; $ repos [ ] = $ repo ; } return $ repos ; }
Retrieve all repos
17,166
public function find ( $ id ) { foreach ( $ this -> findAll ( ) as $ repo ) { if ( $ id == $ repo -> getId ( ) ) { return $ repo ; } } return null ; }
Find repo by ID
17,167
public function findBySlug ( $ slug ) { foreach ( $ this -> findAll ( ) as $ repo ) { if ( $ slug == $ repo -> getSlug ( ) ) { return $ repo ; } } return null ; }
Find repo by Slug
17,168
public function writeJson ( $ path , array $ config ) { $ jsonFile = new JsonFile ( $ path ) ; $ jsonFile -> write ( $ this -> prepareConfig ( $ config ) ) ; }
Saves JSON config to the given path .
17,169
public function hasDependencies ( ) { foreach ( $ this -> dependencies as $ key ) { if ( isset ( $ this -> config [ $ key ] ) && $ this -> config [ $ key ] ) { return true ; } } return false ; }
Returns if the package manager has nonempty dependency list .
17,170
protected function perform ( $ action ) { $ this -> plugin -> io -> writeError ( 'running ' . $ this -> getBin ( ) ) ; if ( $ this -> passthru ( [ $ action ] ) ) { $ this -> plugin -> io -> writeError ( '<error>failed ' . $ this -> name . ' ' . $ action . '</error>' ) ; } }
Run installation . Specific for every package manager .
17,171
public function prepareCommand ( array $ arguments = [ ] ) { $ result = '' ; foreach ( $ arguments as $ a ) { $ result .= ' ' . escapeshellarg ( $ a ) ; } return $ result ; }
Prepares given command arguments .
17,172
public function getBin ( ) { if ( $ this -> bin === null ) { $ this -> bin = $ this -> detectBin ( ) ; } return $ this -> bin ; }
Get path to the binary executable file .
17,173
public function detectBin ( ) { $ pathes = [ static :: buildPath ( [ $ this -> plugin -> getVendorDir ( ) , 'bin' , $ this -> phpBin ] ) , static :: buildPath ( [ $ this -> plugin -> getComposer ( ) -> getConfig ( ) -> get ( 'home' ) , 'vendor' , 'bin' , $ this -> phpBin ] ) , ] ; foreach ( $ pathes as $ path ) { if ( file_exists ( $ path ) ) { return $ path ; } } return $ this -> name ; }
Find path to the binary .
17,174
public static function registerSingletonInstance ( $ instance ) { self :: verifyInstanceNotYetRegistered ( ) ; self :: verifyInstanceType ( $ instance ) ; self :: $ instance = $ instance ; }
Registers a specific instance of the class to use as the singleton instance
17,175
public function putValue ( $ field , $ value ) { $ this -> validateValue ( $ field , $ value ) ; $ this -> setValue ( $ field , $ value ) ; }
Validate field value and set it
17,176
public static function getEntityObject ( $ objType , $ objID = null ) { if ( is_object ( $ objType ) ) { $ objID = $ objType -> entity_id ; $ objType = $ objType -> entity_type ; } $ class = isset ( static :: $ entityClasses [ $ objType ] ) ? static :: $ entityClasses [ $ objType ] : $ objType ; return $ class :: load ( $ objID ) ; }
Get entity instance by type and id
17,177
protected static function parseFieldValue ( $ name , $ value ) { $ field = static :: $ validator -> getField ( $ name ) ; if ( $ field ) { $ field -> getType ( ) -> parseValue ( $ field , $ value ) ; } return parent :: parseFieldValue ( $ name , $ value ) ; }
Parse the value from SQL scalar to PHP type
17,178
protected static function formatFieldValue ( $ name , $ value ) { $ field = static :: $ validator -> getField ( $ name ) ; if ( $ field ) { $ field -> getType ( ) -> formatValue ( $ field , $ value ) ; } return parent :: formatFieldValue ( $ name , $ value ) ; }
Format the value from PHP type to SQL scalar
17,179
public static function listKnownEntities ( ) { $ entities = array ( ) ; foreach ( static :: $ knownEntities as $ class => & $ state ) { if ( $ state == null ) { $ state = class_exists ( $ class , true ) && is_subclass_of ( $ class , 'Orpheus\EntityDescriptor\PermanentEntity' ) ; } if ( $ state === true ) { $ entities [ ] = $ class ; } } return $ entities ; }
List all known entities
17,180
public static function Append ( $ sName , $ sDirectory ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( array_key_exists ( $ sName , $ oThis -> aModules ) ) { return $ oThis -> aModules [ $ sName ] ; } else { $ oModule = new Module ( $ sName , $ sDirectory ) ; $ oThis -> aModules [ $ sName ] = $ oModule ; return $ oModule ; } }
Function to append a module
17,181
public static function buildFromDateTimeInterface ( DateTimeInterface $ date ) { $ parts = explode ( '|' , $ date -> format ( 'Z|I|T' ) ) ; return new static ( ( int ) $ parts [ 0 ] , ( bool ) $ parts [ 1 ] , $ parts [ 2 ] ) ; }
Instanciates a TimeOffset from a DateTimeInterface using the format method to extract properties .
17,182
public function buildTimeZone ( ) { if ( null !== $ this -> value ) { $ sign = $ this -> value < 0 ? '-' : '+' ; $ value = intval ( abs ( $ this -> value ) / 60 ) ; return new DateTimeZone ( sprintf ( '%s%02d:%02d' , $ sign , intval ( $ value / 60 ) , $ value % 60 ) ) ; } }
Build a DateTimeZone object based on TimeOffset properties if possible .
17,183
public function faceGetter ( $ needle ) { if ( $ needle instanceof \ Face \ Core \ EntityFaceElement ) { $ element = $ needle ; } else if ( is_string ( $ needle ) ) { if ( false !== strpos ( $ needle , "." ) ) { return ( new Navigator ( $ needle ) ) -> chainGet ( $ this ) ; } else { $ element = $ this -> getEntityFace ( ) -> getElement ( $ needle ) ; } } else { throw new BadParameterException ( "Variable of type '" . gettype ( $ needle ) . "' is not a valide type for faceGetter" ) ; } if ( $ element -> hasGetter ( ) ) { $ getter = $ element -> getGetter ( ) ; if ( is_string ( $ getter ) ) { return $ this -> $ getter ( ) ; } elseif ( is_callable ( $ getter ) ) { return $ getter ( ) ; } else { throw new \ Exception ( 'Getter is set but it is not usable : ' . var_export ( $ getter , true ) ) ; } } else { $ property = $ element -> getPropertyName ( ) ; return $ this -> $ property ; } }
take the given element and use the right way for getting the value on this instance
17,184
public static function faceQueryBuilder ( Config $ config = null ) { if ( null == $ config ) { return new SelectBuilder ( self :: getEntityFace ( ) ) ; } else { return new SelectBuilder ( self :: getEntityFace ( $ config -> getFaceLoader ( ) ) ) ; } }
Shortcut to construct a FQuery
17,185
public static function faceQueryBy ( $ item , $ itemValue , $ pdo ) { if ( self :: getEntityFace ( ) -> getDirectElement ( $ item ) ) { $ fQuery = self :: faceQueryBuilder ( ) ; if ( is_array ( $ itemValue ) ) { $ fQuery -> whereIN ( "~$item" , $ itemValue ) ; } else { $ fQuery -> where ( "~$item=:itemValue" ) -> bindValue ( ":itemValue" , $ itemValue ) ; } return ORM :: execute ( $ fQuery , $ pdo ) ; } }
Fast querying by only specifying one field
17,186
public static function queryString ( $ string , $ options = [ ] ) { $ joins = [ ] ; $ selectedColumns = [ ] ; $ qS = new \ Face \ Sql \ Query \ QueryString ( self :: getEntityFace ( ) , $ string , $ joins , $ selectedColumns ) ; return $ qS ; }
shortcut to create a
17,187
protected function loadAccessControlRulesForUOID ( $ gid , $ uoid ) { $ rules = array ( ) ; if ( $ gid == '28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF' && $ uoid == '4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1' ) { $ rules [ ] = ( new AccessControlRuleObjectBuilder ( ) ) -> owner ( Sonic :: getContextGlobalID ( ) ) -> index ( 1 ) -> directive ( AccessControlRuleObject :: DIRECTIVE_ALLOW ) -> entityType ( AccessControlRuleObject :: ENTITY_TYPE_INDIVIDUAL ) -> entityID ( '28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF' ) -> targetType ( AccessControlRuleObject :: TARGET_TYPE_CONTENT ) -> target ( '4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1' ) -> accessType ( AccessControlRuleObject :: WILDCARD ) -> build ( ) ; } return $ rules ; }
for demonstration purposes only one rule is created for a specific data object for a specific user
17,188
public static function getParentClasses ( $ className ) { $ result = array ( ) ; $ class = new \ ReflectionClass ( $ className ) ; if ( false === $ class ) { return $ result ; } do { $ name = $ class -> getName ( ) ; $ result [ ] = $ name ; $ class = $ class -> getParentClass ( ) ; } while ( false !== $ class ) ; return $ result ; }
Get all class names of passed class
17,189
public function update ( $ structureID = 0 ) { foreach ( $ _POST as $ key => $ val ) { $ this [ $ key ] = $ val ; } $ this -> save ( ) ; if ( dbQuery ( '\samson\cms\web\navigation\CMSNav' ) -> id ( $ structureID ) -> first ( $ cmsnav ) ) { if ( ! dbQuery ( 'structurefield' ) -> StructureID ( $ cmsnav -> id ) -> FieldID ( $ this -> id ) -> first ( ) ) { $ strField = new \ samson \ activerecord \ structurefield ( false ) ; $ strField -> FieldID = $ this -> id ; $ strField -> StructureID = $ cmsnav -> id ; $ strField -> Active = 1 ; $ strField -> save ( ) ; } } }
Updating field and creating relation with structure
17,190
public function setCaptureType ( $ type ) { if ( $ type === static :: SET || $ type === static :: APPEND || $ type === static :: PREPEND ) { $ this -> captureType = $ type ; return $ this ; } throw new InvalidArgumentException ( sprintf ( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.' , is_scalar ( $ type ) ? $ type : gettype ( $ type ) ) ) ; }
Sets the type of capture .
17,191
public function attach ( $ value , $ capture = null ) { if ( null === $ capture ) { $ capture = $ this -> captureType ; } switch ( $ capture ) { case self :: APPEND : $ this -> append ( $ value ) ; break ; case self :: PREPEND : $ this -> prepend ( $ value ) ; break ; case self :: SET : $ this -> set ( $ value ) ; break ; default : throw new InvalidArgumentException ( sprintf ( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.' , is_scalar ( $ capture ) ? $ capture : gettype ( $ capture ) ) ) ; } return $ this ; }
Attaches the value .
17,192
public function captureStart ( $ type = null ) { if ( $ this -> captureStarted ) { throw new RuntimeException ( 'Capture is already started.' ) ; } if ( null !== $ type ) { $ this -> setCaptureType ( $ type ) ; } $ this -> captureStarted = true ; ob_start ( ) ; return $ this ; }
Starts the capture .
17,193
public function captureEnd ( array $ params = [ ] ) { if ( ! $ this -> captureStarted ) { throw new RuntimeException ( 'Capture has not been started.' ) ; } $ params [ 'capture' ] = ob_get_clean ( ) ; $ this -> attach ( $ params ) ; $ this -> captureStarted = false ; return $ this ; }
Ends the capture .
17,194
public function toString ( $ indent = null ) { $ indent = ( $ indent !== null ) ? $ this -> getWhitespace ( $ indent ) : $ this -> getIndent ( ) ; $ return = $ this -> prefix ; $ keys = array_keys ( $ this -> container ) ; $ lastIndex = end ( $ keys ) ; foreach ( $ this -> container as $ index => $ item ) { $ item = array_merge ( $ this -> defaultParams , ( array ) $ item ) ; $ return .= vsprintf ( $ this -> wrapper , $ item ) ; if ( $ index !== $ lastIndex ) { $ return .= $ this -> separator ; } } $ return .= $ this -> postfix ; return preg_replace ( "/(\r\n?|\n)[ ]*/" , '$1' . $ indent , $ return ) ; }
Renders the placeholder .
17,195
public static function getFirstValue ( $ arr ) { if ( count ( $ arr ) ) { if ( isset ( $ arr [ 0 ] ) ) { return $ arr [ 0 ] ; } else { $ keys = array_keys ( $ arr ) ; return $ arr [ $ keys [ 0 ] ] ; } } return null ; }
Returns the first value in a given array .
17,196
public static function matches ( $ keys = [ ] , $ array = [ ] ) : array { if ( ! empty ( $ keys ) && ! empty ( $ array ) ) { $ matchingProperties = [ ] ; foreach ( $ keys as $ property ) { if ( $ matchedAttribute = static :: getValue ( $ array , $ property ) ) { $ matchingProperties [ $ property ] = $ matchedAttribute ; } } return $ matchingProperties ; } return $ array ; }
Finds matching values from two arrays
17,197
public function set ( $ path , $ value ) { $ old = null ; if ( $ nodes = explode ( '.' , $ path ) ) { $ node = $ this -> data ; for ( $ i = 0 , $ n = count ( $ nodes ) - 1 ; $ i < $ n ; $ i ++ ) { if ( ! isset ( $ node -> { $ nodes [ $ i ] } ) && ( $ i != $ n ) ) { $ node -> { $ nodes [ $ i ] } = new \ stdClass ; } $ node = $ node -> { $ nodes [ $ i ] } ; } if ( isset ( $ node -> { $ nodes [ $ i ] } ) ) { $ old = $ node -> { $ nodes [ $ i ] } ; } $ node -> { $ nodes [ $ i ] } = $ value ; } return $ old ; }
Set a registry value
17,198
protected function bindData ( & $ parent , $ data ) { if ( is_object ( $ data ) ) { $ data = get_object_vars ( $ data ) ; } else { $ data = ( array ) $ data ; } foreach ( $ data as $ k => $ v ) { if ( ( is_array ( $ v ) && ArrayHelper :: isAssociative ( $ v ) ) || is_object ( $ v ) ) { $ parent -> $ k = new \ stdClass ; $ this -> bindData ( $ parent -> $ k , $ v ) ; } else { $ parent -> $ k = $ v ; } } }
Recursively bind data to a parent object
17,199
protected function asArray ( $ data ) { $ array = [ ] ; foreach ( get_object_vars ( ( object ) $ data ) as $ k => $ v ) { if ( is_object ( $ v ) ) { $ array [ $ k ] = $ this -> asArray ( $ v ) ; } else { $ array [ $ k ] = $ v ; } } return $ array ; }
Recursively convert an object of data to an array .