idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
11,000 | public static function startsWith ( string $ searchString , string $ prefix ) : bool { if ( empty ( $ searchString ) || empty ( $ prefix ) ) { return false ; } $ startStringLen = strlen ( $ prefix ) ; if ( strlen ( $ searchString ) < $ startStringLen ) { return false ; } $ possibleStartStringInSearch = substr ( $ searc... | Check if a string starts with a prefix . |
11,001 | public static function startsWithAny ( string $ searchString , array $ prefixOptions , & $ found = null ) : bool { foreach ( $ prefixOptions as $ prefix ) { if ( self :: startsWith ( $ searchString , $ prefix ) ) { $ found = $ prefix ; return true ; } } return false ; } | Check if a string starts with any of multiple prefixes . |
11,002 | public function total ( array $ args = [ ] ) : int { $ default_args = [ 'include' => [ ] , 'exclude' => [ ] , 'exclude_deprecated_levels' => true , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'include' ] = ( array ) $ a... | Total caps . |
11,003 | public function all ( array $ args = [ ] ) : array { $ default_args = [ 'max' => PHP_INT_MAX , 'fail_on_max' => false , 'include' => [ ] , 'exclude' => [ ] , 'exclude_deprecated_levels' => true , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ defau... | All caps . |
11,004 | public function forRole ( string $ role_id , bool $ no_cache = false ) : array { if ( ( $ collection = & $ this -> cacheKey ( __FUNCTION__ , $ role_id ) ) !== null && ! $ no_cache ) { return $ collection ; } $ collection = [ ] ; if ( $ role_id === 'super_admin' ) { $ role_id = 'administrator' ; if ( $ this -> Wp -> is_... | Collect role caps . |
11,005 | public function collectAll ( bool $ no_cache = false ) : array { if ( ( $ collection = & $ this -> cacheKey ( __FUNCTION__ ) ) !== null && ! $ no_cache ) { return $ collection ; } $ collection = [ ] ; foreach ( wp_roles ( ) -> roles as $ _role_id => $ _role ) { foreach ( array_keys ( $ _role [ 'capabilities' ] ?? [ ] )... | Collect caps . |
11,006 | public function handle ( Request $ request , Closure $ next ) { $ request :: setTrustedProxies ( [ $ request -> getClientIp ( ) ] ) ; if ( config ( 'redirect.https' , false ) && ! $ request -> secure ( ) ) { return redirect ( ) -> secure ( $ request -> getRequestUri ( ) ) ; } return $ next ( $ request ) ; } | Automatic redirect on cloudFlare |
11,007 | public function add ( Page $ page ) { $ next = count ( $ this -> pages ) + 1 ; $ this -> pages [ $ next ] = $ page ; if ( $ page -> isPlaceholder ( ) ) { $ this -> isSqueezed = true ; } if ( $ page -> isFirst ( ) ) { $ this -> firstPage = $ page ; } if ( $ page -> isLast ( ) ) { $ this -> lastPage = $ page ; } if ( $ p... | Add a new page . |
11,008 | public function adaptCommand ( ) : void { $ domains = $ this -> findDomainsWithRouteDomainName ( ) ; $ domainCount = \ count ( $ domains ) ; if ( ! $ domainCount ) { $ this -> outputLine ( '<warning>Could not find any domain records to adapt. Did you forget to create one or to configure the platform.sh route domain nam... | Adapts the domain records to the platform . sh environment . |
11,009 | public function initialize ( string $ protocol = 'http' , string $ protocolVersion = '1.1' , $ headers = null , $ body = 'php://memory' ) : void { $ this -> protocol = $ protocol ? : 'http' ; $ this -> protocolVersion = $ protocolVersion ? : '1.1' ; if ( $ headers ) { $ this -> headers = $ headers instanceof Headers ? ... | BaseMessage constructor . |
11,010 | public function search ( $ query ) { $ this -> logger -> debug ( 'Meda:search' ) ; if ( ! Tools :: isGoodString ( $ query ) ) { $ this -> logger -> error ( 'Media::search: invalid query' ) ; return [ ] ; } $ this -> setGeneratorSearch ( $ query , self :: MEDIA_NAMESPACE ) ; return $ this -> getImageinfoResponse ( ) ; } | search for Media files |
11,011 | public function getMediaOnPage ( ) { $ this -> logger -> debug ( 'Meda:getMediaOnPage' ) ; if ( ! $ this -> setIdentifier ( '' , 's' ) ) { return [ ] ; } $ this -> setGeneratorImages ( ) ; return $ this -> getImageinfoResponse ( ) ; } | get Media files embedded on a Page |
11,012 | public function format ( array $ response ) { $ this -> logger -> debug ( 'Meda:format' ) ; $ car = '<br />' ; $ format = '' ; foreach ( $ response as $ media ) { $ format .= '<div class="media">' . '<img' . ' src="' . Tools :: getFromArray ( $ media , 'thumburl' ) . '"' . ' width="' . Tools :: getFromArray ( $ media ,... | format a media file response as a simple string |
11,013 | public function checkEmailAction ( ) { $ session = $ this -> getSession ( ) ; $ email = $ session -> get ( 'silex_user_confirmation_email' ) ; if ( empty ( $ email ) ) { return $ this -> redirect ( 'silex_user.register' ) ; } $ session -> remove ( 'silex_user_confirmation_email' ) ; $ user = $ this -> getUserManager ( ... | Tell the user to check their email provider . |
11,014 | public function confirmAction ( Request $ request , $ token ) { $ userManager = $ this -> getUserManager ( ) ; $ user = $ userManager -> findUserByConfirmationToken ( $ token ) ; if ( null === $ user ) { throw new NotFoundHttpException ( sprintf ( 'The user with confirmation token "%s" does not exist' , $ token ) ) ; }... | Receive the confirmation token from user email provider and login the user . |
11,015 | public function confirmedAction ( ) { $ user = $ this -> getUser ( ) ; if ( ! is_object ( $ user ) || ! $ user instanceof UserInterface ) { throw new AccessDeniedException ( 'This user does not have access to this section.' ) ; } return $ this -> render ( 'silex_user/registration/confirmed.twig' , [ 'user' => $ user ] ... | Tell the user their account is confirmed . |
11,016 | protected function addMeToNormalizer ( InputNormalizerContract $ normalizer ) { foreach ( [ 'adjust' , 'validate' , 'cast' ] as $ action ) { $ normalizer -> onAfter ( $ action , function ( $ input , $ resource , $ locale ) use ( $ action ) { return $ this -> selfNormalize ( $ action , $ input , $ resource , $ locale ) ... | Add the class using this trait to the passed normalizer |
11,017 | protected function keyToNormalizeMethod ( $ key , $ prefix ) { $ arrayKey = "$prefix:$key" ; if ( ! isset ( $ this -> _methodCache [ $ arrayKey ] ) ) { $ method = $ prefix . ucfirst ( Type :: camelCase ( str_replace ( [ ' ' , '.' ] , '_' , $ key ) ) ) ; $ this -> _methodCache [ $ arrayKey ] = method_exists ( $ this , $... | Create a method name for a hook on a key |
11,018 | public function getColoredString ( string $ string , string $ foreground_color = null , string $ background_color = null , bool $ header = true ) : string { if ( $ header ) { $ title = "Console Manager - " . CoreManager :: getCurrentModule ( ) ; $ titleSeparator = $ this -> copyContent ( "-" , strlen ( $ title ) + 10 )... | Return colored string |
11,019 | public function getColoredStringReadLine ( string $ string , string $ foreground_color = null , string $ background_color = null ) : string { $ string = $ this -> resizeContent ( $ string , 0 ) ; $ colored_string = "" ; if ( isset ( $ this -> foreground_colors [ $ foreground_color ] ) ) { $ colored_string .= "\033[" . ... | Return colored string for readline action |
11,020 | final private function copyContent ( string $ content , int $ coef ) : string { $ str = "" ; for ( $ i = 0 ; $ i < $ coef ; $ i ++ ) { $ str = $ str . $ content ; } return ( $ str ) ; } | Copy a string several times |
11,021 | public static function getCountryAll ( ) { $ countries = [ ] ; foreach ( static :: $ identifiers as $ identifier => $ country ) { $ countries [ ] = [ "identifier" => $ identifier , "name" => $ country ] ; } ArrayHelper :: multisort ( $ countries , "identifier" , SORT_ASC , SORT_NUMERIC ) ; return $ countries ; } | Get all of the country |
11,022 | public function deleteAllCompile ( ) { $ a = array ( "dev" , "prod" ) ; for ( $ i = 0 ; $ i < count ( $ a ) ; $ i ++ ) { $ this -> callDelCreaServer ( $ a [ $ i ] ) ; } } | Delete a compile for all environment |
11,023 | private function fileSizeConvert ( int $ bytes ) { $ bytes = floatval ( $ bytes ) ; $ result = "0 B" ; $ arBytes = array ( 0 => array ( "UNIT" => "TB" , "VALUE" => pow ( 1024 , 4 ) ) , 1 => array ( "UNIT" => "GB" , "VALUE" => pow ( 1024 , 3 ) ) , 2 => array ( "UNIT" => "MB" , "VALUE" => pow ( 1024 , 2 ) ) , 3 => array ... | Converts bytes into human readable file size . |
11,024 | public function json ( ) { $ json = json_decode ( $ this -> getBody ( ) , true ) ; if ( $ json === null ) { throw new RuntimeException ( sprintf ( "Can't decode response as JSON: %s" , function_exists ( 'json_last_error_msg' ) ? json_last_error_msg ( ) : 'Error code ' . json_last_error ( ) ) ) ; } return $ json ; } | Try to json_decode the response body |
11,025 | public function getCompressCommand ( LocalFileNodeInterface $ from , LocalFileNodeInterface $ to ) { return sprintf ( "gzip -c %s > %s" , escapeshellarg ( $ from -> getPath ( ) ) , escapeshellarg ( $ to -> getPath ( ) ) ) ; } | Get the command line to compress a file |
11,026 | public function getDecompressCommand ( LocalFileNodeInterface $ from , LocalFileNodeInterface $ to ) { return sprintf ( "gunzip -c %s > %s" , escapeshellarg ( $ from -> getPath ( ) ) , escapeshellarg ( $ to -> getPath ( ) ) ) ; } | Get the command line to decompress a file |
11,027 | public static final function cast ( $ value ) : array { if ( is_array ( $ value ) ) { return $ value ; } if ( is_object ( $ value ) && method_exists ( $ value , 'toArray' ) ) { return $ value -> toArray ( ) ; } if ( $ value instanceof \ Generator ) { return iterator_to_array ( $ value ) ; } return [ $ value ] ; } | Converts any value into an array . |
11,028 | public static final function simplify ( ) : array { return ! empty ( $ Args = array_filter ( func_get_args ( ) ) ) && array_walk_recursive ( $ Args , function ( $ value ) use ( & $ Simple ) { $ Simple [ ] = $ value ; } ) ? self :: cast ( $ Simple ) : [ ] ; } | Convert given arguments into a single - level numbered array . |
11,029 | public static final function append ( array $ Source , array $ Append ) : array { return array_merge ( self :: only ( $ Source , array_filter ( array_keys ( $ Source ) , function ( $ value ) use ( $ Append ) { return is_int ( $ value ) || ! array_key_exists ( $ value , $ Append ) ; } ) ) , $ Append ) ; } | Appends the given array to the end of another one . |
11,030 | public static final function prepend ( array $ Source , array $ Prepend ) : array { return array_merge ( $ Prepend , self :: only ( $ Source , array_filter ( array_keys ( $ Source ) , function ( $ value ) use ( $ Prepend ) { return is_int ( $ value ) || ! array_key_exists ( $ value , $ Prepend ) ; } ) ) ) ; } | Appends the given array to the beginning of another one . |
11,031 | public static final function push ( array $ Source , $ value ) : array { return self :: append ( $ Source , self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) ; } | Adds the given values to the end of an array . Function behavior is similar to array_push but allows an arbitrary list of arguments . |
11,032 | public static final function unshift ( array $ Source , $ value ) : array { return self :: append ( self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) , $ Source ) ; } | Adds the given values to the beginning of an array . Function behavior is similar to array_unshift but allows an arbitrary list of arguments . |
11,033 | public static final function only ( array $ Source , $ keys ) : array { return array_intersect_key ( $ Source , array_fill_keys ( self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) , - 1 ) ) ; } | Returns a subset from the given array using the given list of needed keys . |
11,034 | public static final function insert ( array $ Source , int $ position , $ value ) : array { return $ position > 0 ? self :: append ( array_slice ( $ Source , 0 , $ position ) , self :: prepend ( array_slice ( $ Source , $ position ) , self :: cast ( $ value ) ) ) : self :: prepend ( $ Source , self :: cast ( $ value ) ... | Inserts an element into the specified position of an array . |
11,035 | public static final function except ( array $ Source , $ keys ) { return array_diff_key ( $ Source , array_fill_keys ( self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) , - 1 ) ) ; } | Returns a subset from the given array using the given list of ignored keys . |
11,036 | public static final function has ( array $ Source , $ key ) : bool { return ! count ( array_diff ( self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) , array_keys ( $ Source ) ) ) ; } | Checks if the given keys exist in an array . |
11,037 | public static final function contains ( array $ Source , $ value ) : bool { return count ( array_intersect ( $ Source , $ value = self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) ) == count ( $ value ) ; } | Checks if an array contains the given values . |
11,038 | public static final function find ( array $ Source , $ value , $ default = null ) { return ( $ value = array_search ( $ value , $ Source , true ) ) !== false ? $ value : $ default ; } | Searches an array for a given value and returns the first corresponding key if successful or the given default value otherwise . |
11,039 | public static final function left ( array $ Source , $ to ) : array { return array_slice ( $ Source , 0 , self :: find ( array_keys ( $ Source ) , $ to , count ( $ Source ) - 1 ) + 1 ) ; } | Returns the left part of an array ending by the given value . |
11,040 | public static final function right ( array $ Source , $ from ) : array { return array_slice ( $ Source , self :: find ( array_keys ( $ Source ) , $ from , 0 ) ) ; } | Returns the right part of an array starting by the given value . |
11,041 | public static final function combine ( array $ Keys , array $ Values = [ ] , $ default = null ) : array { return array_combine ( $ Keys , array_pad ( array_slice ( $ Values , 0 , count ( $ Keys ) ) , count ( $ Keys ) , $ default ) ) ; } | Creates an array by using the first given array for keys and the second one for its values . |
11,042 | public static final function compile ( $ Raw ) : array { return self :: combine ( self :: odd ( $ Raw = self :: simplify ( func_get_args ( ) ) ) , self :: even ( $ Raw ) ) ; } | Creates an array using the even elements of given array for keys and its odd elements for values . |
11,043 | public static final function each ( array $ Source , callable $ Callback , $ keys = null ) : array { return array_walk ( $ Source , function ( & $ value , $ key , $ keys ) use ( $ Callback ) { $ value = count ( $ keys ) < 1 || in_array ( $ key , $ keys ) ? $ Callback ( $ key , $ value ) : $ value ; } , array_filter ( A... | Applies the given function to each element of an array or to the specified subset if the third argument is provided . |
11,044 | public static final function make ( array $ Keys , callable $ Callback = null ) : array { return Arr :: combine ( $ Keys , is_callable ( $ Callback ) ? Arr :: each ( $ Keys , function ( ) use ( $ Callback ) { return call_user_func ( $ Callback , func_get_arg ( 1 ) ) ; } ) : [ ] ) ; } | Creates an array using the given array for keys and the given function to get values . |
11,045 | public static final function pack ( array $ Source , string $ separator ) : array { return array_walk ( $ Source , function ( & $ value , $ key ) use ( $ separator ) { $ value = $ key . $ separator . Str :: cast ( $ value ) ; } ) ? array_values ( $ Source ) : [ ] ; } | Returns an array contains string elements formed by a key - value pair of the source array combined by the specified separator . |
11,046 | public static final function get ( array $ Source , $ key , $ default = null ) { return array_key_exists ( $ key , $ Source ) && ! is_null ( $ Source [ $ key ] ) ? $ Source [ $ key ] : $ default ; } | Tries to retrieve a single value from an array by its key or returns the default value if the key does not exist . |
11,047 | public static final function value ( array $ Source , int $ index = 0 , $ default = null ) { return self :: get ( array_values ( $ Source ) , $ index , $ default ) ; } | Tries to retrieve a single value from an array by its position or returns the default value if the position is out of range . |
11,048 | public static final function key ( array $ Source , int $ index = 0 , $ default = null ) { return self :: get ( array_keys ( $ Source ) , $ index , $ default ) ; } | Tries to retrieve a single key from an array by its position or returns the default value if the position is out of range . |
11,049 | public static final function path ( array $ Source , $ keys ) { return count ( $ keys = array_filter ( self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) ) > 0 ? ( isset ( $ Source [ $ keys [ 0 ] ] ) ? ( count ( $ keys ) > 1 ? ( is_array ( $ Source [ $ keys [ 0 ] ] ) ? self :: path ( $ Source [ $ keys [ 0 ] ]... | Tries to retrieve a single value or a subset from an array by the given sequence of keys . |
11,050 | public static final function improve ( array $ Source , $ keys , $ value ) : array { return count ( $ keys = array_filter ( self :: simplify ( array_slice ( func_get_args ( ) , 1 , func_num_args ( ) - 2 ) ) ) ) > 0 ? ( array_merge ( $ Source , [ $ keys [ 0 ] => self :: improve ( self :: cast ( self :: get ( $ Source , ... | Adds the last given argument into an array following the specified path defined by the sequence from the second argument to the penultimate one . |
11,051 | public static final function clear ( array $ Source , $ keys ) : array { return count ( $ keys = self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) > 0 ? ( count ( $ keys ) > 1 ? array_merge ( $ Source , [ $ keys [ 0 ] => self :: clear ( self :: cast ( self :: get ( $ Source , $ keys [ 0 ] , [ ] ) ) , array_s... | Removes an element from an array by the path defined by the sequence from the second argument to last one . |
11,052 | public static final function like ( array $ Source , $ keys ) { return count ( $ keys = self :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) && uksort ( $ Source , function ( $ l , $ r ) use ( $ keys ) { return Arr :: contains ( $ keys , $ r , $ l ) ? array_search ( $ l , $ keys ) - array_search ( $ r , $ keys ... | Sorts an array keys in the order given by arguments . |
11,053 | protected function setFieldset ( $ values ) { foreach ( $ values as $ name => $ field ) { $ this -> fields [ $ name ] = $ field ; } } | Set the fieldsets |
11,054 | public function afterInsertObject ( DomainObjectInterface $ entity , $ signalInfo ) { if ( $ entity instanceof $ this -> className ) { if ( method_exists ( $ this , 'created' ) ) { $ this -> created ( $ entity ) ; } if ( method_exists ( $ this , 'saved' ) ) { $ this -> saved ( $ entity ) ; } } } | After insert object hook . |
11,055 | public function afterUpdateObject ( DomainObjectInterface $ entity , $ signalInfo ) { if ( $ entity instanceof $ this -> className ) { if ( method_exists ( $ this , 'updated' ) ) { $ this -> updated ( $ entity ) ; } if ( method_exists ( $ this , 'saved' ) ) { $ this -> saved ( $ entity ) ; } } } | After update object hook . |
11,056 | public function afterRemoveObject ( DomainObjectInterface $ entity , $ signalInfo ) { if ( $ entity instanceof $ this -> className ) { if ( method_exists ( $ this , 'deleted' ) ) { $ this -> deleted ( $ entity ) ; } } } | After remove object hook . |
11,057 | protected function isDirty ( AbstractEntity $ entity , $ attr ) { $ attr = ( string ) $ attr ; if ( $ entity -> _isDirty ( $ attr ) ) { $ cls = str_replace ( '\\' , '_' , get_class ( $ entity ) ) ; $ uid = ( string ) $ entity -> getUid ( ) ; $ val = $ entity -> { 'get' . ucwords ( $ attr ) } ( ) ; if ( ! isset ( $ this... | Check if the given attribute on the given model is dirty . |
11,058 | public function loadValues ( DecodePropertyValueForWidgetEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( ( $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) !== 'tl_metamodel_attribute' ) || ( $ event -> getProperty ( ) !== 'translatedtabletext_c... | Decode the values into a real table array . |
11,059 | public function saveValues ( EncodePropertyValueFromWidgetEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( ( $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) !== 'tl_metamodel_attribute' ) || ( $ event -> getProperty ( ) !== 'translatedtabletext_... | Encode the values into a serialized array . |
11,060 | public function create ( $ rootPageId , $ setHost = false ) { if ( ! is_object ( $ GLOBALS [ 'TT' ] ) ) { $ GLOBALS [ 'TT' ] = GeneralUtility :: makeInstance ( 'TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker' ) ; $ GLOBALS [ 'TT' ] -> start ( ) ; } $ GLOBALS [ 'TSFE' ] = GeneralUtility :: makeInstance ( 'TYPO3\\CMS\\Fronte... | Create the TSFE . |
11,061 | public function swap ( ) { $ first = $ this -> first ; $ this -> first = $ this -> second ; $ this -> second = $ first ; return $ this ; } | Swaps first and second . |
11,062 | protected function configureAndReturn ( ValidatorContract $ validator , array $ rules , $ resource = null ) { if ( ! $ rules && ! $ resource ) { return $ validator ; } if ( $ validator instanceof AlterableContract ) { $ validator = $ rules ? $ validator -> mergeRules ( $ rules ) : $ validator ; if ( $ validator instanc... | Add rules and resource to the validator and return it . This is a helper to not repeat this same lines in every ValidatorFactory . |
11,063 | protected function callListeners ( $ name , & $ result ) { foreach ( $ this -> _alwaysCalledExtensions as $ listener ) { call_user_func ( $ listener , $ name , $ result ) ; } } | Calls the listeners which get informed on every call . |
11,064 | protected function addChanges ( SimpleXMLElement $ releaseNode , Release $ release ) { $ changesNode = $ releaseNode -> addChild ( 'changes' ) ; foreach ( $ release -> getAllChanges ( ) as $ type => $ changes ) { $ typeNode = $ changesNode -> addChild ( 'type' ) ; $ typeNode -> addAttribute ( 'name' , $ type ) ; foreac... | Adds the release s changes to the given xml release node . |
11,065 | public function call ( $ command , array $ parameters = [ ] ) { array_unshift ( $ parameters , $ command ) ; $ this -> lastOutput = new BufferedOutput ; $ this -> setCatchExceptions ( false ) ; $ result = $ this -> run ( new ArrayInput ( $ parameters ) , $ this -> lastOutput ) ; $ this -> setCatchExceptions ( true ) ; ... | Run an console command by name . |
11,066 | private function loadFile ( array & $ items , string $ path , string $ pathRelative , string $ configKey , $ environment = null ) : void { $ filename = $ path ; if ( $ pathRelative !== null && $ pathRelative !== '' ) { $ filename .= '/' . $ pathRelative ; } $ filename .= '/' . $ configKey ; if ( $ environment !== null ... | Load file . |
11,067 | private function isEnvironmentFilename ( string $ filename ) : bool { $ filenameEnding = substr ( $ filename , strpos ( $ filename , '.' ) ) ; foreach ( $ this -> environments as $ environment ) { if ( $ filenameEnding === '.' . $ environment . '.php' ) { return true ; } } return false ; } | Is environment filename . |
11,068 | public function getDumpFilePath ( ) : string { $ dir = dirname ( $ this -> filePath ) ; $ fileName = \ basename ( $ this -> filePath , ".{$this->fileType}" ) ; $ dir = "." === $ dir ? "" : "{$dir}/" ; $ hash = ! empty ( $ this -> fileNameHash ) ? ".{$this->fileNameHash}" : "" ; return "{$dir}{$fileName}{$hash}.{$this->... | Returns the final storage path where the production file is dumped to |
11,069 | public static function secureKnownType ( $ data , string $ type ) { $ filterType = 'text' ; if ( $ type === 'int' || $ type === 'integer' ) { $ filterType = FILTER_VALIDATE_INT ; } elseif ( $ type === 'float' || $ type === 'double' ) { $ filterType = FILTER_VALIDATE_FLOAT ; } elseif ( $ type === 'bool' || $ type === 'b... | Securize a string for some types with filter_var function . |
11,070 | public static function secureUnknownType ( $ data , string $ type , bool $ htmlentities ) : string { if ( $ type !== 'html' ) { $ data = strip_tags ( $ data ) ; } if ( $ type === 'html' || $ htmlentities === true ) { return htmlentities ( $ data , ENT_QUOTES | ENT_HTML401 ) ; } return addslashes ( $ data ) ; } | Securise a mixed data type who are not managed by securiseKnownType . We work the data like if the type is a string . |
11,071 | public static function secureData ( $ data , string $ type , bool $ htmlentities ) { $ currentClass = get_called_class ( ) ; if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ val ) { unset ( $ data [ $ key ] ) ; $ key = $ currentClass :: secureData ( $ key , gettype ( $ key ) , true ) ; $ val = $ currentClass... | Securise a variable |
11,072 | public static function getSecureKeyInArray ( array & $ array , string $ key , string $ type , bool $ htmlentities = false , bool $ inline = true ) { if ( ! isset ( $ array [ $ key ] ) ) { throw new Exception ( 'The key ' . $ key . ' not exist' , self :: ERR_SECURE_ARRAY_KEY_NOT_EXIST ) ; } $ currentClass = get_called_c... | Securise the value of an array key for a declared type . |
11,073 | public static function getManySecureKeys ( array & $ arraySrc , array $ keysList , bool $ throwOnError = true ) : array { $ currentClass = get_called_class ( ) ; $ result = [ ] ; foreach ( $ keysList as $ keyName => $ infos ) { if ( ! is_array ( $ infos ) ) { $ infos = [ 'type' => $ infos , 'htmlentities' => false , 'i... | Obtain many key from an array in one time |
11,074 | function once ( string $ event , callable $ listener ) { if ( ! isset ( $ this -> onceListeners [ $ event ] ) ) { $ this -> onceListeners [ $ event ] = array ( ) ; } $ this -> onceListeners [ $ event ] [ ] = $ listener ; return $ this ; } | Attach a listener to an event for exactly once . |
11,075 | function removeListener ( string $ event , callable $ listener ) { if ( isset ( $ this -> listeners [ $ event ] ) ) { $ index = \ array_search ( $ listener , $ this -> listeners [ $ event ] , true ) ; if ( $ index !== false ) { unset ( $ this -> listeners [ $ event ] [ $ index ] ) ; if ( \ count ( $ this -> listeners [... | Remove specified listener from an event . |
11,076 | public function getKey ( $ id = false , array $ array = [ ] ) { return $ this -> keyManager -> getKey ( $ id , $ array , $ this -> section , $ this -> modelClass ) ; } | Call the Key Manager to get the Cache key . |
11,077 | public function getTags ( $ id = false , array $ array = [ ] ) { return $ this -> keyManager -> getTags ( $ id , $ array , $ this -> section , $ this -> modelClass ) ; } | Call the Key Manager to get the Cache tags . |
11,078 | public function getCustomMethodKey ( $ customName = false , $ id = false , array $ array = [ ] ) { return $ this -> keyManager -> getCustomMethodKey ( $ customName , $ id , $ array , $ this -> section , $ this -> modelClass ) ; } | Call the Key Manager method to the Custom Method Key . |
11,079 | public function getCustomMethodTags ( $ customName = false , $ id = false , array $ array = [ ] ) { return $ this -> keyManager -> getCustomMethodTags ( $ customName , $ id , $ array , $ this -> section , $ this -> modelClass ) ; } | Call the Key Manager method to get the Custom Method Tags . |
11,080 | public function start ( ) { $ this -> createQueue ( ) ; while ( count ( $ this -> getChannel ( ) -> callbacks ) ) { try { $ this -> getChannel ( ) -> wait ( ) ; } catch ( \ Exception $ e ) { fwrite ( $ this -> errOutput , $ e -> getMessage ( ) ) ; $ this -> forceReconnect ( ) ; continue ; } } $ connection = $ this -> g... | Declare and start queue in broker . |
11,081 | protected function callOnListeners ( $ event , $ args = [ ] ) { $ result = false ; foreach ( $ this -> getOnListeners ( $ event ) as $ listener ) { Helper :: call ( $ listener , $ args ) ; } return $ result ; } | Calls the assigned before listeners . |
11,082 | protected function checkFileReadable ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new \ RuntimeException ( "File [$file] does not exist" ) ; } if ( ! is_file ( $ file ) ) { throw new \ RuntimeException ( "File [$file] is not a file" ) ; } if ( ! is_readable ( $ file ) ) { throw new \ RuntimeException ( "File [$... | Check that a given file is readable |
11,083 | public function parseToFile ( $ dst , $ data ) { $ pattern = new Pattern ( $ this -> src ) ; return file_put_contents ( $ dst , $ pattern -> parse ( $ data ) ) ; } | Parse template and save it to file |
11,084 | public static function loadValidatorMetadata ( ClassMetadata $ metadata ) { $ metadata -> addPropertyConstraint ( 'username' , new NotBlank ( [ 'message' => 'silex_user.username.blank' ] ) ) ; $ metadata -> addPropertyConstraint ( 'username' , new Length ( [ 'min' => 2 , 'max' => 180 , 'minMessage' => 'silex_user.usern... | Used by the validator to validate the User data . |
11,085 | private function getContext ( Request $ request ) : SerializationContext { $ fields = $ request -> get ( 'fields' , [ 'id' ] ) ; $ depth = $ request -> get ( 'depth' , 20 ) ; $ depth = is_numeric ( $ depth ) ? ( int ) $ depth : 20 ; if ( is_string ( $ fields ) ) { $ fields = explode ( ',' , $ fields ) ; } $ context = n... | This method will get the desired fields and depth from the request |
11,086 | public function getPath ( string $ namespace ) : string { if ( ! isset ( $ this -> namespaces [ $ namespace ] ) ) { throw new AssetsException ( sprintf ( "Unknown entry namespace: '%s'" , $ namespace ) ) ; } return $ this -> namespaces [ $ namespace ] ; } | Returns the path to the namespace |
11,087 | public function isSquare ( ) { if ( ! $ this -> isValid ( ) ) { return false ; } return round ( $ this -> first ) == round ( $ this -> second ) ; } | Return if width and height are equal . |
11,088 | public function scaleTo ( $ width = null , $ height = null ) { if ( ! $ width && ! $ height ) { throw new UnderflowException ( 'You have to pass at least width or height.' ) ; } if ( $ width instanceof Size ) { return new static ( $ width -> width ( ) , $ width -> height ( ) ) ; } if ( $ width && $ height ) { return ne... | Scale the size to new dimensions . Left out either width or height to keep the aspect ratio . Returns a new Size . |
11,089 | public function expandTo ( $ width , $ height = null ) { $ size = $ width instanceof Size ? $ width : new static ( $ width , $ height ) ; if ( ! $ size -> isValid ( ) ) { return $ this -> scaleTo ( $ size ) ; } $ myAspectRatio = $ this -> aspectRatio ( ) ; $ newWidth = $ size -> height ( ) * $ myAspectRatio ; if ( $ ne... | Scale the size so that by keeping the aspect ratio it will be bigger then the passed size . But this in the smallest possible size . Returns a new Size . |
11,090 | public function multiply ( $ width , $ height = null ) { if ( $ width instanceof Size ) { $ height = $ width -> height ( ) ; $ width = $ width -> width ( ) ; } $ height = $ height ? $ height : $ width ; return new static ( $ this -> width ( ) * $ width , $ this -> height ( ) * $ height ) ; } | Multiplies the width with another width and this height with another height . Returns a new Size . |
11,091 | public function logsdetailsActivity ( string $ uidie , string $ env ) : Renderer { if ( ! in_array ( $ env , array ( "dev" , "prod" ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Bad environment name $env" , "solution" => "Environment must be 'dev' or 'prod' " ) ) ) ; } $ onelogs = AbstractServ... | Get log details |
11,092 | public function getStatisticsLogsDev ( ) : array { $ last = array_values ( ( AbstractServer :: getLogs ( "dev" ) ) ) ; $ success = 0 ; $ critical = 0 ; $ others = 0 ; $ errors = 0 ; for ( $ i = 0 ; $ i < count ( $ last ) ; $ i ++ ) { $ one = $ last [ $ i ] ; if ( $ one [ 'code' ] == 200 ) { $ success ++ ; } else { $ er... | Get logs statistics for dev |
11,093 | public function clearActivity ( string $ env ) : Renderer { if ( ! in_array ( $ env , array ( "dev" , "prod" ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Bad environment name $env" , "solution" => "Environment must be 'dev' or 'prod' " ) ) ) ; } Server :: delete ( FEnv :: get ( "framework.log... | clear log of dev or prod environment |
11,094 | public static function load ( array $ config ) { assert ( key_exists ( "cache_path" , $ config ) , "Cache path not set." ) ; assert ( key_exists ( "db" , $ config ) , "Database config not set" ) ; $ db_conf = $ config [ 'db' ] ; $ ormMemcache = Persistence \ OrmMemcache :: init ( $ config [ 'cache_path' ] ) ; $ dsn = '... | Initialize the ORM |
11,095 | public function add ( $ item ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } if ( ! $ this -> getConnection ( ) -> getClient ( ) -> rpush ( $ this -> name , $ item ) ) { return false ; } $ this -> _data = null ; $ this -> _count = null ; return tr... | Adds an item to the list |
11,096 | public function remove ( $ item ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } if ( ! $ this -> getConnection ( ) -> getClient ( ) -> lrem ( $ this -> name , $ item , 1 ) ) { return false ; } $ this -> _data = null ; $ this -> _count = null ; ret... | Removes an item from the list |
11,097 | public function unshift ( $ item ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } if ( ! $ this -> getConnection ( ) -> getClient ( ) -> lpush ( $ this -> name , $ item ) ) { return false ; } $ this -> _data = null ; $ this -> _count = null ; retur... | Adds an item to the start of the list |
11,098 | public function shift ( ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ item = $ this -> getConnection ( ) -> getClient ( ) -> lpop ( $ this -> name ) ; $ this -> _data = null ; $ this -> _count = null ; return $ item ; } | Removes and returns the first item from the list |
11,099 | public function pop ( ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ item = $ this -> getConnection ( ) -> getClient ( ) -> rpop ( $ this -> name ) ; $ this -> _data = null ; $ this -> _count = null ; return $ item ; } | Removes and returns the last item from the list |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.