idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
27,900
public function removeRecipientVariable ( string $ recipient , string $ recipientVariable ) : self { unset ( $ this -> recipientVariables [ $ recipient ] [ $ recipientVariable ] ) ; return $ this ; }
Removes the recipient variable for the recipient specified .
27,901
public function setValidityPeriod ( \ DateInterval $ validityPeriod = null ) : self { if ( null !== $ validityPeriod && ( $ validityPeriod -> i < ValidityPeriods :: MIN || $ validityPeriod -> i > ValidityPeriods :: MAX ) ) { throw new InvalidValidityPeriodException ( ) ; } $ this -> validityPeriod = $ validityPeriod ; return $ this ; }
Sets the validity period .
27,902
protected function toTableRow ( array $ doc ) { $ result = isset ( $ doc [ 'value' ] ) ? $ doc [ 'value' ] : [ ] ; if ( isset ( $ result [ _IMPACT_INDEX ] ) ) { unset ( $ result [ _IMPACT_INDEX ] ) ; } return $ result ; }
Models the table row from the source data
27,903
public function lists ( $ type = null ) { $ params = [ 'type' => $ type , ] ; return $ this -> parseJSON ( 'get' , [ self :: API_LISTS , $ params ] ) ; }
List all staffs .
27,904
protected function refreshToken ( ) { $ token = $ this -> authorization -> getApi ( ) -> getAuthorizerToken ( $ this -> authorization -> getAuthorizerCorpId ( ) , $ this -> authorization -> getAuthorizerPermanentCode ( ) ) ; $ this -> authorization -> setAuthorizerAccessToken ( $ token [ 'access_token' ] , $ token [ 'expires_in' ] - 1500 ) ; return $ token [ 'access_token' ] ; }
Refresh authorizer access token .
27,905
public function getDatabaseName ( ) { if ( isset ( $ this -> _data [ 'filter_column' ] ) && is_string ( $ this -> _data [ 'filter_column' ] ) ) { return $ this -> _data [ 'filter_column' ] ; } return $ this -> index ( ) ; }
Returns column s database name
27,906
public function hasRenderer ( ) { if ( ! isset ( $ this -> _data [ 'renderer' ] ) ) { return false ; } if ( is_string ( $ this -> _data [ 'renderer' ] ) ) { $ renderer = $ this -> _data [ 'renderer' ] ; $ namespace = ResourceTable :: collection ( ) -> rendererNamespace ( ) ; if ( $ namespace ) { $ renderer = $ namespace . '\\' . $ renderer ; } if ( ! class_exists ( $ renderer ) ) { return false ; } if ( ! method_exists ( $ renderer , 'render' ) || ! is_callable ( [ $ renderer , 'render' ] ) ) { return false ; } } return true ; }
Checks whether column has a defined renderer
27,907
public function sortUrl ( ) { $ url = Request :: url ( ) ; $ params = Input :: get ( ) ; $ params [ 'order_by' ] = $ this -> index ( ) ; if ( $ this -> sortActive ( ) ) { $ params [ 'order_dir' ] = mb_strtolower ( $ this -> _sortDirection ( ) ) == 'desc' ? 'ASC' : 'DESC' ; } else { $ params [ 'order_dir' ] = ResourceTable :: DEFAULT_SORT_DIR ; } return $ url . '?' . http_build_query ( $ params ) ; }
Returns column sort link
27,908
public function sortActive ( ) { $ sortIndex = $ this -> _sortIndex ( ) ; if ( $ sortIndex === null ) { return false ; } return $ sortIndex == $ this -> index ( ) ; }
Checks whether column is active by current sort index
27,909
public function options ( ) { if ( ! isset ( $ this -> _data [ 'options' ] ) || ( isset ( $ this -> _data [ 'options' ] ) && empty ( $ this -> _data [ 'options' ] ) ) ) { return [ ] ; } if ( ! is_array ( $ this -> _data [ 'options' ] ) ) { return [ ] ; } return ( [ ResourceTable :: ALL_SELECT_VALUES_KEY => trans ( 'resource-table::default.All' ) ] + $ this -> _data [ 'options' ] ) ; }
Returns column array with options for searchable form
27,910
public function searchableContent ( array $ config = array ( ) ) { $ result = '' ; $ type = $ this -> searchType ( ) ; if ( 'resource-table::bootstrap' === $ this -> _viewName ) { switch ( $ type ) { case 'select' : if ( ! count ( $ this -> options ( ) ) ) { return '' ; } $ result .= '<select name="resource_table_' . $ this -> index ( ) . '" class="' . array_get ( $ config , 'control_class' , 'form-control input-sm' ) . ' resource-table-column-filter">' . $ this -> _optionsHTML ( ) . '</select>' ; break ; case 'string' : default : $ result .= '<input type="text" placeholder="' . array_get ( $ config , 'placeholder' , trans ( 'resource-table::default.Search_for' ) . ' ' . $ this -> label ( ) ) . '" class="' . array_get ( $ config , 'control_class' , 'form-control input-sm' ) . ' resource-table-column-filter" name="resource_table_' . $ this -> index ( ) . '" value="' . ResourceTable :: getSearchValue ( $ this -> index ( ) ) . '" />' ; break ; } } if ( ! $ result ) { switch ( $ type ) { case 'select' : if ( ! count ( $ this -> options ( ) ) ) { return '' ; } $ result .= '<select name="resource_table_' . $ this -> index ( ) . '" class="' . array_get ( $ config , 'control_class' ) . ' resource-table-column-filter">' . $ this -> _optionsHTML ( ) . '</select>' ; break ; case 'string' : default : $ result .= '<input type="text" class="' . array_get ( $ config , 'control_class' ) . ' resource-table-column-filter" name="resource_table_' . $ this -> index ( ) . '" value="' . ResourceTable :: getSearchValue ( $ this -> index ( ) ) . '" placeholder="' . array_get ( $ config , 'placeholder' ) . '" />' ; break ; } } return $ result ; }
Returns HTML with column search field
27,911
private function _optionsHTML ( ) { $ result = '' ; foreach ( $ this -> options ( ) as $ key => $ label ) { $ selected = ResourceTable :: getSearchValue ( $ this -> index ( ) ) == $ key ? ' selected="selected"' : '' ; $ result .= '<option value="' . $ key . '"' . $ selected . '>' . $ label . '</option>' ; } return $ result ; }
Returns HTML with select options for searchable column
27,912
protected function canModerate ( ) { $ user = $ this -> getUser ( ) ; if ( $ user -> name == 'Guest' && $ user -> email == 'guest@example.com' ) { return false ; } if ( method_exists ( $ user , 'can' ) ) { return $ user -> can ( 'forum-moderate' ) ; } return false ; }
Determine if the user can moderate the forums .
27,913
protected function buildData ( $ data = [ ] ) { $ user = $ this -> getUser ( ) ; $ data [ 'user' ] = $ user ; $ data [ 'layout' ] = $ this -> getLayout ( ) ; $ data [ 'categories' ] = ForumCategory :: with ( 'forums' ) -> get ( ) ; $ data [ 'sitename' ] = $ this -> getSitename ( ) ; $ data [ 'wysiwyg' ] = config ( 'laravel-forum.wysiwyg' ) ; $ data [ 'sanitizer' ] = $ this -> sanitizer ; $ data [ 'userHelper' ] = new UserHelper ( ) ; if ( Auth :: check ( ) ) { $ data [ 'isAdmin' ] = $ user -> can ( 'create' , Forum :: class ) ; } return $ data ; }
Builds data required for views .
27,914
public function generateViews ( $ resources , $ context = null ) { $ contextAlias = $ this -> getContextAlias ( $ context ) ; $ filter = [ ] ; foreach ( $ resources as $ resource ) { $ resourceAlias = $ this -> labeller -> uri_to_alias ( $ resource ) ; $ this -> getLogger ( ) -> warning ( 'Generating views' , [ 'store' => $ this -> storeName , '_id' => $ resourceAlias ] ) ; foreach ( $ this -> getConfigInstance ( ) -> getViewSpecifications ( $ this -> storeName ) as $ type => $ spec ) { if ( $ spec [ 'from' ] == $ this -> podName ) { $ this -> config -> getCollectionForView ( $ this -> storeName , $ type , $ this -> readPreference ) -> deleteOne ( array ( "_id" => array ( "r" => $ resourceAlias , "c" => $ contextAlias , "type" => $ type ) ) ) ; } } $ filter [ ] = array ( "r" => $ resourceAlias , "c" => $ contextAlias ) ; } $ query = array ( "_id" => array ( '$in' => $ filter ) ) ; $ resourceAndType = $ this -> collection -> find ( $ query , array ( 'projection' => array ( "_id" => 1 , "rdf:type" => 1 ) ) ) ; foreach ( $ resourceAndType as $ rt ) { $ id = $ rt [ "_id" ] ; if ( array_key_exists ( "rdf:type" , $ rt ) ) { if ( array_key_exists ( 'u' , $ rt [ "rdf:type" ] ) ) { $ this -> generateViewsForResourcesOfType ( $ rt [ "rdf:type" ] [ 'u' ] , $ id [ _ID_RESOURCE ] , $ id [ _ID_CONTEXT ] ) ; } else { foreach ( $ rt [ "rdf:type" ] as $ type ) { $ this -> generateViewsForResourcesOfType ( $ type [ 'u' ] , $ id [ _ID_RESOURCE ] , $ id [ _ID_CONTEXT ] ) ; } } } } }
Autodiscovers the multiple view specification that may be applicable for a given resource and submits each for generation
27,915
protected function matchesFilter ( $ linkMatchType , $ linkMatchValue , $ filterType , $ filterMatch ) { if ( $ linkMatchType === $ filterType ) { if ( $ linkMatchValue === $ filterMatch || $ this -> labeller -> uri_to_alias ( $ linkMatchValue ) === $ filterMatch ) { return true ; } } return false ; }
Check to see if a linkMatch matches a filter .
27,916
public function getThreadCount ( ) { try { $ result = DB :: select ( 'SELECT COUNT(*) as count FROM `forum_posts` where forum_id = ?' , [ $ this -> id ] ) ; return $ result [ 0 ] -> count ; } catch ( \ Exception $ e ) { return 0 ; } }
Get the number of threads inside the current forum .
27,917
public static function languagesLocaleCodes ( ) { static $ list ; if ( $ list === null ) { $ list = [ ] ; foreach ( static :: codes ( ) as $ localeCode ) { if ( $ languageCode = static :: languageCode ( $ localeCode ) ) { $ list [ $ languageCode ] [ ] = $ localeCode ; } } } return $ list ; }
Returns list of locale codes grouped by ISO 639 - 1 ISO 639 - 2 or ISO 639 - 3 language codes
27,918
public static function findMainCode ( $ localeCodes ) { $ languageLocaleCodes = [ ] ; foreach ( $ localeCodes as $ localeCode ) { $ languageCode = static :: languageCode ( $ localeCode ) ; if ( ! isset ( $ languageLocaleCodes [ $ languageCode ] ) ) { $ languageLocaleCodes [ $ languageCode ] = $ localeCode ; } } if ( $ mainLanguageCode = Language :: findMainCode ( array_keys ( $ languageLocaleCodes ) ) ) { return $ languageLocaleCodes [ $ mainLanguageCode ] ; } return null ; }
Find main locale code in a list
27,919
public static function countryLocaleCode ( $ countryCode ) { $ countryLocaleCodes = static :: countryLocaleCodes ( $ countryCode ) ; if ( $ languageCode = Language :: countryLanguageCode ( $ countryCode ) ) { $ languageLocaleCodes = static :: languageLocaleCodes ( $ languageCode ) ; if ( $ localeCodes = array_intersect ( $ languageLocaleCodes , $ countryLocaleCodes ) ) { return reset ( $ localeCodes ) ; } elseif ( $ countryLocaleCodes ) { return reset ( $ countryLocaleCodes ) ; } elseif ( $ languageLocaleCodes ) { return reset ( $ languageLocaleCodes ) ; } return \ Locale :: composeLocale ( [ 'language' => $ languageCode , 'region' => $ countryCode , ] ) ; } if ( ! count ( $ countryLocaleCodes ) ) { return null ; } elseif ( count ( $ countryLocaleCodes ) == 1 ) { return reset ( $ countryLocaleCodes ) ; } if ( $ localeCode = static :: findMainCode ( $ countryLocaleCodes ) ) { return $ localeCode ; } foreach ( $ countryLocaleCodes as $ localeCode ) { $ languageCode = static :: languageCode ( $ localeCode ) ; if ( ! strcasecmp ( $ languageCode , $ countryCode ) ) { return $ localeCode ; } } return reset ( $ countryLocaleCodes ) ; }
Tries to find locale code for a country
27,920
public function generate ( ) { if ( $ this -> parentIdentifier && ! $ this -> parentObj ) { $ this -> determineParentObj ( ) ; } $ i = 0 ; $ ids = array ( ) ; $ parentField = $ this -> parentField ; while ( $ i < $ this -> count ) { $ obj = Injector :: inst ( ) -> create ( $ this -> subjectClass ) ; if ( $ this -> parentObj ) { $ obj -> $ parentField = $ this -> parentObj -> ID ; } $ obj -> fill ( array ( 'only_empty' => $ this -> onlyEmpty , 'include_relations' => $ this -> includeRelations , 'download_images' => $ this -> downloadImages , 'relation_create_limit' => $ this -> relationCreateLimit ) ) ; if ( $ this -> parentObj ) { $ obj -> write ( ) ; } if ( $ this -> isSiteTree ) { $ ids [ ] = $ obj -> write ( ) ; $ obj -> publish ( "Stage" , "Live" ) ; } $ this -> log ( "Created {$this->subjectClass} \"{$obj->getTitle()}\"." ) ; $ i ++ ; } return $ ids ; }
Generates new records for the subject class
27,921
public function populate ( ) { if ( $ this -> parentIdentifier && ! $ this -> parentObj ) { $ this -> determineParentObj ( ) ; } $ set = DataList :: create ( $ this -> subjectClass ) ; if ( $ this -> parentObj ) { $ set = $ set -> filter ( array ( $ this -> parentField => $ this -> parentObj -> ID ) ) ; } foreach ( $ set as $ obj ) { $ obj -> fill ( array ( 'only_empty' => $ this -> onlyEmpty , 'include_relations' => $ this -> includeRelations , 'download_images' => $ this -> downloadImages , 'relation_create_limit' => $ this -> relationCreateLimit ) ) ; if ( $ this -> isSiteTree ) { $ obj -> write ( ) ; $ obj -> publish ( "Stage" , "Live" ) ; } $ this -> log ( "Updated {$this->subjectClass} \"{$obj->getTitle()}\"." ) ; } }
Populates existing records with mock data
27,922
protected function getInheritanceFinder ( ) { if ( ! file_exists ( storage_path ( 'class_cache' ) ) ) { mkdir ( storage_path ( 'class_cache' ) ) ; } $ config = new \ Synga \ InheritanceFinder \ File \ FileConfig ( ) ; $ config -> setApplicationRoot ( base_path ( ) ) ; $ config -> setCacheDirectory ( storage_path ( 'class_cache' ) ) ; return ( new InheritanceFinderFactory ( ) ) -> getInheritanceFinder ( $ config ) ; }
Gets an inheritance finder for the Laravel Framework .
27,923
public function handleNotify ( callable $ callback ) { $ notify = $ this -> getNotify ( ) ; if ( ! $ notify -> isValid ( ) ) { throw new FaultException ( 'Invalid request payloads.' , 400 ) ; } $ notify = $ notify -> getNotify ( ) ; $ successful = $ notify -> get ( 'result_code' ) === 'SUCCESS' ; $ handleResult = call_user_func_array ( $ callback , [ $ notify , $ successful ] ) ; if ( is_bool ( $ handleResult ) && $ handleResult ) { $ response = [ 'return_code' => 'SUCCESS' , 'return_msg' => 'OK' , ] ; } else { $ response = [ 'return_code' => 'FAIL' , 'return_msg' => $ handleResult , ] ; } return new Response ( XML :: build ( $ response ) ) ; }
Handle payment notify .
27,924
protected function viewHandle ( ) { $ packageViewsPath = __DIR__ . '/resources/views' ; $ this -> loadViewsFrom ( $ packageViewsPath , 'workflow' ) ; $ this -> publishes ( [ $ packageViewsPath => resource_path ( 'views/' ) , ] , 'workflow_views' ) ; }
Loading and publishing package s views
27,925
protected function migrationHandle ( ) { $ packageMigrationsPath = __DIR__ . '/database/migrations' ; $ this -> loadMigrationsFrom ( $ packageMigrationsPath ) ; $ this -> publishes ( [ $ packageMigrationsPath => database_path ( 'migrations' ) ] , 'workflow_migrations' ) ; }
Publishing package s migrations
27,926
public function player_path ( ) { if ( ! $ this -> player_path ) { $ this -> player_path = realpath ( Config :: $ path_prefix ) . '/phpwarrior/' . $ this -> directory_name ( ) ; } return $ this -> player_path ; }
The pad to the player . php file .
27,927
public static function fromASN1ByOID ( string $ oid , UnspecifiedType $ el ) : self { if ( ! array_key_exists ( $ oid , self :: MAP_OID_TO_CLASS ) ) { return new UnknownAttributeValue ( $ oid , $ el -> asElement ( ) ) ; } $ cls = self :: MAP_OID_TO_CLASS [ $ oid ] ; return $ cls :: fromASN1 ( $ el ) ; }
Initialize from ASN . 1 with given OID hint .
27,928
public static function materialColors ( string $ color = null ) { $ colors = Collection :: make ( [ 'red' => '#F44336' , 'pink' => '#E91E63' , 'purple' => '#9C27B0' , 'deep_purple' => '#673AB7' , 'indigo' => '#3F51B5' , 'blue' => '#2196F3' , 'light_blue' => '#03A9F4' , 'cyan' => '#00BCD4' , 'teal' => '#009688' , 'green' => '#4CAF50' , 'light_green' => '#8BC34A' , 'lime' => '#CDDC39' , 'yellow' => '#FFEB3B' , 'amber' => '#FFC107' , 'orange' => '#FF9800' , 'deep_orange' => '#FF5722' , 'brown' => '#795548' , 'grey' => '#9E9E9E' , 'blue_grey' => '#607D8B' ] ) ; if ( ! $ color ) { return $ colors ; } return $ colors -> has ( $ color ) ? $ colors -> get ( $ color ) : $ color ; }
Return the material color list or an item inside .
27,929
public static function materialRound ( float $ value ) { if ( $ value > 999 && $ value <= 999999 ) { return floor ( $ value / 1000 ) . ' K' ; } elseif ( $ value > 999999 ) { return floor ( $ value / 1000000 ) . ' M' ; } return $ value ; }
Rounds the float value with K or M sufixs .
27,930
public static function materialAvatar ( string $ name , float $ dimensions = 100 , string $ color = null ) : string { $ letter = mb_substr ( $ name , 0 , 1 , 'utf-8' ) ; if ( ! $ color ) { $ color = static :: materialColors ( ) -> random ( ) ; } else { $ color = static :: materialColors ( $ color ) ; } $ text_position = bcdiv ( $ dimensions , 2 , 2 ) ; $ cache_key = "support__material_avatar:{$letter}_{$dimensions}_{$color}" ; if ( ! Cache :: has ( $ cache_key ) ) { $ image = Image :: canvas ( $ dimensions , $ dimensions , $ color ) -> text ( $ letter , $ text_position , $ text_position , function ( $ font ) use ( $ dimensions ) { $ font -> file ( __DIR__ . '/../Assets/fonts/Roboto-Light.ttf' ) -> size ( bcdiv ( $ dimensions , 1.75 , 2 ) ) -> color ( '#ffffff' ) -> align ( 'center' ) -> valign ( 'middle' ) ; } ) -> encode ( 'data-url' ) ; Cache :: put ( $ cache_key , $ image ) ; return $ image ; } return Cache :: get ( $ cache_key ) ; }
Returns a material design avatar for the given data .
27,931
public function getNotify ( ) { if ( ! empty ( $ this -> notify ) ) { return $ this -> notify ; } try { $ xml = XML :: parse ( strval ( $ this -> request -> getContent ( ) ) ) ; } catch ( \ Throwable $ t ) { throw new FaultException ( 'Invalid request XML: ' . $ t -> getMessage ( ) , 400 ) ; } catch ( \ Exception $ e ) { throw new FaultException ( 'Invalid request XML: ' . $ e -> getMessage ( ) , 400 ) ; } if ( ! is_array ( $ xml ) || empty ( $ xml ) ) { throw new FaultException ( 'Invalid request XML.' , 400 ) ; } return $ this -> notify = new Collection ( $ xml ) ; }
Return the notify body from request .
27,932
protected function getViewParams ( ) { foreach ( $ this -> options as $ key => $ value ) { $ this -> variables .= ( $ key == 'disable_mobile' ) ? "var disqus_{$key} = {$value};\n" : "var disqus_{$key} = '{$value}';\n" ; } return [ 'variables' => $ this -> variables , 'credits' => $ this -> showCredits ? $ this -> credits : '' , 'noScript' => $ this -> renderNoScriptContainer ( ) ] ; }
Get view params
27,933
protected function renderNoScriptContainer ( ) { if ( $ this -> noScript == false ) { return '' ; } return Html :: tag ( 'noscript' , Html :: tag ( 'div' , $ this -> noScript , $ this -> noScriptOptions ) ) ; }
Render the noScript container
27,934
public static function escapeString ( string $ str ) : string { $ str = preg_replace ( '/([,\+"\\\<\>;])/u' , '\\\\$1' , $ str ) ; $ str = preg_replace ( '/( )$/u' , '\\\\$1' , $ str ) ; $ str = preg_replace ( '/^([ #])/u' , '\\\\$1' , $ str ) ; $ str = preg_replace_callback ( '/([\pC])/u' , function ( $ m ) { $ octets = str_split ( bin2hex ( $ m [ 1 ] ) , 2 ) ; return implode ( "" , array_map ( function ( $ octet ) { return '\\' . strtoupper ( $ octet ) ; } , $ octets ) ) ; } , $ str ) ; return $ str ; }
Escape a AttributeValue string conforming to RFC 2253 .
27,935
protected function parse ( ) : array { $ offset = 0 ; $ name = $ this -> _parseName ( $ offset ) ; if ( $ offset < $ this -> _len ) { $ remains = substr ( $ this -> _dn , $ offset ) ; throw new \ UnexpectedValueException ( "Parser finished before the end of string" . ", remaining: '$remains'." ) ; } return $ name ; }
Parse DN to name - components .
27,936
private function _parseName ( int & $ offset ) : array { $ idx = $ offset ; $ names = array ( ) ; while ( $ idx < $ this -> _len ) { $ names [ ] = $ this -> _parseNameComponent ( $ idx ) ; if ( $ idx >= $ this -> _len ) { break ; } $ this -> _skipWs ( $ idx ) ; if ( "," != $ this -> _dn [ $ idx ] && ";" != $ this -> _dn [ $ idx ] ) { break ; } $ idx ++ ; $ this -> _skipWs ( $ idx ) ; } $ offset = $ idx ; return array_reverse ( $ names ) ; }
Parse name .
27,937
private function _parseNameComponent ( int & $ offset ) : array { $ idx = $ offset ; $ tvpairs = array ( ) ; while ( $ idx < $ this -> _len ) { $ tvpairs [ ] = $ this -> _parseAttrTypeAndValue ( $ idx ) ; $ this -> _skipWs ( $ idx ) ; if ( $ idx >= $ this -> _len || "+" != $ this -> _dn [ $ idx ] ) { break ; } ++ $ idx ; $ this -> _skipWs ( $ idx ) ; } $ offset = $ idx ; return $ tvpairs ; }
Parse name - component .
27,938
private function _parseAttrTypeAndValue ( int & $ offset ) : array { $ idx = $ offset ; $ type = $ this -> _parseAttrType ( $ idx ) ; $ this -> _skipWs ( $ idx ) ; if ( $ idx >= $ this -> _len || "=" != $ this -> _dn [ $ idx ++ ] ) { throw new \ UnexpectedValueException ( "Invalid type and value pair." ) ; } $ this -> _skipWs ( $ idx ) ; if ( $ idx < $ this -> _len && "#" == $ this -> _dn [ $ idx ] ) { ++ $ idx ; $ data = $ this -> _parseAttrHexValue ( $ idx ) ; try { $ value = Element :: fromDER ( $ data ) ; } catch ( DecodeException $ e ) { throw new \ UnexpectedValueException ( "Invalid DER encoding from hexstring." , 0 , $ e ) ; } } else { $ value = $ this -> _parseAttrStringValue ( $ idx ) ; } $ offset = $ idx ; return array ( $ type , $ value ) ; }
Parse attributeTypeAndValue .
27,939
private function _parseAttrType ( int & $ offset ) : string { $ idx = $ offset ; $ type = $ this -> _regexMatch ( '/^(?:oid\.)?([0-9]+(?:\.[0-9]+)*)/i' , $ idx ) ; if ( null === $ type ) { $ type = $ this -> _regexMatch ( '/^[a-z][a-z0-9\-]*/i' , $ idx ) ; if ( null === $ type ) { throw new \ UnexpectedValueException ( "Invalid attribute type." ) ; } } $ offset = $ idx ; return $ type ; }
Parse attributeType .
27,940
private function _parseAttrStringValue ( int & $ offset ) : string { $ idx = $ offset ; if ( $ idx >= $ this -> _len ) { return "" ; } if ( '"' == $ this -> _dn [ $ idx ] ) { $ val = $ this -> _parseQuotedAttrString ( $ idx ) ; } else { $ val = $ this -> _parseAttrString ( $ idx ) ; } $ offset = $ idx ; return $ val ; }
Parse attributeValue of string type .
27,941
private function _parseAttrString ( int & $ offset ) : string { $ idx = $ offset ; $ val = "" ; $ wsidx = null ; while ( $ idx < $ this -> _len ) { $ c = $ this -> _dn [ $ idx ] ; if ( "\\" == $ c ) { ++ $ idx ; $ val .= $ this -> _parsePairAfterSlash ( $ idx ) ; $ wsidx = null ; continue ; } else if ( '"' == $ c ) { throw new \ UnexpectedValueException ( "Unexpected quotation." ) ; } else if ( false !== strpos ( self :: SPECIAL_CHARS , $ c ) ) { break ; } if ( ' ' == $ c ) { if ( null === $ wsidx ) { $ wsidx = $ idx ; } } else { $ wsidx = null ; } $ val .= $ c ; ++ $ idx ; } if ( null !== $ wsidx ) { $ val = substr ( $ val , 0 , - ( $ idx - $ wsidx ) ) ; } $ offset = $ idx ; return $ val ; }
Parse plain attributeValue string .
27,942
private function _parseQuotedAttrString ( int & $ offset ) : string { $ idx = $ offset + 1 ; $ val = "" ; while ( $ idx < $ this -> _len ) { $ c = $ this -> _dn [ $ idx ] ; if ( "\\" == $ c ) { ++ $ idx ; $ val .= $ this -> _parsePairAfterSlash ( $ idx ) ; continue ; } else if ( '"' == $ c ) { ++ $ idx ; break ; } $ val .= $ c ; ++ $ idx ; } $ offset = $ idx ; return $ val ; }
Parse quoted attributeValue string .
27,943
private function _parseAttrHexValue ( int & $ offset ) : string { $ idx = $ offset ; $ hexstr = $ this -> _regexMatch ( '/^(?:[0-9a-f]{2})+/i' , $ idx ) ; if ( null === $ hexstr ) { throw new \ UnexpectedValueException ( "Invalid hexstring." ) ; } $ data = hex2bin ( $ hexstr ) ; $ offset = $ idx ; return $ data ; }
Parse attributeValue of binary type .
27,944
private function _parsePairAfterSlash ( int & $ offset ) : string { $ idx = $ offset ; if ( $ idx >= $ this -> _len ) { throw new \ UnexpectedValueException ( "Unexpected end of escape sequence." ) ; } $ c = $ this -> _dn [ $ idx ++ ] ; if ( false !== strpos ( self :: SPECIAL_CHARS . '\\" ' , $ c ) ) { $ val = $ c ; } else { if ( $ idx >= $ this -> _len ) { throw new \ UnexpectedValueException ( "Unexpected end of hexpair." ) ; } $ val = @ hex2bin ( $ c . $ this -> _dn [ $ idx ++ ] ) ; if ( false === $ val ) { throw new \ UnexpectedValueException ( "Invalid hexpair." ) ; } } $ offset = $ idx ; return $ val ; }
Parse pair after leading slash .
27,945
private function _regexMatch ( string $ pattern , int & $ offset ) { $ idx = $ offset ; if ( ! preg_match ( $ pattern , substr ( $ this -> _dn , $ idx ) , $ match ) ) { return null ; } $ idx += strlen ( $ match [ 0 ] ) ; $ offset = $ idx ; return end ( $ match ) ; }
Match DN to pattern and extract the last capture group .
27,946
private function _skipWs ( int & $ offset ) { $ idx = $ offset ; while ( $ idx < $ this -> _len ) { if ( " " != $ this -> _dn [ $ idx ] ) { break ; } ++ $ idx ; } $ offset = $ idx ; }
Skip consecutive spaces .
27,947
public function perform ( ) { $ this -> getStat ( ) -> increment ( MONGO_QUEUE_APPLY_OPERATION_JOB . '.' . SUBJECT_COUNT , count ( $ this -> args [ self :: SUBJECTS_KEY ] ) ) ; foreach ( $ this -> args [ self :: SUBJECTS_KEY ] as $ subject ) { $ opTimer = new \ Tripod \ Timer ( ) ; $ opTimer -> start ( ) ; $ impactedSubject = $ this -> createImpactedSubject ( $ subject ) ; $ impactedSubject -> update ( ) ; $ opTimer -> stop ( ) ; $ this -> getStat ( ) -> timer ( MONGO_QUEUE_APPLY_OPERATION . '.' . $ subject [ 'operation' ] , $ opTimer -> result ( ) ) ; if ( isset ( $ this -> args [ self :: TRACKING_KEY ] ) ) { $ jobGroup = $ this -> getJobGroup ( $ subject [ 'storeName' ] , $ this -> args [ self :: TRACKING_KEY ] ) ; $ jobCount = $ jobGroup -> incrementJobCount ( - 1 ) ; if ( $ jobCount <= 0 ) { $ timestamp = new \ MongoDB \ BSON \ UTCDateTime ( hexdec ( substr ( $ jobGroup -> getId ( ) , 0 , 8 ) ) * 1000 ) ; $ tripod = $ this -> getTripod ( $ subject [ 'storeName' ] , $ subject [ 'podName' ] ) ; $ count = 0 ; foreach ( $ subject [ 'specTypes' ] as $ specId ) { switch ( $ subject [ 'operation' ] ) { case \ OP_VIEWS : $ count += $ tripod -> getComposite ( \ OP_VIEWS ) -> deleteViewsByViewId ( $ specId , $ timestamp ) ; break ; case \ OP_TABLES : $ count += $ tripod -> getComposite ( \ OP_TABLES ) -> deleteTableRowsByTableId ( $ specId , $ timestamp ) ; break ; case \ OP_SEARCH : $ searchProvider = $ this -> getSearchProvider ( $ tripod ) ; $ count += $ searchProvider -> deleteSearchDocumentsByTypeId ( $ specId , $ timestamp ) ; break ; } } $ this -> infoLog ( '[JobGroupId ' . $ jobGroup -> getId ( ) -> __toString ( ) . '] composite cleanup for ' . $ subject [ 'operation' ] . ' removed ' . $ count . ' stale composite documents' ) ; } } } }
Run the ApplyOperation job
27,948
public static function forStringType ( int $ string_type ) : self { $ steps = array ( self :: STEP_TRANSCODE => new TranscodeStep ( $ string_type ) , self :: STEP_MAP => new MapStep ( ) , self :: STEP_NORMALIZE => new NormalizeStep ( ) , self :: STEP_PROHIBIT => new ProhibitStep ( ) , self :: STEP_CHECK_BIDI => new CheckBidiStep ( ) , self :: STEP_INSIGNIFICANT_CHARS => new InsignificantNonSubstringSpaceStep ( ) ) ; return new self ( $ steps ) ; }
Get default instance for given string type .
27,949
public function withCaseFolding ( bool $ fold ) : self { $ obj = clone $ this ; $ obj -> _steps [ self :: STEP_MAP ] = new MapStep ( $ fold ) ; return $ obj ; }
Get self with case folding set .
27,950
public function prepare ( string $ string ) : string { foreach ( $ this -> _steps as $ step ) { $ string = $ step -> apply ( $ string ) ; } return $ string ; }
Prepare string .
27,951
public function addPHPConfig ( $ filename ) { $ filename = trim ( $ filename ) ; if ( strlen ( $ filename ) === 0 ) { throw new ConfiguratorException ( "Zero length filename is bogus." ) ; } if ( file_exists ( $ filename ) === false ) { throw new ConfiguratorException ( "File `$filename` does not exist." ) ; } ob_start ( ) ; require ( $ filename ) ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( strlen ( $ contents ) !== 0 ) { $ message = sprintf ( "Filename `%s` output some characters. Please check it is a valid PHP file.\n" , $ filename ) ; throw new ConfiguratorException ( $ message ) ; } if ( isset ( $ default ) === true ) { $ this -> configuratorData -> addConfigDefault ( $ default ) ; } foreach ( $ this -> environmentList as $ environment ) { if ( isset ( $ $ environment ) === true ) { $ this -> configuratorData -> addConfigEnvironment ( $ $ environment ) ; } } if ( isset ( $ override ) === true ) { $ this -> configuratorData -> addConfigOverride ( $ override ) ; } if ( isset ( $ evaluate ) === true ) { $ calculatedValues = $ evaluate ( $ this -> configuratorData -> getConfig ( ) , $ this -> environment ) ; $ this -> configuratorData -> addConfigOverride ( $ calculatedValues ) ; } }
Adds an ini file to the configurator . All of the options are then available for generating config files from .
27,952
public function configurate ( $ inputFilename ) { $ config = $ this -> configuratorData -> getConfig ( ) ; foreach ( $ config as $ key => $ value ) { if ( $ value === false ) { $ $ key = 'false' ; continue ; } $ $ key = $ value ; } $ configuration = require $ inputFilename ; return $ configuration ; }
Reads a config file applies the current config settings to it and returns the generated result .
27,953
private function _request ( ) { if ( $ this -> _request ) { return $ this -> _request ; } $ this -> _request = Zend_Controller_Front :: getInstance ( ) -> getRequest ( ) ; return $ this -> _request ; }
Get the reqeust object
27,954
protected function _getIp ( ) { if ( ! $ this -> _request ( ) ) { return null ; } $ ip = $ this -> _request ( ) -> getClientIp ( ) ; if ( $ this -> _isValidIpv4 ( $ ip ) ) { return $ ip ; } $ ips = explode ( ',' , $ ip , 2 ) ; $ ip = trim ( $ ips [ 0 ] ) ; if ( $ this -> _isValidIpv4 ( $ ip ) ) { return $ ip ; } return null ; }
Get a good ipv4
27,955
public function toUser ( ) { if ( func_num_args ( ) > 0 ) { $ userIds = is_array ( func_get_arg ( 0 ) ) ? func_get_arg ( 0 ) : func_get_args ( ) ; $ this -> to [ 'touser' ] = implode ( '|' , $ userIds ) ; } return $ this ; }
Message target user .
27,956
public function toParty ( ) { if ( func_num_args ( ) > 0 ) { $ partyIds = is_array ( func_get_arg ( 0 ) ) ? func_get_arg ( 0 ) : func_get_args ( ) ; $ this -> to [ 'toparty' ] = implode ( '|' , $ partyIds ) ; } return $ this ; }
Message target party .
27,957
public function toTag ( ) { if ( func_num_args ( ) > 0 ) { $ tagIds = is_array ( func_get_arg ( 0 ) ) ? func_get_arg ( 0 ) : func_get_args ( ) ; $ this -> to [ 'totag' ] = implode ( '|' , $ tagIds ) ; } return $ this ; }
Message target tag .
27,958
public function getView ( ) { $ module = \ Yii :: $ app -> controller -> module ; if ( method_exists ( $ module , 'getView' ) ) { return $ module -> getView ( ) ; } return parent :: getView ( ) ; }
Give ability of configure view to the module class .
27,959
function to_tripod_array ( $ docId , $ context ) { $ docId = $ this -> _labeller -> qname_to_alias ( $ docId ) ; $ contextAlias = $ this -> _labeller -> uri_to_alias ( $ context ) ; if ( $ docId != null ) { $ subjects = $ this -> get_subjects ( ) ; foreach ( $ subjects as $ subject ) { if ( $ subject == $ docId ) { $ graph = $ this -> get_subject_subgraph ( $ subject ) ; $ doc = $ this -> index_to_tarray ( $ graph , $ contextAlias ) ; return $ doc ; } } } return null ; }
Returns a mongo - ready doc for a single CBD
27,960
function to_tripod_view_array ( $ docId , $ context ) { $ subjects = $ this -> get_subjects ( ) ; $ contextAlias = $ this -> _labeller -> uri_to_alias ( $ context ) ; $ doc = array ( ) ; $ doc [ "_id" ] = array ( _ID_RESOURCE => $ docId , _ID_CONTEXT => $ contextAlias ) ; $ doc [ "value" ] = array ( ) ; $ doc [ "value" ] [ _IMPACT_INDEX ] = $ subjects ; $ doc [ "value" ] [ _GRAPHS ] = array ( ) ; foreach ( $ subjects as $ subject ) { $ graph = $ this -> get_subject_subgraph ( $ subject ) ; $ doc [ "value" ] [ _GRAPHS ] [ ] = $ this -> index_to_tarray ( $ graph , $ contextAlias ) ; } return $ doc ; }
Returns a mongo - ready doc for views which can have multiple graphs in the same doc
27,961
private function loadExtendedTypes ( $ serviceId , $ name , ContainerBuilder $ container ) { foreach ( array ( 'choice' , 'language' , 'country' , 'timezone' , 'locale' , 'entity' , 'ajax' ) as $ type ) { $ typeDef = new DefinitionDecorator ( $ serviceId ) ; $ typeDef -> addArgument ( $ type ) -> addTag ( 'form.type' , array ( 'alias' => $ name . '_' . $ type ) ) ; $ container -> setDefinition ( $ serviceId . '.' . $ type , $ typeDef ) ; } }
Loads extended form types .
27,962
public function transformMusic ( AbstractMessage $ message ) { $ response = [ 'Music' => [ 'Title' => $ message -> get ( 'title' ) , 'Description' => $ message -> get ( 'description' ) , 'MusicUrl' => $ message -> get ( 'url' ) , 'HQMusicUrl' => $ message -> get ( 'hq_url' ) , 'ThumbMediaId' => $ message -> get ( 'thumb_media_id' ) , ] , ] ; return $ response ; }
Transform music message .
27,963
public function transformTransfer ( AbstractMessage $ message ) { $ response = [ ] ; if ( $ message -> get ( 'account' ) ) { $ response [ 'TransInfo' ] = [ 'KfAccount' => $ message -> get ( 'account' ) , ] ; } return $ response ; }
Transform transfer message .
27,964
public function write ( $ string , $ length = null ) { if ( null === $ length ) { $ length = strlen ( $ string ) ; } if ( false === ( $ actual = @ fwrite ( $ this -> getHandle ( ) , $ string , $ length ) ) ) { throw FileException :: createUsingLastError ( ) ; } if ( $ length !== $ actual ) { throw FileException :: createUsingFormat ( 'Only %d of %d bytes were written to "%s".' , $ actual , $ length , $ this -> file ) ; } }
Writes a specific number of bytes to the file .
27,965
protected function getFaker ( ) { return $ this -> faker ? $ this -> faker : ( $ this -> faker = Faker \ Factory :: create ( i18n :: get_locale ( ) ) ) ; }
Gets a Faker \ Generator instance
27,966
protected function resolveMinMax ( $ min , $ max , $ adder ) { if ( ! $ max || $ min > $ max ) { $ max = $ min + $ adder ; } elseif ( ! $ min || $ min > $ max ) { $ min = $ max - $ adder ; if ( $ min < 0 ) { $ min = 0 ; } } return array ( $ min , $ max ) ; }
Compares two min values and assures a usable range
27,967
public function Sentence ( $ minWords = 5 , $ maxWords = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minWords , $ maxWords , 10 ) ; $ words = rand ( $ min , $ max ) ; return DBField :: create_field ( "Varchar" , $ this -> getFaker ( ) -> sentence ( $ words ) ) ; }
Generates a sentence
27,968
public function Sentences ( $ minSentences = 1 , $ maxSentences = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minSentences , $ maxSentences , 5 ) ; return DBField :: create_field ( "Text" , $ this -> getFaker ( ) -> paragraph ( rand ( $ min , $ max ) ) ) ; }
Generates a series of sentences
27,969
public function Number ( $ minNum = 0 , $ maxNum = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minNum , $ maxNum , 1000 ) ; return DBField :: create_field ( "Int" , rand ( $ min , $ max ) ) ; }
Generates a random number
27,970
public function Currency ( $ minPrice = 1 , $ maxPrice = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minPrice , $ maxPrice , 1000 ) ; $ rand = mt_rand ( $ min * 100 , $ max * 100 ) ; return DBField :: create_field ( "Currency" , $ rand / 100 ) ; }
Generates a random price
27,971
public function Paragraphs ( $ minVal = 1 , $ maxVal = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minVal , $ maxVal , 5 ) ; $ paragraphs = rand ( $ min , $ max ) ; $ faker = $ this -> getFaker ( ) ; $ i = 0 ; $ html = "" ; while ( $ i < $ paragraphs ) { $ html .= "<p>" . $ faker -> paragraph ( rand ( 2 , 6 ) ) . "</p>" ; $ i ++ ; } return DBField :: create_field ( "HTMLText" , $ html ) ; }
Generates a random number of Paragraphs
27,972
public function Loop ( $ minSize = 1 , $ maxSize = null ) { list ( $ min , $ max ) = $ this -> resolveMinMax ( $ minSize , $ maxSize , 10 ) ; $ limit = rand ( $ min , $ max ) ; $ list = ArrayList :: create ( array ( ) ) ; $ i = 0 ; while ( $ i < $ limit ) { $ list -> push ( new DataObject ( ) ) ; $ i ++ ; } return $ list ; }
Build a set of empty DataObjects that can be iterated over
27,973
public static function of ( $ builder ) { if ( $ builder instanceof \ Illuminate \ Database \ Eloquent \ Builder ) { $ builder = $ builder -> getQuery ( ) ; } $ collection = new Collection ( $ builder ) ; $ collection = self :: _addCustomAttributes ( $ collection ) ; self :: $ _lastCollection = $ collection ; return self :: collection ( ) ; }
Sets builder and returns collection
27,974
public function unit_to_constant ( $ name ) { $ camel = '' ; $ name = str_replace ( ':' , '' , $ name ) ; foreach ( explode ( '_' , $ name ) as $ str ) { $ camel .= ucfirst ( $ str ) ; } return 'PHPWarrior\Units\\' . $ camel ; }
Unit to constant
27,975
public function lastReply ( ) { try { $ replies = ForumReply :: where ( 'post_id' , $ this -> id ) -> get ( ) ; if ( $ replies -> isEmpty ( ) ) { return null ; } $ reply = $ replies -> last ( ) ; return [ 'author' => $ reply -> author -> name , 'date' => $ reply -> created_at ] ; } catch ( Exception $ e ) { return null ; } }
Gets the last reply for the current forum post .
27,976
private function loadContextInitializer ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\GuzzleExtension\Context\Initializer\GuzzleAwareInitializer' , array ( new Reference ( self :: GUZZLE_CLIENT_ID ) , '%guzzle.parameters%' , ) ) ; $ definition -> addTag ( ContextExtension :: INITIALIZER_TAG , array ( 'priority' => 0 ) ) ; $ container -> setDefinition ( 'guzzle.context_initializer' , $ definition ) ; }
Load Context Initializer
27,977
protected function loadOptions ( ) : void { $ options = [ ] ; if ( $ this -> preset == 'custom' ) { $ optionsFile = null ; } else { $ optionsFile = __DIR__ . '/presets/' . $ this -> preset . '.php' ; } if ( $ optionsFile !== null ) { if ( ! is_file ( $ optionsFile ) ) { throw new InvalidConfigException ( 'The CKEditor options file can not be loaded.' ) ; } $ options = require ( $ optionsFile ) ; } $ this -> clientOptions = ArrayHelper :: merge ( $ options , $ this -> clientOptions ) ; }
Set the clientOptions . Options from presets are merging with the client options .
27,978
public function register ( ) { $ this -> commands ( [ 'Synga\PhpStormMeta\Laravel\Command\ExcludeCommand' , 'Synga\PhpStormMeta\Laravel\Command\IncludeCommand' , 'Synga\PhpStormMeta\Laravel\Command\GenerateCommand' , ] ) ; $ this -> app -> singleton ( 'Synga\InheritanceFinder\InheritanceFinderInterface' , function ( ) { if ( ! file_exists ( storage_path ( 'class_cache' ) ) ) { mkdir ( storage_path ( 'class_cache' ) ) ; } $ config = new \ Synga \ InheritanceFinder \ File \ FileConfig ( ) ; $ config -> setApplicationRoot ( base_path ( ) ) ; $ config -> setCacheDirectory ( storage_path ( 'class_cache' ) ) ; return InheritanceFinderFactory :: getInheritanceFinder ( $ config ) ; } ) ; }
Registers the commands
27,979
public function send ( Sms $ sms ) : array { if ( ! $ sms -> hasRecipients ( ) ) { throw new NoRecipientsSpecifiedException ( ) ; } $ messages = [ ] ; $ recipients = $ sms -> getRecipients ( ) ; foreach ( array_chunk ( $ recipients , Recipients :: MAX ) as $ chunk ) { $ message = clone $ sms ; $ message -> setRecipients ( $ chunk ) -> clearRecipientVariables ( ) ; foreach ( $ chunk as $ recipient ) { if ( ! isset ( $ sms -> getRecipientVariables ( ) [ $ recipient ] ) ) { continue ; } foreach ( $ sms -> getRecipientVariables ( ) [ $ recipient ] as $ variable => $ value ) { $ message -> addRecipientVariable ( $ recipient , $ variable , $ value ) ; } } $ messages [ ] = $ message ; } $ responses = [ ] ; foreach ( $ messages as $ message ) { $ request = $ this -> prepareRequest ( $ message ) ; $ responses [ ] = $ this -> executeRequest ( $ request ) ; } return $ responses ; }
Sends an SMS .
27,980
private function configureOptions ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( [ 'username' , 'password' , 'sender' , 'method' , ] ) -> setDefaults ( [ 'delivery_start' => null , 'charset' => Charsets :: UTF8 , 'validity_period' => \ DateInterval :: createFromDateString ( '2800 minutes' ) , 'encoding_schema' => EncodingSchemas :: NORMAL , 'endpoint_uri' => Endpoints :: REST_HTTPS , ] ) -> setAllowedTypes ( 'username' , 'string' ) -> setAllowedTypes ( 'password' , 'string' ) -> setAllowedTypes ( 'sender' , 'string' ) -> setAllowedTypes ( 'method' , 'string' ) -> setAllowedTypes ( 'delivery_start' , [ 'null' , 'DateTime' ] ) -> setAllowedTypes ( 'validity_period' , [ 'null' , 'DateInterval' ] ) -> setAllowedTypes ( 'encoding_schema' , 'string' ) -> setAllowedTypes ( 'charset' , 'string' ) -> setAllowedTypes ( 'endpoint_uri' , 'string' ) -> setAllowedValues ( 'method' , [ SendMethods :: CLASSIC , SendMethods :: CLASSIC_PLUS , SendMethods :: BASIC , SendMethods :: TEST_CLASSIC , SendMethods :: TEST_CLASSIC_PLUS , SendMethods :: TEST_BASIC , ] ) -> setAllowedValues ( 'validity_period' , function ( \ DateInterval $ value ) { return $ value -> i >= ValidityPeriods :: MIN && $ value -> i <= ValidityPeriods :: MAX ; } ) -> setAllowedValues ( 'encoding_schema' , [ EncodingSchemas :: NORMAL , EncodingSchemas :: UCS2 , ] ) -> setAllowedValues ( 'charset' , [ Charsets :: ISO_8859_1 , Charsets :: UTF8 , ] ) ; }
Configure default options for client .
27,981
private function normalizePhoneNumber ( string $ phoneNumber ) : string { $ utils = PhoneNumberUtil :: getInstance ( ) ; $ parsed = $ utils -> parse ( preg_replace ( '/^00/' , '+' , $ phoneNumber ) , null ) ; $ phoneNumber = $ utils -> format ( $ parsed , PhoneNumberFormat :: E164 ) ; return substr ( $ phoneNumber , 1 ) ; }
Normalizes the phoneNumber .
27,982
public static function factory ( $ config = array ( ) ) { $ default = array ( 'base_uri' => 'https://{account_name}.blob.core.windows.net/' ) ; $ required = array ( 'base_uri' , 'account_name' , 'account_key' ) ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; $ client = new self ( $ config -> get ( 'base_uri' ) , $ config -> get ( 'account_name' ) , $ config -> get ( 'account_key' ) ) ; return $ client ; }
Factory method to create a new StorageClient
27,983
protected function rand ( $ min , $ max ) { $ this -> seed = md5 ( $ this -> seed ) ; $ rand = hexdec ( substr ( $ this -> seed , 0 , 8 ) ) ; return ( $ rand % ( $ max - $ min + 1 ) ) + $ min ; }
Generate number from seed
27,984
public static function languages ( string $ locale = 'en' ) : Collection { return Collection :: make ( include __DIR__ . "/../../../umpirsky/language-list/data/{$locale}/language.php" ) -> map ( function ( $ lang ) { return ucfirst ( $ lang ) ; } ) ; }
Returns the language list based on a locale .
27,985
public static function language ( string $ lang = 'en' , string $ locale = 'en' ) : string { return static :: languages ( $ locale ) -> get ( $ lang ) ; }
Returns the language name based on a locale .
27,986
protected function roundRobinGet ( $ field ) { if ( empty ( $ this -> $ field ) || ! is_array ( $ this -> $ field ) ) { return '' ; } $ val = $ this -> $ field ; $ idx = $ field . 'Index' ; if ( ! isset ( $ this -> $ idx ) || $ this -> $ idx >= count ( $ val ) ) { $ this -> $ idx = 0 ; } return $ val [ $ this -> $ idx ++ ] ; }
Given an array property returns the next element from it and increments an index field
27,987
public function getRelativeLinkFor ( $ f ) { $ fn = is_object ( $ f ) ? $ f -> getFilename ( ) : $ f ; return trim ( str_replace ( $ this -> localPath , '' , $ fn ) , '/' ) ; }
Returns the full path and filename relative to the BaseURL
27,988
public function head ( ) { $ head = '' ; $ head .= '<thead>' ; $ head .= '<tr class="resource-table-headings">' ; foreach ( $ this -> _getColumns ( ) as $ column ) { $ head .= '<th class="' . ( $ column -> sortActive ( ) ? 'warning' : '' ) . '">' ; $ head .= $ column -> content ( ) ; $ head .= '</th>' ; } $ head .= '</tr>' ; if ( $ this -> _config [ 'filter' ] ) { $ head .= '<tr class="resource-table-filter">' ; foreach ( $ this -> _getColumns ( ) as $ column ) { if ( ! $ column -> searchable ( ) ) { $ head .= '<td></td>' ; continue ; } $ head .= '<td>' . $ column -> searchableContent ( ) . '</td>' ; } $ head .= '</tr>' ; } $ head .= '</thead>' ; return $ head ; }
Returns table head
27,989
public function body ( ) { $ columns = $ this -> _getColumns ( ) ; $ body = '' ; $ body .= '<tbody>' ; if ( empty ( $ this -> _collection ) ) { $ body .= '<tr><td colspan="' . count ( $ columns ) . '">' . trans ( 'resource-table::default.No_records' ) . '</td></tr>' ; } else { foreach ( $ this -> _collection as $ row ) { $ body .= '<tr>' ; foreach ( $ columns as $ column ) { $ body .= '<td>' ; $ body .= $ column -> content ( $ row ) ; $ body .= '</td>' ; } $ body .= '</tr>' ; } } $ body .= '</tbody>' ; return $ body ; }
Returns table body
27,990
private function _getColumns ( ) { $ columns = [ ] ; foreach ( $ this -> _config [ 'columns' ] as $ data ) { $ columns [ ] = new Column ( $ data , $ this -> _config [ 'view_name' ] ) ; } return $ columns ; }
Returns array with Column objects
27,991
private function _dataForView ( ) { return [ 'collection_generator' => $ this -> _config [ 'collection_generator' ] , 'columns' => $ this -> _getColumns ( ) , 'collection' => $ this -> _collection , 'paginator' => $ this -> _config [ 'paginator_presenter' ] , 'table' => $ this , 'extra' => $ this -> _config [ 'extra' ] , ] ; }
Returns array with view data
27,992
protected function getFilePath ( $ name ) { if ( pathinfo ( $ name , PATHINFO_EXTENSION ) === '' ) { $ name .= ( substr ( $ name , - 1 ) === '/' ? 'index' : '' ) . '.' . $ this -> getExt ( ) ; } return rtrim ( $ this -> path , '/' ) . '/' . ltrim ( $ name , '/' ) ; }
Get the path to a view file
27,993
protected function assertFile ( $ name ) { if ( strpos ( $ name , '..' ) !== false ) { throw new \ InvalidArgumentException ( "File name '$name' isn't valid" ) ; } $ file = $ this -> getFilePath ( $ name ) ; if ( ! file_exists ( $ file ) ) { throw new \ RuntimeException ( "View file '$file' doesn't exist" ) ; } }
Assert the filename and that the file exists
27,994
public function postSetData ( FormEvent $ event ) { $ collection = $ event -> getData ( ) ; $ form = $ event -> getForm ( ) ; if ( $ collection instanceof PersistentCollection ) { foreach ( $ collection as $ key => $ image ) { if ( $ image instanceof MultiImageInterface && null !== $ image -> getId ( ) ) { try { $ this -> imageManager -> copyImagesToTemporaryDirectory ( $ image ) ; } catch ( \ Gaufrette \ Exception \ FileNotFound $ e ) { $ form -> remove ( $ key ) ; $ collection -> removeElement ( $ image ) ; } } } } }
Copy images from permenent to temporary directory
27,995
public function earn_points ( $ points ) { $ this -> score += $ points ; $ this -> say ( sprintf ( __ ( "earns %s points" ) , $ points ) ) ; }
Earn points .
27,996
public function perform_turn ( ) { if ( is_null ( $ this -> current_turn -> action ) ) { $ this -> say ( __ ( "does nothing" ) ) ; } return parent :: perform_turn ( ) ; }
Perform the warrior his turn .
27,997
public function ticket ( $ forceRefresh = false ) { $ key = self :: GROUP_TICKET_CACHE_PREFIX . $ this -> getAccessToken ( ) -> getFingerprint ( ) ; $ ticket = $ this -> getCache ( ) -> fetch ( $ key ) ; if ( ! $ forceRefresh && ! empty ( $ ticket ) ) { return $ ticket ; } $ result = $ this -> parseJSON ( 'get' , [ self :: API_GROUP_TICKET , [ 'type' => 'contact' ] ] ) ; $ this -> getCache ( ) -> save ( $ key , $ result , $ result [ 'expires_in' ] - 500 ) ; return $ result ; }
Get ticket .
27,998
public function prepare ( array $ params ) { $ params [ 'wxappid' ] = $ this -> merchant -> app_id ; $ params [ 'auth_mchid' ] = '1000052601' ; $ params [ 'auth_appid' ] = 'wxbf42bd79c4391863' ; $ params [ 'amt_type' ] = 'ALL_RAND' ; return $ this -> request ( self :: API_PREPARE , $ params ) ; }
Prepare luckymoney .
27,999
public function send ( array $ params , $ type = self :: TYPE_NORMAL ) { $ api = ( $ type === self :: TYPE_NORMAL ) ? self :: API_SEND : self :: API_SEND_GROUP ; $ params [ 'wxappid' ] = $ this -> merchant -> app_id ; if ( $ type === self :: TYPE_GROUP ) { unset ( $ params [ 'client_ip' ] ) ; } return $ this -> request ( $ api , $ params ) ; }
Send LuckyMoney .