idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
13,600
public function enqueue ( QueueItem $ item ) { $ this -> client -> sendMessage ( [ 'QueueUrl' => $ this -> url , 'MessageBody' => json_encode ( [ 'type' => $ item -> getType ( ) , 'id' => $ item -> getId ( ) , ] ) , ] ) ; }
Adds item to the queue .
13,601
public function commit ( QueueItem $ item ) { $ this -> client -> deleteMessage ( [ 'QueueUrl' => $ this -> url , 'ReceiptHandle' => $ item -> getReceipt ( ) , ] ) ; }
Commits to removing item from queue marks item as done and processed .
13,602
public function release ( QueueItem $ item ) { $ this -> client -> changeMessageVisibility ( [ 'QueueUrl' => $ this -> url , 'ReceiptHandle' => $ item -> getReceipt ( ) , 'VisibilityTimeout' => $ this -> visibilityTimeout * ( $ item -> getAttempts ( ) + 1 ) , ] ) ; }
This will happen when an error happens we release the item back into the queue .
13,603
public function filter_by_template_page ( $ sizes , $ id = 0 ) { $ template = get_page_template_slug ( $ id ) ; if ( empty ( $ template ) ) { return $ sizes ; } $ template_name = Formatter :: to_filter_format ( $ template ) ; return apply_filters ( Formatter :: katana_filter ( $ template_name ) , $ sizes ) ; }
Filter that allow to change the sizes on pages that uses custom page templates .
13,604
public static function getCode ( $ val ) { switch ( $ val ) { case self :: DKK : return 'dkk' ; case self :: EUR : return 'eur' ; case self :: NOK : return 'nok' ; case self :: SEK : return 'sek' ; default : return null ; } }
Converts a KlarnaCurrency constant to the respective language code .
13,605
public function gravatar ( ) { $ gravCheck = 'http://www.gravatar.com/avatar/' . md5 ( strtolower ( trim ( $ this -> email ) ) ) . '.png?d=404' ; $ response = get_headers ( $ gravCheck ) ; if ( $ response [ 0 ] != "HTTP/1.0 404 Not Found" ) { return 'http://www.gravatar.com/avatar/' . md5 ( strtolower ( trim ( $ this -> email ) ) ) . '.png?s=200&d=blank' ; } return '/img/no_user.png' ; }
Check for an avatar uploaded to the site resort to gravatar if none exists resort to no user image if no gravatar exists
13,606
public function postsCount ( ) { $ postsCount = $ this -> posts -> count ( ) ; $ repliesCount = $ this -> replies -> count ( ) ; return $ postsCount + $ repliesCount ; }
Get the number of posts from this user
13,607
public function lastActiveReadable ( ) { return ( $ this -> lastActive == '0000-00-00 00:00:00' || $ this -> lastActive == null ? 'Never' : date ( 'F jS, Y \a\t h:ia' , strtotime ( $ this -> lastActive ) ) ) ; }
Make the last active date easier to read
13,608
public static function blowfish ( $ string , $ key , $ operation = self :: ENCRYPT ) { if ( $ operation === static :: ENCRYPT ) { return static :: encrypt ( $ string , $ key , static :: BLOWFISH ) ; } else { return static :: decrypt ( $ string , $ key , static :: BLOWFISH ) ; } }
Encrypt and decrypt a string using the Blowfish algorithm with CBC mode .
13,609
public static function decrypt ( $ string , $ key , $ cipher , $ mode = MCRYPT_MODE_CBC ) { list ( $ key , $ iv ) = static :: vector ( $ key , $ cipher , $ mode ) ; return rtrim ( mcrypt_decrypt ( $ cipher , $ key , $ string , $ mode , $ iv ) , "\0" ) ; }
Decrypt an encrypted string using the passed cipher and mode . Additional types of ciphers and modes can be used that aren t constants of this class .
13,610
public static function encrypt ( $ string , $ key , $ cipher , $ mode = MCRYPT_MODE_CBC ) { list ( $ key , $ iv ) = static :: vector ( $ key , $ cipher , $ mode ) ; return mcrypt_encrypt ( $ cipher , $ key , $ string , $ mode , $ iv ) ; }
Encrypt string using the passed cipher and mode . Additional types of ciphers and modes can be used that aren t constants of this class .
13,611
public static function obfuscate ( $ string ) { $ string = ( string ) $ string ; $ length = mb_strlen ( $ string ) ; $ scrambled = '' ; if ( $ length > 0 ) { for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ scrambled .= '&#' . ord ( $ string [ $ i ] ) . ';' ; } } return $ scrambled ; }
Scrambles the source of a string .
13,612
public static function rijndael ( $ string , $ key , $ operation = self :: ENCRYPT ) { if ( $ operation === static :: ENCRYPT ) { return static :: encrypt ( $ string , $ key , static :: RIJNDAEL ) ; } else { return static :: decrypt ( $ string , $ key , static :: RIJNDAEL ) ; } }
Encrypt and decrypt a string using the Rijndael 128 algorithm with CBC mode .
13,613
public function add ( $ element ) { if ( ! $ this -> contains ( $ element ) ) { $ hashIndex = $ this -> hashIndex ( $ element ) ; $ this -> _items [ $ hashIndex ] = $ element ; $ this -> _iterator = null ; return true ; } else { return false ; } }
add a element to the end of the collection
13,614
public function contains ( $ element ) { $ hashIndex = $ this -> hashIndex ( $ element ) ; if ( array_key_exists ( $ hashIndex , $ this -> _items ) ) { return true ; } return false ; }
collection contains a given element
13,615
public function cmdGetZone ( ) { $ result = $ this -> getListZone ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableZone ( $ result ) ; $ this -> output ( ) ; }
Callback for zone - get command
13,616
public function cmdUpdateZone ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this -> setSubmitted ( null , $ params ) ; $ this -> setSubmitted ( 'update' , $ params [ 0 ] ) ; $ this -> validateComponent ( 'zone' ) ; $ this -> updateZone ( $ params [ 0 ] ) ; $ this -> output ( ) ; }
Callback for zone - update command
13,617
public function cmdDeleteZone ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( ! empty ( $ id ) ) { $ result = $ this -> zone -> delete ( $ id ) ; } else if ( ! empty ( $ all ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> zone -> getList ( ) as $ zone ) { $ count ++ ; $ deleted += ( int ) $ this -> zone -> delete ( $ zone [ 'zone_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for zone - delete command
13,618
protected function submitAddZone ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'zone' ) ; $ this -> addZone ( ) ; }
Add a new zone at once
13,619
protected function addZone ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> zone -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new zone
13,620
protected function wizardAddZone ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'zone' ) ; $ this -> validatePrompt ( 'status' , $ this -> text ( 'Status' ) , 'zone' , 0 ) ; $ this -> validateComponent ( 'zone' ) ; $ this -> addZone ( ) ; }
Add a new zone step by step
13,621
protected function needDefined ( ) { if ( $ this -> defined ) return ; $ this -> defined = true ; $ name = $ pattern = $ note = null ; if ( preg_match ( PARSER_PATTERN , $ this -> definition , $ matches ) ) { $ body = $ matches [ 1 ] ; $ name = $ matches [ 2 ] ; $ note = $ matches [ 3 ] ; $ pos = strpos ( $ name , '|' ) ; if ( $ pos !== false ) { $ pattern = $ this -> assertPattern ( trim ( substr ( $ name , $ pos + 1 ) ) ) ; $ name = trim ( substr ( $ name , 0 , $ pos ) ) ; } } else { $ body = $ this -> definition ; } $ this -> define ( $ body , $ name , $ pattern , $ note ) ; }
Ensure definition has been parsed before actual use . It is safe to call it multiple times .
13,622
protected function assertPattern ( $ pattern ) { if ( strlen ( $ pattern ) == 0 ) return null ; $ pattern = '/^' . str_replace ( '/' , '\\/' , $ pattern ) . '$/' ; if ( @ preg_match ( $ pattern , null ) === false ) { throw new DefinitionException ( "invalid regular expression pattern" ) ; } return $ pattern ; }
Validate the regular expression pattern string
13,623
public function getNodesListAction ( ParamFetcher $ paramFetcher ) { $ page = $ paramFetcher -> get ( 'page' ) ; $ count = $ paramFetcher -> get ( 'count' ) ; $ pager = $ this -> getNodeManager ( ) -> getPager ( $ this -> filterCriteria ( $ paramFetcher ) , $ page , $ count ) ; return $ pager ; }
Retrieve the list of available nodes
13,624
public function getConsts ( $ prefix ) { if ( isset ( self :: $ consts [ $ prefix ] ) ) { return self :: $ consts [ $ prefix ] ; } $ class = new \ ReflectionClass ( $ this ) ; $ consts = $ class -> getConstants ( ) ; $ property = lcfirst ( str_replace ( '_' , '' , ucwords ( $ prefix , '_' ) ) ) . 'Table' ; if ( isset ( $ this -> $ property ) ) { $ data = $ this -> $ property ; } else { $ data = [ ] ; } $ prefix .= '_' ; $ length = strlen ( $ prefix ) ; foreach ( $ consts as $ name => $ id ) { if ( stripos ( $ name , $ prefix ) !== 0 ) { continue ; } if ( in_array ( $ name , $ this -> constExcludes ) ) { continue ; } $ data [ $ id ] [ 'id' ] = $ id ; $ data [ $ id ] [ 'name' ] = strtolower ( strtr ( substr ( $ name , $ length ) , [ '_' => '-' ] ) ) ; } self :: $ consts [ $ prefix ] = $ data ; return $ data ; }
Get constants table by prefix
13,625
public function getConstValue ( $ prefix , $ id , $ key ) { $ consts = $ this -> getConsts ( $ prefix ) ; return isset ( $ consts [ $ id ] [ $ key ] ) ? $ consts [ $ id ] [ $ key ] : null ; }
Returns the constant value by specified id and key
13,626
public function getConstIdByName ( $ prefix , $ name ) { $ nameToIds = $ this -> getConstNameToIds ( $ prefix ) ; return isset ( $ nameToIds [ $ name ] ) ? $ nameToIds [ $ name ] : null ; }
Returns the constant id by name
13,627
protected function getConstNameToIds ( $ prefix ) { if ( ! isset ( self :: $ constNameToIds [ $ prefix ] ) ) { foreach ( $ this -> getConsts ( $ prefix ) as $ const ) { self :: $ constNameToIds [ $ prefix ] [ $ const [ 'name' ] ] = $ const [ 'id' ] ; } } return self :: $ constNameToIds [ $ prefix ] ; }
Returns the name to id map
13,628
public static function between ( $ input , $ min , $ max ) { $ length = mb_strlen ( $ input ) ; return ( $ length <= $ max && $ length >= $ min ) ; }
Validate input string length is between the min and max .
13,629
public static function comparison ( $ input , $ check , $ mode ) { switch ( mb_strtolower ( $ mode ) ) { case 'greater' : case 'gt' : case '>' : return ( $ input > $ check ) ; break ; case 'greaterorequal' : case 'gte' : case '>=' : return ( $ input >= $ check ) ; break ; case 'less' : case 'lt' : case '<' : return ( $ input < $ check ) ; break ; case 'lessorequal' : case 'lte' : case '<=' : return ( $ input <= $ check ) ; break ; case 'equal' : case 'eq' : case '==' : case '=' : return ( $ input == $ check ) ; break ; case 'notequal' : case 'neq' : case 'ne' : case '!=' : return ( $ input != $ check ) ; break ; default : throw new InvalidArgumentException ( sprintf ( 'Unsupported mode %s for %s' , $ mode , __METHOD__ ) ) ; break ; } }
Compare two numerical values .
13,630
public static function date ( $ input ) { $ input = Time :: toUnix ( $ input ) ; if ( ! $ input ) { return false ; } list ( $ m , $ d , $ y ) = explode ( '/' , date ( 'm/d/Y' , $ input ) ) ; return checkdate ( $ m , $ d , $ y ) ; }
Validate input is a real date .
13,631
public static function decimal ( $ input , $ places = 2 ) { if ( ! $ places ) { $ regex = '/^[-+]?[0-9]*\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/' ; } else { $ regex = '/^[-+]?[0-9]*\.{1}[0-9]{' . $ places . '}$/' ; } return static :: custom ( $ input , $ regex ) ; }
Validate input is a decimal .
13,632
public static function dimensions ( $ input , $ type , $ size ) { if ( static :: file ( $ input ) ) { $ input = $ input [ 'tmp_name' ] ; } if ( ! file_exists ( $ input ) ) { return false ; } if ( $ file = getimagesize ( $ input ) ) { $ width = $ file [ 0 ] ; $ height = $ file [ 1 ] ; switch ( $ type ) { case 'width' : return ( $ width == $ size ) ; case 'height' : return ( $ height == $ size ) ; case 'maxWidth' : return ( $ width <= $ size ) ; case 'maxHeight' : return ( $ height <= $ size ) ; case 'minWidth' : return ( $ width >= $ size ) ; case 'minHeight' : return ( $ height >= $ size ) ; } } return false ; }
Validate an images dimensions .
13,633
public static function ext ( $ input , $ extensions = array ( 'gif' , 'jpeg' , 'png' , 'jpg' ) ) { if ( is_array ( $ input ) && isset ( $ input [ 'name' ] ) ) { $ input = $ input [ 'name' ] ; } return in_array ( Path :: ext ( $ input ) , ( array ) $ extensions , true ) ; }
Validate input has an extension and is in the whitelist .
13,634
public static function luhn ( $ input ) { if ( $ input == 0 ) { return false ; } $ sum = 0 ; $ length = mb_strlen ( $ input ) ; for ( $ position = 1 - ( $ length % 2 ) ; $ position < $ length ; $ position += 2 ) { $ sum += $ input [ $ position ] ; } for ( $ position = ( $ length % 2 ) ; $ position < $ length ; $ position += 2 ) { $ number = $ input [ $ position ] * 2 ; $ sum += ( $ number < 10 ) ? $ number : $ number - 9 ; } return ( $ sum % 10 == 0 ) ; }
Luhn algorithm .
13,635
public static function mimeType ( $ input , $ mimes ) { if ( static :: file ( $ input ) ) { $ input = $ input [ 'tmp_name' ] ; } if ( ! file_exists ( $ input ) ) { return false ; } $ file = finfo_open ( FILEINFO_MIME_TYPE ) ; $ type = finfo_file ( $ file , $ input ) ; finfo_close ( $ file ) ; return in_array ( $ type , ( array ) $ mimes ) ; }
Validate a files mime type is in the whitelist .
13,636
public static function minFilesize ( $ input , $ min ) { if ( static :: file ( $ input ) ) { $ size = $ input [ 'size' ] ; } else if ( file_exists ( $ input ) ) { $ size = filesize ( $ input ) ; } else { return false ; } return ( $ size >= Number :: bytesFrom ( $ min ) ) ; }
Validate an images file size is above the minimum .
13,637
public static function maxFilesize ( $ input , $ max ) { if ( static :: file ( $ input ) ) { $ size = $ input [ 'size' ] ; } else if ( file_exists ( $ input ) ) { $ size = filesize ( $ input ) ; } else { return false ; } return ( $ size <= Number :: bytesFrom ( $ max ) ) ; }
Validate an images file size is below the maximum .
13,638
public function createMigration ( $ script , $ rollbackScript ) { $ this -> releaseChecker -> checkScript ( $ script , $ rollbackScript ) ; if ( $ this -> rollbackedFirst ) { list ( $ rollbackScript , $ script ) = array ( $ script , $ rollbackScript ) ; } $ this -> migrations [ ] = $ this -> migrationFactory -> createMigration ( $ this -> loader -> load ( $ script ) -> getQueries ( ) , $ this -> loader -> load ( $ rollbackScript ) -> getQueries ( ) ) ; return $ this ; }
Create a migration from SQL script & rollback script
13,639
private function createMigrations ( ) { $ scripts = $ this -> locator -> findScripts ( ) ; $ rollbacks = $ this -> locator -> findRollbackScripts ( ) ; $ this -> releaseChecker -> checkScripts ( $ scripts , $ rollbacks ) ; foreach ( $ scripts as $ k => $ script ) { $ this -> createMigration ( $ script , $ rollbacks [ $ k ] ) ; } }
Create migrations from scripts & rollback files
13,640
public function get ( $ key ) { $ url = $ this -> authenticationService -> getServerEndPoint ( ) . Endpoints :: VERSION . Endpoints :: BASE_META . Endpoints :: META ; $ result = $ this -> authenticationService -> getTransport ( ) -> fetch ( $ url , array ( "key" => $ key ) ) ; if ( $ result [ "code" ] == APIResponse :: RESPONSE_SUCCESS ) { $ unwrapped = @ json_decode ( $ result [ 'results' ] [ 'value' ] ) ; $ value = $ unwrapped === null ? $ result [ 'results' ] [ 'value' ] : $ unwrapped ; return array ( "value" => $ value , "validity" => $ result [ 'results' ] [ 'validity' ] ) ; } else { return null ; } }
Gets the stored meta data for the key provided
13,641
public function add ( $ key , $ value , $ valid_for_minutes = null ) { if ( is_object ( $ value ) || is_array ( $ value ) ) { $ value = json_encode ( $ value ) ; } $ url = $ this -> authenticationService -> getServerEndPoint ( ) . Endpoints :: VERSION . Endpoints :: BASE_META . Endpoints :: META ; $ result = $ this -> authenticationService -> getTransport ( ) -> fetch ( $ url , array ( "key" => $ key , "value" => $ value , "validity" => $ valid_for_minutes ) , 'PUT' , array ( ) , 0 ) ; if ( $ result [ "code" ] == APIResponse :: RESPONSE_SUCCESS ) { return true ; } else { return false ; } }
Adds or Updates meta data for the key provided
13,642
public function loadCache ( ) { if ( empty ( $ this -> name ) ) throw new DBException ( "Please provide a name for the schema when using the cache" ) ; $ cachemgr = CacheManager :: getInstance ( ) ; $ this -> tables = $ cachemgr -> getCache ( 'dbschema_' . $ this -> name ) ; }
Load the cache containing table definitions
13,643
public function getTable ( $ table_name ) { if ( ! $ this -> tables -> has ( 'tables' , $ table_name ) ) { if ( $ this -> db !== null ) { $ table = $ this -> db -> loadTable ( $ table_name ) ; $ this -> tables -> set ( 'tables' , $ table_name , $ table ) ; } else throw new DBException ( "Table $table not ofund" ) ; } return $ this -> tables -> get ( 'tables' , $ table_name ) ; }
Get a table definition from the schema
13,644
public function putTable ( Table $ table ) { $ this -> tables -> set ( 'tables' , $ table -> getName ( ) , $ table ) ; return $ this ; }
Add a table to the schema
13,645
public function removeTable ( $ table ) { if ( $ table instanceof Table ) $ table = $ table -> getName ( ) ; $ this -> tables -> set ( 'tables' , $ table , null ) ; return $ this ; }
Remove a schema from the table definition
13,646
public static function stringTrim ( string $ string , int $ length ) : string { if ( $ length < 16 ) return $ string ; if ( strlen ( $ string ) > $ length ) { $ str_head = substr ( $ string , 0 , $ length - 10 ) ; $ str_tail = substr ( $ string , - 7 , 7 ) ; return $ str_head . '...' . $ str_tail ; } return $ string ; }
Helper function to make a non - unicode string shortter
13,647
public static function renderBlockAttrs ( array $ embed ) : string { $ classes = array ( ) ; $ styles = array ( ) ; $ d = & $ embed [ 'dimension' ] ; $ classes [ ] = 'videoblock' ; if ( $ d -> dynamic ) { $ classes [ ] = 'videoblock-dynamic' ; } if ( $ d -> dynamic ) { $ styles [ ] = 'max-width:' . $ d -> width . 'px' ; } else { $ styles [ ] = 'width: ' . $ d -> width . 'px' ; } $ class = implode ( ' ' , $ classes ) ; $ style = implode ( '; ' , $ styles ) . ( ! empty ( $ styles ) ? ';' : '' ) ; return 'class="' . $ class . '" style="' . $ style . '"' ; }
Helper funcion to template . Render attributes for . videoblock
13,648
public static function renderWrapperAttrs ( array $ embed ) : string { $ classes = array ( ) ; $ styles = array ( ) ; $ d = & $ embed [ 'dimension' ] ; $ classes [ ] = 'video-wrapper' ; if ( $ d -> dynamic ) { $ classes [ ] = 'wrap-' . $ d -> scale_model ; } if ( $ d -> dynamic && ( $ d -> scale_model == 'scale-width-height' ) ) { $ styles [ ] = 'padding-bottom: ' . ( $ d -> factor * 100 ) . '%;' ; } $ class = implode ( ' ' , $ classes ) ; $ style = implode ( '; ' , $ styles ) . ( ! empty ( $ styles ) ? ';' : '' ) ; return 'class="' . $ class . '" style="' . $ style . '"' ; }
Helper funcion to template . Render attributes for . videowrapper
13,649
public static function toHTML ( array $ embed , bool $ inlineStyle = false ) : string { static $ css_done ; $ css = '' ; $ d = & $ embed [ 'dimension' ] ; if ( $ inlineStyle && ! isset ( $ css_done ) ) { $ css = '<style>' . Theme :: style ( ) . '</style>' ; $ css_done = true ; } ob_start ( ) ; include __DIR__ . '/Theme/theme.tpl.php' ; $ codeblock = ob_get_contents ( ) ; ob_end_clean ( ) ; return preg_replace ( '/[\t ]*[\r\n]+[\t ]*/' , ' ' , $ css . $ codeblock ) ; }
Theme the given embed information array into HTML string
13,650
private function classExists ( $ fqcn ) { if ( isset ( $ this -> classExists [ $ fqcn ] ) ) return $ this -> classExists [ $ fqcn ] ; if ( class_exists ( $ fqcn ) ) return $ this -> classExists [ $ fqcn ] = true ; return false ; }
Attempts to check if a class exists or not .
13,651
public function wherePivotIn ( $ column , $ values , $ boolean = 'and' , $ not = false ) { $ this -> pivotWheres [ ] = func_get_args ( ) ; return $ this -> whereIn ( $ this -> table . '.' . $ column , $ values , $ boolean , $ not ) ; }
Set a where in clause for a pivot table column .
13,652
public function findOrNew ( $ id , $ columns = [ '*' ] ) { if ( is_null ( $ instance = $ this -> find ( $ id , $ columns ) ) ) { $ instance = $ this -> getRelated ( ) -> newInstance ( ) ; } return $ instance ; }
Find a related model by its primary key or return new instance of the related model .
13,653
protected function attachNew ( array $ records , array $ current , $ touch = true ) { $ changes = [ 'attached' => [ ] , 'updated' => [ ] ] ; foreach ( $ records as $ id => $ attributes ) { if ( ! in_array ( $ id , $ current ) ) { $ this -> attach ( $ id , $ attributes , $ touch ) ; $ changes [ 'attached' ] [ ] = is_numeric ( $ id ) ? ( int ) $ id : ( string ) $ id ; } elseif ( count ( $ attributes ) > 0 && $ this -> updateExistingPivot ( $ id , $ attributes , $ touch ) ) { $ changes [ 'updated' ] [ ] = is_numeric ( $ id ) ? ( int ) $ id : ( string ) $ id ; } } return $ changes ; }
Attach all of the IDs that aren t in the current array .
13,654
public static function fillBuffer ( StreamInterface $ stream , $ bufferSize = 8192 ) { if ( ! $ stream -> isReadable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Stream is not readable: %s' , get_class ( $ stream ) ) ) ; } $ buffer = '' ; while ( ! $ stream -> eof ( ) && strlen ( $ buffer ) < $ bufferSize ) { $ buffer .= $ stream -> read ( $ bufferSize - strlen ( $ buffer ) ) ; } return $ buffer ; }
Read contents from the given input stream until EOF or the specified buffer is full .
13,655
public static function reader ( StreamInterface $ stream , $ bufferSize = 8192 ) { if ( ! $ stream -> isReadable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Stream is not readable: %s' , get_class ( $ stream ) ) ) ; } while ( ! $ stream -> eof ( ) ) { yield $ stream -> read ( $ bufferSize ) ; } }
Turn a stream into an iterator .
13,656
public static function bufferedReader ( StreamInterface $ stream , $ bufferSize = 8192 ) { if ( ! $ stream -> isReadable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Stream is not readable: %s' , get_class ( $ stream ) ) ) ; } $ buffer = '' ; while ( ! $ stream -> eof ( ) ) { $ buffer .= $ stream -> read ( $ bufferSize ) ; while ( strlen ( $ buffer ) >= $ bufferSize ) { yield ( string ) substr ( $ buffer , 0 , $ bufferSize ) ; $ buffer = ( string ) substr ( $ buffer , $ bufferSize ) ; } } if ( $ buffer !== '' ) { yield $ buffer ; } }
Turn a stream into an iterator returning even - sized results .
13,657
public static function pipe ( StreamInterface $ in , StreamInterface $ out , $ chunkSize = 8192 ) { if ( ! $ in -> isReadable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Input stream is not readable: %s' , get_class ( $ in ) ) ) ; } if ( ! $ out -> isWritable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Output stream is not writable: %s' , get_class ( $ out ) ) ) ; } $ size = 0 ; while ( ! $ in -> eof ( ) ) { $ size += $ out -> write ( $ in -> read ( $ chunkSize ) ) ; } return $ size ; }
Pipe data from an input stream into an output stream .
13,658
public function deleteCompiledFile ( $ templateName ) { $ className = $ this -> jigConverter -> getClassNameFromFilename ( $ templateName ) ; $ compileFilename = $ this -> jigConfig -> getCompiledFilenameFromClassname ( $ className ) ; $ deleted = @ unlink ( $ compileFilename ) ; return $ deleted ; }
Delete the compiled version of a template .
13,659
public function setQueryBuilderInitializer ( \ Closure $ initializer = null ) { if ( ! is_null ( $ initializer ) ) { $ this -> validateQueryBuilderInitializer ( $ initializer ) ; } $ this -> queryBuilderInitializer = $ initializer ; return $ this ; }
Sets the query builder initializer .
13,660
private function validateQueryBuilderInitializer ( \ Closure $ initializer ) { $ reflection = new \ ReflectionFunction ( $ initializer ) ; $ parameters = $ reflection -> getParameters ( ) ; if ( 2 !== count ( $ parameters ) ) { throw new InvalidArgumentException ( "The query builder initializer must have two and only two arguments." ) ; } $ class = $ parameters [ 0 ] -> getClass ( ) ; if ( ! $ class || $ class -> getName ( ) !== QueryBuilder :: class ) { throw new InvalidArgumentException ( sprintf ( "The query builder initializer's first argument must be type hinted to the %s class." , QueryBuilder :: class ) ) ; } if ( ! in_array ( $ parameters [ 1 ] -> getType ( ) , [ null , 'string' ] , true ) ) { throw new InvalidArgumentException ( sprintf ( "The query builder initializer's second must be type hinted to 'string'." , QueryBuilder :: class ) ) ; } }
Validates the query builder initializer .
13,661
public function addAll ( ) { if ( func_num_args ( ) > 0 ) { for ( $ i = 0 ; $ i < func_num_args ( ) ; $ i ++ ) { if ( func_get_arg ( $ i ) instanceof \ bootbuilder \ Controls \ Control ) { array_push ( $ this -> controls , func_get_arg ( $ i ) ) ; } } } }
Add multiple controls to form
13,662
public function replaceControl ( $ nr , $ control ) { if ( isset ( $ this -> controls [ $ nr ] ) ) { $ this -> controls [ $ nr ] = $ control ; } }
Replace current control in array with new one
13,663
public function parseParameters ( $ parameters ) { for ( $ i = 0 ; $ i < count ( $ this -> controls ) ; $ i ++ ) { $ this -> controls [ $ i ] = $ this -> parseParameterControl ( $ this -> controls [ $ i ] , $ parameters ) ; } }
Parse Posted Parameters into controls
13,664
public function save ( $ replace = true , $ prepare = true ) { $ this -> add ( new \ bootbuilder \ Controls \ Hidden ( "bootbuilder-form" , $ this -> id ) ) ; if ( $ replace ) { \ bootbuilder \ Validation \ Validator :: clean ( ) ; } \ bootbuilder \ Validation \ Validator :: save ( $ this , $ this -> id , $ prepare ) ; }
Save form for validation
13,665
public static function captureQueries ( \ Closure $ closure ) { DB :: enableQueryLog ( ) ; $ closure ( ) ; $ logs = DB :: getQueryLog ( ) ; return array_map ( function ( $ log ) { return static :: inlineBindings ( $ log [ 'query' ] , $ log [ 'bindings' ] ) ; } , $ logs ) ; }
Capture SQL queries called via Eloquent inside argument closure
13,666
public static function plainSql ( $ query ) { $ query = static :: getBaseQuery ( $ query ) ; return self :: inlineBindings ( $ query -> toSql ( ) , $ query -> getBindings ( ) ) ; }
Present query builder as plain SQL including inline parameter values
13,667
private function generateModuleJsonFile ( ) { $ path = $ this -> module -> getModulePath ( $ this -> getName ( ) ) . 'module.json' ; if ( ! $ this -> filesystem -> isDirectory ( $ dir = dirname ( $ path ) ) ) { $ this -> filesystem -> makeDirectory ( $ dir , 0775 , true ) ; } $ this -> filesystem -> put ( $ path , $ this -> getStubContents ( 'json' ) ) ; }
Generate the module . json file
13,668
protected function cleanup ( ) { if ( $ this -> resource ) { proc_terminate ( $ this -> resource ) ; } if ( is_resource ( $ this -> handle ) ) { fclose ( $ this -> handle ) ; } $ this -> handle = null ; $ this -> resource = null ; }
Performs cleanup duties so that no traces of this timer having ever been used remain .
13,669
public function setAttribute ( $ name , $ value ) { if ( strlen ( $ name ) < 1 ) { throw new HTMLTagException ( "Attribute name is empty" ) ; } $ this -> tag_attributes [ strtolower ( $ name ) ] = $ value ; return $ this ; }
Sets the attribute of this tag to the value given a value of NULL will list the attribute with no = value after
13,670
public function removeAttribute ( $ name ) { if ( strlen ( $ name ) < 1 ) { throw new HTMLTagException ( "Attribute name is empty" ) ; } unset ( $ this -> tag_attributes [ strtolower ( $ name ) ] ) ; return $ this ; }
Removes the attribute from the tag along with its value .
13,671
public function addClass ( $ className ) { if ( strlen ( $ className ) < 1 ) { throw new HTMLTagException ( "Class name is empty" ) ; } if ( ! $ this -> hasClass ( $ className ) ) { $ classes = $ this -> getClasses ( ) . " " . $ this -> removeMultipleSpaces ( trim ( $ className ) ) ; $ this -> setAttribute ( "class" , trim ( $ classes ) ) ; } return $ this ; }
Add a class name to the class attribute this won t add duplicates .
13,672
public function removeClass ( $ className ) { if ( strlen ( $ className ) < 1 ) { throw new HTMLTagException ( "Class name is empty" ) ; } $ classes = explode ( " " , $ this -> getClasses ( ) ) ; $ this -> clearClasses ( ) ; foreach ( $ classes as $ class ) { if ( strtolower ( $ class ) != strtolower ( $ className ) ) { $ this -> addClass ( $ class ) ; } } return $ this ; }
Removes the specified class name .
13,673
public function hasClass ( $ className ) { if ( strlen ( $ className ) < 1 ) { throw new HTMLTagException ( "Class name is empty" ) ; } if ( $ this -> hasAttribute ( "class" ) ) { $ classes = $ this -> getClasses ( ) ; foreach ( explode ( " " , $ classes ) as $ class ) { if ( strtolower ( $ class ) == strtolower ( $ className ) ) { return true ; } } } return false ; }
Checks to see if the given class name is inside of the class attribute
13,674
public function getClasses ( ) { $ classes = $ this -> getAttribute ( "class" ) ; return ( strlen ( $ classes ) > 0 ) ? trim ( $ this -> removeMultipleSpaces ( $ classes ) ) : "" ; }
Returns a space separated string of classes belonging to the tag .
13,675
public function getFormattedAttributes ( ) { $ rtn = "" ; foreach ( $ this -> listAttributes ( ) as $ name => $ value ) { $ rtn .= sprintf ( " %s=\"%s\"" , htmlentities ( $ name ) , htmlentities ( $ value ) ) ; } return $ rtn ; }
Format and return attributes in a name = value format as it should appear in an HTML tag .
13,676
public function setTagPrefix ( $ prefix ) { if ( ! is_string ( $ prefix ) && $ prefix !== null ) { throw new HTMLTagException ( "The tag prefix must be a string or null." ) ; } $ this -> tag_prefix_previous = $ this -> getTagPrefix ( ) ; $ this -> tag_prefix = $ prefix ; return $ this ; }
Sets the string that should precede a tag
13,677
public function write ( ) { foreach ( $ this -> parameters as $ prop => $ value ) { $ placeHolders [ ] = sprintf ( '<%s>' , $ prop ) ; $ replacements [ ] = $ value ; } $ config = str_replace ( $ placeHolders , $ replacements , self :: $ configTemplate ) ; $ config = sprintf ( '%s%s%s' , self :: $ defaultConfigTemplate , PHP_EOL , $ config ) ; if ( true === $ this -> parameters [ 'composer' ] ) { $ config = sprintf ( '%s%s%s' , $ config , PHP_EOL , self :: $ downloadComposerTaskTemplate ) ; } if ( true === $ this -> parameters [ 'schemadb' ] ) { $ config = sprintf ( '%s%s%s' , $ config , PHP_EOL , self :: $ updateSchemaTaskTemplate ) ; } fwrite ( $ this -> file , $ this -> addHeaders ( $ config ) ) ; }
Writes deployment file .
13,678
public static function recoverable ( Address $ path ) : self { try { return new self ( $ path ) ; } catch ( FailedToOpenSocket $ e ) { @ unlink ( ( string ) $ path ) ; return new self ( $ path ) ; } }
On open failure it will try to delete existing socket file the ntry to reopen the socket connection
13,679
protected function serviceFromDefinition ( $ id , $ args ) { $ service = $ this -> createServiceObject ( $ id , $ args ) ; $ this -> runDefinedMethods ( $ id , $ service ) ; $ this -> decorateService ( $ service ) ; return $ service ; }
Check circular create service and decorate service
13,680
public function getIp ( ) : string { if ( $ this -> ip === null ) { foreach ( [ "HTTP_X_FORWARDED_FOR" , "X_FORWARDED_FOR" ] as $ key ) { $ proxyIpList = $ this -> environment [ $ key ] ?? "" ; if ( $ proxyIpList ) { $ commaPosition = strpos ( $ proxyIpList , "," ) ; if ( $ commaPosition !== false ) { $ this -> ip = substr ( $ proxyIpList , 0 , $ commaPosition ) ; } else { $ this -> ip = $ proxyIpList ; } return $ this -> ip ; } } $ this -> ip = $ this -> environment [ "REMOTE_ADDR" ] ?? "" ; } return $ this -> ip ; }
Retrieve the client ip address
13,681
public function count ( ) : int { $ key = $ this -> storeKey ( ) ; if ( ! $ this -> isCountable ( $ this -> $ key ) ) { return 0 ; } return count ( $ this -> $ key ) ; }
Get size of collection
13,682
public function increase ( int $ size ) { $ count = $ this -> count ( ) ; if ( $ size > $ this -> count ( ) ) { $ add = $ size - $ this -> count ( ) ; $ key = $ this -> storeKey ( ) ; for ( $ i = 0 ; $ i < $ add ; $ i ++ ) { $ this -> addEmpty ( ) ; } } return $ this ; }
Increase size of collection
13,683
public function findByUsernameContains ( $ searched_term ) { $ qb = $ this -> createQueryBuilder ( 'u' ) ; $ qb instanceof QueryBuilder ; $ qb -> add ( 'where' , $ qb -> expr ( ) -> like ( 'u.username' , $ qb -> expr ( ) -> lower ( ':searched_term' ) ) ) -> setParameter ( 'searched_term' , $ searched_term . '%' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find user by username
13,684
public function normalizeId ( $ id ) { if ( ! \ is_string ( $ id ) ) { $ id = ( string ) $ id ; } if ( isset ( $ this -> normalizedIds [ $ normalizedId = strtolower ( $ id ) ] ) ) { $ normalizedId = $ this -> normalizedIds [ $ normalizedId ] ; if ( $ id !== $ normalizedId ) { @ trigger_error ( sprintf ( 'Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.3.' , $ id , $ normalizedId ) , E_USER_DEPRECATED ) ; } } else { $ normalizedId = $ this -> normalizedIds [ $ normalizedId ] = $ id ; } return $ normalizedId ; }
Returns the case sensitive id used at registration time .
13,685
public function getTimestamp ( $ returnType = 'string' ) { if ( in_array ( $ returnType , [ 'array' , 'float' , 'string' ] ) ) { return $ this -> getTimestampRaw ( $ returnType ) ; } return sprintf ( $ this -> lclMsgCmn ( 'i18n_Error_UnknownReturnType' ) , $ returnType ) ; }
Returns server Timestamp into various formats
13,686
public function isJsonByDanielGP ( $ inputJson ) { if ( is_string ( $ inputJson ) ) { json_decode ( $ inputJson ) ; return ( json_last_error ( ) == JSON_ERROR_NONE ) ; } return $ this -> lclMsgCmn ( 'i18n_Error_GivenInputIsNotJson' ) ; }
Tests if given string has a valid Json format
13,687
protected function sendBackgroundEncodedFormElementsByPost ( $ urlToSendTo , $ params = [ ] ) { $ postingUrl = filter_var ( $ urlToSendTo , FILTER_VALIDATE_URL ) ; if ( $ postingUrl === false ) { throw new \ Exception ( 'Invalid URL in ' . __FUNCTION__ ) ; } if ( $ params !== [ ] ) { $ cntFailErrMsg = $ this -> lclMsgCmn ( 'i18n_Error_FailedToConnect' ) ; $ this -> sendBackgroundPostData ( $ postingUrl , $ params , $ cntFailErrMsg ) ; return '' ; } throw new \ Exception ( $ this -> lclMsgCmn ( 'i18n_Error_GivenParameterIsNotAnArray' ) ) ; }
Send an array of parameters like a form through a POST action
13,688
public function setJsonToArray ( $ inputJson ) { if ( ! $ this -> isJsonByDanielGP ( $ inputJson ) ) { return [ 'error' => $ this -> lclMsgCmn ( 'i18n_Error_GivenInputIsNotJson' ) ] ; } $ sReturn = ( json_decode ( $ inputJson , true ) ) ; $ jsonError = $ this -> setJsonErrorInPlainEnglish ( ) ; if ( $ jsonError == '' ) { return $ sReturn ; } return [ 'error' => $ jsonError ] ; }
Converts a JSON string into an Array
13,689
protected function _setSubjectConfig ( $ subjectConfig ) { if ( $ subjectConfig === null || $ subjectConfig = $ this -> _normalizeContainer ( $ subjectConfig ) ) { $ this -> subjectConfig = $ subjectConfig ; } }
Sets the subject factory configuration for this instance .
13,690
public function setExpressionVisitor ( \ Aztech \ Skwal \ Visitor \ Printer \ Expression $ visitor ) { $ this -> expressionVisitor = $ visitor ; }
Sets the visitor instance for used to output expressions .
13,691
public function setTableReferenceVisitor ( \ Aztech \ Skwal \ Visitor \ Printer \ TableReference $ visitor ) { $ this -> tableReferenceVisitor = $ visitor ; }
Sets the visitor instance for used to output correlated references .
13,692
public function setPredicateVisitor ( \ Aztech \ Skwal \ Visitor \ Printer \ Predicate $ visitor ) { $ this -> predicateVisitor = $ visitor ; }
Sets the visitor instance for used to output predicates .
13,693
public function printQuery ( \ Aztech \ Skwal \ Query $ query ) { $ this -> visit ( $ query ) ; return $ this -> queryStack -> pop ( ) ; }
Generates the SQL command for a given query .
13,694
private function appendSelectList ( \ Aztech \ Skwal \ Visitor \ Printer \ Assembler \ Select $ assembler , \ Aztech \ Skwal \ Query \ Select $ query ) { $ this -> expressionVisitor -> useAliases ( true ) ; $ selectList = array ( ) ; foreach ( $ query -> getColumns ( ) as $ column ) { $ selectList [ ] = $ this -> expressionVisitor -> printExpression ( $ column ) ; } $ assembler -> setSelectList ( $ selectList ) ; }
Adds the select list elements of a query to a query assembler .
13,695
private function appendFromClause ( \ Aztech \ Skwal \ Visitor \ Printer \ Assembler \ Select $ assembler , \ Aztech \ Skwal \ Query \ Select $ query ) { $ fromStatement = $ this -> tableReferenceVisitor -> printTableStatement ( $ query -> getTable ( ) ) ; $ assembler -> setFromClause ( $ fromStatement ) ; }
Adds the from clause of a query to a query assembler .
13,696
private function appendWhereClauseIfNecessary ( \ Aztech \ Skwal \ Visitor \ Printer \ Assembler \ Select $ assembler , \ Aztech \ Skwal \ Query \ Select $ query ) { if ( $ query -> getCondition ( ) != null ) { $ whereClause = $ this -> predicateVisitor -> printPredicateStatement ( $ query -> getCondition ( ) ) ; $ assembler -> setWhereClause ( $ whereClause ) ; } }
Adds the where clause of a query to a query assembler if the given query has a selection condition .
13,697
private function appendGroupByList ( \ Aztech \ Skwal \ Visitor \ Printer \ Assembler \ Select $ assembler , \ Aztech \ Skwal \ Query \ Select $ query ) { $ this -> expressionVisitor -> useAliases ( false ) ; $ groupByList = array ( ) ; foreach ( $ query -> getGroupingColumns ( ) as $ groupingColumn ) { $ groupByList [ ] = $ this -> expressionVisitor -> printExpression ( $ groupingColumn ) ; } $ assembler -> setGroupByList ( $ groupByList ) ; }
Adds the group by list from a query to a query assembler .
13,698
private function appendOrderByList ( \ Aztech \ Skwal \ Visitor \ Printer \ Assembler \ Select $ assembler , \ Aztech \ Skwal \ Query \ Select $ query ) { $ this -> expressionVisitor -> useAliases ( false ) ; $ orderByList = array ( ) ; foreach ( $ query -> getSortingColumns ( ) as $ sortingColumn ) { $ direction = $ this -> getSortDirectionText ( $ sortingColumn ) ; $ orderByList [ ] = $ this -> expressionVisitor -> printExpression ( $ sortingColumn -> getExpression ( ) ) . $ direction ; } $ assembler -> setOrderByList ( $ orderByList ) ; }
Adds the sort expressions from a query to a query assembler .
13,699
public function route ( $ name = '' ) { $ routes = AsCollector :: getAs ( ) ; if ( isset ( $ routes [ $ name ] ) ) { $ this -> to ( $ routes [ $ name ] ) ; } else { throw new RouteNotFoundException ( sprintf ( '%s Route Not Found' ) ) ; } }
redirect to a route