idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
5,600
|
public function render ( $ view , $ data = [ ] , $ mergeData = [ ] ) { return $ this -> container [ 'view' ] -> make ( $ view , $ data , $ mergeData ) -> render ( ) ; }
|
Render shortcut .
|
5,601
|
public function generate ( $ node = null , $ clockSeq = null ) { $ uuid = uuid_create ( UUID_TYPE_TIME ) ; return uuid_parse ( $ uuid ) ; }
|
Generate a version 1 UUID using the PECL UUID extension
|
5,602
|
public function build ( CodecInterface $ codec , array $ fields ) { return new DegradedUuid ( $ fields , $ this -> numberConverter , $ codec , $ this -> timeConverter ) ; }
|
Builds a DegradedUuid
|
5,603
|
public static function applyVersion ( $ timeHi , $ version ) { $ timeHi = hexdec ( $ timeHi ) & 0x0fff ; $ timeHi &= ~ ( 0xf000 ) ; $ timeHi |= $ version << 12 ; return $ timeHi ; }
|
Applies the RFC 4122 version number to the time_hi_and_version field
|
5,604
|
public function encode ( UuidInterface $ uuid ) { $ sixPieceComponents = array_values ( $ uuid -> getFieldsHex ( ) ) ; $ this -> swapTimestampAndRandomBits ( $ sixPieceComponents ) ; return vsprintf ( '%08s-%04s-%04s-%02s%02s-%012s' , $ sixPieceComponents ) ; }
|
Encodes a UuidInterface as a string representation of a timestamp first COMB UUID
|
5,605
|
public function encodeBinary ( UuidInterface $ uuid ) { $ stringEncoding = $ this -> encode ( $ uuid ) ; return hex2bin ( str_replace ( '-' , '' , $ stringEncoding ) ) ; }
|
Encodes a UuidInterface as a binary representation of timestamp first COMB UUID
|
5,606
|
public function decode ( $ encodedUuid ) { $ fivePieceComponents = $ this -> extractComponents ( $ encodedUuid ) ; $ this -> swapTimestampAndRandomBits ( $ fivePieceComponents ) ; return $ this -> getBuilder ( ) -> build ( $ this , $ this -> getFields ( $ fivePieceComponents ) ) ; }
|
Decodes a string representation of timestamp first COMB UUID into a UuidInterface object instance
|
5,607
|
protected function swapTimestampAndRandomBits ( array & $ components ) { $ last48Bits = $ components [ 4 ] ; if ( count ( $ components ) == 6 ) { $ last48Bits = $ components [ 5 ] ; $ components [ 5 ] = $ components [ 0 ] . $ components [ 1 ] ; } else { $ components [ 4 ] = $ components [ 0 ] . $ components [ 1 ] ; } $ components [ 0 ] = substr ( $ last48Bits , 0 , 8 ) ; $ components [ 1 ] = substr ( $ last48Bits , 8 , 4 ) ; }
|
Swaps the first 48 bits with the last 48 bits
|
5,608
|
public function generate ( $ node = null , $ clockSeq = null ) { $ node = $ this -> getValidNode ( $ node ) ; if ( $ clockSeq === null ) { $ clockSeq = random_int ( 0 , 0x3fff ) ; } $ timeOfDay = $ this -> timeProvider -> currentTime ( ) ; $ uuidTime = $ this -> timeConverter -> calculateTime ( ( string ) $ timeOfDay [ 'sec' ] , ( string ) $ timeOfDay [ 'usec' ] ) ; $ timeHi = BinaryUtils :: applyVersion ( $ uuidTime [ 'hi' ] , 1 ) ; $ clockSeqHi = BinaryUtils :: applyVariant ( $ clockSeq >> 8 ) ; $ hex = vsprintf ( '%08s%04s%04s%02s%02s%012s' , [ $ uuidTime [ 'low' ] , $ uuidTime [ 'mid' ] , sprintf ( '%04x' , $ timeHi ) , sprintf ( '%02x' , $ clockSeqHi ) , sprintf ( '%02x' , $ clockSeq & 0xff ) , $ node , ] ) ; return hex2bin ( $ hex ) ; }
|
Generate a version 1 UUID from a host ID sequence number and the current time
|
5,609
|
protected function uuidFromNsAndName ( $ ns , $ name , $ version , $ hashFunction ) { if ( ! ( $ ns instanceof UuidInterface ) ) { $ ns = $ this -> codec -> decode ( $ ns ) ; } $ hash = call_user_func ( $ hashFunction , ( $ ns -> getBytes ( ) . $ name ) ) ; return $ this -> uuidFromHashedName ( $ hash , $ version ) ; }
|
Returns a version 3 or 5 namespaced Uuid
|
5,610
|
public function decode ( $ encodedUuid ) { $ components = $ this -> extractComponents ( $ encodedUuid ) ; $ fields = $ this -> getFields ( $ components ) ; return $ this -> builder -> build ( $ this , $ fields ) ; }
|
Decodes a string representation of a UUID into a UuidInterface object instance
|
5,611
|
public function decodeBytes ( $ bytes ) { if ( strlen ( $ bytes ) !== 16 ) { throw new InvalidArgumentException ( '$bytes string should contain 16 characters.' ) ; } $ hexUuid = unpack ( 'H*' , $ bytes ) ; return $ this -> decode ( $ hexUuid [ 1 ] ) ; }
|
Decodes a binary representation of a UUID into a UuidInterface object instance
|
5,612
|
protected function getFields ( array $ components ) { return [ 'time_low' => str_pad ( $ components [ 0 ] , 8 , '0' , STR_PAD_LEFT ) , 'time_mid' => str_pad ( $ components [ 1 ] , 4 , '0' , STR_PAD_LEFT ) , 'time_hi_and_version' => str_pad ( $ components [ 2 ] , 4 , '0' , STR_PAD_LEFT ) , 'clock_seq_hi_and_reserved' => str_pad ( substr ( $ components [ 3 ] , 0 , 2 ) , 2 , '0' , STR_PAD_LEFT ) , 'clock_seq_low' => str_pad ( substr ( $ components [ 3 ] , 2 ) , 2 , '0' , STR_PAD_LEFT ) , 'node' => str_pad ( $ components [ 4 ] , 12 , '0' , STR_PAD_LEFT ) ] ; }
|
Returns the fields that make up this UUID
|
5,613
|
public function encode ( UuidInterface $ uuid ) { $ components = array_values ( $ uuid -> getFieldsHex ( ) ) ; $ this -> swapFields ( $ components ) ; return vsprintf ( '%08s-%04s-%04s-%02s%02s-%012s' , $ components ) ; }
|
Encodes a UuidInterface as a string representation of a GUID
|
5,614
|
public function encodeBinary ( UuidInterface $ uuid ) { $ components = array_values ( $ uuid -> getFieldsHex ( ) ) ; return hex2bin ( implode ( '' , $ components ) ) ; }
|
Encodes a UuidInterface as a binary representation of a GUID
|
5,615
|
public function decode ( $ encodedUuid ) { $ components = $ this -> extractComponents ( $ encodedUuid ) ; $ this -> swapFields ( $ components ) ; return $ this -> getBuilder ( ) -> build ( $ this , $ this -> getFields ( $ components ) ) ; }
|
Decodes a string representation of a GUID into a UuidInterface object instance
|
5,616
|
protected function swapFields ( array & $ components ) { $ hex = unpack ( 'H*' , pack ( 'L' , hexdec ( $ components [ 0 ] ) ) ) ; $ components [ 0 ] = $ hex [ 1 ] ; $ hex = unpack ( 'H*' , pack ( 'S' , hexdec ( $ components [ 1 ] ) ) ) ; $ components [ 1 ] = $ hex [ 1 ] ; $ hex = unpack ( 'H*' , pack ( 'S' , hexdec ( $ components [ 2 ] ) ) ) ; $ components [ 2 ] = $ hex [ 1 ] ; }
|
Swaps fields to support GUID byte order
|
5,617
|
public function getNode ( ) { foreach ( $ this -> nodeProviders as $ provider ) { if ( $ node = $ provider -> getNode ( ) ) { return $ node ; } } return null ; }
|
Returns the system node ID by iterating over an array of node providers and returning the first non - empty value found
|
5,618
|
public function encodeBinary ( UuidInterface $ uuid ) { $ fields = $ uuid -> getFieldsHex ( ) ; $ optimized = [ $ fields [ 'time_hi_and_version' ] , $ fields [ 'time_mid' ] , $ fields [ 'time_low' ] , $ fields [ 'clock_seq_hi_and_reserved' ] , $ fields [ 'clock_seq_low' ] , $ fields [ 'node' ] , ] ; return hex2bin ( implode ( '' , $ optimized ) ) ; }
|
Encodes a UuidInterface as an optimized binary representation of a UUID
|
5,619
|
public function decodeBytes ( $ bytes ) { if ( strlen ( $ bytes ) !== 16 ) { throw new InvalidArgumentException ( '$bytes string should contain 16 characters.' ) ; } $ hex = unpack ( 'H*' , $ bytes ) [ 1 ] ; $ hex = substr ( $ hex , 8 , 4 ) . substr ( $ hex , 12 , 4 ) . substr ( $ hex , 4 , 4 ) . substr ( $ hex , 0 , 4 ) . substr ( $ hex , 16 ) ; return $ this -> decode ( $ hex ) ; }
|
Decodes an optimized binary representation of a UUID into a UuidInterface object instance
|
5,620
|
public function build ( CodecInterface $ codec , array $ fields ) { return new Uuid ( $ fields , $ this -> numberConverter , $ codec , $ this -> timeConverter ) ; }
|
Builds a Uuid
|
5,621
|
public function generate ( $ length ) { if ( $ length < self :: TIMESTAMP_BYTES || $ length < 0 ) { throw new \ InvalidArgumentException ( 'Length must be a positive integer.' ) ; } $ hash = '' ; if ( self :: TIMESTAMP_BYTES > 0 && $ length > self :: TIMESTAMP_BYTES ) { $ hash = $ this -> randomGenerator -> generate ( $ length - self :: TIMESTAMP_BYTES ) ; } $ lsbTime = str_pad ( $ this -> converter -> toHex ( $ this -> timestamp ( ) ) , self :: TIMESTAMP_BYTES * 2 , '0' , STR_PAD_LEFT ) ; return hex2bin ( str_pad ( bin2hex ( $ hash ) , $ length - self :: TIMESTAMP_BYTES , '0' ) . $ lsbTime ) ; }
|
Generates a string of binary data of the specified length
|
5,622
|
public function toHex ( $ integer ) { if ( ! $ integer instanceof BigNumber ) { $ integer = new BigNumber ( $ integer ) ; } return BigNumber :: convertFromBase10 ( $ integer , 16 ) ; }
|
Converts an integer or Moontoast \ Math \ BigNumber integer representation into a hexadecimal string representation
|
5,623
|
public function unserialize ( $ serialized ) { $ uuid = self :: fromString ( $ serialized ) ; $ this -> codec = $ uuid -> codec ; $ this -> numberConverter = $ uuid -> getNumberConverter ( ) ; $ this -> fields = $ uuid -> fields ; }
|
Re - constructs the object from its serialized form .
|
5,624
|
protected function getIfconfig ( ) { if ( strpos ( strtolower ( ini_get ( 'disable_functions' ) ) , 'passthru' ) !== false ) { return '' ; } ob_start ( ) ; switch ( strtoupper ( substr ( php_uname ( 'a' ) , 0 , 3 ) ) ) { case 'WIN' : passthru ( 'ipconfig /all 2>&1' ) ; break ; case 'DAR' : passthru ( 'ifconfig 2>&1' ) ; break ; case 'FRE' : passthru ( 'netstat -i -f link 2>&1' ) ; break ; case 'LIN' : default : passthru ( 'netstat -ie 2>&1' ) ; break ; } return ob_get_clean ( ) ; }
|
Returns the network interface configuration for the system
|
5,625
|
protected function getSysfs ( ) { $ mac = false ; if ( strtoupper ( php_uname ( 's' ) ) === 'LINUX' ) { $ addressPaths = glob ( '/sys/class/net/*/address' , GLOB_NOSORT ) ; if ( empty ( $ addressPaths ) ) { return false ; } array_walk ( $ addressPaths , function ( $ addressPath ) use ( & $ macs ) { $ macs [ ] = file_get_contents ( $ addressPath ) ; } ) ; $ macs = array_map ( 'trim' , $ macs ) ; $ macs = array_filter ( $ macs , function ( $ mac ) { return $ mac !== '00:00:00:00:00:00' && preg_match ( '/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i' , $ mac ) ; } ) ; $ mac = reset ( $ macs ) ; } return $ mac ; }
|
Returns mac address from the first system interface via the sysfs interface
|
5,626
|
protected function buildCodec ( $ useGuids = false ) { if ( $ useGuids ) { return new GuidStringCodec ( $ this -> builder ) ; } return new StringCodec ( $ this -> builder ) ; }
|
Determines which UUID coder - decoder to use and returns the configured codec for this environment
|
5,627
|
protected function buildTimeGenerator ( TimeProviderInterface $ timeProvider ) { if ( $ this -> enablePecl ) { return new PeclUuidTimeGenerator ( ) ; } return ( new TimeGeneratorFactory ( $ this -> nodeProvider , $ this -> timeConverter , $ timeProvider ) ) -> getGenerator ( ) ; }
|
Determines which time - based UUID generator to use and returns the configured time - based UUID generator for this environment
|
5,628
|
protected function buildTimeConverter ( ) { if ( $ this -> is64BitSystem ( ) ) { return new PhpTimeConverter ( ) ; } elseif ( $ this -> hasGmp ( ) ) { return new GmpTimeConverter ( ) ; } elseif ( $ this -> hasBigNumber ( ) ) { return new BigNumberTimeConverter ( ) ; } return new DegradedTimeConverter ( ) ; }
|
Determines which time converter to use and returns the configured time converter for this environment
|
5,629
|
protected function buildUuidBuilder ( ) { if ( $ this -> is64BitSystem ( ) ) { return new DefaultUuidBuilder ( $ this -> numberConverter , $ this -> timeConverter ) ; } return new DegradedUuidBuilder ( $ this -> numberConverter , $ this -> timeConverter ) ; }
|
Determines which UUID builder to use and returns the configured UUID builder for this environment
|
5,630
|
public function validate ( $ uuid ) { $ uuid = str_replace ( [ 'urn:' , 'uuid:' , '{' , '}' ] , '' , $ uuid ) ; if ( $ uuid === Uuid :: NIL || preg_match ( '/' . self :: VALID_PATTERN . '/D' , $ uuid ) ) { return true ; } return false ; }
|
Validate that a string represents a UUID
|
5,631
|
public function columnQuote ( $ column ) { if ( empty ( $ column ) ) { return null ; } preg_match ( '/^(?:(?<table>\w+)\.)?(?<column>\w+)$/iu' , $ column , $ match ) ; if ( isset ( $ match [ 'table' ] , $ match [ 'column' ] ) ) { $ table = $ this -> tableQuote ( $ match [ 'table' ] ) ; $ match [ 'column' ] = str_replace ( '`' , '' , $ match [ 'column' ] ) ; $ column = $ this -> escapes ? "`{$match['column']}`" : "{$match['column']}" ; return $ table ? $ table . '.' . $ column : $ column ; } return $ column ; }
|
Quotes a column name for use in a query .
|
5,632
|
public function set ( $ column , $ value = null , $ quote = null ) { if ( is_array ( $ column ) ) { foreach ( $ column as $ columnName => $ columnValue ) { $ this -> set ( $ columnName , $ columnValue , $ quote ) ; } } else { $ this -> set [ ] = array ( 'column' => $ this -> columnQuote ( $ column ) , 'value' => $ value , 'quote' => $ quote ) ; } return $ this ; }
|
Add one or more column values to INSERT UPDATE or REPLACE .
|
5,633
|
private function criteria ( array & $ criteria , $ column , $ value , $ operator = self :: EQUALS , $ connector = self :: LOGICAL_AND , $ quote = null ) { $ criteria [ ] = array ( 'column' => $ this -> columnQuote ( $ column ) , 'value' => $ value , 'operator' => $ operator , 'connector' => $ connector , 'quote' => $ quote ) ; return $ this ; }
|
Add a condition to the specified WHERE or HAVING criteria .
|
5,634
|
public function orHaving ( $ column , $ value , $ operator = self :: EQUALS , $ quote = null ) { return $ this -> orCriteria ( $ this -> having , $ column , $ value , $ operator , self :: LOGICAL_OR , $ quote ) ; }
|
Add an OR HAVING condition .
|
5,635
|
public function getJoinString ( ) { $ statement = "" ; foreach ( $ this -> join as $ i => $ join ) { $ statement .= " " . $ join [ 'type' ] . " " . $ join [ 'table' ] ; if ( $ join [ 'alias' ] ) { $ statement .= " AS " . $ join [ 'alias' ] ; } if ( $ join [ 'criteria' ] ) { $ statement .= " ON " ; foreach ( $ join [ 'criteria' ] as $ x => $ criterion ) { if ( $ x != 0 ) { $ statement .= " " . self :: LOGICAL_AND . " " ; } if ( strpos ( $ criterion , '=' ) === false ) { $ statement .= $ this -> getJoinCriteriaUsingPreviousTable ( $ i , $ join [ 'table' ] , $ criterion ) ; } else { $ statement .= $ criterion ; } } } } $ statement = trim ( $ statement ) ; return $ statement ; }
|
Get the JOIN portion of the statement as a string .
|
5,636
|
public function mergeInto ( Miner $ Miner , $ overrideLimit = true ) { if ( $ this -> isSelect ( ) ) { $ this -> mergeSelectInto ( $ Miner ) ; $ this -> mergeFromInto ( $ Miner ) ; $ this -> mergeJoinInto ( $ Miner ) ; $ this -> mergeWhereInto ( $ Miner ) ; $ this -> mergeGroupByInto ( $ Miner ) ; $ this -> mergeHavingInto ( $ Miner ) ; $ this -> mergeOrderByInto ( $ Miner ) ; if ( $ overrideLimit ) { $ this -> mergeLimitInto ( $ Miner ) ; } } elseif ( $ this -> isInsert ( ) ) { $ this -> mergeInsertInto ( $ Miner ) ; $ this -> mergeSetInto ( $ Miner ) ; } elseif ( $ this -> isReplace ( ) ) { $ this -> mergeReplaceInto ( $ Miner ) ; $ this -> mergeSetInto ( $ Miner ) ; } elseif ( $ this -> isUpdate ( ) ) { $ this -> mergeUpdateInto ( $ Miner ) ; $ this -> mergeJoinInto ( $ Miner ) ; $ this -> mergeSetInto ( $ Miner ) ; $ this -> mergeWhereInto ( $ Miner ) ; if ( ! $ this -> join ) { $ this -> mergeOrderByInto ( $ Miner ) ; if ( $ overrideLimit ) { $ this -> mergeLimitInto ( $ Miner ) ; } } } elseif ( $ this -> isDelete ( ) ) { $ this -> mergeDeleteInto ( $ Miner ) ; $ this -> mergeFromInto ( $ Miner ) ; $ this -> mergeJoinInto ( $ Miner ) ; $ this -> mergeWhereInto ( $ Miner ) ; if ( $ this -> isDeleteTableFrom ( ) ) { $ this -> mergeOrderByInto ( $ Miner ) ; if ( $ overrideLimit ) { $ this -> mergeLimitInto ( $ Miner ) ; } } } return $ Miner ; }
|
Merge this Miner into the given Miner .
|
5,637
|
protected function prepareDirectory ( ) { if ( File :: exists ( $ this -> docDir ) && ! is_writable ( $ this -> docDir ) ) { throw new L5SwaggerException ( 'Documentation storage directory is not writable' ) ; } if ( File :: exists ( $ this -> docDir ) ) { File :: deleteDirectory ( $ this -> docDir ) ; } File :: makeDirectory ( $ this -> docDir ) ; return $ this ; }
|
Check directory structure and permissions .
|
5,638
|
protected function defineConstants ( ) { if ( ! empty ( $ this -> constants ) ) { foreach ( $ this -> constants as $ key => $ value ) { defined ( $ key ) || define ( $ key , $ value ) ; } } return $ this ; }
|
Define constant which will be replaced .
|
5,639
|
protected function scanFilesForDocumentation ( ) { if ( $ this -> isOpenApi ( ) ) { $ this -> swagger = \ OpenApi \ scan ( $ this -> appDir , [ 'exclude' => $ this -> excludedDirs ] ) ; } if ( ! $ this -> isOpenApi ( ) ) { $ this -> swagger = \ Swagger \ scan ( $ this -> appDir , [ 'exclude' => $ this -> excludedDirs ] ) ; } return $ this ; }
|
Scan directory and create Swagger .
|
5,640
|
protected function populateServers ( ) { if ( config ( 'l5-swagger.paths.base' ) !== null ) { if ( $ this -> isOpenApi ( ) ) { $ this -> swagger -> servers = [ new \ OpenApi \ Annotations \ Server ( [ 'url' => config ( 'l5-swagger.paths.base' ) ] ) , ] ; } if ( ! $ this -> isOpenApi ( ) ) { $ this -> swagger -> basePath = config ( 'l5-swagger.paths.base' ) ; } } return $ this ; }
|
Generate servers section or basePath depending on Swagger version .
|
5,641
|
protected function saveJson ( ) { $ this -> swagger -> saveAs ( $ this -> docsFile ) ; $ security = new SecurityDefinitions ( ) ; $ security -> generate ( $ this -> docsFile ) ; return $ this ; }
|
Save documentation as json file .
|
5,642
|
protected function makeYamlCopy ( ) { if ( $ this -> yamlCopyRequired ) { file_put_contents ( $ this -> yamlDocsFile , ( new YamlDumper ( 2 ) ) -> dump ( json_decode ( file_get_contents ( $ this -> docsFile ) , true ) , 20 ) ) ; } }
|
Save documentation as yaml file .
|
5,643
|
public function generateSwaggerApi ( Collection $ documentation , array $ securityConfig ) { $ securityDefinitions = collect ( ) ; if ( $ documentation -> has ( 'securityDefinitions' ) ) { $ securityDefinitions = collect ( $ documentation -> get ( 'securityDefinitions' ) ) ; } foreach ( $ securityConfig as $ key => $ cfg ) { $ securityDefinitions -> offsetSet ( $ key , self :: arrayToObject ( $ cfg ) ) ; } $ documentation -> offsetSet ( 'securityDefinitions' , $ securityDefinitions ) ; return $ documentation ; }
|
Inject security settings for Swagger 1 & 2 .
|
5,644
|
public function generateOpenApi ( Collection $ documentation , array $ securityConfig ) { $ components = collect ( ) ; if ( $ documentation -> has ( 'components' ) ) { $ components = collect ( $ documentation -> get ( 'components' ) ) ; } $ securitySchemes = collect ( ) ; if ( $ components -> has ( 'securitySchemes' ) ) { $ securitySchemes = collect ( $ components -> get ( 'securitySchemes' ) ) ; } foreach ( $ securityConfig as $ key => $ cfg ) { $ securitySchemes -> offsetSet ( $ key , self :: arrayToObject ( $ cfg ) ) ; } $ components -> offsetSet ( 'securitySchemes' , $ securitySchemes ) ; $ documentation -> offsetSet ( 'components' , $ components ) ; return $ documentation ; }
|
Inject security settings for OpenApi 3 .
|
5,645
|
public function updateGeoIp ( ) { $ updater = new GeoIpUpdater ( ) ; $ success = $ updater -> updateGeoIpFiles ( $ this -> config -> get ( 'geoip_database_path' ) ) ; $ this -> messageRepository -> addMessage ( $ updater -> getMessages ( ) ) ; return $ success ; }
|
Update the GeoIp2 database .
|
5,646
|
public function addMessage ( $ message ) { collect ( ( array ) $ message ) -> each ( function ( $ item ) { collect ( $ item ) -> flatten ( ) -> each ( function ( $ flattened ) { $ this -> messageList -> push ( $ flattened ) ; } ) ; } ) ; }
|
Add a message to the messages list .
|
5,647
|
public function parse ( $ refererUrl , $ pageUrl ) { $ this -> setReferer ( $ this -> parser -> parse ( $ refererUrl , $ pageUrl ) ) ; return $ this ; }
|
Parse a referer .
|
5,648
|
public function fire ( ) { $ tracker = app ( 'tracker' ) ; $ type = $ tracker -> updateGeoIp ( ) ? 'info' : 'error' ; $ this -> displayMessages ( $ type , $ tracker -> getMessages ( ) ) ; }
|
Update the geo ip database .
|
5,649
|
public function display ( $ result , $ method = 'info' ) { if ( $ result ) { if ( is_array ( $ result ) ) { $ this -> displayTable ( $ result ) ; } elseif ( is_bool ( $ result ) ) { $ this -> { $ method } ( $ result ? 'Statement executed sucessfully.' : 'And error ocurred while executing the statement.' ) ; } else { $ this -> { $ method } ( $ result ) ; } } }
|
Display results .
|
5,650
|
public function displayTable ( $ table ) { $ headers = $ this -> makeHeaders ( $ table [ 0 ] ) ; $ rows = [ ] ; foreach ( $ table as $ row ) { $ rows [ ] = ( array ) $ row ; } $ this -> table = $ this -> getHelperSet ( ) -> get ( 'table' ) ; $ this -> table -> setHeaders ( $ headers ) -> setRows ( $ rows ) ; $ this -> table -> render ( $ this -> getOutput ( ) ) ; }
|
Display results in table format .
|
5,651
|
protected function registerTracker ( ) { $ this -> app -> singleton ( 'tracker' , function ( $ app ) { $ app [ 'tracker.loaded' ] = true ; return new Tracker ( $ app [ 'tracker.config' ] , $ app [ 'tracker.repositories' ] , $ app [ 'request' ] , $ app [ 'router' ] , $ app [ 'log' ] , $ app , $ app [ 'tracker.messages' ] ) ; } ) ; }
|
Takes all the components of Tracker and glues them together to create Tracker .
|
5,652
|
protected function registerGlobalViewComposers ( ) { $ me = $ this ; $ this -> app -> make ( 'view' ) -> composer ( 'pragmarx/tracker::*' , function ( $ view ) use ( $ me ) { $ view -> with ( 'stats_layout' , $ me -> getConfig ( 'stats_layout' ) ) ; $ template_path = url ( '/' ) . $ me -> getConfig ( 'stats_template_path' ) ; $ view -> with ( 'stats_template_path' , $ template_path ) ; } ) ; }
|
Register global view composers .
|
5,653
|
private function calculateStartEnd ( ) { if ( $ this -> minutes == 0 ) { $ this -> setToday ( ) ; } else { $ this -> start = Carbon :: now ( ) -> subMinutes ( $ this -> minutes ) ; $ this -> end = Carbon :: now ( ) ; } }
|
Calculate start and end dates .
|
5,654
|
public function slug ( Model $ model , bool $ force = false ) : bool { $ this -> setModel ( $ model ) ; $ attributes = [ ] ; foreach ( $ this -> model -> sluggable ( ) as $ attribute => $ config ) { if ( is_numeric ( $ attribute ) ) { $ attribute = $ config ; $ config = $ this -> getConfiguration ( ) ; } else { $ config = $ this -> getConfiguration ( $ config ) ; } $ slug = $ this -> buildSlug ( $ attribute , $ config , $ force ) ; if ( $ slug !== null ) { $ this -> model -> setAttribute ( $ attribute , $ slug ) ; $ attributes [ ] = $ attribute ; } } return $ this -> model -> isDirty ( $ attributes ) ; }
|
Slug the current model .
|
5,655
|
public function buildSlug ( string $ attribute , array $ config , bool $ force = null ) { $ slug = $ this -> model -> getAttribute ( $ attribute ) ; if ( $ force || $ this -> needsSlugging ( $ attribute , $ config ) ) { $ source = $ this -> getSlugSource ( $ config [ 'source' ] ) ; if ( $ source || is_numeric ( $ source ) ) { $ slug = $ this -> generateSlug ( $ source , $ config , $ attribute ) ; $ slug = $ this -> validateSlug ( $ slug , $ config , $ attribute ) ; $ slug = $ this -> makeSlugUnique ( $ slug , $ config , $ attribute ) ; } } return $ slug ; }
|
Build the slug for the given attribute of the current model .
|
5,656
|
protected function getSlugSource ( $ from ) : string { if ( is_null ( $ from ) ) { return $ this -> model -> __toString ( ) ; } $ sourceStrings = array_map ( function ( $ key ) { $ value = data_get ( $ this -> model , $ key ) ; if ( is_bool ( $ value ) ) { $ value = ( int ) $ value ; } return $ value ; } , ( array ) $ from ) ; return implode ( $ sourceStrings , ' ' ) ; }
|
Get the source string for the slug .
|
5,657
|
protected function generateSlug ( string $ source , array $ config , string $ attribute ) : string { $ separator = $ config [ 'separator' ] ; $ method = $ config [ 'method' ] ; $ maxLength = $ config [ 'maxLength' ] ; $ maxLengthKeepWords = $ config [ 'maxLengthKeepWords' ] ; if ( $ method === null ) { $ slugEngine = $ this -> getSlugEngine ( $ attribute ) ; $ slug = $ slugEngine -> slugify ( $ source , $ separator ) ; } elseif ( is_callable ( $ method ) ) { $ slug = call_user_func ( $ method , $ source , $ separator ) ; } else { throw new \ UnexpectedValueException ( 'Sluggable "method" for ' . get_class ( $ this -> model ) . ':' . $ attribute . ' is not callable nor null.' ) ; } $ len = mb_strlen ( $ slug ) ; if ( is_string ( $ slug ) && $ maxLength && $ len > $ maxLength ) { $ reverseOffset = $ maxLength - $ len ; $ lastSeparatorPos = mb_strrpos ( $ slug , $ separator , $ reverseOffset ) ; if ( $ maxLengthKeepWords && $ lastSeparatorPos !== false ) { $ slug = mb_substr ( $ slug , 0 , $ lastSeparatorPos ) ; } else { $ slug = trim ( mb_substr ( $ slug , 0 , $ maxLength ) , $ separator ) ; } } return $ slug ; }
|
Generate a slug from the given source string .
|
5,658
|
protected function validateSlug ( string $ slug , array $ config , string $ attribute ) : string { $ separator = $ config [ 'separator' ] ; $ reserved = $ config [ 'reserved' ] ; if ( $ reserved === null ) { return $ slug ; } if ( $ reserved instanceof \ Closure ) { $ reserved = $ reserved ( $ this -> model ) ; } if ( is_array ( $ reserved ) ) { if ( in_array ( $ slug , $ reserved ) ) { $ method = $ config [ 'uniqueSuffix' ] ; if ( $ method === null ) { $ suffix = $ this -> generateSuffix ( $ slug , $ separator , collect ( $ reserved ) ) ; } elseif ( is_callable ( $ method ) ) { $ suffix = $ method ( $ slug , $ separator , collect ( $ reserved ) ) ; } else { throw new \ UnexpectedValueException ( 'Sluggable "uniqueSuffix" for ' . get_class ( $ this -> model ) . ':' . $ attribute . ' is not null, or a closure.' ) ; } return $ slug . $ separator . $ suffix ; } return $ slug ; } throw new \ UnexpectedValueException ( 'Sluggable "reserved" for ' . get_class ( $ this -> model ) . ':' . $ attribute . ' is not null, an array, or a closure that returns null/array.' ) ; }
|
Checks that the given slug is not a reserved word .
|
5,659
|
protected function makeSlugUnique ( string $ slug , array $ config , string $ attribute ) : string { if ( ! $ config [ 'unique' ] ) { return $ slug ; } $ separator = $ config [ 'separator' ] ; $ list = $ this -> getExistingSlugs ( $ slug , $ attribute , $ config ) ; if ( $ list -> count ( ) === 0 || $ list -> contains ( $ slug ) === false ) { return $ slug ; } if ( $ list -> has ( $ this -> model -> getKey ( ) ) ) { $ currentSlug = $ list -> get ( $ this -> model -> getKey ( ) ) ; if ( $ currentSlug === $ slug || strpos ( $ currentSlug , $ slug ) === 0 ) { return $ currentSlug ; } } $ method = $ config [ 'uniqueSuffix' ] ; if ( $ method === null ) { $ suffix = $ this -> generateSuffix ( $ slug , $ separator , $ list ) ; } elseif ( is_callable ( $ method ) ) { $ suffix = $ method ( $ slug , $ separator , $ list ) ; } else { throw new \ UnexpectedValueException ( 'Sluggable "uniqueSuffix" for ' . get_class ( $ this -> model ) . ':' . $ attribute . ' is not null, or a closure.' ) ; } return $ slug . $ separator . $ suffix ; }
|
Checks if the slug should be unique and makes it so if needed .
|
5,660
|
protected function generateSuffix ( string $ slug , string $ separator , Collection $ list ) : string { $ len = strlen ( $ slug . $ separator ) ; if ( $ list -> search ( $ slug ) === $ this -> model -> getKey ( ) ) { $ suffix = explode ( $ separator , $ slug ) ; return end ( $ suffix ) ; } $ list -> transform ( function ( $ value , $ key ) use ( $ len ) { return ( int ) substr ( $ value , $ len ) ; } ) ; return $ list -> max ( ) + 1 ; }
|
Generate a unique suffix for the given slug ( and list of existing similar slugs .
|
5,661
|
public static function createSlug ( $ model , string $ attribute , string $ fromString , array $ config = null ) : string { if ( is_string ( $ model ) ) { $ model = new $ model ; } $ instance = ( new static ( ) ) -> setModel ( $ model ) ; if ( $ config === null ) { $ config = Arr :: get ( $ model -> sluggable ( ) , $ attribute ) ; if ( $ config === null ) { $ modelClass = get_class ( $ model ) ; throw new \ InvalidArgumentException ( "Argument 2 passed to SlugService::createSlug ['{$attribute}'] is not a valid slug attribute for model {$modelClass}." ) ; } } elseif ( ! is_array ( $ config ) ) { throw new \ UnexpectedValueException ( 'SlugService::createSlug expects an array or null as the fourth argument; ' . gettype ( $ config ) . ' given.' ) ; } $ config = $ instance -> getConfiguration ( $ config ) ; $ slug = $ instance -> generateSlug ( $ fromString , $ config , $ attribute ) ; $ slug = $ instance -> validateSlug ( $ slug , $ config , $ attribute ) ; $ slug = $ instance -> makeSlugUnique ( $ slug , $ config , $ attribute ) ; return $ slug ; }
|
Generate a unique slug for a given string .
|
5,662
|
public function scopeFindSimilarSlugs ( Builder $ query , string $ attribute , array $ config , string $ slug ) : Builder { $ separator = $ config [ 'separator' ] ; return $ query -> where ( function ( Builder $ q ) use ( $ attribute , $ slug , $ separator ) { $ q -> where ( $ attribute , '=' , $ slug ) -> orWhere ( $ attribute , 'LIKE' , $ slug . $ separator . '%' ) ; } ) ; }
|
Query scope for finding similar slugs used to determine uniqueness .
|
5,663
|
public function getSlugKeyName ( ) : string { if ( property_exists ( $ this , 'slugKeyName' ) ) { return $ this -> slugKeyName ; } $ config = $ this -> sluggable ( ) ; $ name = reset ( $ config ) ; $ key = key ( $ config ) ; if ( $ key === 0 ) { return $ name ; } return $ key ; }
|
Primary slug column of this model .
|
5,664
|
public function scopeWhereSlug ( Builder $ scope , string $ slug ) : Builder { return $ scope -> where ( $ this -> getSlugKeyName ( ) , $ slug ) ; }
|
Query scope for finding a model by its primary slug .
|
5,665
|
protected function extract ( $ file , $ path ) { $ command = 'tar -xzf ' . ProcessExecutor :: escape ( $ file ) . ' -C ' . ProcessExecutor :: escape ( $ path ) ; if ( 0 === $ this -> process -> execute ( $ command , $ ignoredOutput ) ) { return ; } throw new \ RuntimeException ( "Failed to execute '$command'\n\n" . $ this -> process -> getErrorOutput ( ) ) ; }
|
extract using cmdline tar which merges with existing files and folders
|
5,666
|
public function download ( PackageInterface $ package , $ path , $ output = true ) { $ temporaryDir = $ this -> config -> get ( 'vendor-dir' ) . '/composer/' . substr ( md5 ( uniqid ( '' , true ) ) , 0 , 8 ) ; $ this -> filesystem -> ensureDirectoryExists ( $ temporaryDir ) ; if ( ! $ package -> getDistUrl ( ) ) { throw new \ InvalidArgumentException ( 'The given package is missing url information' ) ; } $ this -> io -> writeError ( " - Installing <info>" . $ package -> getName ( ) . "</info> (<comment>" . $ package -> getFullPrettyVersion ( ) . "</comment>)" ) ; $ urls = $ package -> getDistUrls ( ) ; while ( $ url = array_shift ( $ urls ) ) { try { $ fileName = $ this -> doDownload ( $ package , $ temporaryDir , $ url ) ; } catch ( \ Exception $ e ) { if ( $ this -> io -> isDebug ( ) ) { $ this -> io -> writeError ( '' ) ; $ this -> io -> writeError ( 'Failed: [' . get_class ( $ e ) . '] ' . $ e -> getCode ( ) . ': ' . $ e -> getMessage ( ) ) ; } elseif ( count ( $ urls ) ) { $ this -> io -> writeError ( '' ) ; $ this -> io -> writeError ( ' Failed, trying the next URL (' . $ e -> getCode ( ) . ': ' . $ e -> getMessage ( ) . ')' ) ; } if ( ! count ( $ urls ) ) { throw $ e ; } } } $ this -> io -> writeError ( ' Extracting archive' , true , IOInterface :: VERBOSE ) ; try { $ this -> extract ( $ fileName , $ path ) ; } catch ( \ Exception $ e ) { parent :: clearLastCacheWrite ( $ package ) ; throw $ e ; } $ this -> filesystem -> unlink ( $ fileName ) ; if ( $ this -> filesystem -> isDirEmpty ( $ this -> config -> get ( 'vendor-dir' ) . '/composer/' ) ) { $ this -> filesystem -> removeDirectory ( $ this -> config -> get ( 'vendor-dir' ) . '/composer/' ) ; } if ( $ this -> filesystem -> isDirEmpty ( $ this -> config -> get ( 'vendor-dir' ) ) ) { $ this -> filesystem -> removeDirectory ( $ this -> config -> get ( 'vendor-dir' ) ) ; } $ this -> io -> writeError ( '' ) ; }
|
we can t do that since we need our contents to be merged into the probably existing folder structure
|
5,667
|
public function setReplacements ( $ replacements ) { if ( ! ( $ replacements instanceof Swift_Plugins_Decorator_Replacements ) ) { $ this -> replacements = ( array ) $ replacements ; } else { $ this -> replacements = $ replacements ; } }
|
Sets replacements .
|
5,668
|
public function getReplacementsFor ( $ address ) { if ( $ this -> replacements instanceof Swift_Plugins_Decorator_Replacements ) { return $ this -> replacements -> getReplacementsFor ( $ address ) ; } return $ this -> replacements [ $ address ] ?? null ; }
|
Find a map of replacements for the address .
|
5,669
|
private function restoreMessage ( Swift_Mime_SimpleMessage $ message ) { if ( $ this -> lastMessage === $ message ) { if ( isset ( $ this -> originalBody ) ) { $ message -> setBody ( $ this -> originalBody ) ; $ this -> originalBody = null ; } if ( ! empty ( $ this -> originalHeaders ) ) { foreach ( $ message -> getHeaders ( ) -> getAll ( ) as $ header ) { if ( array_key_exists ( $ header -> getFieldName ( ) , $ this -> originalHeaders ) ) { $ header -> setFieldBodyModel ( $ this -> originalHeaders [ $ header -> getFieldName ( ) ] ) ; } } $ this -> originalHeaders = [ ] ; } if ( ! empty ( $ this -> originalChildBodies ) ) { $ children = ( array ) $ message -> getChildren ( ) ; foreach ( $ children as $ child ) { $ id = $ child -> getId ( ) ; if ( array_key_exists ( $ id , $ this -> originalChildBodies ) ) { $ child -> setBody ( $ this -> originalChildBodies [ $ id ] ) ; } } $ this -> originalChildBodies = [ ] ; } $ this -> lastMessage = null ; } }
|
Restore a changed message back to its original state
|
5,670
|
public function reset ( ) { $ this -> headerHash = null ; $ this -> signedHeaders = [ ] ; $ this -> bodyHash = null ; $ this -> bodyHashHandler = null ; $ this -> bodyCanonIgnoreStart = 2 ; $ this -> bodyCanonEmptyCounter = 0 ; $ this -> bodyCanonLastChar = null ; $ this -> bodyCanonSpace = false ; }
|
Reset the Signer .
|
5,671
|
public function setHashAlgorithm ( $ hash ) { switch ( $ hash ) { case 'rsa-sha1' : $ this -> hashAlgorithm = 'rsa-sha1' ; break ; case 'rsa-sha256' : $ this -> hashAlgorithm = 'rsa-sha256' ; if ( ! defined ( 'OPENSSL_ALGO_SHA256' ) ) { throw new Swift_SwiftException ( 'Unable to set sha256 as it is not supported by OpenSSL.' ) ; } break ; default : throw new Swift_SwiftException ( 'Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).' , $ hash ) ; } return $ this ; }
|
Set hash_algorithm must be one of rsa - sha256 | rsa - sha1 .
|
5,672
|
public function setBodySignedLen ( $ len ) { if ( true === $ len ) { $ this -> showLen = true ; $ this -> maxLen = PHP_INT_MAX ; } elseif ( false === $ len ) { $ this -> showLen = false ; $ this -> maxLen = PHP_INT_MAX ; } else { $ this -> showLen = true ; $ this -> maxLen = ( int ) $ len ; } return $ this ; }
|
Set the length of the body to sign .
|
5,673
|
public function startBody ( ) { switch ( $ this -> hashAlgorithm ) { case 'rsa-sha256' : $ this -> bodyHashHandler = hash_init ( 'sha256' ) ; break ; case 'rsa-sha1' : $ this -> bodyHashHandler = hash_init ( 'sha1' ) ; break ; } $ this -> bodyCanonLine = '' ; }
|
Start Body .
|
5,674
|
public function setHeaders ( Swift_Mime_SimpleHeaderSet $ headers ) { $ this -> headerCanonData = '' ; $ listHeaders = $ headers -> listAll ( ) ; foreach ( $ listHeaders as $ hName ) { if ( ! isset ( $ this -> ignoredHeaders [ strtolower ( $ hName ) ] ) ) { if ( $ headers -> has ( $ hName ) ) { $ tmp = $ headers -> getAll ( $ hName ) ; foreach ( $ tmp as $ header ) { if ( '' != $ header -> getFieldBody ( ) ) { $ this -> addHeader ( $ header -> toString ( ) ) ; $ this -> signedHeaders [ ] = $ header -> getFieldName ( ) ; } } } } } return $ this ; }
|
Set the headers to sign .
|
5,675
|
public function setLanguage ( $ lang ) { $ this -> clearCachedValueIf ( $ this -> lang != $ lang ) ; $ this -> lang = $ lang ; }
|
Set the language used in this Header .
|
5,676
|
protected function getEncodableWordTokens ( $ string ) { $ tokens = [ ] ; $ encodedToken = '' ; foreach ( preg_split ( '~(?=[\t ])~' , $ string ) as $ token ) { if ( $ this -> tokenNeedsEncoding ( $ token ) ) { $ encodedToken .= $ token ; } else { if ( strlen ( $ encodedToken ) > 0 ) { $ tokens [ ] = $ encodedToken ; $ encodedToken = '' ; } $ tokens [ ] = $ token ; } } if ( strlen ( $ encodedToken ) ) { $ tokens [ ] = $ encodedToken ; } return $ tokens ; }
|
Splits a string into tokens in blocks of words which can be encoded quickly .
|
5,677
|
public function reset ( ) { $ this -> hashHandler = null ; $ this -> bodyCanonIgnoreStart = 2 ; $ this -> bodyCanonEmptyCounter = 0 ; $ this -> bodyCanonLastChar = null ; $ this -> bodyCanonSpace = false ; return $ this ; }
|
Resets internal states .
|
5,678
|
public function setNameAddresses ( $ mailboxes ) { $ this -> mailboxes = $ this -> normalizeMailboxes ( ( array ) $ mailboxes ) ; $ this -> setCachedValue ( null ) ; }
|
Set a list of mailboxes to be shown in this Header .
|
5,679
|
public function removeAddresses ( $ addresses ) { $ this -> setCachedValue ( null ) ; foreach ( ( array ) $ addresses as $ address ) { unset ( $ this -> mailboxes [ $ address ] ) ; } }
|
Remove one or more addresses from this Header .
|
5,680
|
protected function normalizeMailboxes ( array $ mailboxes ) { $ actualMailboxes = [ ] ; foreach ( $ mailboxes as $ key => $ value ) { if ( is_string ( $ key ) ) { $ address = $ key ; $ name = $ value ; } else { $ address = $ value ; $ name = null ; } $ this -> assertValidAddress ( $ address ) ; $ actualMailboxes [ $ address ] = $ name ; } return $ actualMailboxes ; }
|
Normalizes a user - input list of mailboxes into consistent key = > value pairs .
|
5,681
|
protected function createDisplayNameString ( $ displayName , $ shorten = false ) { return $ this -> createPhrase ( $ this , $ displayName , $ this -> getCharset ( ) , $ this -> getEncoder ( ) , $ shorten ) ; }
|
Produces a compliant formatted display - name based on the string given .
|
5,682
|
private function createNameAddressStrings ( array $ mailboxes ) { $ strings = [ ] ; foreach ( $ mailboxes as $ email => $ name ) { $ mailboxStr = $ this -> addressEncoder -> encodeString ( $ email ) ; if ( null !== $ name ) { $ nameStr = $ this -> createDisplayNameString ( $ name , empty ( $ strings ) ) ; $ mailboxStr = $ nameStr . ' <' . $ mailboxStr . '>' ; } $ strings [ ] = $ mailboxStr ; } return $ strings ; }
|
Return an array of strings conforming the the name - addr spec of RFC 2822 .
|
5,683
|
public function bindEventListener ( Swift_Events_EventListener $ listener ) { foreach ( $ this -> listeners as $ l ) { if ( $ l === $ listener ) { return ; } } $ this -> listeners [ ] = $ listener ; }
|
Bind an event listener to this dispatcher .
|
5,684
|
public function dispatchEvent ( Swift_Events_EventObject $ evt , $ target ) { $ this -> prepareBubbleQueue ( $ evt ) ; $ this -> bubble ( $ evt , $ target ) ; }
|
Dispatch the given Event to all suitable listeners .
|
5,685
|
private function getHandle ( $ nsKey , $ itemKey , $ position ) { if ( ! isset ( $ this -> keys [ $ nsKey ] [ $ itemKey ] ) ) { $ openMode = $ this -> hasKey ( $ nsKey , $ itemKey ) ? 'r+b' : 'w+b' ; $ fp = fopen ( $ this -> path . '/' . $ nsKey . '/' . $ itemKey , $ openMode ) ; $ this -> keys [ $ nsKey ] [ $ itemKey ] = $ fp ; } if ( self :: POSITION_START == $ position ) { fseek ( $ this -> keys [ $ nsKey ] [ $ itemKey ] , 0 , SEEK_SET ) ; } elseif ( self :: POSITION_END == $ position ) { fseek ( $ this -> keys [ $ nsKey ] [ $ itemKey ] , 0 , SEEK_END ) ; } return $ this -> keys [ $ nsKey ] [ $ itemKey ] ; }
|
Get a file handle on the cache item .
|
5,686
|
public function setParameters ( array $ parameters ) { $ this -> clearCachedValueIf ( $ this -> params != $ parameters ) ; $ this -> params = $ parameters ; }
|
Set an associative array of parameter names mapped to values .
|
5,687
|
private function getEndOfParameterValue ( $ value , $ encoded = false , $ firstLine = false ) { if ( ! preg_match ( '/^' . self :: TOKEN_REGEX . '$/D' , $ value ) ) { $ value = '"' . $ value . '"' ; } $ prepend = '=' ; if ( $ encoded ) { $ prepend = '*=' ; if ( $ firstLine ) { $ prepend = '*=' . $ this -> getCharset ( ) . "'" . $ this -> getLanguage ( ) . "'" ; } } return $ prepend . $ value ; }
|
Returns the parameter value from the = and beyond .
|
5,688
|
private function getResponse ( $ secret , $ challenge ) { if ( strlen ( $ secret ) > 64 ) { $ secret = pack ( 'H32' , md5 ( $ secret ) ) ; } if ( strlen ( $ secret ) < 64 ) { $ secret = str_pad ( $ secret , 64 , chr ( 0 ) ) ; } $ k_ipad = substr ( $ secret , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ; $ k_opad = substr ( $ secret , 0 , 64 ) ^ str_repeat ( chr ( 0x5C ) , 64 ) ; $ inner = pack ( 'H32' , md5 ( $ k_ipad . $ challenge ) ) ; $ digest = md5 ( $ k_opad . $ inner ) ; return $ digest ; }
|
Generate a CRAM - MD5 response from a server challenge .
|
5,689
|
public function setCharacterSet ( $ charset ) { $ this -> charset = $ charset ; $ this -> charReader = null ; $ this -> mapType = 0 ; }
|
Set the character set used in this CharacterStream .
|
5,690
|
public function afterEhlo ( Swift_Transport_SmtpAgent $ agent ) { if ( $ this -> username ) { $ count = 0 ; $ errors = [ ] ; foreach ( $ this -> getAuthenticatorsForAgent ( ) as $ authenticator ) { if ( in_array ( strtolower ( $ authenticator -> getAuthKeyword ( ) ) , array_map ( 'strtolower' , $ this -> esmtpParams ) ) ) { ++ $ count ; try { if ( $ authenticator -> authenticate ( $ agent , $ this -> username , $ this -> password ) ) { return ; } } catch ( Swift_TransportException $ e ) { $ errors [ ] = [ $ authenticator -> getAuthKeyword ( ) , $ e -> getMessage ( ) ] ; } } } $ message = 'Failed to authenticate on SMTP server with username "' . $ this -> username . '" using ' . $ count . ' possible authenticators.' ; foreach ( $ errors as $ error ) { $ message .= ' Authenticator ' . $ error [ 0 ] . ' returned ' . $ error [ 1 ] . '.' ; } throw new Swift_TransportException ( $ message ) ; } }
|
Runs immediately after a EHLO has been issued .
|
5,691
|
protected function getAuthenticatorsForAgent ( ) { if ( ! $ mode = strtolower ( $ this -> auth_mode ) ) { return $ this -> authenticators ; } foreach ( $ this -> authenticators as $ authenticator ) { if ( strtolower ( $ authenticator -> getAuthKeyword ( ) ) == $ mode ) { return [ $ authenticator ] ; } } throw new Swift_TransportException ( 'Auth mode ' . $ mode . ' is invalid' ) ; }
|
Returns the authenticator list for the given agent .
|
5,692
|
public function queueMessage ( Swift_Mime_SimpleMessage $ message ) { $ ser = serialize ( $ message ) ; $ fileName = $ this -> path . '/' . $ this -> getRandomString ( 10 ) ; for ( $ i = 0 ; $ i < $ this -> retryLimit ; ++ $ i ) { $ fp = @ fopen ( $ fileName . '.message' , 'xb' ) ; if ( false !== $ fp ) { if ( false === fwrite ( $ fp , $ ser ) ) { return false ; } return fclose ( $ fp ) ; } else { $ fileName .= $ this -> getRandomString ( 1 ) ; } } throw new Swift_IoException ( sprintf ( 'Unable to create a file for enqueuing Message in "%s".' , $ this -> path ) ) ; }
|
Queues a message .
|
5,693
|
public function recover ( $ timeout = 900 ) { foreach ( new DirectoryIterator ( $ this -> path ) as $ file ) { $ file = $ file -> getRealPath ( ) ; if ( '.message.sending' == substr ( $ file , - 16 ) ) { $ lockedtime = filectime ( $ file ) ; if ( ( time ( ) - $ lockedtime ) > $ timeout ) { rename ( $ file , substr ( $ file , 0 , - 8 ) ) ; } } } }
|
Execute a recovery if for any reason a process is sending for too long .
|
5,694
|
public function setDisposition ( $ disposition ) { if ( ! $ this -> setHeaderFieldModel ( 'Content-Disposition' , $ disposition ) ) { $ this -> getHeaders ( ) -> addParameterizedHeader ( 'Content-Disposition' , $ disposition ) ; } return $ this ; }
|
Set the Content - Disposition of this attachment .
|
5,695
|
public function setFile ( Swift_FileStream $ file , $ contentType = null ) { $ this -> setFilename ( basename ( $ file -> getPath ( ) ) ) ; $ this -> setBody ( $ file , $ contentType ) ; if ( ! isset ( $ contentType ) ) { $ extension = strtolower ( substr ( $ file -> getPath ( ) , strrpos ( $ file -> getPath ( ) , '.' ) + 1 ) ) ; if ( array_key_exists ( $ extension , $ this -> mimeTypes ) ) { $ this -> setContentType ( $ this -> mimeTypes [ $ extension ] ) ; } } return $ this ; }
|
Set the file that this attachment is for .
|
5,696
|
public function getReaderFor ( $ charset ) { $ charset = strtolower ( trim ( $ charset ) ) ; foreach ( self :: $ map as $ pattern => $ spec ) { $ re = '/^' . $ pattern . '$/D' ; if ( preg_match ( $ re , $ charset ) ) { if ( ! array_key_exists ( $ pattern , self :: $ loaded ) ) { $ reflector = new ReflectionClass ( $ spec [ 'class' ] ) ; if ( $ reflector -> getConstructor ( ) ) { $ reader = $ reflector -> newInstanceArgs ( $ spec [ 'constructor' ] ) ; } else { $ reader = $ reflector -> newInstance ( ) ; } self :: $ loaded [ $ pattern ] = $ reader ; } return self :: $ loaded [ $ pattern ] ; } } }
|
Returns a CharacterReader suitable for the charset applied .
|
5,697
|
public function terminate ( ) { if ( isset ( $ this -> stream ) ) { switch ( $ this -> params [ 'type' ] ) { case self :: TYPE_PROCESS : fclose ( $ this -> in ) ; fclose ( $ this -> out ) ; proc_close ( $ this -> stream ) ; break ; case self :: TYPE_SOCKET : default : fclose ( $ this -> stream ) ; break ; } } $ this -> stream = null ; $ this -> out = null ; $ this -> in = null ; }
|
Perform any shutdown logic needed .
|
5,698
|
public function setWriteTranslations ( array $ replacements ) { foreach ( $ this -> translations as $ search => $ replace ) { if ( ! isset ( $ replacements [ $ search ] ) ) { $ this -> removeFilter ( $ search ) ; unset ( $ this -> translations [ $ search ] ) ; } } foreach ( $ replacements as $ search => $ replace ) { if ( ! isset ( $ this -> translations [ $ search ] ) ) { $ this -> addFilter ( $ this -> replacementFactory -> createFilter ( $ search , $ replace ) , $ search ) ; $ this -> translations [ $ search ] = true ; } } }
|
Set an array of string replacements which should be made on data written to the buffer .
|
5,699
|
protected function doCommit ( $ bytes ) { if ( isset ( $ this -> in ) ) { $ bytesToWrite = strlen ( $ bytes ) ; $ totalBytesWritten = 0 ; while ( $ totalBytesWritten < $ bytesToWrite ) { $ bytesWritten = fwrite ( $ this -> in , substr ( $ bytes , $ totalBytesWritten ) ) ; if ( false === $ bytesWritten || 0 === $ bytesWritten ) { break ; } $ totalBytesWritten += $ bytesWritten ; } if ( $ totalBytesWritten > 0 ) { return ++ $ this -> sequence ; } } }
|
Write this bytes to the stream
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.