idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
14,900
|
public function validateFormData ( WebRequest $ request , Response $ response , callable $ callback = null ) { $ form = $ this -> searchSubmittedForm ( $ request , $ response ) ; if ( $ form === null ) { return Form :: NOT_SUBMITTED ; } $ errors = $ form -> validateFormData ( $ this -> framework ) ; if ( is_callable ( $ callback ) ) { $ callbackErrors = call_user_func_array ( $ callback , array ( $ this -> getFormValues ( ) ) ) ; if ( is_array ( $ callbackErrors ) ) { $ errors = array_merge ( $ errors , $ callbackErrors ) ; } } if ( is_array ( $ errors ) && count ( $ errors ) > 0 ) { $ this -> updateErrorBox ( $ form , $ errors ) ; return Form :: DATA_INVALID ; } return Form :: DATA_VALID ; }
|
Searches the submitted Form object in the layout and validates the data
|
14,901
|
protected function searchSubmittedForm ( WebRequest $ request , Response $ response ) { $ this -> verifyLayout ( ) ; $ form = null ; foreach ( $ this -> layout -> getChildrenByType ( '\\Zepi\\Web\\UserInterface\\Form\\Form' , true ) as $ availableForm ) { $ availableForm -> processFormData ( $ request , $ response ) ; if ( $ availableForm -> isSubmitted ( ) ) { $ form = $ availableForm ; break ; } } return $ form ; }
|
Searches the submitted form object in the layout .
|
14,902
|
protected function updateErrorBox ( Form $ form , $ errors ) { foreach ( $ form -> getChildrenByType ( '\\Zepi\\Web\\UserInterface\\Form\\ErrorBox' , true ) as $ errorBox ) { $ errorBox -> updateErrorBox ( $ form , false , $ errors ) ; } }
|
Updates all error boxes inside the given form
|
14,903
|
public function getFormValues ( ) { $ this -> verifyLayout ( ) ; $ values = array ( ) ; foreach ( $ this -> layout -> getChildrenByType ( '\\Zepi\\Web\\UserInterface\\Form\\Form' , true ) as $ form ) { $ values = $ this -> extractFormValues ( $ form ) ; } return $ values ; }
|
Returns all the values of the form fields
|
14,904
|
protected function extractFormValues ( Form $ form ) { $ values = array ( ) ; foreach ( $ form -> getChildrenByType ( '\\Zepi\\Web\\UserInterface\\Form\\Field\\FieldAbstract' , true ) as $ field ) { if ( $ field -> getValue ( ) === null ) { continue ; } $ values [ $ field -> getPath ( $ form ) ] = $ field -> getValue ( ) ; } return $ values ; }
|
Extracts all values from the given form and returns an array with the field path and the field value .
|
14,905
|
public function error ( $ message = '' , $ title = '' ) { $ this -> dataCollection -> add ( 'message' , $ message ) ; $ this -> dataCollection -> add ( 'title' , $ title ) ; return $ this -> render ( 'Error' ) ; }
|
Modal error component
|
14,906
|
protected function log ( $ message , $ source = null , $ level = E_NOTICE , $ data = null ) { if ( ! ( $ this -> evtManager instanceof Manager ) ) { $ e = new ExceptionExtended ( sprintf ( "%s::\$evtManager isn't instance of %s" , get_class ( $ this ) , Manager :: class ) ) ; $ e -> setData ( $ data ) ; throw $ e ; } if ( is_null ( $ source ) ) { $ source = ":missed:" ; } $ args = new Args ( [ 'message' => $ message , 'source' => $ source , 'level' => ( int ) $ level , ] ) ; $ this -> evtManager -> fire ( ':log:' , $ args ) ; }
|
Fires event to log message .
|
14,907
|
public function processContent ( Operation $ operation , $ data ) { try { if ( is_array ( $ data ) ) { $ message = $ this -> contentService -> getMessageByOperation ( $ operation ) ; $ message -> setMessage ( $ data [ 'message' ] ) ; } else { $ message = $ data ; } } catch ( \ Exception $ e ) { $ message = $ data ; } return $ message ; }
|
Create or modify the Content object from the form data .
|
14,908
|
public function postPersistNewEvent ( Operation $ operation , $ content = null ) { $ this -> publishNow ( $ operation ) ; $ this -> em -> persist ( $ content ) ; $ this -> em -> flush ( ) ; }
|
This event is being called after the new Activity and its related content was persisted .
|
14,909
|
public function i ( $ text , $ context = array ( ) ) { $ this -> log -> info ( $ text , $ context ) ; $ this -> emit ( self :: SIGNAL_INFORMATION_ENTERED ) ; }
|
Add a information message .
|
14,910
|
public function w ( $ text , $ context = array ( ) ) { $ this -> log -> warn ( $ text , $ context ) ; $ this -> emit ( self :: SIGNAL_WARNING_ENTERED ) ; }
|
Add a warning message .
|
14,911
|
public function e ( $ text , $ context = array ( ) ) { $ this -> log -> error ( $ text , $ context ) ; $ this -> emit ( self :: SIGNAL_ERROR_ENTERED ) ; }
|
Add a error message .
|
14,912
|
public static function load ( string $ filename ) : ConfigInterface { if ( ! file_exists ( $ filename ) ) { throw new \ RuntimeException ( sprintf ( 'Expected config in %s, but the file does not exist.' , $ filename ) , 1 ) ; } $ filename = realpath ( $ filename ) ? : $ filename ; try { $ config = require $ filename ; } catch ( Exception $ e ) { throw new \ RuntimeException ( sprintf ( 'There was an error loading config from %s. Message: %s' , $ filename , $ e -> getMessage ( ) ) , 1 , $ e ) ; } if ( 1 === $ config ) { throw new \ RuntimeException ( sprintf ( 'No configuration was returned from %s.' , $ filename ) , 1 ) ; } if ( ! $ config instanceof ConfigInterface ) { throw new \ RuntimeException ( sprintf ( 'Configuration returned from %s is not an instance of %s.' , $ filename , ConfigInterface :: class ) , 1 ) ; } if ( '' === $ config -> getDocroot ( ) ) { $ config -> setDocroot ( dirname ( $ filename ) ) ; } if ( '' === $ config -> getCachePrefix ( ) ) { $ config -> setCachePrefix ( md5 ( $ filename ) ) ; } return $ config ; }
|
Loads a ConfigInterface from a PHP file .
|
14,913
|
public function checkIsAliasExistsAlready ( $ alias , $ path , array $ pathParameters = array ( ) , $ locale = null ) { if ( $ alias === null ) { return false ; } $ already = $ this -> findByAlias ( $ alias ) ; if ( $ already ) { $ seo = $ this -> createNewAlias ( $ alias , $ path , $ pathParameters , $ locale ) ; if ( $ seo -> getKeyword ( ) == $ already -> getKeyword ( ) ) { return false ; } return true ; } return false ; }
|
Returns true if there is already an alias of another path + pathParameters + locale .
|
14,914
|
protected function _mapIterable ( $ iterable , $ callback , $ start = null , $ count = null , array & $ results = null ) { $ iterable = $ this -> _normalizeIterable ( $ iterable ) ; $ start = is_null ( $ start ) ? 0 : $ this -> _normalizeInt ( $ start ) ; $ count = is_null ( $ count ) ? 0 : $ this -> _normalizeInt ( $ count ) ; $ cStop = $ count - 1 ; $ i = 0 ; $ c = 0 ; foreach ( $ iterable as $ _k => $ _v ) { if ( $ i < $ start ) { ++ $ i ; continue ; } $ result = $ this -> _invokeCallable ( $ callback , [ $ _v , $ _k , $ iterable ] ) ; if ( is_array ( $ results ) ) { $ results [ $ _k ] = $ result ; } if ( $ c === $ cStop ) { break ; } ++ $ c ; ++ $ i ; } }
|
Invokes a callback for each element of the iterable .
|
14,915
|
protected function getMove ( $ player = self :: PLAYER_X ) { $ move = $ this -> calculateBestMove ( $ player ) ; if ( ! empty ( $ move ) ) { $ this -> board -> setValue ( $ move , $ player ) ; } return $ move ; }
|
return recommended value
|
14,916
|
private function winningValues ( ) { return array_merge ( $ this -> board -> getBoard ( ) , $ this -> transpose ( $ this -> board -> getBoard ( ) ) , $ this -> diagonals ( ) ) ; }
|
Determine winning values
|
14,917
|
private function calculateBestMove ( $ player , $ stopOpponentPlayer = true , & $ playerMoveScore = 0 ) { $ winningMoves = [ ] ; $ opponentMoveScore = 0 ; $ opponentMove = [ ] ; if ( ! $ this -> checkPlayer ( $ player ) || $ this -> isFinished ( ) ) { return $ winningMoves ; } if ( $ stopOpponentPlayer ) { $ opponentMove = $ this -> calculateBestMove ( $ this -> getOpponentPlayer ( $ player ) , false , $ opponentMoveScore ) ; } foreach ( $ this -> board -> getBoard ( ) as $ positionX => $ col ) { foreach ( $ col as $ positionY => $ tile ) { $ moveScore = $ this -> calculateMoveScore ( $ player , [ $ positionX , $ positionY ] ) ; if ( ! is_null ( $ moveScore ) ) { if ( $ moveScore > $ playerMoveScore ) { $ winningMoves = [ [ $ positionX , $ positionY ] ] ; $ playerMoveScore = $ moveScore ; continue ; } if ( $ moveScore == $ playerMoveScore ) { array_push ( $ winningMoves , [ $ positionX , $ positionY ] ) ; continue ; } } } } if ( $ stopOpponentPlayer && $ opponentMoveScore >= 10 && $ playerMoveScore < 10 ) { return $ opponentMove ; } if ( count ( $ winningMoves ) ) { return $ winningMoves [ array_rand ( $ winningMoves ) ] ; } return $ winningMoves ; }
|
Get the best move of a player
|
14,918
|
private function calculateMoveScore ( $ player , array $ position ) { if ( $ this -> board -> getValue ( $ position ) ) { return null ; } $ totalScore = 0 ; foreach ( $ this -> positions as $ row ) { if ( ! in_array ( $ position , $ row ) ) { continue ; } $ countOpponentMoves = 0 ; $ countPlayerMoves = 0 ; foreach ( $ row as $ positionTile ) { $ positionValue = $ this -> board -> getValue ( $ positionTile ) ; if ( $ positionValue ) { $ countOpponentMoves ++ ; if ( $ positionValue == $ player ) { $ countPlayerMoves ++ ; $ countOpponentMoves -- ; } } } if ( ! $ countOpponentMoves && $ countPlayerMoves == 2 ) { $ totalScore += 10 ; continue ; } if ( ! $ countOpponentMoves && $ countPlayerMoves == 1 ) { $ totalScore += 2 ; continue ; } if ( ! $ countOpponentMoves && ! $ countPlayerMoves ) { $ totalScore ++ ; continue ; } } return $ totalScore ; }
|
Get the score of a move
|
14,919
|
public function get ( $ root , $ path ) { $ url = $ root . $ path ; $ response = Http :: get ( $ url . $ this -> countryCode . $ this -> localLang ) ; if ( is_array ( $ response ) ) { return $ response ; } else { return false ; } }
|
Gets requested data using Http client and returns the json decoded response
|
14,920
|
public function getAppDetails ( $ id , $ filter = '' ) { if ( ! empty ( $ filter ) ) { $ filter = '&filters=' . $ filter ; } $ app = $ this -> get ( self :: STEAM_STORE_ROOT , self :: APP_DETAILS_PATH . $ id . $ filter ) ; if ( $ app [ $ id ] [ 'success' ] == true ) { return new App ( $ app [ $ id ] [ 'data' ] ) ; } else { return false ; } }
|
Retrieves App information for a specific AppID
|
14,921
|
protected function buildQuery ( ) { $ search = $ this -> repository -> createSearch ( ) ; $ search -> setSize ( $ this -> limit ) ; $ search -> addSort ( new Sort ( 'left' , Sort :: ORDER_ASC ) ) ; $ search -> addQuery ( new TermQuery ( 'active' , true ) , 'must' ) ; if ( ! $ this -> loadHiddenCategories ) { $ search -> addQuery ( new TermQuery ( 'is_hidden' , 0 ) , 'must' ) ; } return $ search ; }
|
Builds a search query .
|
14,922
|
private function buildChildNode ( $ node , $ references , $ maxLevel ) { if ( isset ( $ references [ $ node -> getParentId ( ) ] ) ) { $ level = $ references [ $ node -> getParentId ( ) ] -> getLevel ( ) + 1 ; if ( $ maxLevel == 0 || $ level <= $ maxLevel ) { $ node -> setLevel ( $ level ) ; $ node -> setParent ( $ references [ $ node -> getParentId ( ) ] ) ; $ references [ $ node -> getParentId ( ) ] -> setChild ( $ node , $ node -> getId ( ) ) ; } } }
|
Builds a child node .
|
14,923
|
private function buildRootNode ( $ node , $ tree , $ level ) { $ node -> setLevel ( $ level ) ; $ tree [ $ node -> getId ( ) ] = $ node ; }
|
Builds a root node .
|
14,924
|
private function buildNode ( $ node , $ references , $ tree , $ maxLevel ) { if ( $ node -> getId ( ) == $ this -> getCurrentCategoryId ( ) ) { $ node -> setCurrent ( true ) ; $ this -> currentLeaf = $ node ; } $ references [ $ node -> getId ( ) ] = $ node ; if ( $ node -> getParentId ( ) == $ this -> rootId ) { $ this -> buildRootNode ( $ node , $ tree , 1 ) ; } else { $ this -> buildChildNode ( $ node , $ references , $ maxLevel ) ; } }
|
Builds a node . Sets node parameters .
|
14,925
|
private function expandNodes ( $ references ) { $ id = $ this -> getCurrentCategoryId ( ) ; if ( $ id ) { while ( isset ( $ references [ $ id ] ) ) { $ references [ $ id ] -> setExpanded ( true ) ; $ id = $ references [ $ id ] -> getParentId ( ) ; } } }
|
Expands nodes .
|
14,926
|
private function buildTree ( $ dataSet , $ maxLevel = 0 ) { $ tree = new \ ArrayIterator ( ) ; $ references = new \ ArrayIterator ( ) ; foreach ( $ dataSet as $ node ) { if ( $ node -> isActive ( ) ) { $ this -> buildNode ( $ node , $ references , $ tree , $ maxLevel ) ; } } $ this -> expandNodes ( $ references ) ; $ this -> sortChildTree ( $ tree ) ; return $ tree ; }
|
Builds nested tree from single category list .
|
14,927
|
protected function sortChildTree ( & $ tree ) { if ( is_array ( $ tree ) ) { uasort ( $ tree , [ $ this , 'sortNodes' ] ) ; foreach ( $ tree as $ node ) { $ children = $ node -> getChildren ( ) ; if ( $ children ) { $ this -> sortChildTree ( $ children ) ; $ node -> setChildren ( $ children ) ; } } } else { $ tree -> uasort ( [ $ this , 'sortNodes' ] ) ; $ tree -> rewind ( ) ; foreach ( $ tree as $ node ) { $ children = $ node -> getChildren ( ) ; if ( $ children ) { $ this -> sortChildTree ( $ children ) ; $ node -> setChildren ( $ children ) ; } } } }
|
Sorts category tree by sort field .
|
14,928
|
public function sortNodes ( $ a , $ b ) { if ( $ a -> getSort ( ) < $ b -> getSort ( ) ) { return - 1 ; } elseif ( $ a -> getSort ( ) > $ b -> getSort ( ) ) { return 1 ; } elseif ( $ a -> getLeft ( ) < $ b -> getLeft ( ) ) { return - 1 ; } elseif ( $ a -> getLeft ( ) > $ b -> getLeft ( ) ) { return 1 ; } return 0 ; }
|
Sorts nodes by field sort if value equal then by field left .
|
14,929
|
public function getTree ( $ maxLevel = 0 , $ getHidden = false ) { $ hash = $ maxLevel . $ getHidden ; if ( ! isset ( $ this -> treeCache [ $ hash ] ) ) { $ this -> setLoadHiddenCategories ( $ getHidden ) ; $ query = $ this -> buildQuery ( ) ; $ results = $ this -> repository -> execute ( $ query , Repository :: RESULTS_OBJECT ) ; $ tree = $ this -> buildTree ( $ results , $ maxLevel ) ; $ this -> treeCache [ $ hash ] = $ tree ; } return $ this -> treeCache [ $ hash ] ; }
|
Returns nested category tree .
|
14,930
|
protected function findPartialTree ( $ tree , $ categoryId ) { foreach ( $ tree as $ node ) { if ( $ node -> getId ( ) == $ categoryId ) { return [ $ node ] ; } if ( $ node -> getChildren ( ) ) { $ result = $ this -> findPartialTree ( $ node -> getChildren ( ) , $ categoryId ) ; if ( ! empty ( $ result ) ) { return $ result ; } } } return [ ] ; }
|
Returns partial tree by category ID .
|
14,931
|
public function getCategoryInsertionPointValueOptions ( ) { $ trees = $ this -> getCategoryService ( ) -> getAllCategoryTreesAsArray ( ) ; $ valueOptions = array ( ) ; foreach ( $ trees as $ rootId => $ tree ) { $ valueOptions [ $ rootId ] = array ( 'label' => 'Label of category ' . $ rootId , 'options' => array ( ) ) ; foreach ( $ tree as $ node ) { $ category = $ node -> getNode ( ) ; if ( $ category -> getId ( ) == $ rootId ) { $ valueOptions [ $ rootId ] [ 'label' ] = $ category -> getTitle ( ) ; } $ valueOptions [ $ rootId ] [ 'options' ] [ $ category -> getId ( ) ] = str_repeat ( '-' , $ node -> getLevel ( ) ) . $ category -> getTitle ( ) ; } } return $ valueOptions ; }
|
Returns all categoies for the category position select box
|
14,932
|
protected function _getTranslations ( $ domain ) { if ( ! isset ( $ this -> _translations [ $ domain ] ) ) { if ( ! isset ( $ this -> _translationSources [ $ domain ] ) ) { $ msg = sprintf ( 'No translation directory for domain "%1$s" available' , $ domain ) ; throw new MW_Translation_Exception ( $ msg ) ; } $ locations = array_reverse ( $ this -> _getTranslationFileLocations ( $ this -> _translationSources [ $ domain ] , $ this -> getLocale ( ) ) ) ; $ options = $ this -> _options ; foreach ( $ locations as $ location ) { $ options [ 'content' ] = $ location ; $ this -> _translations [ $ domain ] [ ] = new Zend_Translate ( $ options ) ; } } return ( isset ( $ this -> _translations [ $ domain ] ) ? $ this -> _translations [ $ domain ] : array ( ) ) ; }
|
Returns the initialized Zend translation object which contains the translations .
|
14,933
|
public static function dispatch ( ) { self :: $ _config = MRest :: getConfig ( 'routing' ) ; $ routeData = self :: _callDispatcher ( self :: $ _config [ 'dispatcher' ] ) ; if ( ! class_exists ( $ routeData [ 'class' ] ) || ! ( new \ ReflectionClass ( $ routeData [ 'class' ] ) ) -> isInstantiable ( ) ) { throw new \ Exception ( 'Application class [' . $ routeData [ 'class' ] . '] was not found' , 404 ) ; } $ class = new $ routeData [ 'class' ] ( ) ; if ( ! is_callable ( [ $ class , $ routeData [ 'method' ] ] ) ) { throw new \ Exception ( 'Method [' . $ routeData [ 'method' ] . '] not allowed' , 405 ) ; } return call_user_func_array ( [ $ class , $ routeData [ 'method' ] ] , $ routeData [ 'attributes' ] ) ; }
|
Initialization of the Routing class
|
14,934
|
private static function _callDispatcher ( $ dispatcherCallback ) { $ dispatcherCallback = $ dispatcherCallback [ 0 ] !== '\\' ? __NAMESPACE__ . '\\' . $ dispatcherCallback : $ dispatcherCallback ; if ( ! is_callable ( $ dispatcherCallback ) ) { throw new \ Exception ( 'Routing dispacher [' . $ dispatcherCallback . '] cannot be called.' , 500 ) ; } return call_user_func_array ( $ dispatcherCallback , [ self :: $ _uri , self :: $ _config ] ) ; }
|
Calls the route dispatcher which is specified in the configuration .
|
14,935
|
private static function _mainDispatcher ( $ uri , $ config ) { $ uriInfo = self :: analizeUri ( ) ; $ uri = $ uriInfo [ 'uri' ] ; $ uriItems = explode ( '/' , $ uri ) ; $ attributes = [ ] ; foreach ( $ config [ 'routes' ] as $ routePattern => $ className ) { if ( preg_match ( '#' . $ routePattern . '#' , $ uri ) ) { $ class = $ className ; $ itemCount = count ( explode ( '/' , str_replace ( '\\/' , '/' , $ routePattern ) ) ) ; for ( $ i = 0 ; $ i < $ itemCount ; $ i ++ ) { unset ( $ uriItems [ $ i ] ) ; } $ attributes = array_values ( $ uriItems ) ; break ; } } if ( ! $ class ) { $ class = self :: _getController ( $ uri , 'App\\' ) ; $ classUri = self :: _getControllerBaseUri ( $ class ) ; if ( strpos ( $ uri , $ classUri ) === 0 && strlen ( $ uri ) > strlen ( $ classUri ) ) { $ attributesUri = substr ( $ uri , strlen ( $ classUri ) + 1 ) ; $ attributes = explode ( '/' , $ attributesUri ) ; } } return [ 'class' => self :: fixNamespace ( $ class ? $ class : self :: _getController ( $ uri , 'App\\' ) ) , 'method' => strtolower ( $ _SERVER [ 'REQUEST_METHOD' ] ) , 'attributes' => $ attributes ] ; }
|
Main dispatcher . Looks for patterns from the config .
|
14,936
|
private static function _getController ( $ uri , $ namespace ) { $ dir = realpath ( APP_PATH . '/../' . $ namespace ) . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ dir . $ uri ) ) { $ uriParts = explode ( '/' , $ uri , 2 ) ; if ( is_dir ( $ dir . $ uriParts [ 0 ] ) ) { return self :: _getController ( $ uriParts [ 1 ] , $ namespace . $ uriParts [ 0 ] . '\\' ) ; } elseif ( is_file ( $ dir . $ uriParts [ 0 ] . '.php' ) ) { $ uri = $ uriParts [ 0 ] ; } } else { $ namespace = $ namespace . '\\' . str_replace ( '/' , '\\' , $ uri ) ; $ uri = '' ; } if ( substr ( $ namespace , - 1 ) == '\\' ) { $ namespace = substr ( $ namespace , 0 , strlen ( $ namespace ) - 1 ) ; } if ( ! $ uri ) { $ uri = self :: getNamespaceDefaultClass ( $ namespace , 'App\\' ) ; } return self :: fixNamespace ( $ namespace . '\\' . $ uri ) ; }
|
Returns the controller s data for an URI
|
14,937
|
public static function getUri ( ) { if ( self :: $ _uri === null ) { $ uri = explode ( '?' , $ _SERVER [ 'REQUEST_URI' ] , 2 ) [ 0 ] ; self :: $ _uri = self :: fixUri ( substr ( $ uri , strlen ( BASE_URI ) ) ) ; } return self :: $ _uri ; }
|
Get the current URI
|
14,938
|
public static function analizeUri ( ) { $ uri = self :: getUri ( ) ; $ uriInfo = pathinfo ( $ uri ) ; if ( ! isset ( $ uriInfo [ 'dirname' ] ) || $ uriInfo [ 'dirname' ] == '.' ) { $ uriInfo [ 'dirname' ] = '' ; } return [ 'type' => isset ( $ uriInfo [ 'extension' ] ) ? $ uriInfo [ 'extension' ] : MRest :: getConfig ( ) [ 'contentType' ] , 'uri' => self :: fixUri ( $ uriInfo [ 'dirname' ] . '/' . $ uriInfo [ 'filename' ] ) ] ; }
|
Make an analize of the URI . Returns the output content type and the URI
|
14,939
|
public static function fixUri ( $ url ) { $ url = preg_replace ( '#/+|\\\+#' , '/' , $ url ) ; if ( $ url [ 0 ] == '/' ) { $ url = substr ( $ url , 1 , strlen ( $ url ) ) ; } if ( substr ( $ url , - 1 ) == '/' ) { $ url = substr ( $ url , 0 , strlen ( $ url ) - 1 ) ; } return $ url ; }
|
Fix the URI . Removes the multiple slashes
|
14,940
|
private function directoryOperation ( string $ operation , string $ destination ) : void { try { Filesystem :: checkExists ( $ destination ) ; } catch ( FileNotFoundException $ e ) { $ destinationDir = new self ( $ destination ) ; $ destinationDir -> create ( ) ; } $ files = $ this -> getFiles ( ) ; foreach ( $ files as $ file ) { $ destinationPath = "$destination/" . basename ( $ file ) ; $ file -> $ operation ( $ destinationPath ) ; } }
|
Used to perform copies and moves .
|
14,941
|
public function getSize ( ) : int { $ files = $ this -> getFiles ( ) ; $ size = 0 ; foreach ( $ files as $ file ) { $ size += $ file -> getSize ( ) ; } return $ size ; }
|
Recursively get the size of all contents in the directory .
|
14,942
|
public function moveTo ( string $ destination ) : void { $ this -> directoryOperation ( 'moveTo' , $ destination ) ; $ this -> delete ( ) ; $ this -> path = $ destination ; }
|
Recursively move a directory and its contents to another location .
|
14,943
|
public function create ( $ permissions = 0755 ) { Filesystem :: checkNotExists ( $ this -> path ) ; Filesystem :: checkWritable ( dirname ( $ this -> path ) ) ; mkdir ( $ this -> path , $ permissions , true ) ; }
|
Create the directory pointed to by path .
|
14,944
|
public function delete ( ) : void { $ files = $ this -> getFiles ( ) ; foreach ( $ files as $ file ) { $ file -> delete ( ) ; } rmdir ( $ this -> path ) ; }
|
Recursively delete the directory and all its contents .
|
14,945
|
public function getFiles ( ) : array { Filesystem :: checkExists ( $ this -> path ) ; Filesystem :: checkReadable ( $ this -> path ) ; $ contents = [ ] ; $ files = scandir ( $ this -> path ) ; foreach ( $ files as $ file ) { if ( $ file != '.' && $ file != '..' ) { $ contents [ ] = Filesystem :: get ( "$this->path/$file" ) ; } } return $ contents ; }
|
Get the files in the directory .
|
14,946
|
protected function curl ( $ type , $ endpoint , $ variables ) { $ url = $ this -> baseUrl . '/' . $ endpoint ; $ handle = curl_init ( ) ; curl_setopt ( $ handle , CURLOPT_POST , true ) ; $ fieldsString = "" ; foreach ( $ variables as $ key => $ value ) { $ fieldsString .= $ key . '=' . $ value . '&' ; } $ fieldsString = rtrim ( $ fieldsString , '&' ) ; curl_setopt ( $ handle , CURLOPT_POSTFIELDS , $ fieldsString ) ; curl_setopt ( $ handle , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ handle , CURLOPT_URL , $ url ) ; $ response = curl_exec ( $ handle ) ; $ statusCode = curl_getinfo ( $ handle , CURLINFO_HTTP_CODE ) ; return array ( 'statusCode' => $ statusCode , 'response' => $ response ) ; }
|
Curls the API with the desired request type .
|
14,947
|
protected function setOption ( $ key , $ value ) { if ( ! isset ( $ this -> config [ $ key ] ) ) { throw new Exception \ DomainException ( sprintf ( 'Option "%s" does not exist; available options are (%s)' , $ key , implode ( ', ' , array_map ( function ( $ opt ) { return '"' . $ opt . '"' ; } , array_keys ( $ this -> config ) ) ) ) ) ; } if ( ! ArrayUtils :: isList ( $ this -> config [ $ key ] , false ) ) { throw new Exception \ DomainException ( sprintf ( 'Option "%s" does not have a list of allowed values' , $ key ) ) ; } if ( ! ArrayUtils :: inArray ( $ value , $ this -> config [ $ key ] , true ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Option "%s" can not be set to value "%s"; allowed values are (%s)' , $ key , $ value , implode ( ', ' , array_map ( function ( $ val ) { return '"' . $ val . '"' ; } , $ this -> config [ $ key ] ) ) ) ) ; } $ this -> options [ $ key ] = $ value ; return $ this ; }
|
Option setter with validation If option can have the specified value then it is set otherwise this method throws exception
|
14,948
|
protected function getOption ( $ key ) { if ( ! isset ( $ this -> options [ $ key ] ) ) { throw new Exception \ RuntimeException ( sprintf ( 'Option "%s" not found' , $ key ) ) ; } return $ this -> options [ $ key ] ; }
|
Option getter with check
|
14,949
|
public function Start ( $ Force = FALSE ) { if ( function_exists ( 'apc_fetch' ) && C ( 'Garden.Apc' , FALSE ) ) $ this -> Apc = TRUE ; $ this -> AvailableThemes ( $ Force ) ; $ ThemeName = $ this -> CurrentTheme ( ) ; $ ThemeInfo = $ this -> GetThemeInfo ( $ ThemeName ) ; $ ThemeHooks = GetValue ( 'RealHooksFile' , $ ThemeInfo , NULL ) ; if ( file_exists ( $ ThemeHooks ) ) include_once ( $ ThemeHooks ) ; }
|
Sets up the theme framework
|
14,950
|
public function AvailableThemes ( $ Force = FALSE ) { if ( is_null ( $ this -> ThemeCache ) || $ Force ) { $ this -> ThemeCache = array ( ) ; foreach ( $ this -> SearchPaths ( ) as $ SearchPath => $ Trash ) { unset ( $ SearchPathCache ) ; $ SearchPathCacheKey = 'Garden.Themes.PathCache.' . $ SearchPath ; if ( $ this -> Apc ) { $ SearchPathCache = apc_fetch ( $ SearchPathCacheKey ) ; } else { $ SearchPathCache = Gdn :: Cache ( ) -> Get ( $ SearchPathCacheKey , array ( Gdn_Cache :: FEATURE_NOPREFIX => TRUE ) ) ; } $ CacheHit = ( $ SearchPathCache !== Gdn_Cache :: CACHEOP_FAILURE ) ; if ( $ CacheHit && is_array ( $ SearchPathCache ) ) { $ CacheIntegrityCheck = ( sizeof ( array_intersect ( array_keys ( $ SearchPathCache ) , array ( 'CacheIntegrityHash' , 'ThemeInfo' ) ) ) == 2 ) ; if ( ! $ CacheIntegrityCheck ) { $ SearchPathCache = array ( 'CacheIntegrityHash' => NULL , 'ThemeInfo' => array ( ) ) ; } } $ CacheThemeInfo = & $ SearchPathCache [ 'ThemeInfo' ] ; if ( ! is_array ( $ CacheThemeInfo ) ) $ CacheThemeInfo = array ( ) ; $ PathListing = scandir ( $ SearchPath , 0 ) ; sort ( $ PathListing ) ; $ PathIntegrityHash = md5 ( serialize ( $ PathListing ) ) ; if ( GetValue ( 'CacheIntegrityHash' , $ SearchPathCache ) != $ PathIntegrityHash ) { $ PathIntegrityHash = $ this -> IndexSearchPath ( $ SearchPath , $ CacheThemeInfo , $ PathListing ) ; if ( $ PathIntegrityHash === FALSE ) continue ; $ SearchPathCache [ 'CacheIntegrityHash' ] = $ PathIntegrityHash ; if ( $ this -> Apc ) { apc_store ( $ SearchPathCacheKey , $ SearchPathCache ) ; } else { Gdn :: Cache ( ) -> Store ( $ SearchPathCacheKey , $ SearchPathCache , array ( Gdn_Cache :: FEATURE_NOPREFIX => TRUE ) ) ; } } $ this -> ThemeCache = array_merge ( $ this -> ThemeCache , $ CacheThemeInfo ) ; } } return $ this -> ThemeCache ; }
|
Looks through the themes directory for valid themes and returns them as an associative array of Theme Name = > Theme Info Array . It also adds a Folder definition to the Theme Info Array for each .
|
14,951
|
public function getBalance ( ) : float { $ this -> authenticator -> authenticate ( ) ; return ( float ) $ this -> soapClient -> __soapCall ( 'GetCreditBalance' , [ ] ) -> GetCreditBalanceResult ; }
|
Get the balance
|
14,952
|
private function tryResolveErrorReason ( string $ message ) : string { $ key = $ this -> responseParser -> parse ( $ message ) ; if ( $ key === 'invalid_phone' ) { return ErrorReasons :: INVALID_PHONE_NUMBER ; } return ErrorReasons :: UNKNOWN ; }
|
Try to resolve error reason
|
14,953
|
private function processResultMessages ( Message $ message , array $ recipients , $ resultMessages ) : ResultCollection { if ( is_scalar ( $ resultMessages ) ) { $ key = $ this -> responseParser -> parse ( $ resultMessages ) ; if ( $ key === 'signature_not_allowed' ) { throw new SenderNameNotAllowedException ( sprintf ( 'The signature (sender) "%s" not allowed.' , $ message -> getSender ( ) ) ) ; } elseif ( $ key === 'signature_invalid' ) { throw new InvalidSenderNameException ( sprintf ( 'Invalid signature (sender): %s' , $ message -> getSender ( ) ) ) ; } throw new SendSmsException ( sprintf ( 'Cannot resolve the error for sending SMS. Error: %s' , $ resultMessages ) ) ; } $ sendResult = $ resultMessages [ 0 ] ; $ sendResultKey = $ this -> responseParser -> parse ( $ sendResult ) ; if ( $ sendResultKey === 'missing_required_parameters' ) { throw new MissingRequiredParameterException ( 'Missing required parameters.' ) ; } if ( $ sendResultKey !== 'success' && $ sendResultKey !== 'fail' ) { throw new SendSmsException ( sprintf ( 'Fail send sms. Result messages: %s' , json_encode ( $ resultMessages ) ) ) ; } array_shift ( $ resultMessages ) ; $ resultData = [ ] ; foreach ( $ recipients as $ recipient ) { $ messageId = array_shift ( $ resultMessages ) ; $ success = preg_match ( '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/' , $ messageId ) ; if ( $ success ) { $ resultData [ ] = Result :: successfully ( $ recipient , $ messageId ) ; } else { $ reason = $ this -> tryResolveErrorReason ( $ messageId ) ; $ resultData [ ] = Result :: failed ( $ recipient , new Error ( $ reason , $ messageId ) ) ; } } return new ResultCollection ( ... $ resultData ) ; }
|
Process the response from TurboSMS
|
14,954
|
public function makeHttpRequest ( ) { $ url = $ this -> addUrlData ( $ this -> Request -> getUrl ( ) , $ this -> Request -> getUrlData ( ) ) ; $ url = $ this -> addGetData ( $ url , $ this -> Request -> getGetData ( ) ) ; $ Resource = curl_init ( $ url ) ; $ options = [ CURLOPT_RETURNTRANSFER => true , CURLOPT_CONNECTTIMEOUT => $ this -> Request -> getConnectTimeout ( ) , CURLOPT_TIMEOUT => $ this -> Request -> getTimeout ( ) , CURLOPT_HEADER => true , ] ; if ( ! $ this -> Request -> isDefaultSslVersion ( ) ) { $ options [ CURLOPT_SSLVERSION ] = $ this -> Request -> getSslVersion ( ) ; } curl_setopt_array ( $ Resource , $ this -> getOptions ( ) + $ options ) ; $ this -> addHeaders ( $ Resource , $ this -> Request -> getHeaders ( ) ) ; $ this -> addPostData ( $ Resource , $ this -> Request -> getPostData ( ) ) ; $ this -> setMethod ( $ Resource , $ this -> Request -> getMethod ( ) ) ; $ result = curl_exec ( $ Resource ) ; if ( $ result === false ) { $ errorCode = curl_errno ( $ Resource ) ; $ errorMessage = curl_error ( $ Resource ) ; curl_close ( $ Resource ) ; throw new CurlErrorException ( $ errorMessage , $ errorCode ) ; } $ headerSize = curl_getinfo ( $ Resource , CURLINFO_HEADER_SIZE ) ; $ headers = substr ( $ result , 0 , $ headerSize ) ; $ this -> parseResponseHeaders ( $ headers ) ; $ body = substr ( $ result , $ headerSize ) ; $ httpCode = curl_getinfo ( $ Resource , CURLINFO_HTTP_CODE ) ; curl_close ( $ Resource ) ; switch ( floor ( $ httpCode / 100 ) ) { case 1 : throw new HttpInformationalCodeException ( $ body , $ httpCode ) ; case 3 : throw new HttpRedirectionCodeException ( $ body , $ httpCode ) ; case 4 : throw new HttpClientErrorCodeException ( $ body , $ httpCode ) ; case 5 : throw new HttpServerErrorCodeException ( $ body , $ httpCode ) ; default : case 2 : return $ body ; } }
|
Transportation implementation method
|
14,955
|
private function parseResponseHeaders ( $ string ) { $ parts = explode ( "\n" , $ string ) ; foreach ( $ parts as $ part ) { if ( strpos ( $ part , ':' ) !== false ) { list ( $ name , $ value ) = explode ( ':' , $ part ) ; $ this -> responseHeaders [ trim ( $ name ) ] = trim ( $ value ) ; } } }
|
Parsing response block for headers
|
14,956
|
private function addHeaders ( $ Resource , $ headers ) { $ httpHeaders = array ( ) ; foreach ( $ headers as $ header => $ value ) { $ httpHeaders [ ] = $ header . ': ' . $ value ; } curl_setopt ( $ Resource , CURLOPT_HTTPHEADER , $ httpHeaders ) ; }
|
Add http headers method
|
14,957
|
private function addGetData ( $ url , $ data ) { $ parts [ ] = $ url ; if ( ! empty ( $ data ) ) { $ parts [ ] = http_build_query ( $ data ) ; } return implode ( '?' , $ parts ) ; }
|
Add GET data for resource
|
14,958
|
private function addPostData ( $ Resource , $ data ) { if ( ! empty ( $ data ) ) { switch ( $ this -> Request -> getContentTypeCode ( ) ) { case Request :: CONTENT_TYPE_UNDEFINED : $ string = http_build_query ( $ data ) ; break ; case Request :: CONTENT_TYPE_JSON : $ string = json_encode ( $ data ) ; break ; case Request :: CONTENT_TYPE_TEXT : $ string = ( string ) $ data ; break ; case Request :: CONTENT_TYPE_XML : if ( $ data instanceof DOMDocument ) { $ string = $ data -> saveXML ( ) ; } else { $ string = ( string ) $ data ; } break ; default : throw new HttpContentTypeException ( ) ; } curl_setopt_array ( $ Resource , array ( CURLOPT_POST => true , CURLOPT_POSTFIELDS => $ string , ) ) ; } }
|
Add POST data for request
|
14,959
|
private function addUrlData ( $ url , array $ data ) { if ( empty ( $ data ) ) { return $ url ; } if ( strpos ( $ url , '?' ) !== false ) { throw new \ InvalidArgumentException ( ) ; } $ parts [ ] = trim ( $ url , '/' ) ; foreach ( $ data as $ key => $ value ) { if ( $ value ) { $ parts [ ] = urlencode ( $ key ) . '/' . urlencode ( $ value ) ; } else { $ parts [ ] = urlencode ( $ key ) ; } } return implode ( '/' , $ parts ) ; }
|
Add url parameters for url
|
14,960
|
private function setMethod ( $ Resource , $ method ) { switch ( $ method ) { case Request :: METHOD_GET : curl_setopt ( $ Resource , CURLOPT_HTTPGET , true ) ; break ; case Request :: METHOD_POST : curl_setopt ( $ Resource , CURLOPT_POST , true ) ; break ; } }
|
Set request HTTP method
|
14,961
|
public function getPageCount ( ) : int { if ( $ this -> lastResponse && $ this -> lastResponse -> getHeaderLine ( 'X-Total-Pages' ) ) { return ( int ) $ this -> lastResponse -> getHeaderLine ( 'X-Total-Pages' ) ; } return 0 ; }
|
Returns the number of pages in the collection Returns 0 if the header isn t set
|
14,962
|
public function getItemCount ( ) : int { if ( $ this -> lastResponse && $ this -> lastResponse -> getHeaderLine ( 'X-Total-Count' ) ) { return ( int ) $ this -> lastResponse -> getHeaderLine ( 'X-Total-Count' ) ; } return 0 ; }
|
Returns the total item count in the collection Returns 0 if the header isn t set
|
14,963
|
public function setTaxes ( $ value ) { if ( is_array ( $ value ) ) { $ bag = new Bag ( ) ; foreach ( $ value as $ taxParameters ) { $ bag -> add ( new Tax ( $ taxParameters ) ) ; } $ value = $ bag ; } return $ this -> setParameter ( 'taxes' , $ value ) ; }
|
Set the item taxes
|
14,964
|
public function withProperty ( string $ name , $ value ) : self { return new self ( $ this -> object , $ this -> properties -> put ( $ name , $ value ) , $ this -> injectionStrategy , $ this -> extractionStrategy ) ; }
|
Add a property that will be injected
|
14,965
|
public function build ( ) : object { return $ this -> properties -> reduce ( $ this -> object , function ( object $ object , string $ key , $ value ) : object { return $ this -> inject ( $ object , $ key , $ value ) ; } ) ; }
|
Return the object with the list of properties set on it
|
14,966
|
public function extract ( string ... $ properties ) : MapInterface { $ map = new Map ( 'string' , 'mixed' ) ; foreach ( $ properties as $ property ) { $ map = $ map -> put ( $ property , $ this -> extractProperty ( $ property ) ) ; } return $ map ; }
|
Extract the given list of properties
|
14,967
|
private function getRedis ( ) { if ( is_null ( $ this -> Redis ) ) { if ( $ this -> isConfigured ( ) ) { $ this -> Redis = new \ Redis ( ) ; $ this -> connect ( ) ; } else { throw new RedisNotConfiguredException ( ) ; } } return $ this -> Redis ; }
|
Getter of phpredis object
|
14,968
|
public function incr ( $ key , $ value = 1 ) { $ value = ( int ) $ value ; try { $ result = ( $ value > 1 ) ? $ this -> getRedis ( ) -> incrBy ( $ key , $ value ) : $ this -> getRedis ( ) -> incr ( $ key ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Increment key value
|
14,969
|
public function decr ( $ key , $ value = 1 ) { $ value = ( int ) $ value ; try { $ result = ( $ value > 1 ) ? $ this -> getRedis ( ) -> decrBy ( $ key , $ value ) : $ this -> getRedis ( ) -> decr ( $ key ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Decrement key value
|
14,970
|
public function append ( $ key , $ value ) { try { $ result = $ this -> getRedis ( ) -> append ( $ key , $ value ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Append string value
|
14,971
|
public function mget ( array $ keys ) { try { $ result = $ this -> getRedis ( ) -> mGet ( $ keys ) ; if ( $ result !== false ) { return array_combine ( $ keys , $ result ) ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Get multiple keys values
|
14,972
|
public function set ( $ key , $ value , $ timeout = 0 ) { try { $ result = ( $ timeout == 0 ) ? $ this -> getRedis ( ) -> set ( $ key , $ value ) : $ this -> getRedis ( ) -> psetex ( $ key , $ timeout , $ value ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Set key value
|
14,973
|
public function setnx ( $ key , $ value ) { try { return $ this -> getRedis ( ) -> setnx ( $ key , $ value ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Set key value if not exists
|
14,974
|
public function delete ( $ keys ) { try { $ result = $ this -> getRedis ( ) -> delete ( $ keys ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Delete key or keys
|
14,975
|
public function renamenx ( $ source , $ destination ) { try { return $ this -> getRedis ( ) -> renamenx ( $ source , $ destination ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Rename key if needed key name was not
|
14,976
|
public function strlen ( $ key ) { try { $ result = $ this -> getRedis ( ) -> strlen ( $ key ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Get string length of a key
|
14,977
|
public function expire ( $ key , $ timeout ) { try { return $ this -> getRedis ( ) -> pexpire ( $ key , $ timeout ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Set ttl for a key
|
14,978
|
public function expireat ( $ key , $ timestamp ) { try { return $ this -> getRedis ( ) -> expireat ( $ key , $ timestamp ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Set time of life for the key
|
14,979
|
public function ttl ( $ key ) { try { $ result = $ this -> getRedis ( ) -> pttl ( $ key ) ; return ( $ result != - 1 ) ? $ result : false ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Get ttl of the key
|
14,980
|
public function getbit ( $ key , $ offset ) { $ offset = ( int ) $ offset ; try { $ result = $ this -> getRedis ( ) -> getBit ( $ key , $ offset ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Get key bit
|
14,981
|
public function setbit ( $ key , $ offset , $ value ) { $ offset = ( int ) $ offset ; $ value = ( int ) ( bool ) $ value ; try { $ result = $ this -> getRedis ( ) -> setBit ( $ key , $ offset , $ value ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Set key bit
|
14,982
|
public function evaluate ( $ code , array $ arguments = array ( ) ) { try { if ( empty ( $ arguments ) ) { $ result = $ this -> getRedis ( ) -> eval ( $ code ) ; } else { $ result = $ this -> getRedis ( ) -> eval ( $ code , $ arguments , count ( $ arguments ) ) ; } $ lastError = $ this -> getRedis ( ) -> getLastError ( ) ; $ this -> getRedis ( ) -> clearLastError ( ) ; if ( is_null ( $ lastError ) ) { return $ result ; } throw new ScriptExecutionException ( $ lastError ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Evaluate Lua code
|
14,983
|
public function evalSha ( $ sha , array $ arguments = array ( ) ) { try { if ( empty ( $ arguments ) ) { $ result = $ this -> getRedis ( ) -> evalSha ( $ sha ) ; } else { $ result = $ this -> getRedis ( ) -> evalSha ( $ sha , $ arguments , count ( $ arguments ) ) ; } $ lastError = $ this -> getRedis ( ) -> getLastError ( ) ; $ this -> getRedis ( ) -> clearLastError ( ) ; if ( is_null ( $ lastError ) ) { return $ result ; } throw new ScriptExecutionException ( $ lastError ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Evaluate Lua code by hash
|
14,984
|
public function sadd ( $ key , $ member ) { try { $ result = $ this -> getRedis ( ) -> sAdd ( $ key , $ member ) ; if ( $ result !== false ) { return $ result ; } throw new ImpossibleValueException ( ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Add member to the set
|
14,985
|
public function sismembers ( $ key , $ member ) { try { return $ this -> getRedis ( ) -> sIsMember ( $ key , $ member ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Check that member is a member of the set
|
14,986
|
public function srem ( $ key , $ member ) { try { return $ this -> getRedis ( ) -> sRem ( $ key , $ member ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Remove member from the set
|
14,987
|
public function sdiffstore ( $ destination , array $ sources ) { try { return call_user_func_array ( array ( $ this -> getRedis ( ) , 'sDiffStore' , ) , array_merge ( array ( $ destination ) , $ sources ) ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Create difference set
|
14,988
|
public function rpush ( $ key , $ member ) { try { return $ this -> getRedis ( ) -> rPush ( $ key , $ member ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Append value to a list
|
14,989
|
public function llen ( $ key ) { try { $ length = $ this -> getRedis ( ) -> lLen ( $ key ) ; if ( $ length === false ) { throw new ImpossibleValueException ( ) ; } return $ length ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Returns list length
|
14,990
|
public function publish ( $ channel , $ message ) { try { return $ this -> getRedis ( ) -> publish ( $ channel , $ message ) ; } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Publish message to channel
|
14,991
|
public function transaction ( Closure $ Commands , $ mode = Redis :: MULTI ) { try { $ Instance = $ this -> multi ( $ mode ) ; $ result = $ Commands ( $ Instance ) ; if ( $ result == true ) { return $ Instance -> exec ( ) ; } else { $ Instance -> discard ( ) ; return false ; } } catch ( RedisException $ ex ) { throw new ConnectException ( ) ; } }
|
Execute transaction method
|
14,992
|
protected function prepareBody ( ) { $ body = $ this -> body ; $ result = $ body ; if ( $ this -> isJson ( ) && ( is_array ( $ body ) || is_object ( $ body ) ) ) { $ result = json_encode ( \ pwf \ helpers \ ArrayHelper :: toArray ( $ body ) ) ; } return $ result ; }
|
Prepare response body for sending
|
14,993
|
private static function padString ( string $ string , int $ left , int $ right , string $ char ) : string { $ leftPadding = str_repeat ( $ char , $ left ) ; $ rightPadding = str_repeat ( $ char , $ right ) ; return $ leftPadding . $ string . $ rightPadding ; }
|
Applies padding to a string
|
14,994
|
public static function set ( $ url = null , array $ config = [ ] ) { $ config [ 'class' ] = static :: className ( ) ; return Instance :: ensure ( $ config , static :: className ( ) , [ $ url ] ) ; }
|
Modify URL .
|
14,995
|
public function replacePath ( $ value , $ replace ) { $ this -> data [ 'path' ] = str_replace ( $ value , $ replace , $ this -> data [ 'path' ] ) ; return $ this ; }
|
Replacing path .
|
14,996
|
public function setQuery ( $ query ) { if ( ! empty ( $ query ) ) { $ this -> data [ 'query' ] = $ this -> _queryToArray ( $ query ) ; } return $ this ; }
|
Sets a query .
|
14,997
|
public function addQueryParams ( array $ queryParams ) { $ this -> data [ 'query' ] = array_merge ( Helper :: getValue ( $ this -> data [ 'query' ] , [ ] ) , $ queryParams ) ; $ this -> data [ 'query' ] = array_filter ( $ this -> data [ 'query' ] ) ; return $ this ; }
|
Adds a query params .
|
14,998
|
public function removeQueryParams ( array $ queryParams ) { if ( empty ( $ this -> data [ 'query' ] ) ) { return $ this ; } $ this -> data [ 'query' ] = array_diff_key ( $ this -> data [ 'query' ] , array_flip ( $ queryParams ) ) ; return $ this ; }
|
Removes a query params .
|
14,999
|
public function replace ( array $ placeholders = [ ] ) { if ( empty ( $ placeholders ) ) { return $ this ; } $ callback = function ( $ value ) use ( $ placeholders ) { return StringHelper :: replace ( $ value , $ placeholders , false ) ; } ; $ this -> data = ArrayHelper :: map ( $ this -> data , $ callback , true ) ; return $ this ; }
|
Replacing placeholders to URL - data .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.