idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
11,700 | public function slugs ( array $ basenames ) : array { $ slugs = [ ] ; foreach ( $ basenames as $ _basename ) { if ( ( $ _slug = $ this -> slug ( ( string ) $ _basename ) ) ) { $ slugs [ $ _basename ] = $ _slug ; } } return $ slugs ; } | Plugin slugs from basenames . |
11,701 | public function installedData ( string $ slug , string $ key ) : string { if ( ! $ slug || ! $ key ) { return '' ; } switch ( $ key ) { case 'basename' : $ key = 'Basename' ; break ; case 'name' : $ key = 'Name' ; break ; case 'version' : $ key = 'Version' ; break ; case 'description' : $ key = 'Description' ; break ; ... | Installed plugin data from slug . |
11,702 | public function path ( string $ path ) : PathList { if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( 'Arg path doesn\'t exist, path[' . $ path . '].' ) ; } if ( ! is_dir ( $ path ) ) { throw new \ InvalidArgumentException ( 'Arg path is not a directory, path[' . $ path . '].' ) ; } $ this -> pat... | Set path to find in . |
11,703 | public function itemValue ( callable $ valueFunction ) { $ this -> pathNameRecord = $ this -> requireUnique ? 'none' : 'key' ; $ this -> itemValue = $ valueFunction ; return $ this ; } | Provide function to set list item values . |
11,704 | public function listDocumentRootReplaced ( ) { if ( $ this -> pathNameRecord == 'none' ) { throw new \ LogicException ( 'Can\'t listDocumentRootReplaced() ' . ( ! $ this -> dirs ? 'filenames' : 'dirnames' ) . ' when items\' paths aren\'t recorded' . ( ! $ this -> requireUnique || ! $ this -> itemValue ? '.' : ( ', inco... | List all files|dirs paths having document root replaced . |
11,705 | public function describe ( ) : array { $ info = [ 'path' => $ this -> path , 'maxDepth' => $ this -> maxDepth , 'skipSymLinks' => $ this -> skipSymLinks , 'dirs' => $ this -> dirs , 'itemValue' => $ this -> itemValue , 'traverseHidden' => $ this -> traverseHidden , 'skipUnreadable' => $ this -> skipUnreadable , 'requir... | Dumps requirements inclusions and exclusions to array . |
11,706 | public function getList ( array $ module ) { $ list = array ( ) ; foreach ( $ this -> getScanFolders ( ) as $ folder ) { $ files = gplcart_file_scan_recursive ( "{$module['directory']}/$folder" ) ; sort ( $ files ) ; $ list [ $ folder ] = $ files ; } $ this -> hook -> attach ( 'module.editor.list' , $ list ) ; return $... | Returns an array of editable files |
11,707 | public function save ( $ data ) { $ result = null ; $ this -> hook -> attach ( 'module.editor.save.before' , $ data , $ result ) ; if ( isset ( $ result ) ) { return $ result ; } if ( ! $ this -> backup ( $ data ) ) { return false ; } $ result = $ this -> write ( $ data [ 'content' ] , $ data [ 'path' ] ) ; $ this -> h... | Saves an edited file |
11,708 | protected function backup ( array $ data ) { $ has_backup = true ; try { $ backup = $ this -> module -> getInstance ( 'backup' ) ; if ( ! $ backup -> exists ( $ data [ 'module' ] [ 'id' ] ) ) { $ has_backup = $ backup -> backup ( 'module' , $ data [ 'module' ] ) === true ; } } catch ( Exception $ ex ) { trigger_error (... | Backup a module |
11,709 | protected function write ( $ content , $ file ) { if ( file_exists ( $ file ) ) { return file_put_contents ( $ file , $ content ) !== false ; } return false ; } | Writes a content to a file |
11,710 | public function validatePhpFile ( $ file ) { if ( ! $ this -> canValidatePhpCode ( ) ) { return null ; } $ output = shell_exec ( 'php -l ' . escapeshellarg ( $ file ) ) ; $ count = 0 ; $ error = preg_replace ( '/Errors parsing.*$/' , '' , $ output , - 1 , $ count ) ; return $ count > 0 ? trim ( "$error" ) : true ; } | Tries to validate syntax of a PHP file |
11,711 | public function validatePhpCode ( $ code ) { $ temp = tmpfile ( ) ; fwrite ( $ temp , $ code ) ; $ meta_data = stream_get_meta_data ( $ temp ) ; $ result = $ this -> validatePhpFile ( $ meta_data [ 'uri' ] ) ; fclose ( $ temp ) ; return $ result ; } | Tries to validate a PHP code |
11,712 | protected function openAppConfig ( string $ name ) { if ( JL :: exists ( FEnv :: get ( "app.config.file" , $ name ) ) ) { return ( JL :: open ( FEnv :: get ( "app.config.file" , $ name ) ) ) ; } else { return ( null ) ; } } | Open the config . json file for one app |
11,713 | private function checkHosts ( ) : bool { if ( null === $ this -> config ) { return ( true ) ; } $ current_env = FEnv :: get ( "framework.env" ) ; $ ip = ToolsExceptions :: getClientIp ( ) ; $ result = true ; if ( "dev" === $ current_env ) { if ( property_exists ( $ this -> config , "hosts_denied_dev" ) ) { $ dd = $ thi... | Check the allowed and denied host for an app |
11,714 | public function checkVisibility ( ) : bool { if ( null === $ this -> config ) { return ( true ) ; } $ current_env = FEnv :: get ( "framework.env" ) ; if ( property_exists ( $ this -> config , "visibility_$current_env" ) ) { if ( false === $ this -> config -> { "visibility_$current_env" } ) { return ( false ) ; } elseif... | Check visibility in current env |
11,715 | public static function createHimSelf ( string $ appname ) : bool { if ( false == JL :: exists ( FEnv :: get ( "framework.root" ) . "apps/" . $ appname . "/config.json" ) ) { $ file = new \ stdClass ( ) ; $ file -> visibility_dev = null ; $ file -> visibility_prod = null ; $ file -> hosts_allowed_dev = null ; $ file -> ... | Create the config . json if does not exist |
11,716 | public static function getByTitle ( $ title ) : Sources { $ sourceData = self :: findFirstByTitle ( $ title ) ; if ( ! $ sourceData ) { throw new \ Exception ( _ ( 'Importing site is not currently supported.' ) ) ; } return $ sourceData ; } | Get a source by its title |
11,717 | public function notify ( $ event , array $ data = [ ] ) { $ event = ( string ) $ event ; if ( ( $ pos = strpos ( $ event , '.' ) ) == false ) { throw new \ InvalidArgumentException ( 'The event name is invalid (expecting "action.event")' ) ; } $ action = substr ( $ event , 0 , $ pos ) ; if ( ! isset ( $ this -> respond... | Notifies the observer of an event . |
11,718 | public function getResponders ( $ action ) { if ( ! is_string ( $ action ) || empty ( $ action ) ) { throw new \ InvalidArgumentException ( 'The action name is invalid' ) ; } return $ this -> responders [ $ action ] ; } | Gets all registered responders assigned to the given event action . |
11,719 | public function addResponder ( $ actions , $ responder , array $ data = null ) { if ( ! $ responder instanceof ResponderInterface && ! is_callable ( $ responder ) ) { throw new \ InvalidArgumentException ( 'The $responder parameter must be either a ResponderInterface object or a callable' ) ; } $ actions = ( array ) $ ... | Assigns a responder to the given event action . |
11,720 | public function getData ( $ action , $ key ) { if ( ! is_string ( $ action ) || empty ( $ action ) ) { throw new \ InvalidArgumentException ( 'The action name is invalid' ) ; } if ( ! is_string ( $ key ) || empty ( $ key ) ) { throw new \ InvalidArgumentException ( 'The data key name is invalid' ) ; } return $ this -> ... | Gets the value of the given data key . |
11,721 | public function setData ( $ actions , $ key , $ value ) { if ( ! is_string ( $ key ) || empty ( $ key ) ) { throw new \ InvalidArgumentException ( 'The data key name is invalid' ) ; } $ actions = ( array ) $ actions ; foreach ( $ actions as $ action ) { if ( ! is_string ( $ action ) || empty ( $ action ) ) { throw new ... | Sets the given data key to the specified value . |
11,722 | private function removeDir ( $ theDir ) { $ this -> logVerbose ( "Removing %s" , $ theDir ) ; $ suc = rmdir ( $ theDir ) ; if ( $ suc === false ) $ this -> logError ( "Unable to remove directory %s" , $ theDir ) ; $ this -> myCount ++ ; } | Removes a directory and does housekeeping . |
11,723 | private function removeEmptyDirs ( $ theDirName ) { $ entries = scandir ( $ theDirName , SCANDIR_SORT_ASCENDING ) ; if ( $ entries === false ) $ this -> logError ( "Unable to scan directory %s" , $ theDirName ) ; foreach ( $ entries as $ i => $ entry ) { $ path = $ theDirName . '/' . $ entry ; if ( $ entry == '.' || $ ... | Removes recursively empty directories under a parent directory . |
11,724 | protected function sanitiseRow ( $ table , $ row ) { $ data = [ ] ; foreach ( $ this -> keys [ $ table ] as $ key ) { $ data [ $ key ] = isset ( $ row [ $ key ] ) ? $ row [ $ key ] : null ; } return $ data ; } | Sanitises a row |
11,725 | public function update ( $ table , $ row , $ identifier = [ ] ) { if ( ! array_key_exists ( $ table , $ this -> rows ) ) { $ this -> loadTable ( $ table ) ; } $ data = $ this -> sanitiseRow ( $ table , $ row ) ; if ( empty ( $ identifier ) && isset ( $ data [ 'id' ] ) ) { $ identifier = [ 'id' => $ data [ 'id' ] ] ; } ... | Updates an entity in the storage |
11,726 | protected function match ( $ row , $ identifier ) { foreach ( $ identifier as $ key => $ value ) { if ( $ row [ $ key ] != $ value ) { return false ; } } return true ; } | Checks if a row matches an identifier |
11,727 | public function delete ( $ table , $ row , $ identifier = [ ] ) { if ( ! array_key_exists ( $ table , $ this -> rows ) ) { $ this -> loadTable ( $ table ) ; } if ( empty ( $ identifier ) ) { $ identifier = $ this -> sanitiseRow ( $ table , $ row ) ; } $ rows = [ ] ; foreach ( $ this -> rows [ $ table ] as $ key => $ ro... | Deletes an entity from the storage |
11,728 | public function commit ( ) { try { $ this -> storeAllTables ( ) ; $ this -> snapshot = [ ] ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( 'Commit failed: ' . $ e -> getMessage ( ) , 0 , $ e ) ; } } | Commit all changes |
11,729 | protected function storeTable ( $ table ) { $ fh = fopen ( $ this -> dataFile ( $ table ) , 'w' ) ; fputcsv ( $ fh , $ this -> keys [ $ table ] ) ; foreach ( $ this -> rows [ $ table ] as $ row ) { fputcsv ( $ fh , $ this -> sanitiseRow ( $ table , $ row ) ) ; } fclose ( $ fh ) ; } | Persists all changes |
11,730 | public function rollBack ( ) { try { $ this -> rows = $ this -> snapshot ; $ this -> storeAllTables ( ) ; $ this -> snapshot = [ ] ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( 'Rollback failed: ' . $ e -> getMessage ( ) , 0 , $ e ) ; } } | Roll back the changes |
11,731 | protected function key ( array $ notice ) : string { $ hashable_notice = $ this -> normalize ( $ notice ) ; unset ( $ hashable_notice [ '_insertion_time' ] ) ; unset ( $ hashable_notice [ '_recurrences' ] ) ; unset ( $ hashable_notice [ '_last_recur_dismiss_time' ] ) ; if ( $ hashable_notice [ 'id' ] ) { return $ hasha... | Build a notice key . |
11,732 | protected function currentUserCan ( array $ notice ) : bool { $ WP_User = wp_get_current_user ( ) ; $ notice = $ this -> normalize ( $ notice ) ; if ( $ notice [ 'for_user_id' ] && ( int ) $ WP_User -> ID !== $ notice [ 'for_user_id' ] ) { return false ; } if ( ! $ notice [ 'requires_cap' ] ) { return true ; } elseif (... | Current user can? |
11,733 | protected function isApplicableContext ( array $ notice ) : bool { if ( $ this -> Wp -> is_network_admin ) { $ context = 'network' ; } elseif ( $ this -> Wp -> is_user_admin ) { $ context = 'user' ; } elseif ( $ this -> Wp -> is_admin ) { $ context = 'admin' ; } else { debug ( 0 , $ this -> c :: issue ( vars ( ) , 'Con... | Is an applicable context? |
11,734 | protected function isApplicablePage ( array $ notice ) : bool { $ notice = $ this -> normalize ( $ notice ) ; if ( $ notice [ 'for_page' ] && $ notice [ 'for_page' ] [ 0 ] === '/' ) { $ applicable_pages = [ $ notice [ 'for_page' ] ] ; } else { $ applicable_pages = preg_split ( '/[|\s]+/u' , $ notice [ 'for_page' ] , - ... | Is an applicable page? |
11,735 | public function enqueue ( $ markup , array $ args = [ ] ) { $ notice = $ args ; if ( $ markup && empty ( $ notice [ 'markup' ] ) ) { $ notice [ 'markup' ] = $ markup ; } $ notice = $ this -> normalize ( $ notice ) ; if ( ! $ notice [ 'markup' ] ) { return ; } $ key = $ this -> key ( $ notice ) ; $ notices = $ this -> g... | Enqueue an administrative notice . |
11,736 | public function userEnqueue ( $ markup , array $ args = [ ] ) { if ( ! isset ( $ args [ 'for_user_id' ] ) ) { $ args [ 'for_user_id' ] = ( int ) get_current_user_id ( ) ; } if ( ! $ args [ 'for_user_id' ] ) { return ; } $ this -> enqueue ( $ markup , $ args ) ; } | Enqueue an administrative notice ; for a particular user . |
11,737 | public function dequeue ( string $ key ) { $ notices = $ this -> get ( ) ; if ( ! isset ( $ notices [ $ key ] ) ) { return ; } unset ( $ notices [ $ key ] ) ; $ this -> update ( $ notices ) ; } | Dequeue a notice . |
11,738 | public function dismiss ( string $ key ) { $ notices = $ this -> get ( ) ; if ( ! isset ( $ notices [ $ key ] ) ) { return ; } $ notices [ $ key ] = $ this -> normalize ( $ notices [ $ key ] ) ; $ notice = & $ notices [ $ key ] ; if ( $ notice [ 'recurs_every' ] ) { ++ $ notice [ '_recurrences' ] ; if ( $ notice [ '_re... | Dismiss a notice . |
11,739 | public function load ( $ id ) { $ this -> customerAddressStmt -> execute ( array ( MemberNames :: ENTITY_ID => $ id ) ) ; return $ this -> customerAddressStmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; } | Return s the customer address with the passed entity ID . |
11,740 | public function getProviderId ( ) { $ id = $ this -> getAttribute ( 'providerId' ) ; if ( null === $ id && null !== $ this -> provider ) { $ id = $ this -> provider -> id ; $ this -> setAttribute ( 'providerId' , $ id ) ; } return $ id ; } | Get associated providerId |
11,741 | public function setProvider ( $ provider = null ) { $ this -> provider = null ; if ( null === ( $ provider = $ this -> internalResolveProvider ( $ provider ) ) ) { $ this -> provider = $ this -> providerId = null ; } else { $ this -> providerId = $ provider -> id ; $ this -> provider = $ provider ; } return $ this ; } | Associate a provider |
11,742 | public function export ( ) { $ text = implode ( "\n" , array_map ( [ $ this , 'formatMessage' ] , $ this -> messages ) ) . "\n" ; if ( ( $ fp = @ fopen ( $ this -> logFile , 'a' ) ) === false ) { throw new InvalidConfigException ( "Unable to append to log file: {$this->logFile}" ) ; } @ flock ( $ fp , LOCK_EX ) ; if ( ... | Writes log messages to a file . |
11,743 | protected function applySorting ( $ sort ) { if ( is_array ( $ sort ) ) { array_map ( [ $ this , 'applySorting' ] , $ sort ) ; return ; } if ( ! strpos ( $ sort , ':' ) ) { $ this -> sort ( $ sort , CanSort :: ASC ) ; return ; } list ( $ key , $ direction ) = explode ( ':' , $ sort , 2 ) ; $ this -> sort ( $ key , $ di... | Add the input parameter to the sorting . |
11,744 | protected function applyParameter ( $ key , $ value ) { if ( $ key == $ this -> sortParameter ) { $ this -> applySorting ( $ value ) ; return ; } $ this -> applyFilter ( $ key , $ value ) ; } | Dispatch the parameter to sort filter ... |
11,745 | protected function parseInput ( ) { foreach ( $ this -> input as $ key => $ value ) { $ this -> applyParameter ( $ key , $ value ) ; } } | Dispatch the parameters to sort filter ... |
11,746 | protected function filterWouldMatch ( $ filterValue , $ value , $ key ) { if ( $ value === null ) { return $ filterValue === null ; } if ( is_array ( $ filterValue ) ) { return is_array ( $ value ) ? $ filterValue == $ value : in_array ( $ value , $ filterValue ) ; } if ( is_numeric ( $ value ) ) { return $ filterValue... | Overwrite this method to adjust the filter to value comparison . |
11,747 | public function setDialect ( $ dialect ) { if ( ! Type :: isStringLike ( $ dialect ) ) { throw new InvalidArgumentException ( 'Dialect hast to be stringlike, not ' . Type :: of ( $ dialect ) ) ; } $ this -> dialect = $ dialect ; return $ this ; } | Assign the dialect . |
11,748 | public function transaction ( callable $ run , $ attempts = 1 ) { if ( $ attempts < 1 ) { throw new InvalidArgumentException ( "Invalid transaction attempts: $attempts" ) ; } for ( $ i = 1 ; $ i <= $ attempts ; $ i ++ ) { $ this -> begin ( ) ; try { $ result = $ run ( $ this ) ; $ this -> commit ( ) ; return $ result ;... | Run the callable in an transaction . |
11,749 | public function select ( $ query , array $ bindings = [ ] , $ fetchMode = null ) { $ fetchMode = $ fetchMode === null ? $ this -> getOption ( static :: FETCH_MODE ) : $ fetchMode ; $ this -> callBeforeListeners ( 'select' , [ $ query , $ bindings ] ) ; $ statement = $ bindings ? $ this -> prepared ( $ query , $ binding... | Run a select statement and return the result . |
11,750 | public function insert ( $ query , array $ bindings = [ ] , $ returnLastInsertId = null ) { $ returnLastInsertId = $ returnLastInsertId !== null ? $ returnLastInsertId : $ this -> getOption ( static :: RETURN_LAST_ID ) ; $ this -> callBeforeListeners ( 'insert' , [ $ query , $ bindings ] ) ; $ result = $ bindings ? $ t... | Run an insert statement . |
11,751 | public function write ( $ query , array $ bindings = [ ] , $ returnAffected = null ) { $ returnAffected = $ returnAffected !== null ? $ returnAffected : $ this -> getOption ( static :: RETURN_LAST_AFFECTED ) ; $ this -> callBeforeListeners ( 'write' , [ $ query , $ bindings ] ) ; if ( ! $ bindings ) { $ rows = $ this -... | Run an altering statement . |
11,752 | protected function attempt ( Closure $ run , $ query = '' ) { try { return $ run ( ) ; } catch ( Exception $ e ) { throw $ this -> convertException ( $ e , $ query ) ; } } | Try to perform an operation . If it fails convert the native exception into a SQLException . |
11,753 | public function save ( ) : bool { $ _SESSION = $ this -> session ; return ( 0 === count ( array_diff ( $ this -> session , $ _SESSION ) ) ) ? true : false ; } | Save the modification about sessions items |
11,754 | public function has ( $ name ) : bool { return ( ( isset ( $ this -> session [ $ name ] ) && null != $ this -> session [ $ name ] ) ? true : false ) ; } | Check if a session key exist |
11,755 | public function get ( $ name ) { return ( ( isset ( $ this -> session [ $ name ] ) && null != $ this -> session [ $ name ] ) ? $ this -> session [ $ name ] : null ) ; } | Get a session key value |
11,756 | public function set ( $ name , $ value ) { if ( is_string ( $ name ) ) { $ this -> session [ $ name ] = $ value ; return ( ( isset ( $ this -> session [ $ name ] ) && null != $ this -> session [ $ name ] ) ? true : false ) ; } else { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Session Error : Your s... | Edit a session key |
11,757 | public function replace ( array $ attributes ) : bool { $ status = false ; foreach ( $ this -> session as $ one => $ value ) { if ( null !== $ this -> get ( $ one ) ) { $ this -> set ( $ one , $ value ) ; $ status = true ; } } if ( true === $ status ) { $ this -> save ( ) ; } return ( $ status ) ; } | Replace session items |
11,758 | public function remove ( $ name ) : bool { if ( isset ( $ this -> session [ $ name ] ) ) { unset ( $ this -> session [ $ name ] ) ; $ this -> save ( ) ; return ( true ) ; } else { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Session Error : The session name [$name] is not defined" , "solution" => "Pl... | Remove a session item |
11,759 | public function clear ( ) : bool { if ( true === $ this -> isStarted ( ) ) { session_unset ( ) ; $ this -> setToDefault ( ) ; session_regenerate_id ( true ) ; return ( empty ( $ _SESSION ) ? true : false ) ; } throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Cannot clear the session when is not started" ... | Clear the session |
11,760 | private function setToDefault ( ) : void { $ this -> session = null ; $ this -> id = null ; $ this -> name = null ; } | Set all value to default |
11,761 | private function initSessionConfig ( ) : void { if ( ! defined ( "IUMIO_ENV" ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Framework Environment is not defined" , "solution" => "Please initialize the framework environment" ) ) ) ; } if ( false === Server :: exist ( IUMIO_ROOT . "/elements/cache/... | Init the session configuration |
11,762 | public static function getDuration ( $ start ) { $ time = microtime ( ) ; $ time = explode ( ' ' , $ time ) ; $ time = $ time [ 1 ] + $ time [ 0 ] ; $ finish = $ time ; return round ( ( $ finish - $ start ) , 4 ) ; } | Get the difference between the current timestamp in microseconds and the given timestamp . |
11,763 | public static function displayAsGreen ( string $ message , string $ exit = "yes" , bool $ header = true ) { $ colors = self :: getManagerColorInstance ( ) ; echo $ colors -> getColoredString ( $ message , "green" , "transparent" , $ header ) ; if ( $ exit == "yes" ) { exit ( ) ; } } | display As Green Message with transparent background |
11,764 | public static function displayAsEndSuccess ( string $ message , string $ exit = "yes" ) { $ colors = self :: getManagerColorInstance ( ) ; self :: clear ( ) ; echo "\n" . $ colors -> getColoredString ( $ message , "green" , "transparent" ) ; if ( $ exit == "yes" ) { exit ( ) ; } } | display for end Success Message |
11,765 | public function checkRequired ( $ value ) { if ( is_null ( $ value ) ) { return false ; } if ( is_string ( $ value ) && trim ( $ value ) === '' ) { return false ; } if ( ( is_array ( $ value ) || $ value instanceof Countable ) && count ( $ value ) < 1 ) { return false ; } return true ; } | Check if the passed value is set . |
11,766 | protected function makeComparable ( $ value , $ parameter ) { if ( ! $ value instanceof DateTimeInterface && ! $ parameter instanceof DateTimeInterface ) { return [ $ this -> getSize ( $ value ) , $ parameter ] ; } try { $ value = $ this -> toTimestamp ( $ value ) ; $ parameter = $ this -> toTimestamp ( $ parameter ) ;... | Make two values comparable by normal operators . |
11,767 | protected function getSize ( $ value ) { if ( is_numeric ( $ value ) ) { return $ value ; } if ( is_array ( $ value ) || $ value instanceof Countable ) { return count ( $ value ) ; } return mb_strlen ( $ value ) ; } | Try to guess the size of a parameter . |
11,768 | private function setDefaults ( ) { $ this -> options = [ CURLOPT_RETURNTRANSFER => true , CURLOPT_FOLLOWLOCATION => true , CURLOPT_HEADER => true , CURLINFO_HEADER_OUT => true ] ; } | Set default CURL options |
11,769 | public function close ( ) { if ( is_resource ( $ this -> handle ) ) { curl_close ( $ this -> handle ) ; } $ this -> handle = null ; return $ this ; } | Close currently opened handle |
11,770 | public function prepare ( AbstractRequest $ request ) { $ config = $ request -> getOptions ( ) ; $ this -> options [ CURLOPT_URL ] = ( string ) $ config -> url ; $ this -> options [ CURLOPT_UPLOAD ] = ( bool ) $ config -> upload ; $ this -> options [ CURLOPT_HTTPHEADER ] = $ request -> getHeaderLines ( ) ; if ( $ confi... | Prepare the handle to be configured by a given request |
11,771 | private function prepareHttp ( Configuration \ HttpConfiguration $ config ) { switch ( $ config -> method ) { case 'GET' : $ this -> options [ CURLOPT_HTTPGET ] = true ; break ; case 'PUT' : if ( is_resource ( $ config -> body ) ) { $ this -> options [ CURLOPT_PUT ] = true ; } else { $ this -> options [ CURLOPT_CUSTOMR... | Specific method to prepare HTTP requests options |
11,772 | public function execute ( ) { if ( ! is_resource ( $ this -> handle ) ) { throw new RuntimeException ( 'Curl handle has been closed, just open it before execute...' ) ; } curl_setopt_array ( $ this -> handle , array_filter ( $ this -> options ) ) ; $ return = curl_exec ( $ this -> handle ) ; if ( $ return === false ) {... | Execute current handle and return result |
11,773 | public function reset ( ) { if ( is_resource ( $ this -> handle ) ) { curl_reset ( $ this -> handle ) ; $ this -> setDefaults ( ) ; return true ; } return false ; } | Check PHP version and reset handle option if possible |
11,774 | public function infos ( ) { return ( new ExecutionInfos ( $ this ) ) -> status ( curl_getinfo ( $ this -> handle , CURLINFO_HTTP_CODE ) ) -> headers ( curl_getinfo ( $ this -> handle , CURLINFO_HEADER_OUT ) ) -> effectiveUrl ( curl_getinfo ( $ this -> handle , CURLINFO_EFFECTIVE_URL ) ) -> transactionTime ( curl_getinf... | Retrieve ExecutionInfos details |
11,775 | private function setFieldErrorsAndFocus ( array $ nodes ) { foreach ( $ nodes as $ nodeKey => $ node ) { if ( ! ( $ node instanceof Field ) && ! ( $ node instanceof Fieldset ) ) { throw new \ Exception ( 'Invalid node' ) ; } if ( $ node instanceof Field ) { if ( method_exists ( $ node , 'getValue' ) && mb_strlen ( $ no... | recursive when encounters a fieldset |
11,776 | protected function createApiInstance ( ) { $ configToken = $ this -> getConfig ( 'token' ) ; if ( $ configToken === null ) { throw new InvalidArgumentException ( 'API token has not been set in the config.' ) ; } $ token = new Token ( $ configToken ) ; $ this -> api = new Api ( ) ; $ this -> api -> setToken ( $ token ) ... | Creates a new instance of the API library to use later . |
11,777 | public function getCustomMethodTags ( $ customName = false ) { if ( ! $ customName ) { $ customName = debug_backtrace ( ) [ 1 ] [ 'function' ] ; } $ tags = $ this -> getTags ( ) ; $ tags [ ] = $ this -> xmlFilePath . $ customName ; return $ tags ; } | Return Cache tags generated by using the current active class id and with array . It has an additional method - customized tag . If no customName is provided the name of the calling method will be used . |
11,778 | protected function interpolateContext ( $ sMessage , array $ aContext ) { $ aReplace = array ( ) ; foreach ( $ aContext as $ sKey => $ mValue ) { $ sValue = ( string ) $ mValue ; $ aReplace [ '{' . trim ( $ sKey ) . '}' ] = $ sValue ; } return strtr ( $ sMessage , $ aReplace ) ; } | Interpolates context values into the message placeholders . Taken from PSR - 3 s example implementation . |
11,779 | protected function runActionMethod ( $ action , $ vars = array ( ) ) { return call_user_func_array ( array ( $ this , $ action ) , $ this -> getActionArguments ( $ action , $ vars ) ) ; } | RUN THIS METHOD ACTION |
11,780 | protected function getActionArguments ( $ action , $ vars = array ( ) ) { $ reflectionObject = new \ ReflectionObject ( $ this ) ; $ method = $ reflectionObject -> getMethod ( $ action ) ; $ parameters = $ method -> getParameters ( ) ; $ arguments = array ( ) ; foreach ( $ parameters as $ param ) { $ name = $ param -> ... | GET ACTION NEED ARGUMENTS |
11,781 | private function clean ( $ string ) { $ string = str_replace ( ' ' , '' , $ string ) ; $ string = str_replace ( '-' , '' , $ string ) ; return preg_replace ( '/[^A-Za-z0-9\-]/' , '' , $ string ) ; } | clean clean the given string so it can be used as a class name on an element |
11,782 | protected function tryToRender ( ) { try { $ output = $ this -> toString ( ) ; $ this -> _lastRenderError = null ; return $ output ; } catch ( Exception $ e ) { return $ this -> processException ( $ e ) ; } } | Try to render the string an call the handler . |
11,783 | protected function processException ( Exception $ e ) { $ this -> _lastRenderError = $ e ; if ( $ this -> _errorListener ) { call_user_func ( $ this -> _errorListener , $ e , $ this ) ; } return '' ; } | Process the exception which did occur during toString . |
11,784 | public static function cancel ( $ promise ) { if ( ! static :: isPromise ( $ promise , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The "%s" method must be called with a compatible Promise.' , __METHOD__ ) ) ; } $ promise -> cancel ( ) ; } | Cancel a promise |
11,785 | public function setup ( ) { parent :: setup ( ) ; increase_time_limit_to ( ) ; $ restart = $ this -> currentStep == 0 ; if ( ! $ this -> tempFile || ! file_exists ( $ this -> tempFile ) ) { $ tmpfile = tempnam ( getTempFolder ( ) , 'postsitemap' ) ; if ( file_exists ( $ tmpfile ) ) { $ this -> tempFile = $ tmpfile ; } ... | Note that this is duplicated for backwards compatibility purposes ... |
11,786 | public function prepareForRestart ( ) { parent :: prepareForRestart ( ) ; if ( ! $ this -> tempFile || ! file_exists ( $ this -> tempFile ) ) { $ tmpfile = tempnam ( getTempFolder ( ) , 'postsitemap' ) ; if ( file_exists ( $ tmpfile ) ) { $ this -> tempFile = $ tmpfile ; } $ this -> currentStep = 0 ; $ this -> toProces... | On any restart make sure to check that our temporary file is being created still . |
11,787 | protected function completeJob ( ) { $ content = '<?xml version="1.0" encoding="UTF-8"?>' . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' ; $ content .= file_get_contents ( $ this -> tempFile ) ; $ content .= '</urlset>' ; $ sitemap = Director :: baseFolder ( ) . '/sitemap.xml' ; file_put_contents ( $ ... | Outputs the completed file to the site s webroot |
11,788 | public function get ( string $ key ) : string { if ( ! $ this -> users_id ) { throw new Exception ( 'No users is set to save config' ) ; } if ( $ config = $ this -> findFirst ( [ 'conditions' => 'users_id = ?0 and name = ?1' , 'bind' => [ $ this -> users_id , $ key ] ] ) ) { return $ config -> value ; } throw new Excep... | get a value to the table |
11,789 | public function getConfig ( $ key = null ) { if ( $ key === null ) { return array_merge ( $ this -> configDefaults , $ this -> config ) ; } elseif ( isset ( $ this -> config [ $ key ] ) ) { return $ this -> config [ $ key ] ; } elseif ( isset ( $ this -> configDefaults [ $ key ] ) ) { return $ this -> configDefaults [ ... | Gets the given config key will load from config defaults if not set or return null if there is no default . |
11,790 | public static function get ( string $ param , string $ appname = null ) { if ( isset ( self :: $ framework_paths [ $ param ] ) ) { if ( ! is_array ( self :: $ framework_paths [ $ param ] ) && strpos ( self :: $ framework_paths [ $ param ] , "%app_name%" ) !== false ) { if ( $ appname != null ) { return ( str_replace ( ... | Get a path value in framework_path |
11,791 | public static function set ( string $ index , $ value ) : int { self :: $ framework_paths [ $ index ] = $ value ; $ container = FrameworkContainer :: getInstance ( ) ; $ container -> set ( $ index , $ value ) ; if ( isset ( self :: $ framework_paths [ $ index ] ) ) { return ( 1 ) ; } else { return ( 0 ) ; } } | Set or edit path value in framework_path |
11,792 | public static function isset ( string $ index ) : bool { return ( isset ( self :: $ framework_paths [ $ index ] ) ? true : false ) ; } | Check if element is isset in path framework |
11,793 | protected function bootstrapper ( ) { if ( ! $ this -> bootstrapper ) { $ this -> bootstrapper = $ this -> app -> make ( $ this -> bootClass ( ) ) ; } return $ this -> bootstrapper ; } | Return the created bootstrapper . |
11,794 | public function getAllHostsPerConfigActivity ( ) : Renderer { $ file = ( array ) JL :: open ( FEnv :: get ( "framework.config.hosts.dev.file" ) ) ; if ( ! ( isset ( $ file [ 'allowed' ] ) ) || ! ( isset ( $ file [ 'denied' ] ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Undefined key allowed o... | Get Hosts list |
11,795 | public function getoneConfigActivity ( string $ env ) : Renderer { if ( ! in_array ( $ env , array ( "dev" , "prod" ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Undefined environment $env" , "solution" => "Environment must be [dev or prod]" ) ) ) ; } $ file = ( array ) JL :: open ( FEnv :: ge... | Get one hosts config |
11,796 | public function updateActivity ( string $ env ) : Renderer { $ allowed = $ this -> get ( "request" ) -> get ( "allowed" ) ; $ denied = $ this -> get ( "request" ) -> get ( "denied" ) ; if ( ! in_array ( $ env , array ( "dev" , "prod" ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Undefined envi... | save one hosts configuration |
11,797 | protected function proxy ( $ parent , Storage $ storage , $ storageName = self :: DEFAULT_STORAGE ) { return new CacheProxy ( $ parent , $ this -> categorizer , $ storage , $ storageName ) ; } | Create a new proxy for a different storage . |
11,798 | public function retry_incremental ( \ Exception $ e = null , $ output = null , $ exp = 2 , $ unit = 'minutes' ) { if ( self :: $ max_attempts > 0 AND $ this -> retry_attempt >= self :: $ max_attempts ) { echo $ output ; throw $ e ; } $ this -> retry_attempt ++ ; $ this -> schedule ( pow ( $ this -> retry_attempt , $ ex... | Retry transaction using an incremental time algorithm |
11,799 | protected function addMenuPages ( ) { $ this -> s :: addMenuPageItem ( [ 'auto_prefix' => false , 'parent_page' => 'index.php' , 'page_title' => $ this -> App :: CORE_CONTAINER_NAME , 'menu_title' => $ this -> App :: CORE_CONTAINER_NAME . ' <i class="sharkicon sharkicon-wp-sharks-fin"></i>' , 'template_file' => 's-core... | Adds menu pages . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.