idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
2,200
public function applyCookies ( $ cookies ) { $ headers = $ this -> headers ( ) ; foreach ( $ cookies as $ cookie ) { $ headers [ 'Set-Cookie' ] [ ] = $ cookie -> toString ( ) ; } return $ this ; }
Set the Set - Cookie header
2,201
public function cookies ( $ request ) { $ headers = $ response -> headers ( ) ; if ( ! isset ( $ headers [ 'Set-Cookie' ] ) ) { return [ ] ; } $ setCookies = [ ] ; foreach ( $ headers [ 'Set-Cookie' ] as $ setCookieHeader ) { $ setCookie = Cookie :: fromString ( $ setCookieHeader ) ; if ( ! $ setCookie -> domain ( ) ) ...
Extract cookies .
2,202
public function redirect ( $ location , $ status = 302 ) { if ( ! $ location ) { return ; } $ this -> status ( $ status ) ; $ headers = $ this -> headers ( ) ; $ headers [ 'Location' ] = $ location ; return $ this ; }
Set a redirect location .
2,203
public function export ( $ options = [ ] ) { $ this -> _setContentLength ( ) ; return [ 'status' => $ this -> status ( ) , 'version' => $ this -> version ( ) , 'headers' => $ this -> headers ( ) , 'body' => $ this -> stream ( ) ] ; }
Exports a Response instance to an array .
2,204
public static function parse ( $ message , $ options = [ ] ) { $ parts = explode ( "\r\n\r\n" , $ message , 2 ) ; if ( count ( $ parts ) < 2 ) { throw new NetException ( "The CRLFCRLF separator between headers and body is missing." ) ; } $ response = new static ( $ options + [ 'format' => null ] ) ; list ( $ header , $...
Creates a response instance from an entire HTTP message including HTTP status headers and body .
2,205
public static function encode ( $ body , $ encoding , $ wrapWidth = 76 , $ le = "\r\n" , $ cut = false ) { $ encoding = strtolower ( $ encoding ) ; switch ( $ encoding ) { case 'quoted-printable' : $ body = quoted_printable_encode ( $ body ) ; return $ wrapWidth ? rtrim ( chunk_split ( $ body , $ wrapWidth , $ le ) ) :...
Encoding method .
2,206
public static function encodeEmail ( $ email ) { if ( ( $ pos = strpos ( $ email , '@' ) ) === false ) { return ; } if ( ! preg_match ( '~[\x80-\xFF]~' , $ email ) ) { return $ email ; } $ domain = substr ( $ email , ++ $ pos ) ; return substr ( $ email , 0 , $ pos ) . idn_to_ascii ( $ domain , 0 , INTL_IDNA_VARIANT_UT...
Punycode email address to its ASCII form also known as punycode .
2,207
public static function encodeValue ( $ value , $ wrapWidth = 998 , $ folding = "\r\n " ) { if ( ! preg_match ( '~[^\x00-\x7F]~' , $ value ) ) { $ encoding = '7bit' ; } elseif ( preg_match_all ( '/[\000-\010\013\014\016-\037\177-\377]/' , $ value ) > ( strlen ( $ value ) / 3 ) ) { $ encoding = 'base64' ; } else { $ enco...
MIME - encode a value to its mots suitable format
2,208
function getEndpoint ( ) { $ endpoint = $ this -> endpointBase ; if ( $ this -> spaceId ) { $ endpoint .= '/' . $ this -> spaceId ; } return $ endpoint ; }
Get the endpoint .
2,209
function build_url ( $ resource , array $ query = array ( ) ) { $ url = $ this -> getEndpoint ( ) ; if ( $ resource && $ this -> spaceId ) $ url .= '/' ; if ( $ resource ) $ url .= $ resource ; if ( ! empty ( $ query ) ) $ url .= '?' . http_build_query ( $ query ) ; return $ url ; }
Build the query URL .
2,210
function buildCacheKey ( $ method , $ resource , $ url , $ headers = array ( ) , $ query = array ( ) ) { return md5 ( $ method . $ resource . $ url . json_encode ( $ query ) . json_encode ( $ headers ) ) ; }
Return a unique key for the query .
2,211
public function autoAddToObjects ( ) { $ modelClassName = PropertiesHelper :: classNameForApplicablePropertyModelId ( $ this -> applicable_property_model_id ) ; $ modelIdsWithoutGroup = $ modelClassName :: find ( ) -> leftJoin ( $ modelClassName :: bindedPropertyGroupsTable ( ) . ' bpg' , 'bpg.model_id = id' ) -> where...
Finds new applicable models and binds this group to them
2,212
public function search ( $ applicablePropertyModelId , $ params , $ showHidden = false ) { $ query = self :: find ( ) -> where ( [ 'applicable_property_model_id' => $ applicablePropertyModelId , ] ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'pagination' => [ 'pageSize' => 10 , ] , ] ) ; $ dataP...
Returns ActiveDataProvider for searching PropertyGroup models
2,213
public function string ( $ str = null ) { if ( $ str !== null ) { foreach ( $ this -> childScanners as $ s ) { $ s -> string ( $ str ) ; } } return parent :: string ( $ str ) ; }
override string to hit the child scanners as well
2,214
public function configurationAction ( ) { $ redirect = $ this -> getRedirect ( ) ; $ installation = $ this -> getInstallation ( ) ; $ step = $ installation -> getCurrentStep ( ) ; $ member = $ step -> getCurrentMember ( ) ; $ validator = $ this -> getValidator ( ) ; if ( ! $ validator instanceof PhpIni ) { throw new Do...
Checks the settings in the php . ini file in accordance with the configuration of the module . If the settings are not compatible the installation process stops and displays the information message .
2,215
protected function combineTo ( Swift_Mime_SimpleMessage $ message ) { return array_merge ( ( array ) $ message -> getTo ( ) , ( array ) $ message -> getCc ( ) , ( array ) $ message -> getBcc ( ) ) ; }
Combine all contacts for the message .
2,216
protected function prepareTo ( Swift_Mime_SimpleMessage $ message ) { $ to = array_map ( function ( $ name , $ address ) { return $ name ? $ name . " <{$address}>" : $ address ; } , $ this -> combineTo ( $ message ) , array_keys ( $ this -> combineTo ( $ message ) ) ) ; return implode ( ',' , $ to ) ; }
Format the to addresses to match Mailgun message . mime format .
2,217
protected function extractToken ( ) { if ( $ this -> request -> input ( 'token' ) === false ) { if ( ! $ this -> request -> getHeader ( 'X-JS-CLIENTS-TOKEN' ) ) { return 'token' ; } return $ this -> request -> getHeader ( 'X-JS-CLIENTS-TOKEN' ) ; } return $ this -> request -> input ( 'token' ) ; }
extract token from form or JavaScript Clients like Axios Ajax JQuery .
2,218
public static function getInstance ( ) { if ( ! static :: $ instance instanceof self ) { static :: $ instance = $ session = new self ( ) ; if ( ! $ session -> isStarted ( ) ) { $ session -> start ( ) ; } } return static :: $ instance ; }
Session singleton .
2,219
public function createFlashMessage ( $ key , $ value ) { $ session = static :: getInstance ( ) ; $ session -> getFlashBag ( ) -> add ( $ key , $ value ) ; }
Add flash message .
2,220
public function getFlashMessage ( $ key ) { $ session = static :: getInstance ( ) ; foreach ( $ session -> getFlashBag ( ) -> get ( $ key , [ ] ) as $ message ) { return $ message ? : null ; } return '' ; }
Get message from flash bag .
2,221
public function getURL ( $ start_timestamp = 0 , $ calendar_guid = 0 ) { if ( ! $ start_timestamp ) { $ start_timestamp = $ this -> getNextOccurrence ( ) ; } $ url = parent :: getURL ( ) ; return elgg_http_add_url_query_elements ( $ url , array_filter ( array ( 'ts' => $ start_timestamp , 'calendar' => $ calendar_guid ...
Returns canonical URL with instance start time added as query element
2,222
public function getCalendars ( $ params = array ( ) , $ public = false ) { $ defaults = array ( 'type' => 'object' , 'subtype' => 'calendar' , 'relationship' => Calendar :: EVENT_CALENDAR_RELATIONSHIP , 'relationship_guid' => $ this -> guid , 'limit' => false ) ; $ options = array_merge ( $ defaults , $ params ) ; if (...
Get all calendars this event is on
2,223
public function move ( $ params ) { $ this -> all_day = elgg_extract ( 'all_day' , $ params , false ) ; $ this -> start_timestamp = $ params [ 'new_start_timestamp' ] ; $ this -> end_timestamp = $ params [ 'new_end_timestamp' ] ; $ this -> start_date = $ params [ 'new_start_date' ] ; $ this -> end_date = $ params [ 'ne...
Perform a move action with calculated parameters
2,224
public function resize ( $ params ) { $ this -> end_timestamp = $ params [ 'new_end_timestamp' ] ; $ this -> end_date = $ params [ 'new_end_date' ] ; $ this -> end_time = $ params [ 'new_end_time' ] ; $ this -> end_delta = $ params [ 'new_end_timestamp' ] - $ this -> getStartTimestamp ( ) ; $ this -> repeat_end_timesta...
Extends event duration
2,225
public function getMoveParams ( $ day_delta , $ minute_delta , $ all_day = false ) { $ start_timestamp = $ this -> getStartTimestamp ( ) ; $ end_timestamp = $ this -> getEndTimestamp ( ) ; $ time_diff = $ end_timestamp - $ start_timestamp ; $ new_start_timestamp = $ start_timestamp + ( $ day_delta * Util :: SECONDS_IN_...
Calculates parameters for a move action
2,226
public function getResizeParams ( $ day_delta = 0 , $ minute_delta = 0 ) { $ end_timestamp = $ this -> getEndTimestamp ( ) ; $ new_end_timestamp = $ end_timestamp + ( $ day_delta * Util :: SECONDS_IN_A_DAY ) + ( $ minute_delta * Util :: SECONDS_IN_A_MINUTE ) ; $ params = array ( 'entity' => $ this , 'new_end_timestamp'...
Calculates parameters for the resize action
2,227
public function calculateRepeatEndTimestamp ( ) { switch ( $ this -> repeat_end_type ) { case Util :: REPEAT_END_ON : $ repeat_end_timestamp = strtotime ( $ this -> repeat_end_on ) ; if ( $ repeat_end_timestamp === false ) { $ repeat_end_timestamp = 0 ; } $ return = $ repeat_end_timestamp ; break ; case Util :: REPEAT_...
Calculates and returns the last timestamp for event recurrences
2,228
public function getNextOccurrence ( $ after_timestamp = null ) { if ( $ after_timestamp === null ) { $ after_timestamp = time ( ) ; } $ after_timestamp = ( int ) $ after_timestamp ; $ next = false ; if ( $ this -> isRecurring ( ) ) { $ next = $ this -> calculateEndAfterTimestamp ( 1 , $ after_timestamp , false ) ; } el...
Returns the start timestamp of the next event occurence Returns false if there are no future occurrences
2,229
public function getLastOccurrence ( $ before_timestamp = null ) { if ( $ before_timestamp === null ) { $ before_timestamp = time ( ) ; } $ before_timestamp = ( int ) $ before_timestamp ; $ prev = false ; if ( $ this -> isRecurring ( ) ) { $ starttimes = $ this -> getStartTimes ( $ this -> getStartTimestamp ( ) , $ befo...
Returns the timestamp of the previous event occurence Returns false if there are no past occurrences
2,230
public function buildReminders ( $ starttime , $ endtime ) { if ( ! $ this -> hasReminders ( ) ) { return true ; } $ starttime = sanitize_int ( $ starttime ) ; $ endtime = sanitize_int ( $ endtime ) ; $ this -> removeReminders ( $ starttime , $ endtime ) ; $ reminders = elgg_get_metadata ( array ( 'guid' => $ this -> g...
Creates reminder annotations for this event
2,231
public function indexAction ( ) { if ( ! $ this -> params ( ) -> fromRoute ( 'process' ) ) { return new ViewModel ( ) ; } $ installation = $ this -> getInstallation ( ) ; $ redirect = $ this -> getRedirect ( ) ; $ step = $ installation -> getCurrentStep ( ) ; $ member = $ step -> getCurrentMember ( ) ; $ service = $ th...
Runs services specified in the configuration .
2,232
public function getAllEvents ( $ starttime = null , $ endtime = null ) { if ( is_null ( $ starttime ) ) { $ starttime = time ( ) ; } if ( is_null ( $ endtime ) ) { $ endtime = strtotime ( '+1 year' , $ starttime ) ; } $ starttime = sanitize_int ( $ starttime ) ; $ endtime = sanitize_int ( $ endtime ) ; $ relationship_n...
Returns all event objects
2,233
public static function compareInstancesByStartTime ( $ a , $ b ) { $ start_a = $ a -> getStartTimestamp ( ) ; $ start_b = $ b -> getStartTimestamp ( ) ; if ( $ start_a == $ start_b ) { return 0 ; } return ( $ start_a < $ start_b ) ? - 1 : 1 ; }
Compares two event instances by start time
2,234
public function getRecurringEvents ( $ starttime = null , $ endtime = null ) { if ( is_null ( $ starttime ) ) { $ starttime = time ( ) ; } if ( is_null ( $ endtime ) ) { $ endtime = strtotime ( '+1 year' , $ starttime ) ; } $ starttime = sanitize_int ( $ starttime ) ; $ endtime = sanitize_int ( $ endtime ) ; $ relation...
Returns a batch of recurring events in a given time range
2,235
public function getOneTimeEvents ( $ starttime = null , $ endtime = null ) { if ( is_null ( $ starttime ) ) { $ starttime = time ( ) ; } if ( is_null ( $ endtime ) ) { $ endtime = strtotime ( '+1 year' , $ starttime ) ; } $ starttime = sanitize_int ( $ starttime ) ; $ endtime = sanitize_int ( $ endtime ) ; $ relationsh...
Returns one - time events
2,236
public function hasEvent ( $ event ) { return ( bool ) check_entity_relationship ( $ event -> guid , self :: EVENT_CALENDAR_RELATIONSHIP , $ this -> guid ) ; }
Checks if the event is on calendar
2,237
public function getIcalURL ( $ base_url = '' , array $ params = array ( ) ) { $ user = elgg_get_logged_in_user_entity ( ) ; $ params [ 'view' ] = 'ical' ; $ params [ 'u' ] = $ user -> guid ; $ params [ 't' ] = $ this -> getUserToken ( $ user -> guid ) ; $ url = elgg_http_add_url_query_elements ( $ base_url , $ params )...
Returns a URL of the iCal feed
2,238
public function toIcal ( $ starttime = null , $ endtime = null , $ filename = 'calendar.ics' ) { if ( is_null ( $ starttime ) ) { $ starttime = time ( ) ; } if ( is_null ( $ endtime ) ) { $ endtime = strtotime ( '+1 year' , $ starttime ) ; } $ instances = $ this -> getAllEventInstances ( $ starttime , $ endtime , true ...
Returns an iCal feed for this calendar
2,239
public static function createPublicCalendar ( $ container ) { if ( ! $ container instanceof ElggEntity ) { return false ; } try { $ calendar = new Calendar ( ) ; $ calendar -> access_id = ACCESS_PUBLIC ; $ calendar -> owner_guid = $ container -> guid ; $ calendar -> container_guid = $ container -> guid ; $ calendar -> ...
Creates a public calendar for a container
2,240
public static function getCalendars ( $ container , $ count = false ) { if ( ! $ container instanceof ElggEntity ) { return false ; } $ options = array ( 'type' => 'object' , 'subtype' => 'calendar' , 'container_guid' => $ container -> guid , 'limit' => false ) ; if ( $ count ) { $ options [ 'count' ] = true ; return e...
Retrieves all calendars for a container
2,241
public static function getPublicCalendar ( $ container ) { if ( ! $ container instanceof ElggEntity ) { return false ; } $ calendars = elgg_get_entities ( array ( 'type' => 'object' , 'subtype' => Calendar :: SUBTYPE , 'container_guid' => $ container -> guid , 'limit' => 1 , 'metadata_name_value_pairs' => array ( 'name...
Retrieves user s or group s public calendar
2,242
public function getMemberships ( Communicator $ communicator = null ) : ClassValidationArray { if ( $ communicator !== null ) { $ membershipJSON = $ communicator -> get ( "api/groups/" . $ this -> groupID . "/memberships" ) ; $ membershipStd = json_decode ( $ membershipJSON ) ; $ memberships = [ ] ; foreach ( $ members...
Returns an array of all the memberships the group is referenced in . If a communicator is not provided it will not fetch memberships from the API but return those that has been fetched if any .
2,243
public function getContacts ( Communicator $ communicator = null ) : ClassValidationArray { if ( $ communicator !== null ) { $ contactStd = $ communicator -> get ( 'api/groups/' . $ this -> groupID . '/contacts' ) ; $ contactStd = json_decode ( $ contactStd ) ; $ contacts = RecipientFactory :: createProcessedGroupsFrom...
Returns an array of all the Contacts that belong to the Group . If a communicator is not provided it will not fetch Contacts from the API but return those that has been fetched if any .
2,244
public function openHandler ( & $ parser , $ name , $ attrs , $ closed ) { foreach ( $ attrs as $ key => $ attr ) { $ attrs [ $ key ] = $ this -> parseData ( $ attr ) ; } if ( $ closed ) { $ this -> tokens [ ] = new HTMLPurifier_Token_Empty ( $ name , $ attrs ) ; } else { $ this -> tokens [ ] = new HTMLPurifier_Token_S...
Open tag event handler interface is defined by PEAR package .
2,245
public function closeHandler ( & $ parser , $ name ) { if ( $ this -> tokens [ count ( $ this -> tokens ) - 1 ] instanceof HTMLPurifier_Token_Empty ) { return true ; } $ this -> tokens [ ] = new HTMLPurifier_Token_End ( $ name ) ; return true ; }
Close tag event handler interface is defined by PEAR package .
2,246
public function escapeHandler ( & $ parser , $ data ) { if ( strpos ( $ data , '--' ) === 0 ) { $ this -> tokens [ ] = new HTMLPurifier_Token_Comment ( $ data ) ; } return true ; }
Escaped text handler interface is defined by PEAR package .
2,247
public function findExistingWidgets ( $ theme , $ names ) { if ( ! is_array ( $ names ) ) { $ names = [ $ names ] ; } $ select = $ this -> getSql ( ) -> select ( ) -> from ( $ this -> getTable ( self :: LayoutTableAlias ) ) -> columns ( [ 'name' , ] ) -> where ( [ 'theme' => $ theme , 'name' => $ names , ] ) ; $ result...
Returns the names of the widgets from a predefined list that are registered in the database .
2,248
private function isResolvableCallable ( Invokable $ reflectedCallable ) : bool { $ callable = $ reflectedCallable -> callable ( ) ; return $ reflectedCallable -> isFunction ( ) || is_object ( $ callable [ 0 ] ) || $ this -> isResolvableService ( $ callable [ 0 ] ) ; }
Verifies that provided callable can be called by service container .
2,249
private function register ( string $ id , bool $ shared , Closure $ registrationCallback ) { $ this -> validateId ( $ id ) ; $ id = $ this -> normalize ( $ id ) ; unset ( $ this -> instances [ $ id ] , $ this -> shared [ $ id ] , $ this -> keys [ $ id ] ) ; $ registrationCallback ( $ id ) ; $ this -> shared [ $ id ] = ...
Registers binding . After this method call binding can be resolved by container .
2,250
private function validateId ( string $ id ) { if ( ! interface_exists ( $ id ) && ! class_exists ( $ id ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid service id "%s". Service id must be an existing interface or class name.' , $ id ) ) ; } }
Validate service identifier . Throw an Exception in case of invalid value .
2,251
private function getModelNameFromClass ( $ model_class ) { if ( ( $ pos = strrpos ( $ model_class , '\\' ) ) !== false ) { return Inflector :: pluralize ( Inflector :: tableize ( substr ( $ model_class , $ pos + 1 ) ) ) ; } else { return Inflector :: pluralize ( Inflector :: tableize ( $ model_class ) ) ; } }
Get model name from model class .
2,252
public static function getClassesToRead ( \ ReflectionObject $ reflectionObject ) { $ cacheId = md5 ( "classesToRead:" . $ reflectionObject -> getName ( ) ) ; $ objectClasses = self :: getFromCache ( $ cacheId ) ; if ( $ objectClasses !== null ) { return $ objectClasses ; } $ objectClasses = array ( $ reflectionObject ...
Get a list of classes and traits to analyze .
2,253
public static function getProperties ( $ classes ) { array_reverse ( $ classes ) ; $ properties = array ( ) ; foreach ( $ classes as $ class ) { foreach ( $ class -> getProperties ( ) as $ property ) { $ properties [ $ property -> getName ( ) ] = $ property ; } } return $ properties ; }
Get the properties from a list of classes .
2,254
public static function getClassInformation ( $ object ) { $ reflectionObject = new \ ReflectionObject ( $ object ) ; $ cacheId = md5 ( "classInformation:" . $ reflectionObject -> getName ( ) ) ; $ classInfo = self :: getFromCache ( $ cacheId ) ; if ( $ classInfo !== null ) { return $ classInfo ; } $ objectClasses = sel...
Get the information on a class from its instance .
2,255
public static function saveToCache ( $ id , $ value ) { $ arrayCache = Configuration :: getArrayCache ( ) ; $ cacheDriver = Configuration :: getCacheDriver ( ) ; $ arrayCache -> save ( $ id , $ value ) ; if ( $ cacheDriver !== null ) { $ cacheDriver -> save ( $ id , $ value ) ; } }
Save a value to the cache .
2,256
public static function add ( & $ set , $ args ) { self :: assertArgsNumber ( 1 , $ args ) ; $ value = $ args [ 0 ] ; foreach ( $ set as $ item ) { if ( $ item === $ value ) { return ; } } $ set [ ] = $ value ; }
Adds an element to the set if it is not already present .
2,257
public static function remove ( & $ set , $ args ) { self :: assertArgsNumber ( 1 , $ args ) ; foreach ( $ set as $ key => $ value ) { if ( $ value === $ args [ 0 ] ) { unset ( $ set [ $ key ] ) ; return ; } } }
Removes an element from the set .
2,258
public function dispatch ( ) { foreach ( $ this -> getSubscribers ( ) as $ channelIdentifier => $ subscribers ) { $ channel = $ this -> getChannelFactory ( ) -> getChannel ( $ channelIdentifier ) ; $ message = $ this -> getMessage ( $ channel ) ; $ message = $ this -> decorate ( $ message , $ channel ) ; foreach ( $ su...
Dispatch the event to its subscribers through the subscribed channels .
2,259
public static function getParsers ( ) { $ parsers = [ ] ; $ parserClassList = ClassMapGenerator :: createMap ( base_path ( ) . '/vendor/abuseio' ) ; $ parserClassListFiltered = array_where ( array_keys ( $ parserClassList ) , function ( $ value , $ key ) { if ( strpos ( $ value , 'AbuseIO\Parsers\\' ) !== false ) { ret...
Get a list of installed AbuseIO parsers and return as an array
2,260
public static function create ( $ parsedMail , $ arfMail ) { $ parsers = Factory :: getParsers ( ) ; foreach ( $ parsers as $ parserName ) { $ parserClass = 'AbuseIO\\Parsers\\' . $ parserName ; if ( config ( "parsers.{$parserName}.parser.enabled" ) === true ) { $ report_file = config ( "parsers.{$parserName}.parser.re...
Create and return a Parser class and it s configuration
2,261
public function getRegions ( $ themeName ) { $ translator = $ this -> getTranslator ( ) ; $ options = $ this -> getModuleOptions ( ) ; $ theme = $ options -> getThemeByName ( $ themeName ) ; $ map = [ ] ; if ( ! isset ( $ theme [ 'frontend' ] [ 'regions' ] ) || ! is_array ( $ theme [ 'frontend' ] [ 'regions' ] ) || emp...
Get the existing regions from the module options .
2,262
protected static function getApplicablePropertyModelClassNames ( $ id ) { if ( isset ( static :: $ applicablePropertyModelClassNames [ $ id ] ) === false ) { $ subQuery = PropertyPropertyGroup :: find ( ) -> from ( PropertyPropertyGroup :: tableName ( ) . ' ppg' ) -> select ( 'pg.applicable_property_model_id' ) -> join...
Get applicable property model class names by property id .
2,263
public function import ( $ name ) { $ object = null ; if ( ! isset ( $ this -> modules [ $ name ] ) ) { if ( isset ( $ this -> moduleMap [ $ name ] ) ) { $ object_class = $ this -> moduleMap [ $ name ] ; $ object = new $ object_class ( ) ; $ object -> setSystem ( $ this ) ; $ object -> setEventLoop ( $ this -> eventLoo...
import a module based on name similar to node . js s require
2,264
public static function getLocaleFallbackList ( $ locale , $ fallbackLocale = '' ) { if ( empty ( $ locale ) ) { throw new InvalidArgumentException ( __METHOD__ . ': The given locale is empty' ) ; } $ fallbackList = [ ] ; $ fallbackList = array_merge ( $ fallbackList , self :: getFallbackList ( $ locale ) ) ; if ( $ fal...
Get a locale fallback list to check while translating .
2,265
protected function renderChildren ( $ def ) { $ context = new HTMLPurifier_Context ( ) ; $ ret = '' ; $ ret .= $ this -> start ( 'tr' ) ; $ elements = array ( ) ; $ attr = array ( ) ; if ( isset ( $ def -> elements ) ) { if ( $ def -> type == 'strictblockquote' ) { $ def -> validateChildren ( array ( ) , $ this -> conf...
Renders a row describing the allowed children of an element
2,266
protected function listifyTagLookup ( $ array ) { ksort ( $ array ) ; $ list = array ( ) ; foreach ( $ array as $ name => $ discard ) { if ( $ name !== '#PCDATA' && ! isset ( $ this -> def -> info [ $ name ] ) ) continue ; $ list [ ] = $ name ; } return $ this -> listify ( $ list ) ; }
Listifies a tag lookup table .
2,267
protected function listifyAttr ( $ array ) { ksort ( $ array ) ; $ list = array ( ) ; foreach ( $ array as $ name => $ obj ) { if ( $ obj === false ) continue ; $ list [ ] = "$name&nbsp;=&nbsp;<i>" . $ this -> getClass ( $ obj , 'AttrDef_' ) . '</i>' ; } return $ this -> listify ( $ list ) ; }
Listifies a hash of attributes to AttrDef classes
2,268
public function addDimension ( $ name , $ value , $ increment = 1 ) { $ dimension = new LogDimension ( $ name , $ value ) ; $ dimension -> setIncrement ( $ increment ) ; $ this -> dimensions [ ] = $ dimension ; return $ this ; }
Add a dimension to the entry .
2,269
public static function classToIndex ( $ className ) { if ( false === is_string ( $ className ) ) { return '' ; } $ modelClass = strtolower ( $ className ) ; return StringHelper :: basename ( $ modelClass ) ; }
Builds index name according to given model class
2,270
public static function storageClassToType ( $ storageClass ) { if ( false === is_string ( $ storageClass ) ) { return '' ; } $ name = StringHelper :: basename ( $ storageClass ) ; return Inflector :: camel2id ( $ name , '_' ) ; }
Builds index type according to given property storage class name
2,271
public static function primaryKeysByCondition ( $ client , $ condition ) { $ primaryKeys = [ ] ; $ count = $ client -> count ( $ condition ) ; $ count = empty ( $ count [ 'count' ] ) ? 10 : $ count [ 'count' ] ; $ condition [ 'size' ] = $ count ; $ condition [ '_source' ] = true ; $ res = $ client -> search ( $ conditi...
Performs fast scan for docs ids in elasticsearch indices
2,272
public function checkScheme ( $ url = '' , $ secure = false ) { $ parsed = [ ] ; $ parsed = parse_url ( $ url ) ; $ pos = strpos ( $ url , '//' ) ; if ( empty ( $ parsed [ 'scheme' ] ) && strpos ( $ url , '//' ) !== false ) return $ url ; elseif ( empty ( $ parsed [ 'scheme' ] ) ) return 'http' . ( $ secure ? 's' : '' ...
Checks if a string contains a scheme . Adds one if necessary checks for schemaless urls .
2,273
public function jsonResponse ( $ data = [ ] ) { global $ db_show_debug ; $ json = '' ; $ result = false ; if ( empty ( $ data ) ) return false ; $ json = json_encode ( $ data ) ; $ result = json_last_error ( ) == JSON_ERROR_NONE ; if ( $ result ) { $ db_show_debug = false ; ob_end_clean ( ) ; if ( $ this -> _app -> mod...
Outputs a json encoded string It assumes the data is a valid array .
2,274
public function parser ( $ text , $ replacements = [ ] ) : string { global $ context ; if ( empty ( $ text ) || empty ( $ replacements ) || ! is_array ( $ replacements ) ) return '' ; $ find = [ ] ; $ replace = [ ] ; foreach ( $ replacements as $ f => $ r ) { $ find [ ] = '{' . $ f . '}' ; $ replace [ ] = $ r . ( ( str...
Parses and replace tokens by their given values . also automatically adds the session var for href tokens .
2,275
public function commaSeparated ( $ string , $ type = 'alphanumeric' , $ delimiter = ',' ) { if ( empty ( $ string ) ) return false ; $ t = isset ( $ this -> _commaCases [ $ type ] ) ? $ this -> _commaCases [ $ type ] : $ this -> _commaCases [ 'alphanumeric' ] ; return empty ( $ string ) ? false : implode ( $ delimiter ...
Checks and returns a comma separated string .
2,276
public function formatBytes ( $ bytes , $ showUnits = false , $ log = 1024 ) : string { $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' ) ; $ bytes = max ( $ bytes , 0 ) ; $ pow = floor ( ( $ bytes ? log ( $ bytes ) : 0 ) / log ( $ log ) ) ; $ pow = min ( $ pow , count ( $ units ) - 1 ) ; $ bytes /= ( 1 << ( 10 * $ p...
Returns a formatted string .
2,277
private function determineSourceFolder ( ) { $ this -> sourceFolder = JPATH_BASE . "/" . $ this -> getJConfig ( ) -> source ; if ( ! is_dir ( $ this -> sourceFolder ) ) { $ this -> say ( 'Warning - Directory: ' . $ this -> sourceFolder . ' is not available' ) ; } }
Sets the source folder
2,278
private function determineOperatingSystem ( ) { $ this -> os = strtoupper ( substr ( PHP_OS , 0 , 3 ) ) ; if ( $ this -> os === 'WIN' ) { $ this -> fileExtension = '.exe' ; } }
Sets the operating system
2,279
public function actionCreate ( ) { $ model = new SeoPresets ( ) ; $ model -> loadDefaultValues ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { if ( Yii :: $ app -> request -> post ( 'action' ) === 'apply' ) { return $ this -> redirect ( [ 'update' , 'id' => $ model -> id ] ...
Creates a new SeoPresets model . If creation is successful the browser will be redirected to the view page .
2,280
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ model -> loadDefaultValues ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { if ( Yii :: $ app -> request -> post ( 'action' ) === 'apply' ) { return $ this -> redirect ( [ 'update' , 'id' => $...
Updates an existing SeoPresets model . If update is successful the browser will be redirected to the view page .
2,281
public function prepare ( TokenStream $ stream ) : void { $ this -> root = $ this -> scope = new RootNode ( ) ; $ this -> stream = $ stream ; $ this -> lastTokenIndex = max ( 0 , count ( $ this -> stream -> getTokens ( ) ) - 1 ) ; $ this -> cursor = 0 ; }
Prepares the parser for parsing
2,282
public function parseOutsideTag ( ) : void { if ( ! count ( $ this -> stream -> getTokens ( ) ) ) { return ; } if ( $ this -> accept ( Token :: T_TEXT ) ) { $ this -> insert ( new TextNode ( $ this -> getCurrentToken ( ) -> getValue ( ) ) ) ; $ this -> advance ( ) ; } if ( $ this -> skip ( Token :: T_OPENING_TAG ) ) { ...
Parses outside of tags
2,283
public function expect ( int $ type , $ value = null ) : bool { if ( ! $ this -> accept ( $ type , $ value ) ) { $ this -> syntaxError ( 'Expected ' . Token :: getStringRepresentation ( $ type , $ value ) . ' got ' . $ this -> getCurrentToken ( ) ) ; } return true ; }
Expects the current token to be of given type and optionally has given value
2,284
public function expectNext ( int $ type , $ value = null ) : bool { if ( ! $ this -> acceptNext ( $ type , $ value ) ) { $ this -> syntaxError ( 'Expected ' . Token :: getStringRepresentation ( $ type , $ value ) . ' got ' . $ this -> getNextToken ( ) ) ; } return true ; }
Expects the next token to be of given type and optionally has given value
2,285
public function skip ( int $ type , $ value = null ) : bool { if ( $ this -> accept ( $ type , $ value ) ) { $ this -> advance ( ) ; return true ; } return false ; }
Skips the current token if it s of given type and optionally has given value
2,286
public function accept ( int $ type , $ value = null ) : bool { if ( $ this -> getCurrentToken ( ) -> getType ( ) === $ type ) { if ( $ value ) { if ( $ this -> getCurrentToken ( ) -> getValue ( ) === $ value ) { return true ; } return false ; } return true ; } return false ; }
Accepts the current token if it s of given type and optionally has given value
2,287
public function acceptNext ( int $ type , $ value = null ) : bool { if ( $ this -> getNextToken ( ) -> getType ( ) === $ type ) { if ( $ value ) { if ( $ this -> getNextToken ( ) -> getValue ( ) === $ value ) { return true ; } return false ; } return true ; } return false ; }
Accepts the next token if it s of given type and optionally has given value
2,288
public function traverseDown ( ) : void { try { $ parent = $ this -> getScope ( ) -> getParent ( ) ; } catch ( AegisError $ e ) { throw new ParseError ( $ e -> getMessage ( ) ) ; } $ this -> setScope ( $ parent ) ; }
Moves outside the current scope
2,289
public function advance ( ) : void { if ( $ this -> cursor < count ( $ this -> stream -> getTokens ( ) ) - 1 ) { ++ $ this -> cursor ; } }
Advances the cursor
2,290
public function wrap ( Node $ node ) : void { $ last = $ this -> scope -> getLastChild ( ) ; $ this -> scope -> removeLastChild ( ) ; $ this -> insert ( $ node ) ; $ this -> traverseUp ( ) ; $ this -> insert ( $ last ) ; }
Wraps the last inserted node with the given node
2,291
public function setAttribute ( ) : void { $ last = $ this -> scope -> getLastChild ( ) ; $ this -> scope -> removeLastChild ( ) ; $ this -> scope -> setAttribute ( $ last ) ; }
Sets the last inserted node as attribute
2,292
public function insert ( Node $ node ) : void { $ node -> setParent ( $ this -> scope ) ; $ this -> scope -> insert ( $ node ) ; }
Inserts the given node
2,293
public function listAction ( ) { $ this -> routeParam ( ) -> mapPageTo ( $ this -> queryService ) ; $ collection = $ this -> queryService -> findUsedTags ( ) ; return $ this -> viewModelFactory ( ) -> createFor ( $ collection ) ; }
Tag list retrieval
2,294
public function build ( ) { $ this -> setLayout ( 'locales/index.tpl' ) ; $ this -> addModule ( 'head' , 'SharedHead' ) ; $ this -> addModule ( 'footer' , 'SharedFooter' ) ; $ this -> addModule ( 'system_messages' , 'SharedSystemMessages' ) ; $ params = $ this -> getParams ( ) ; $ action = \ Sifo \ Router :: getReversa...
Main method controller .
2,295
public function getLanguagesInstance ( $ instance = null ) { $ languages = false ; if ( $ instance != '' ) { $ languages = $ this -> scanFiles ( ROOT_PATH . '/instances/' . $ instance . '/locale' , false ) ; if ( is_array ( $ languages ) && count ( $ languages ) > 0 ) { $ locales = array ( ) ; foreach ( $ languages as ...
Build a list with all of the languages of an instance
2,296
private function _mergeAssociated ( array $ result , array $ associated , $ refKey , $ colName ) { foreach ( $ result as $ index => $ item ) { if ( is_array ( $ item ) ) { $ refValue = $ item [ $ refKey ] ; } else { $ refValue = $ item -> { $ refKey } ; } if ( isset ( $ associated [ $ refValue ] ) ) { if ( is_array ( $...
Merge associated data with result
2,297
private function _getQueryChecksum ( ) { return md5 ( serialize ( [ "name" => $ this -> getName ( ) , "entity" => Convention :: classToName ( $ this -> reflection -> getClassName ( ) , Convention :: ENTITY_MASK ) , "limit" => $ this -> limit , "offset" => $ this -> offset , "selection" => $ this -> selection , "orderBy...
Get a unique query checksum
2,298
protected function getRequestConfig ( array $ config ) : array { if ( ! empty ( $ this -> defaultRequestOptions ) ) { $ config = array_replace_recursive ( $ this -> defaultRequestOptions , $ config ) ; } return $ config ; }
Update request config with default options
2,299
private static function createBackoff ( array $ options , LoggerInterface $ logger ) { $ headerName = isset ( $ options [ 'http' ] [ 'retryHeader' ] ) ? $ options [ 'http' ] [ 'retryHeader' ] : 'Retry-After' ; $ httpRetryCodes = isset ( $ options [ 'http' ] [ 'codes' ] ) ? $ options [ 'http' ] [ 'codes' ] : [ 500 , 502...
Create exponential backoff for GuzzleClient