idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
18,200
public function delete ( $ listId , Subscriber $ subscriber ) { $ subscriberHash = $ this -> mailchimp -> subscriberHash ( $ subscriber -> getEmail ( ) ) ; $ result = $ this -> mailchimp -> delete ( "lists/$listId/members/$subscriberHash" ) ; if ( ! $ this -> mailchimp -> success ( ) ) { $ this -> throwMailchimpError (...
Delete a Subscriber to a list
18,201
public function batchSubscribe ( $ listId , array $ subscribers ) { $ batchResults = [ ] ; $ subscriberChunks = array_chunk ( $ subscribers , self :: SUBSCRIBER_BATCH_SIZE ) ; foreach ( $ subscriberChunks as $ subscriberChunk ) { $ Batch = $ this -> mailchimp -> new_batch ( ) ; foreach ( $ subscriberChunk as $ index =>...
Subscribe a batch of Subscriber to a list
18,202
public function batchDelete ( $ listId , array $ emails ) { $ batchIds = [ ] ; $ emailsChunks = array_chunk ( $ emails , self :: SUBSCRIBER_BATCH_SIZE ) ; foreach ( $ emailsChunks as $ emailsChunk ) { $ Batch = $ this -> mailchimp -> new_batch ( ) ; foreach ( $ emailsChunk as $ index => $ email ) { $ emailHash = $ this...
Delete a batch of Subscriber to a list
18,203
public function getMembers ( $ listId ) { $ emails = [ ] ; $ result = $ this -> mailchimp -> get ( "lists/$listId/members" ) ; if ( ! $ this -> mailchimp -> success ( ) ) { $ this -> throwMailchimpError ( $ this -> mailchimp -> getLastResponse ( ) ) ; } return $ result ; }
Get Members of a list
18,204
public function getSubscriberEmails ( $ listId ) { $ emails = [ ] ; $ members = [ ] ; $ offset = 0 ; $ maxresult = 200 ; $ result = $ this -> mailchimp -> get ( "lists/$listId/members" , [ 'count' => $ maxresult ] ) ; if ( ! $ this -> mailchimp -> success ( ) ) { $ this -> throwMailchimpError ( $ this -> mailchimp -> g...
Get an array of subscribers emails from a list
18,205
public function registerMainWebhook ( $ listId , $ webhookurl ) { $ subscribeWebhook = [ 'url' => $ webhookurl , 'events' => [ 'subscribe' => true , 'unsubscribe' => true , 'profile' => true , 'cleaned' => true , 'upemail' => true , 'campaign' => true ] , 'sources' => [ 'user' => true , 'admin' => true , 'api' => false...
Automatically configure Webhook for a list
18,206
public function formatMailChimp ( ) { $ options = $ this -> options ; if ( ! empty ( $ this -> getMergeFields ( ) ) ) { $ options = array_merge ( [ 'merge_fields' => $ this -> getMergeFields ( ) ] , $ options ) ; } return array_merge ( [ 'email_address' => $ this -> getEmail ( ) ] , $ options ) ; }
Formate Subscriber for MailChimp API request
18,207
public function getMergeFields ( ) { foreach ( $ this -> mergeFields as $ key => $ value ) { if ( $ value === null ) { unset ( $ this -> mergeFields [ $ key ] ) ; } } return $ this -> mergeFields ; }
Correspond to merge_fields in MailChimp request
18,208
public function getMessage ( $ message = "codeco" ) { $ folder = $ this -> _path . SEPARATOR . $ this -> _directory . SEPARATOR . "messages" ; return $ folder . SEPARATOR . strtolower ( $ message ) . ".xml" ; }
Get path to xml message
18,209
public function getServiceMessages ( $ version = '3' , $ message = 'contrl' ) { $ folder = $ this -> _path . SEPARATOR . "Service_V" . $ version . SEPARATOR . "messages" ; return $ folder . SEPARATOR . strtolower ( $ message ) . ".xml" ; }
Get path to service messages xml
18,210
public function listMessages ( ) { $ folder = $ this -> _path . SEPARATOR . $ this -> _directory . SEPARATOR . "messages" ; $ messages = array_slice ( scandir ( $ folder ) , 2 ) ; foreach ( $ messages as & $ msg ) { $ msg = str_replace ( '.xml' , '' , $ msg ) ; } return $ messages ; }
Get message names from folder in this directory
18,211
private function createList ( $ listId , $ listParameters ) { $ providerServiceKey = $ listParameters [ 'subscriber_provider' ] ; $ provider = $ this -> providerFactory -> create ( $ providerServiceKey ) ; $ subscriberList = new SubscriberList ( $ listId , $ provider , $ listParameters [ 'merge_fields' ] ) ; $ subscrib...
create one SubscriberList
18,212
private function refreshBatchesResult ( $ batchesResult ) { $ refreshedBatchsResults = [ ] ; $ mailchimp = $ this -> getContainer ( ) -> get ( 'welp_mailchimp.mailchimp_master' ) ; foreach ( $ batchesResult as $ key => $ batch ) { $ batch = $ mailchimp -> get ( "batches/" . $ batch [ 'id' ] ) ; array_push ( $ refreshed...
Refresh all batch from MailChimp API
18,213
public function setOptions ( $ width = 900 , $ height = 1300 , array $ ignore = [ ] , $ timeout = null ) { $ this -> width = $ width ; $ this -> height = $ height ; $ this -> ignore = $ ignore ; $ this -> timeout = $ timeout ; }
Set optional options for Critical .
18,214
protected function shouldRegisterBladeDirective ( ) { if ( ! $ this -> app [ 'config' ] -> get ( 'criticalcss.blade_directive' ) ) { return false ; } if ( $ this -> app -> runningInConsole ( ) ) { return false ; } return true ; }
Should the Blade directive be registered? Fixes compatibility issues with Laravel 5 . 0 .
18,215
protected function setupConfig ( ) { $ src = realpath ( __DIR__ . '/config/criticalcss.php' ) ; if ( $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ $ src => config_path ( 'criticalcss.php' ) , ] ) ; } $ this -> mergeConfigFrom ( $ src , 'criticalcss' ) ; }
Set up the config .
18,216
protected function registerAppBindings ( ) { $ this -> app -> singleton ( 'criticalcss.storage' , function ( $ app ) { return new LaravelStorage ( $ app [ 'config' ] -> get ( 'criticalcss.storage' ) , $ app -> make ( 'filesystem' ) -> disk ( $ app [ 'config' ] -> get ( 'filesystems.default' ) ) , $ app [ 'config' ] -> ...
Register Application bindings .
18,217
protected function getUris ( ) { $ uris = $ this -> laravel [ 'config' ] -> get ( 'criticalcss.routes' ) ; if ( is_null ( $ uris ) ) { $ uris = [ ] ; $ router = $ this -> laravel [ 'router' ] ; foreach ( $ router -> getRoutes ( ) as $ route ) { if ( $ route -> getMethods ( ) [ 0 ] === 'GET' ) { $ uris [ ] = $ route -> ...
Returns a list of URIs to generate critical - path CSS for .
18,218
protected function clearViews ( ) { $ this -> info ( 'Clearing compiled views' ) ; try { Artisan :: call ( 'view:clear' ) ; } catch ( InvalidArgumentException $ e ) { $ views = $ this -> laravel [ 'files' ] -> glob ( $ this -> laravel [ 'config' ] [ 'view.compiled' ] . '/*' ) ; foreach ( $ views as $ view ) { $ this ->...
Clear compiled views .
18,219
public static function parseUriFromBladeExpression ( $ expr ) { if ( is_null ( $ expr ) ) { return app ( 'router' ) -> current ( ) -> getUri ( ) ; } $ expr = trim ( $ expr , '()\'" ' ) ; if ( $ expr !== '/' ) { return ltrim ( $ expr , '/' ) ; } return $ expr ; }
Parse the URI from the Blade directive expression .
18,220
public function validateStoragePath ( ) { if ( ! $ this -> files -> exists ( $ this -> storage ) ) { return $ this -> files -> makeDirectory ( $ this -> storage ) ; } return true ; }
Validate that the storage directory exists . If it does not create it .
18,221
protected function call ( $ uri ) { $ request = Request :: create ( $ uri , 'GET' ) ; $ kernel = $ this -> app -> make ( HttpKernel :: class ) ; $ response = $ kernel -> handle ( $ request ) ; $ kernel -> terminate ( $ request , $ response ) ; return $ response ; }
Call the given URI and return a Response .
18,222
public function sendPayload ( $ deviceToken , Payload $ payload ) { return $ this -> socketClient -> write ( $ this -> createApnMessage ( $ deviceToken , $ payload ) -> getBinaryMessage ( ) ) ; }
Send Payload instance to a given device token .
18,223
public function send ( $ deviceToken , $ title , $ body , $ deepLink = null ) { return $ this -> client -> sendPayload ( $ deviceToken , $ this -> createPayload ( $ title , $ body , $ deepLink ) ) ; }
Sends a safari website push notification to the given deviceToken .
18,224
public function createPushPackageForUser ( $ userId ) { $ packageDir = sprintf ( '/%s/pushPackage%s.%s' , sys_get_temp_dir ( ) , time ( ) , $ userId ) ; $ package = $ this -> createPackage ( $ packageDir , $ userId ) ; $ this -> generatePackage ( $ package ) ; return $ package ; }
Create a safari website push notification package for the given User .
18,225
public function populate ( EventRegistryInterface $ eventsRegistry , \ DateTime $ fromDate , \ DateTime $ toDate , $ limit = null , array $ extraFilters = array ( ) ) { if ( $ fromDate > $ toDate ) { throw new \ RangeException ( "'From' date should be before the 'to' date." ) ; } $ filters = array_merge ( array ( 'from...
Populates the calendar with events using an event registry and filters the results based on other parameters .
18,226
public function sort ( ) { usort ( $ this -> allEvents , function ( $ event1 , $ event2 ) { if ( $ event1 -> getStartDate ( ) == $ event2 -> getStartDate ( ) ) { return $ event1 -> getId ( ) < $ event2 -> getId ( ) ? - 1 : 1 ; } return $ event1 -> getStartDate ( ) < $ event2 -> getStartDate ( ) ? - 1 : 1 ; } ) ; return...
Sorts the events into ascending order based on their start dates .
18,227
protected function processRecurringEvents ( \ DateTime $ fromDate , \ DateTime $ toDate , $ limit = null ) { if ( $ this -> recurrenceFactory ) { foreach ( $ this -> recurrenceFactory -> getRecurrenceTypes ( ) as $ recurrence ) { $ recurrenceType = new $ recurrence ( ) ; $ occurrences = $ recurrenceType -> generateOccu...
Generates the occurrences for recurring events if a recurrence factory is present .
18,228
protected function removeOveriddenEvents ( ) { $ this -> sort ( ) ; $ events = array ( ) ; array_walk ( $ this -> allEvents , function ( $ event ) use ( & $ events ) { if ( $ event -> getOccurrenceDate ( ) ) { $ events [ $ event -> getOccurrenceDate ( ) -> format ( 'Y-m-d H:i:s' ) . '.' . ( $ event -> getParentId ( ) ?...
Removes the occurrences of recurring events that have been overridden .
18,229
protected function removeOutOfRangeEvents ( \ DateTime $ fromDate , \ DateTime $ toDate ) { $ this -> allEvents = array_filter ( $ this -> allEvents , function ( $ event ) use ( $ fromDate , $ toDate ) { if ( $ event -> getStartDate ( ) <= $ toDate && $ event -> getEndDate ( ) >= $ fromDate ) { return true ; } return f...
Remove any events particularly occurrences of recurring events that are out of the date range provided .
18,230
public function populate ( $ rows ) : array { $ result = [ ] ; if ( $ this -> indexBy === null ) { return array_values ( $ rows ) ; } foreach ( $ rows as $ row ) { if ( is_string ( $ this -> indexBy ) ) { $ key = $ row [ $ this -> indexBy ] ; } else { $ key = call_user_func ( $ this -> indexBy , $ row ) ; } $ result [ ...
Converts the raw query results into the format as specified by this query .
18,231
public function parse ( $ text , $ fixWebkit = false ) { if ( $ fixWebkit ) { return $ this -> webkitFix ( $ this -> closeParsing ( $ this -> parseTajweed ( $ text ) ) ) ; } return $ this -> closeParsing ( $ this -> parseTajweed ( $ text ) ) ; }
Parses tajweed from the GlobalQuran and AlQuran APIs to return markup
18,232
public function createManifest ( Package $ package ) { $ manifestData = array ( ) ; foreach ( Package :: $ packageFiles as $ rawFile ) { $ filePath = sprintf ( '%s/%s' , $ package -> getPackageDir ( ) , $ rawFile ) ; $ manifestData [ $ rawFile ] = sha1 ( file_get_contents ( $ filePath ) ) ; } $ manifestJsonPath = sprin...
Generates a manifest JSON file and returns the path .
18,233
public function generateOccurrences ( Array $ events , \ DateTime $ fromDate , \ DateTime $ toDate , $ limit = null ) { $ return = array ( ) ; $ object = $ this ; $ monthlyEvents = array_filter ( $ events , function ( $ event ) use ( $ object ) { return $ event -> getRecurrenceType ( ) === $ object -> getLabel ( ) ; } ...
Generate the occurrences for each monthly recurring event .
18,234
public function addRecurrenceType ( $ type , $ recurrenceType ) { if ( is_string ( $ recurrenceType ) and ! class_exists ( $ recurrenceType ) ) { throw new \ InvalidArgumentException ( "Class {$recurrenceType} does not exist." ) ; } elseif ( ! in_array ( 'Plummer\Calendarful\Recurrence\RecurrenceInterface' , class_impl...
Stores recurrence type class paths when provided with a key and an instance or class path of an implementation .
18,235
public function createRecurrenceType ( $ type ) { if ( ! isset ( $ this -> recurrenceTypes [ $ type ] ) ) { throw new \ OutOfBoundsException ( "A recurrence type called {$type} does not exist within the factory." ) ; } $ recurrenceType = new $ this -> recurrenceTypes [ $ type ] ( ) ; return $ recurrenceType ; }
Creates and returns an instance of a stored recurrence type .
18,236
public function createPackageSignature ( Certificate $ certificate , Package $ package ) { $ pkcs12 = $ certificate -> getCertificateString ( ) ; $ certPassword = $ certificate -> getPassword ( ) ; $ certs = array ( ) ; if ( ! openssl_pkcs12_read ( $ pkcs12 , $ certs , $ certPassword ) ) { throw new RuntimeException ( ...
Creates a package signature using the given certificate and package directory .
18,237
public function generateOccurrences ( Array $ events , \ DateTime $ fromDate , \ DateTime $ toDate , $ limit = null ) { $ return = array ( ) ; $ object = $ this ; $ dailyEvents = array_filter ( $ events , function ( $ event ) use ( $ object ) { return $ event -> getRecurrenceType ( ) === $ object -> getLabel ( ) ; } ) ...
Generate the occurrences for each daily recurring event .
18,238
public function generateOccurrences ( Array $ events , \ DateTime $ fromDate , \ DateTime $ toDate , $ limit = null ) { $ return = array ( ) ; $ object = $ this ; $ weeklyEvents = array_filter ( $ events , function ( $ event ) use ( $ object ) { return $ event -> getRecurrenceType ( ) === $ object -> getLabel ( ) ; } )...
Generate the occurrences for each weekly recurring event .
18,239
public function getBinaryMessage ( ) { $ encodedPayload = $ this -> jsonEncode ( $ this -> payload -> getPayload ( ) ) ; return chr ( 0 ) . chr ( 0 ) . chr ( 32 ) . pack ( 'H*' , $ this -> deviceToken ) . chr ( 0 ) . chr ( strlen ( $ encodedPayload ) ) . $ encodedPayload ; }
Returns a binary message that the Apple Push Notification Service understands .
18,240
public function addCalendarType ( $ type , $ calendarType ) { if ( is_string ( $ calendarType ) and ! class_exists ( $ calendarType ) ) { throw new \ InvalidArgumentException ( "Class {$calendarType} does not exist." ) ; } elseif ( ! in_array ( 'Plummer\Calendarful\Calendar\CalendarInterface' , class_implements ( $ cal...
Stores calendar type class paths when provided with a key and an instance or class path of an implementation .
18,241
public function createCalendar ( $ type ) { if ( ! isset ( $ this -> calendarTypes [ $ type ] ) ) { throw new \ OutOfBoundsException ( "A calendar type called {$type} does not exist within the factory." ) ; } $ calendar = new $ this -> calendarTypes [ $ type ] ( ) ; return $ calendar ; }
Creates and returns an instance of a stored calendar type .
18,242
public function findQuery ( $ cmd ) { foreach ( $ cmd as $ backend => $ val ) if ( preg_match ( '/' . $ backend . '/' , $ this -> db -> driver ( ) ) ) return $ val ; trigger_error ( sprintf ( 'DB Engine `%s` is not supported for this action.' , $ this -> db -> driver ( ) ) , E_USER_ERROR ) ; }
parse command array and return backend specific query
18,243
public function getDatabases ( ) { $ cmd = array ( 'mysql' => 'SHOW DATABASES' , 'pgsql' => 'SELECT datname FROM pg_catalog.pg_database' , 'mssql|sybase|dblib|sqlsrv|odbc' => 'EXEC SP_HELPDB' , ) ; $ query = $ this -> findQuery ( $ cmd ) ; if ( ! $ query ) return false ; $ result = $ this -> db -> exec ( $ query ) ; if...
get a list of all databases
18,244
public function getTables ( ) { $ cmd = array ( 'mysql' => array ( "show tables" ) , 'sqlite2?' => array ( "SELECT name FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" ) , 'pgsql|sybase|dblib' => array ( "select table_name from information_schema.tables where table_schema = 'public'" ) , 'mssql|sqlsr...
get all tables of current DB
18,245
public function renameTable ( $ name , $ new_name , $ exec = true ) { $ name = $ this -> db -> quotekey ( $ name ) ; $ new_name = $ this -> db -> quotekey ( $ new_name ) ; if ( preg_match ( '/odbc/' , $ this -> db -> driver ( ) ) ) { $ queries = array ( ) ; $ queries [ ] = "SELECT * INTO $new_name FROM $name;" ; $ quer...
rename a table
18,246
public function truncateTable ( $ name , $ exec = true ) { if ( is_object ( $ name ) && $ name instanceof TableBuilder ) $ name = $ name -> name ; $ cmd = array ( 'mysql|ibm|pgsql|sybase|dblib|mssql|sqlsrv|odbc' => 'TRUNCATE TABLE ' . $ this -> db -> quotekey ( $ name ) . ';' , 'sqlite2?' => array ( 'DELETE FROM ' . $ ...
clear a table
18,247
public function isCompatible ( $ colType , $ colDef ) { $ raw_type = $ this -> findQuery ( $ this -> dataTypes [ strtoupper ( $ colType ) ] ) ; preg_match_all ( '/(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))/' , $ raw_type , $ match ) ; return ( bool ) preg_match_all ( '/' . preg_quote ( $ match [ 'type' ] [ 0 ] ) . '($...
check if a data type is compatible with a given column definition
18,248
public function addColumn ( $ key , $ args = null ) { if ( $ key instanceof Column ) { $ args = $ key -> getColumnArray ( ) ; $ key = $ key -> name ; } if ( array_key_exists ( $ key , $ this -> columns ) ) trigger_error ( sprintf ( self :: TEXT_ColumnExists , $ key ) , E_USER_ERROR ) ; $ column = new Column ( $ key , $...
add a new column to this table
18,249
protected function assembleIndexKey ( $ index_cols , $ table_name ) { if ( ! is_array ( $ index_cols ) ) $ index_cols = array ( $ index_cols ) ; $ name = $ table_name . ' ' . implode ( '__' , $ index_cols ) ; if ( strlen ( $ name ) > 64 ) $ name = $ table_name . ' ' . \ Base :: instance ( ) -> hash ( implode ( '__' , $...
create index name from one or more given column names max . 64 char lengths
18,250
public function _sqlite_increment_trigger ( $ pkey ) { $ table = $ this -> db -> quotekey ( $ this -> name ) ; $ pkey = $ this -> db -> quotekey ( $ pkey ) ; $ triggerName = $ this -> db -> quotekey ( $ this -> name . '_insert' ) ; $ queries [ ] = "DROP TRIGGER IF EXISTS $triggerName;" ; $ queries [ ] = 'CREATE TRIGGER...
create an insert trigger to work - a - round auto - incrementation in composite primary keys
18,251
public function getCols ( $ types = false ) { $ schema = $ this -> db -> schema ( $ this -> name , null , 0 ) ; if ( ! $ types ) return array_keys ( $ schema ) ; else foreach ( $ schema as $ name => & $ cols ) { $ default = ( $ cols [ 'default' ] === '' ) ? null : $ cols [ 'default' ] ; if ( ! is_null ( $ default ) && ...
get columns of a table
18,252
public function isCompatible ( $ colType , $ column ) { $ cols = $ this -> getCols ( true ) ; return $ this -> schema -> isCompatible ( $ colType , $ cols [ $ column ] [ 'type' ] ) ; }
check if a data type is compatible with an existing column type
18,253
public function dropColumn ( $ name ) { $ colTypes = $ this -> getCols ( true ) ; if ( ! in_array ( $ name , array_keys ( $ colTypes ) ) ) return true ; if ( preg_match ( '/sqlite2?/' , $ this -> db -> driver ( ) ) ) { $ this -> rebuild_cmd [ 'drop' ] [ ] = $ name ; } else { $ quotedTable = $ this -> db -> quotekey ( $...
removes a column from a table
18,254
public function renameColumn ( $ name , $ new_name ) { $ existing_columns = $ this -> getCols ( true ) ; if ( ! in_array ( $ name , array_keys ( $ existing_columns ) ) ) trigger_error ( 'cannot rename column. it does not exist.' , E_USER_ERROR ) ; if ( in_array ( $ new_name , array_keys ( $ existing_columns ) ) ) trigg...
rename a column
18,255
public function updateColumn ( $ name , $ datatype , $ force = false ) { if ( $ datatype instanceof Column ) { $ col = $ datatype ; $ datatype = $ col -> type ; $ force = $ col -> passThrough ; } if ( ! $ force ) $ datatype = $ this -> findQuery ( $ this -> schema -> dataTypes [ strtoupper ( $ datatype ) ] ) ; $ table ...
modifies column datatype
18,256
public function dropIndex ( $ name ) { if ( is_array ( $ name ) ) $ name = $ this -> name . ' ' . implode ( '__' , $ name ) ; elseif ( ! is_int ( strpos ( $ name , ' ' ) ) ) $ name = $ this -> name . ' ' . $ name ; $ name = $ this -> db -> quotekey ( $ name ) ; $ table = $ this -> db -> quotekey ( $ this -> name ) ; $ ...
drop a column index
18,257
public function listIndex ( ) { $ table = $ this -> db -> quotekey ( $ this -> name ) ; $ cmd = array ( 'sqlite2?' => "PRAGMA index_list($table);" , 'mysql' => "SHOW INDEX FROM $table;" , 'mssql|sybase|dblib|sqlsrv' => "select * from sys.indexes " . "where object_id = (select object_id from sys.objects where name = '$t...
returns table indexes as assoc array
18,258
public function rename ( $ new_name , $ exec = true ) { $ query = $ this -> schema -> renameTable ( $ this -> name , $ new_name , $ exec ) ; $ this -> name = $ new_name ; return ( $ exec ) ? $ this : $ query ; }
rename this table
18,259
public function copyfrom ( $ args ) { if ( ( $ args || \ Base :: instance ( ) -> exists ( $ args , $ args ) ) && is_array ( $ args ) ) foreach ( $ args as $ arg => $ val ) $ this -> { $ arg } = $ val ; }
feed column from array or hive key
18,260
public function getColumnArray ( ) { $ fields = array ( 'name' , 'type' , 'passThrough' , 'default' , 'nullable' , 'index' , 'unique' , 'after' , 'pkey' ) ; $ fields = array_flip ( $ fields ) ; foreach ( $ fields as $ key => & $ val ) $ val = $ this -> { $ key } ; unset ( $ val ) ; return $ fields ; }
returns an array of this column configuration
18,261
public function getTypeVal ( ) { if ( ! $ this -> type ) trigger_error ( sprintf ( 'Cannot build a column query for `%s`: no column type set' , $ this -> name ) , E_USER_ERROR ) ; if ( $ this -> passThrough ) $ this -> type_val = $ this -> type ; else { $ this -> type_val = $ this -> findQuery ( $ this -> schema -> dat...
return resolved column datatype
18,262
public function getColumnQuery ( ) { $ type_val = $ this -> getTypeVal ( ) ; $ query = $ this -> db -> quotekey ( $ this -> name ) . ' ' . $ type_val . ' ' . $ this -> getNullable ( ) ; if ( preg_match ( '/bool/i' , $ type_val ) && $ this -> default !== null ) $ this -> default = ( int ) $ this -> default ; if ( $ this...
generate SQL column definition query
18,263
public function getDefault ( ) { if ( $ this -> default === Schema :: DF_CURRENT_TIMESTAMP ) { $ stamp_type = $ this -> findQuery ( $ this -> schema -> dataTypes [ 'TIMESTAMP' ] ) ; if ( $ this -> type != 'TIMESTAMP' && ( $ this -> passThrough && strtoupper ( $ this -> type ) != strtoupper ( $ stamp_type ) ) ) trigger_...
return query part for default value
18,264
public function write ( $ binaryMessage ) { if ( strlen ( $ binaryMessage ) > self :: PAYLOAD_MAX_BYTES ) { throw new \ InvalidArgumentException ( sprintf ( 'The maximum size allowed for a notification payload is %s bytes; Apple Push Notification Service refuses any notification that exceeds this limit.' , self :: PAYL...
Writes a binary message to apns .
18,265
protected function applyOrderBy ( array $ data , $ orderBy ) { if ( ! empty ( $ orderBy ) ) { ArrayHelper :: multisort ( $ data , array_keys ( $ orderBy ) , array_values ( $ orderBy ) ) ; } return $ data ; }
Applies sort for given data .
18,266
protected function applyLimit ( array $ data , $ limit , $ offset ) { if ( empty ( $ limit ) && empty ( $ offset ) ) { return $ data ; } if ( ! ctype_digit ( ( string ) $ limit ) ) { $ limit = null ; } if ( ! ctype_digit ( ( string ) $ offset ) ) { $ offset = 0 ; } return array_slice ( $ data , $ offset , $ limit ) ; }
Applies limit and offset for given data .
18,267
public function filterCondition ( array $ data , $ condition ) { if ( empty ( $ condition ) ) { return $ data ; } if ( ! is_array ( $ condition ) ) { throw new InvalidParamException ( 'Condition must be an array' ) ; } if ( isset ( $ condition [ 0 ] ) ) { $ operator = strtoupper ( $ condition [ 0 ] ) ; if ( isset ( $ t...
Applies filter conditions .
18,268
public function filterHashCondition ( array $ data , $ condition ) { foreach ( $ condition as $ column => $ value ) { if ( is_array ( $ value ) ) { $ data = $ this -> filterInCondition ( $ data , 'IN' , [ $ column , $ value ] ) ; } else { $ data = array_filter ( $ data , function ( $ row ) use ( $ column , $ value ) { ...
Applies a condition based on column - value pairs .
18,269
protected function filterAndCondition ( array $ data , $ operator , $ operands ) { foreach ( $ operands as $ operand ) { if ( is_array ( $ operand ) ) { $ data = $ this -> filterCondition ( $ data , $ operand ) ; } } return $ data ; }
Applies 2 or more conditions using AND logic .
18,270
protected function filterOrCondition ( array $ data , $ operator , $ operands ) { $ parts = [ ] ; foreach ( $ operands as $ operand ) { if ( is_array ( $ operand ) ) { $ parts [ ] = $ this -> filterCondition ( $ data , $ operand ) ; } } if ( empty ( $ parts ) ) { return $ data ; } $ data = [ ] ; foreach ( $ parts as $ ...
Applies 2 or more conditions using OR logic .
18,271
protected function filterNotCondition ( array $ data , $ operator , $ operands ) { if ( count ( $ operands ) != 1 ) { throw new InvalidParamException ( "Operator '$operator' requires exactly one operand." ) ; } $ operand = reset ( $ operands ) ; $ filteredData = $ this -> filterCondition ( $ data , $ operand ) ; if ( e...
Inverts a filter condition .
18,272
protected function filterBetweenCondition ( array $ data , $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] , $ operands [ 2 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires three operands." ) ; } list ( $ column , $ value1 , $ value2 ) = $ operands ; if ( strncmp (...
Applies BETWEEN condition .
18,273
protected function filterInCondition ( array $ data , $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires two operands." ) ; } list ( $ column , $ values ) = $ operands ; if ( $ values === [ ] || $ column === [ ] ) { retur...
Applies IN condition .
18,274
protected function filterLikeCondition ( array $ data , $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires two operands." ) ; } list ( $ column , $ values ) = $ operands ; if ( ! is_array ( $ values ) ) { $ values = [ $ v...
Applies LIKE condition .
18,275
public function filterCallbackCondition ( array $ data , $ operator , $ operands ) { if ( count ( $ operands ) != 1 ) { throw new InvalidParamException ( "Operator '$operator' requires exactly one operand." ) ; } $ callback = reset ( $ operands ) ; return array_filter ( $ data , $ callback ) ; }
Applies CALLBACK condition .
18,276
public function parse ( $ input ) { $ tidy = new PhpTidy ; $ tidy -> parseString ( $ input , $ this -> tidy_options , $ this -> encoding ) ; $ tidy -> cleanRepair ( ) ; $ output = $ this -> doctype . "\n" . preg_replace ( '_ xmlns="http://www.w3.org/1999/xhtml"_' , null , $ tidy , 1 ) ; if ( $ this -> display_errors an...
Parse response with PHP s HTML Tidy extension
18,277
public function selectLayoutBasedOnRoute ( MvcEvent $ e ) { $ app = $ e -> getParam ( 'application' ) ; $ sm = $ app -> getServiceManager ( ) ; $ config = $ sm -> get ( 'config' ) ; if ( false === $ config [ 'zfcadmin' ] [ 'use_admin_layout' ] ) { return ; } $ match = $ e -> getRouteMatch ( ) ; $ controller = $ e -> ge...
Select the admin layout based on route name
18,278
public function addCondition ( $ recordField , $ operator , $ value ) { $ this -> conditions [ ] = [ $ recordField , $ operator , $ value ] ; return $ this ; }
Add a condition to this query
18,279
protected function assertCondition ( $ record , $ condition ) { $ left = $ condition [ 0 ] ; $ op = $ condition [ 1 ] ; $ right = $ condition [ 2 ] ; switch ( $ op ) { case '=' : $ value = $ this -> getRecordField ( $ record , $ left ) ; return $ value == $ right ; case '==' : $ value = $ this -> getRecordField ( $ rec...
Check if a single record should be matched for a single Query condition
18,280
protected function getFilename ( $ collection ) { $ file = rtrim ( $ this -> storageDir , '/' ) . '/' . $ collection ; if ( ! file_exists ( $ file ) ) { file_put_contents ( $ file , serialize ( [ ] ) ) ; chmod ( $ file , 0777 ) ; } return $ file ; }
Get the corresponding file path for a given collection
18,281
public function handle ( ReadQuery $ query ) { $ this -> validateQuery ( $ query ) ; $ records = $ this -> getAllRecordsMatchingQueryConditions ( $ query ) ; $ this -> sortRecords ( $ records , $ query ) ; $ this -> limitRecords ( $ records , $ query ) ; return new Collection ( $ records ) ; }
Handle a ReadQuery and return the records in a \ Flatbase \ Collection
18,282
protected function getAllRecordsMatchingQueryConditions ( ReadQuery $ query ) { $ records = [ ] ; foreach ( $ this -> getIterator ( $ query -> getCollection ( ) ) as $ record ) { $ records [ ] = $ record ; } if ( ! $ query -> getConditions ( ) ) { return $ records ; } foreach ( $ records as $ key => $ record ) { if ( !...
Get all the records in a collection matching the Query conditions
18,283
protected function getConfig ( ) { $ configPath = $ this -> input -> getOption ( 'config' ) ? : ( getcwd ( ) . '/flatbase.json' ) ; $ defaults = new \ stdClass ( ) ; $ defaults -> path = null ; if ( file_exists ( $ configPath ) ) { foreach ( json_decode ( file_get_contents ( $ configPath ) ) as $ property => $ value ) ...
Get the config data
18,284
protected function getFlatbase ( $ storagePath ) { $ factory = $ this -> factory ; return $ factory ? $ factory ( $ storagePath ) : new Flatbase ( new Filesystem ( $ storagePath ) ) ; }
Get a Flatbase object for a given storage path .
18,285
protected function resolveHandler ( Query $ query ) { if ( $ query instanceof ReadQuery ) { return new ReadQueryHandler ( $ this ) ; } if ( $ query instanceof InsertQuery ) { return new InsertQueryHandler ( $ this ) ; } if ( $ query instanceof DeleteQuery ) { return new DeleteQueryHandler ( $ this ) ; } if ( $ query in...
Find the appropriate handler for a given Query
18,286
public function storeMenu ( Menu $ menu ) { $ this -> client -> send ( new Request ( 'POST' , "https://api.weixin.qq.com/cgi-bin/menu/create" , [ ] , json_encode ( $ this -> reduceMenu ( $ menu ) ) ) ) ; }
Creates a menu for the OA .
18,287
public function fetchCurrentMenu ( ) { $ request = new Request ( "GET" , "https://api.weixin.qq.com/cgi-bin/menu/get" ) ; $ response = $ this -> client -> send ( $ request ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) ) ; if ( ! isset ( $ json -> menu -> button ) ) { throw new Exception ( 'Unexpected ...
Retrieve the current menu for the OA and return it as an instance of Garbetjie \ WeChatClient \ Menu \ Menu .
18,288
protected function validateItem ( MenuItem $ item ) { if ( count ( $ item -> getChildren ( ) ) > 0 ) { foreach ( $ item -> getChildren ( ) as $ childItem ) { if ( ! $ this -> validateItem ( $ childItem ) ) { return false ; } } if ( strlen ( $ item -> getTitle ( ) ) > 16 ) { return false ; } return true ; } if ( strlen ...
Validates whether the supplied item qualifies as a valid menu item .
18,289
protected function reduceMenu ( Menu $ menu ) { $ reduced = [ 'button' => [ ] ] ; foreach ( $ menu -> getItems ( ) as $ menuItem ) { $ reduced [ 'button' ] [ ] = $ this -> reduceItem ( $ menuItem ) ; } return $ reduced ; }
Reduces the supplied menu into its array equivalent ready for sending to the WeChat API .
18,290
protected function reduceItem ( MenuItem $ item ) { $ reduced = [ 'name' => $ item -> getTitle ( ) ] ; if ( count ( $ item -> getChildren ( ) ) > 0 ) { $ reduced [ 'sub_button' ] = [ ] ; foreach ( $ item -> getChildren ( ) as $ childItem ) { $ reduced [ 'sub_button' ] [ ] = $ this -> reduceItem ( $ childItem ) ; } } el...
Reduces a menu item and returns it as an array that can be used in a request to the WeChat API .
18,291
protected function inflateItem ( $ item ) { if ( isset ( $ item -> sub_button ) & count ( $ item -> sub_button ) > 0 ) { $ object = new MenuItem ( $ item -> name , MenuItem :: KEYWORD ) ; foreach ( $ item -> sub_button as $ subItem ) { $ object = $ object -> withItem ( $ this -> inflateItem ( $ subItem ) ) ; } } else {...
Inflate the given array representation of an item and return it as an instance of Garbetjie \ WeChatClient \ Menu \ MenuItem .
18,292
public function fetchTemporaryImage ( $ mediaID , $ into = null ) { return new Downloaded \ Image ( $ mediaID , $ this -> doTemporaryFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a temporary image .
18,293
public function fetchPermanentImage ( $ mediaID , $ into = null ) { return new Downloaded \ Image ( $ mediaID , $ this -> doPermanentFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a permanent image .
18,294
public function fetchTemporaryAudio ( $ mediaID , $ into = null ) { return new Downloaded \ Audio ( $ mediaID , $ this -> doTemporaryFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a temporary audio item .
18,295
public function fetchPermanentAudio ( $ mediaID , $ into = null ) { return new Downloaded \ Audio ( $ mediaID , $ this -> doPermanentFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a permanent audio item .
18,296
public function fetchTemporaryThumbnail ( $ mediaID , $ into = null ) { return new Downloaded \ Thumbnail ( $ mediaID , $ this -> doTemporaryFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a temporary thumbnail item .
18,297
public function fetchPermanentThumbnail ( $ mediaID , $ into = null ) { return new Downloaded \ Thumbnail ( $ mediaID , $ this -> doPermanentFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a permanent thumbnail item .
18,298
public function fetchPermanentNews ( $ mediaID ) { $ stream = $ this -> doPermanentFetchToStream ( $ mediaID , null ) ; $ json = json_decode ( stream_get_contents ( $ stream ) ) ; return $ this -> expandNews ( $ json -> news_item , new Downloaded \ News ( $ mediaID , $ json -> update_time ) ) ; }
Downloads the specified permanent news item and returns an object representation of it .
18,299
public function fetchTemporaryVideo ( $ mediaID , $ into = null ) { return new Downloaded \ Video ( $ mediaID , $ this -> doTemporaryFetchToStream ( $ mediaID , $ into ) ) ; }
Downloads a temporary video .