idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
9,400
protected function getDefaultHeaders ( ) { $ headers = array ( ) ; $ mimeType = $ this -> calendar -> getContentType ( ) ; $ headers [ 'Content-Type' ] = sprintf ( '%s; charset=utf-8' , $ mimeType ) ; $ filename = $ this -> calendar -> getFilename ( ) ; $ headers [ 'Content-Disposition' ] = sprintf ( 'attachment; filen...
Get default response headers for a calendar
9,401
public static function length ( $ value , $ encoding = null ) { if ( $ encoding !== null ) { return mb_strlen ( $ value , $ encoding ) ; } return mb_strlen ( $ value ) ; }
Return the length of the given string .
9,402
private function writeToOutputNow ( $ output , $ handlerContentType ) { $ Response = $ this -> system -> ResIns ( ) ; if ( $ Response instanceof Response ) { if ( $ this -> sendHttpCode ( ) ) { $ Response -> withStatus ( $ this -> sendHttpCode ( ) ) ; } $ Response -> withHeader ( 'Content-Type' , $ handlerContentType )...
Auto write Output to Browser or Console
9,403
public function get ( $ index ) { $ config = $ this -> config ; foreach ( explode ( '.' , $ index ) as $ value ) { $ config = $ config [ $ value ] ; } return $ config ; }
Get a particular value back from the config array
9,404
public function initURL ( $ url ) { $ contents = file_get_contents ( $ url ) ; $ lines = explode ( "\n" , $ contents ) ; return $ this -> initLines ( $ lines ) ; }
Initializes lines from a URL
9,405
public function initLines ( $ lines ) { if ( stristr ( $ lines [ 0 ] , 'BEGIN:VCALENDAR' ) === false ) { return false ; } foreach ( $ lines as $ line ) { $ line = rtrim ( $ line ) ; $ add = $ this -> keyValueFromString ( $ line ) ; if ( $ add === false ) { $ this -> addCalendarComponentWithKeyAndValue ( $ component , f...
Initializes lines from file
9,406
public function keyValueFromString ( $ text ) { preg_match ( '/(.*?)(?::(?=(?:[^"]*"[^"]*")*[^"]*$)|;(?=[^:]*$))([\w\W]*)/' , htmlspecialchars ( $ text , ENT_QUOTES , 'UTF-8' ) , $ matches ) ; if ( count ( $ matches ) == 0 ) { return false ; } if ( preg_match ( '/^([A-Z-]+)([;][\w\W]*)?$/' , $ matches [ 1 ] ) ) { $ mat...
Get a key - value pair of a string .
9,407
public static function iCalDateToUnixTimestamp ( $ icalDate ) { $ icalDate = str_replace ( 'T' , '' , $ icalDate ) ; $ icalDate = str_replace ( 'Z' , '' , $ icalDate ) ; $ pattern = '/([0-9]{4})' ; $ pattern .= '([0-9]{2})' ; $ pattern .= '([0-9]{2})' ; $ pattern .= '([0-9]{0,2})' ; $ pattern .= '([0-9]{0,2})' ; $ patt...
Return Unix timestamp from iCal date time format
9,408
public function eventsFromRange ( $ rangeStart = false , $ rangeEnd = false ) { $ events = $ this -> sortEventsWithOrder ( $ this -> events ( ) , SORT_ASC ) ; if ( ! $ events ) { return false ; } $ extendedEvents = [ ] ; $ rangeStart = ( $ rangeStart === false ) ? new DateTime ( ) : new DateTime ( $ rangeStart ) ; if (...
Returns false when the current calendar has no events in range else the events .
9,409
public function sortEventsWithOrder ( $ events , $ sortOrder = SORT_ASC ) { $ extendedEvents = [ ] ; foreach ( $ events as $ anEvent ) { if ( ! array_key_exists ( 'UNIX_TIMESTAMP' , $ anEvent ) ) { $ anEvent [ 'UNIX_TIMESTAMP' ] = $ this -> iCalDateToUnixTimestamp ( $ anEvent [ 'DTSTART' ] ) ; } if ( ! array_key_exists...
Returns a boolean value whether the current calendar has events or not
9,410
public function updateMetadata ( Node $ node ) { $ this -> updateFileTimes ( $ node ) ; $ this -> updateOwnership ( $ node ) ; return $ node ; }
Updates time and ownership of a node
9,411
public function getCallable ( $ methodName ) { $ this -> checkMethodName ( $ methodName ) ; $ class = $ this -> getClassName ( $ methodName ) ; $ method = $ this -> getMethodName ( $ methodName ) ; $ object = $ this -> createObject ( $ class ) ; if ( ! method_exists ( $ object , $ method ) ) { throw new JsonRpc \ Excep...
Maps JSON - RPC method name to a PHP callable function .
9,412
private function createObject ( $ class ) { if ( ! class_exists ( $ class ) ) { throw new JsonRpc \ Exception \ Method ( ) ; } try { return new $ class ( ) ; } catch ( Exception $ e ) { throw new JsonRpc \ Exception \ Method ( ) ; } }
Create an object from the given class name
9,413
private function isPositionalArguments ( $ arguments ) { $ i = 0 ; foreach ( $ arguments as $ key => $ value ) { if ( $ key !== $ i ++ ) { return false ; } } return true ; }
Returns true if the argument array is a zero - indexed list of positional arguments or false if the argument array is a set of named arguments .
9,414
public function getContainerFromContext ( $ path ) { $ scheme = current ( preg_split ( '#://#' , $ path ) ) ; $ options = stream_context_get_options ( stream_context_get_default ( ) ) ; return $ options [ $ scheme ] [ 'Container' ] ; }
Returns Container object fished form default_context_options by scheme .
9,415
public function stream_stat ( ) { try { $ file = $ this -> currentlyOpenedFile -> getFile ( ) ; return array_merge ( $ this -> getStatArray ( ) , array ( 'mode' => $ file -> mode ( ) , 'uid' => $ file -> user ( ) , 'gid' => $ file -> group ( ) , 'atime' => $ file -> atime ( ) , 'mtime' => $ file -> mtime ( ) , 'ctime' ...
Returns stat data for file inclusion .
9,416
public function url_stat ( $ path ) { try { $ file = $ this -> getContainerFromContext ( $ path ) -> nodeAt ( $ this -> stripScheme ( $ path ) ) ; return array_merge ( $ this -> getStatArray ( ) , array ( 'mode' => $ file -> mode ( ) , 'uid' => $ file -> user ( ) , 'gid' => $ file -> group ( ) , 'atime' => $ file -> at...
Returns file stat information
9,417
public function mkdir ( $ path , $ mode , $ options ) { $ container = $ this -> getContainerFromContext ( $ path ) ; $ path = $ this -> stripScheme ( $ path ) ; $ recursive = ( bool ) ( $ options & STREAM_MKDIR_RECURSIVE ) ; try { $ parentPath = $ path ; while ( $ parentPath = dirname ( $ parentPath ) ) { try { $ paren...
Called in response to mkdir to create directory .
9,418
public function stream_seek ( $ offset , $ whence = SEEK_SET ) { switch ( $ whence ) { case SEEK_SET : $ this -> currentlyOpenedFile -> position ( $ offset ) ; break ; case SEEK_CUR : $ this -> currentlyOpenedFile -> offsetPosition ( $ offset ) ; break ; case SEEK_END : $ this -> currentlyOpenedFile -> seekToEnd ( ) ; ...
Sets file pointer to specified position
9,419
public function unlink ( $ path ) { $ container = $ this -> getContainerFromContext ( $ path ) ; try { $ path = $ this -> stripScheme ( $ path ) ; $ parent = $ container -> nodeAt ( dirname ( $ path ) ) ; $ permissionHelper = $ container -> getPermissionHelper ( $ parent ) ; if ( ! $ permissionHelper -> isWritable ( ) ...
Deletes file at given path
9,420
public function dir_opendir ( $ path ) { $ container = $ this -> getContainerFromContext ( $ path ) ; $ path = $ this -> stripScheme ( $ path ) ; if ( ! $ container -> hasNodeAt ( $ path ) ) { trigger_error ( sprintf ( 'opendir(%s): failed to open dir: No such file or directory' , $ path ) , E_USER_WARNING ) ; return f...
Opens directory for iteration
9,421
public function dir_readdir ( ) { $ node = $ this -> currentlyOpenedDir -> iterator ( ) -> current ( ) ; if ( ! $ node ) { return false ; } $ this -> currentlyOpenedDir -> iterator ( ) -> next ( ) ; return $ node -> basename ( ) ; }
Returns next file url in directory
9,422
public function setDirectory ( Directory $ directory ) { $ this -> directory = $ directory ; $ this -> iterator = new \ ArrayIterator ( $ directory -> children ( ) ) ; }
Sets directory in context .
9,423
public function addNode ( Node $ node ) { if ( array_key_exists ( $ node -> basename ( ) , $ this -> children ) ) { throw new FileExistsException ( sprintf ( '%s already exists' , $ node -> basename ( ) ) ) ; } $ this -> children [ $ node -> basename ( ) ] = $ node ; $ node -> setParent ( $ this ) ; }
Adds child Node .
9,424
public function childAt ( $ path ) { if ( ! array_key_exists ( $ path , $ this -> children ) ) { throw new NotFoundException ( sprintf ( 'Could not find child %s in %s' , $ path , $ this -> path ( ) ) ) ; } return $ this -> children [ $ path ] ; }
Returns child Node existing at path .
9,425
public function evaluate ( $ method , $ arguments = array ( ) ) { $ callable = $ this -> mapper -> getCallable ( $ method ) ; $ arguments = $ this -> mapper -> getArguments ( $ callable , $ arguments ) ; return $ this -> execute ( $ callable , $ arguments ) ; }
Map method name to callable and run it with the given arguments .
9,426
private function execute ( $ callable , $ arguments ) { try { return call_user_func_array ( $ callable , $ arguments ) ; } catch ( Exception $ e ) { if ( $ e instanceof JsonRpc \ Exception ) { throw $ e ; } else { error_log ( strval ( $ e ) ) ; throw new JsonRpc \ Exception \ Evaluation ( $ e -> getMessage ( ) , $ e ->...
Executes the given callable with the arguments provided .
9,427
private function arrayAnalyzer ( $ input ) { $ result = [ ] ; foreach ( $ input as $ key => $ value ) { if ( $ key == 'Field' ) { $ result [ ] = $ value ; } elseif ( $ key == 'Type' ) { if ( str_contains ( $ value , 'int' ) ) { $ result [ ] = 'text' ; } elseif ( str_contains ( $ value , 'char' ) ) { $ result [ ] = 'tex...
arrayAnalyser . add specified types from attributes .
9,428
private function getResult ( ) { $ result = [ ] ; foreach ( $ this -> attributes -> getAttributes ( ) as $ key ) { $ result [ ] = $ this -> arrayAnalyzer ( $ key ) ; } return $ result ; }
get result from attributes and arrayAnalyzer .
9,429
public function getModelArray ( Model $ model ) { $ result = [ ] ; foreach ( $ model -> getAttributes ( ) as $ key => $ value ) { $ result [ ] = [ 'type' => 'text' , 'name' => $ key , 'key' => $ key . ' :' , 'value' => $ value ] ; } unset ( $ result [ 0 ] ) ; return $ result ; }
get simple array from Model .
9,430
public static function getIp ( ) { if ( self :: $ ip === null ) { $ ip = self :: detectAndCleanIP ( ) ; if ( ! empty ( $ ip ) && ( $ ip != '0.0.0.0' ) && \ function_exists ( 'inet_pton' ) && \ function_exists ( 'inet_ntop' ) ) { $ myIP = @ inet_pton ( $ ip ) ; if ( $ myIP !== false ) { $ ip = inet_ntop ( $ myIP ) ; } }...
Get the current visitor s IP address
9,431
public static function workaroundIPIssues ( ) { $ ip = self :: getIp ( ) ; if ( $ _SERVER [ 'REMOTE_ADDR' ] === $ ip ) { return ; } if ( array_key_exists ( 'REMOTE_ADDR' , $ _SERVER ) ) { $ _SERVER [ 'JOOMLA_REMOTE_ADDR' ] = $ _SERVER [ 'REMOTE_ADDR' ] ; } elseif ( \ function_exists ( 'getenv' ) ) { if ( getenv ( 'REMO...
Works around the REMOTE_ADDR not containing the user s IP
9,432
protected static function detectAndCleanIP ( ) { $ ip = self :: detectIP ( ) ; if ( strstr ( $ ip , ',' ) !== false || strstr ( $ ip , ' ' ) !== false ) { $ ip = str_replace ( ' ' , ',' , $ ip ) ; $ ip = str_replace ( ',,' , ',' , $ ip ) ; $ ips = explode ( ',' , $ ip ) ; $ ip = '' ; while ( empty ( $ ip ) && ! empty (...
Gets the visitor s IP address .
9,433
protected static function detectIP ( ) { if ( isset ( $ _SERVER ) ) { if ( self :: $ allowIpOverrides && array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ _SERVER ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } if ( self :: $ allowIpOverrides && array_key_exists ( 'HTTP_CLIENT_IP' , $ _SERVER ) ) { return $ _SERVER [...
Gets the visitor s IP address
9,434
protected static function inetToBits ( $ inet ) { if ( \ strlen ( $ inet ) == 4 ) { $ unpacked = unpack ( 'A4' , $ inet ) ; } else { $ unpacked = unpack ( 'A16' , $ inet ) ; } $ unpacked = str_split ( $ unpacked [ 1 ] ) ; $ binaryip = '' ; foreach ( $ unpacked as $ char ) { $ binaryip .= str_pad ( decbin ( \ ord ( $ ch...
Converts inet_pton output to bits string
9,435
public function mtEditFormModal ( $ input , $ link , $ title ) { $ modal = $ this -> modalDirector -> build ( $ title , 'update' , $ input , $ link , $ this -> MtModal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show Ajaxis materialize form to edit specified resource .
9,436
public function mtDeleting ( $ title , $ message , $ link ) { $ modal = new MaterializeDeleteConfirmationMessage ( ) ; $ modal = $ this -> modalDirector -> build ( $ title , 'Delete' , $ message , $ link , $ modal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show materialize confirmation message to delete specified resource .
9,437
public function mtDisplay ( $ input ) { $ modal = new MaterializeDisplayBuilder ( ) ; $ modal = $ this -> modalDirector -> build ( null , null , $ input , null , $ modal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show materialize modal to displa specified resource .
9,438
public function btDeleting ( $ title , $ body , $ link ) { $ modal = new BootstrapDeleteConfirmationMessage ( ) ; $ modal = $ this -> modalDirector -> build ( $ title , 'Agree' , $ body , $ link , $ modal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show bootsrap modal to delete specified resource .
9,439
public function btCreateFormModal ( $ input , $ link , $ title ) { $ modal = $ this -> modalDirector -> build ( $ title , 'Create' , $ input , $ link , $ this -> BtModal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show Ajaxis bootstrap form to create specified resource .
9,440
public function btDisplay ( $ input ) { $ modal = new BootstrapDisplayBuilder ( ) ; $ modal = $ this -> modalDirector -> build ( 'Dsiplay' , 'ok' , $ input , null , $ modal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
Show bootstrap modal to display specified resource .
9,441
public function mtGet ( $ table , $ link , $ title ) { $ result = new AutoArray ( $ table ) ; $ modal = $ this -> modalDirector -> build ( $ title , 'Create' , $ result -> merge ( ) , $ link , $ this -> MtModal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
build Materialize modal quickly by a table name .
9,442
public function btGet ( $ table , $ link , $ title ) { $ result = new AutoArray ( $ table ) ; $ modal = $ this -> modalDirector -> build ( $ title , 'Create' , $ result -> merge ( ) , $ link , $ this -> BtModal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
build Bootstrap modal quickly by a table name .
9,443
public function btText ( $ input , $ link ) { $ director = new ModalDirector ( ) ; $ modal = new BootstrapText ( ) ; $ modal = $ director -> build ( 'Has Role' , 'Ok' , $ input , $ link , $ modal ) ; return $ modal -> modalHead . $ modal -> modalBody . $ modal -> modalFooter ; }
build simple modal with text .
9,444
public function progressiveCall ( string $ uri , array $ args = [ ] , array $ argskw = [ ] , array $ options = null ) : Observable { $ options [ 'receive_progress' ] = true ; return Observable :: defer ( function ( ) use ( $ uri , $ args , $ argskw , $ options ) { $ completed = new Subject ( ) ; return $ this -> sessio...
This is a variant of call that expects the far end to emit more than one result . It will also repeat the call if the websocket connection resets and the observable has not completed or errored .
9,445
public static function sort ( $ array , Closure $ callback ) { $ results = [ ] ; foreach ( $ array as $ key => $ value ) { $ results [ $ key ] = $ callback ( $ value ) ; } return $ results ; }
Sort the array using the given Closure .
9,446
protected function respondWithModel ( Model $ model , $ functionName = null ) { if ( $ functionName && isset ( $ this -> partialFields ) ) { if ( ! isset ( $ this -> allowedPartialFields [ $ functionName ] ) ) { throw new Exception ( 'Partial fields not specified for ' . $ functionName ) ; } if ( array_diff ( $ this ->...
Respond with a single model pass function name
9,447
protected function respondWithModels ( ResultsetInterface $ models ) { if ( count ( $ models ) == 0 ) { $ this -> response -> data = [ ] ; } else { foreach ( $ models as $ model ) { $ this -> response -> data [ ] = ( object ) $ model -> toArray ( ) ; } $ this -> response -> getMeta ( ) -> count = count ( $ models ) ; }...
Respond with multiple models a result set
9,448
public function substringAfterFirst ( $ separator ) { if ( ( $ offset = $ this -> indexOf ( $ separator ) ) === false ) { return false ; } return static :: create ( mb_substr ( $ this -> str , $ offset + mb_strlen ( $ separator , $ this -> encoding ) , null , $ this -> encoding ) , $ this -> encoding ) ; }
Gets the substring after the first occurrence of a separator . If no match is found returns false .
9,449
public function substringAfterLast ( $ separator ) { if ( ( $ offset = $ this -> indexOfLast ( $ separator ) ) === false ) { return false ; } return static :: create ( mb_substr ( $ this -> str , $ offset + mb_strlen ( $ separator , $ this -> encoding ) , null , $ this -> encoding ) , $ this -> encoding ) ; }
Gets the substring after the last occurrence of a separator . If no match is found returns false .
9,450
public function substringBeforeFirst ( $ separator ) { if ( ( $ offset = $ this -> indexOf ( $ separator ) ) === false ) { return false ; } return static :: create ( mb_substr ( $ this -> str , 0 , $ offset , $ this -> encoding ) , $ this -> encoding ) ; }
Gets the substring before the first occurrence of a separator . If no match is found returns false .
9,451
public function substringBeforeLast ( $ separator ) { if ( ( $ offset = $ this -> indexOfLast ( $ separator ) ) === false ) { return false ; } return static :: create ( mb_substr ( $ this -> str , 0 , $ offset , $ this -> encoding ) , $ this -> encoding ) ; }
Gets the substring before the last occurrence of a separator . If no match is found returns false .
9,452
public function substringBetween ( $ start , $ end ) { $ ini = mb_stripos ( $ this -> str , $ start , 0 , $ this -> encoding ) ; if ( $ ini === 0 ) { return "" ; } $ ini += mb_strlen ( $ start , $ this -> encoding ) ; $ len = mb_stripos ( $ this -> str , $ end , $ ini , $ this -> encoding ) - $ ini ; return static :: c...
Extracts a string from between two substrings present on the current string
9,453
public function year ( ) { if ( ! isset ( $ this -> year ) ) { $ this -> year = new Year ( $ this -> startDateTime -> format ( 'Y' ) ) ; } return $ this -> year ; }
Returns a year object for this month
9,454
public function weeks ( $ startDay = 'Monday' ) { if ( ! isset ( $ this -> weeks [ $ startDay ] ) ) { $ this -> weeks [ $ startDay ] = array ( ) ; $ keepWeeking = true ; $ weekPoint = clone $ this -> firstDay ( ) ; while ( $ keepWeeking ) { $ candidateWeek = new Week ( $ weekPoint , $ startDay ) ; if ( $ candidateWeek ...
Returns the weeks associated with this month . Not all of these weeks might start and end in this month but they all contain days from this month .
9,455
protected function registerContextOptions ( Container $ container ) { $ defaultOptions = stream_context_get_options ( stream_context_get_default ( ) ) ; stream_context_set_default ( array_merge ( $ defaultOptions , array ( $ this -> scheme => array ( 'Container' => $ container ) ) ) ) ; }
Registers Container object as default context option for scheme associated with FileSystem instance .
9,456
public function createDirectory ( $ path , $ recursive = false , $ mode = null ) { return $ this -> container ( ) -> createDir ( $ path , $ recursive , $ mode ) ; }
Creates and returns a directory
9,457
public function createCalendar ( ) { $ calendar = new Calendar ( ) ; if ( ! is_null ( $ this -> timezone ) ) { $ calendar -> setTimezone ( $ this -> timezone ) ; } if ( ! is_null ( $ this -> prodid ) ) { $ calendar -> setProdId ( $ this -> prodid ) ; } return $ calendar ; }
Create new calendar
9,458
public static function addColumn ( array $ array , array $ column , $ colName , $ keyCol = null ) { $ result = array ( ) ; foreach ( $ array as $ i => $ item ) { $ value = null ; if ( ! isset ( $ keyCol ) ) { $ value = static :: getValue ( $ column , $ i ) ; } else { $ subject = \ is_object ( $ item ) ? static :: fromO...
Adds a column to an array of arrays or objects
9,459
public static function dropColumn ( array $ array , $ colName ) { $ result = array ( ) ; foreach ( $ array as $ i => $ item ) { if ( \ is_object ( $ item ) && isset ( $ item -> $ colName ) ) { unset ( $ item -> $ colName ) ; } elseif ( \ is_array ( $ item ) && isset ( $ item [ $ colName ] ) ) { unset ( $ item [ $ colNa...
Remove a column from an array of arrays or objects
9,460
public static function invert ( array $ array ) { $ return = array ( ) ; foreach ( $ array as $ base => $ values ) { if ( ! \ is_array ( $ values ) ) { continue ; } foreach ( $ values as $ key ) { if ( is_scalar ( $ key ) ) { $ return [ $ key ] = $ base ; } } } return $ return ; }
Takes an associative array of arrays and inverts the array keys to values using the array values as keys .
9,461
public function mapRoute ( ) { $ this -> map ( '/null/create' , 'create' ) -> via ( 'GET' , 'POST' ) ; $ this -> map ( '/:id/read' , 'read' ) -> via ( 'GET' ) ; $ this -> map ( '/:id/update' , 'update' ) -> via ( 'GET' , 'POST' ) ; $ this -> map ( '/:id/delete' , 'delete' ) -> via ( 'GET' , 'POST' ) ; $ this -> map ( '...
Map routes to available method
9,462
public function li ( $ iconOrLine , $ liVal = null ) { if ( is_string ( $ iconOrLine ) === false && is_array ( $ iconOrLine ) === false ) { throw new IncompleteListException ( 'List items must be a string or array of strings.' ) ; } if ( is_string ( $ iconOrLine ) && is_null ( $ liVal ) ) { return $ this -> addItem ( n...
Adds items to unordered list
9,463
protected function output ( ) { $ listItems = '' ; foreach ( $ this -> lines as $ li ) { $ icon = $ this -> buildIcon ( $ li [ 0 ] ) ; $ listItems .= sprintf ( self :: LI_HTML , $ icon , $ li [ 1 ] ) ; } return sprintf ( self :: UL_HTML , $ listItems ) ; }
Outputs the FontAwesomeList object as an HTML string
9,464
private function addItem ( $ icon , $ liVal ) { if ( $ icon === null ) { $ this -> lines [ ] = array ( $ this -> icon , $ liVal ) ; } else { $ this -> lines [ ] = array ( $ icon , $ liVal ) ; } return $ this ; }
Add an item to the list
9,465
private function addItems ( array $ lineArray ) { foreach ( $ lineArray as $ icon => $ liVal ) { $ icon = is_string ( $ icon ) ? $ icon : null ; $ this -> addItem ( $ icon , $ liVal ) ; } return $ this ; }
Add multiple items to list
9,466
public function process ( PluginInterface $ plugin , Bot $ bot ) { $ client = $ bot -> getClient ( ) ; if ( $ plugin instanceof LoopAwareInterface && $ client instanceof LoopAccessorInterface ) { $ plugin -> setLoop ( $ client -> getLoop ( ) ) ; } }
Injects the event loop of the bot s client into the plugin if it implements \ Phergie \ Irc \ Bot \ React \ LoopInterface .
9,467
public static function conn ( ) { if ( ! isset ( self :: $ connection ) ) { if ( ! class_exists ( 'Jasny\Config' ) || ! isset ( \ Jasny \ Config :: i ( ) -> db ) ) throw new DB_Exception ( "Unable to create DB connection: not configured" ) ; new static ( \ Jasny \ Config :: i ( ) -> db ) ; } return self :: $ connection...
Get the DB connection .
9,468
public function fetchColumn ( $ query ) { if ( func_num_args ( ) > 1 ) $ query = call_user_func_array ( array ( get_class ( ) , 'bind' ) , func_get_args ( ) ) ; $ result = $ query instanceof \ mysqli_result ? $ query : $ this -> query ( $ query ) ; $ values = array ( ) ; while ( list ( $ value ) = $ result -> fetch_row...
Query and fetch a single column from all result rows .
9,469
public function fetchValue ( $ query ) { if ( func_num_args ( ) > 1 ) $ query = call_user_func_array ( array ( get_class ( ) , 'bind' ) , func_get_args ( ) ) ; $ result = $ query instanceof \ mysqli_result ? $ query : $ this -> query ( $ query ) ; list ( $ value ) = $ result -> fetch_row ( ) ; return $ value ; }
Query and fetch a single value .
9,470
public function save ( $ table , array $ values = array ( ) , $ update = true ) { if ( ! is_array ( reset ( $ values ) ) ) $ values = array ( $ values ) ; $ fields = array ( ) ; $ query_values = array ( ) ; $ query_update = array ( ) ; foreach ( array_keys ( reset ( $ values ) ) as $ key ) { $ field = static :: backquo...
Insert or update a record . All rows should have the same keys in the same order .
9,471
public static function quote ( $ value , $ empty = 'NULL' ) { if ( is_array ( $ value ) ) return '(' . join ( ', ' , array_map ( array ( get_class ( ) , 'quote' ) , $ value ) ) . ')' ; if ( is_null ( $ value ) ) return $ empty ; if ( is_bool ( $ value ) ) return $ value ? 'TRUE' : 'FALSE' ; if ( is_int ( $ value ) || i...
Quote a value so it can be savely used in a query .
9,472
private function loadFromFile ( $ path ) { if ( ! is_file ( $ path ) ) { return ; } $ config = require_once $ path ; if ( is_array ( $ config ) ) { $ this -> config = $ config ; } }
Load configuration from file . The file should returns an array of settings .
9,473
public static function post ( $ url , $ data = [ ] , $ method = 'POST' ) { $ ch = curl_init ( ) ; if ( ! empty ( $ data ) ) { $ data = http_build_query ( $ data ) ; } curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ method ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , fals...
Make a POST request to the end point
9,474
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( AtosCurrencyTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ Atos \ Mo...
Performs a DELETE on the database given a AtosCurrency or Criteria object OR a primary key value .
9,475
protected function loadMessages ( ) { $ message = $ this -> event -> get ( 'message' ) ; $ text = $ message [ 'text' ] ; if ( $ this -> config -> get ( 'strip_annotations' ) === true && isset ( $ message [ 'annotations' ] ) ) { $ start = $ message [ 'annotations' ] [ 0 ] [ 'startIndex' ] ; $ length = $ message [ 'annot...
Load the messages from the incoming payload .
9,476
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof \ Atos \ Model \ AtosCurrencyQuery ) { return $ criteria ; } $ query = new \ Atos \ Model \ AtosCurrencyQuery ( ) ; if ( null !== $ modelAlias ) { $ query -> setModelAlias ( $ modelAlias ) ; } if ( $ criteria instance...
Returns a new ChildAtosCurrencyQuery object .
9,477
public function filterByAtosCode ( $ atosCode = null , $ comparison = null ) { if ( is_array ( $ atosCode ) ) { $ useMinMax = false ; if ( isset ( $ atosCode [ 'min' ] ) ) { $ this -> addUsingAlias ( AtosCurrencyTableMap :: ATOS_CODE , $ atosCode [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( iss...
Filter the query on the atos_code column
9,478
public function filterByDecimals ( $ decimals = null , $ comparison = null ) { if ( is_array ( $ decimals ) ) { $ useMinMax = false ; if ( isset ( $ decimals [ 'min' ] ) ) { $ this -> addUsingAlias ( AtosCurrencyTableMap :: DECIMALS , $ decimals [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isse...
Filter the query on the decimals column
9,479
public function setLogger ( LoggerInterface $ logger ) { $ this -> logger = $ logger ; $ this -> getClient ( ) -> setLogger ( $ logger ) ; }
Sets the logger in use by the bot .
9,480
public function getLogger ( ) { if ( ! $ this -> logger ) { $ this -> logger = $ this -> getClient ( ) -> getLogger ( ) ; } return $ this -> logger ; }
Returns the logger in use by the bot .
9,481
public function run ( $ autorun = true ) { $ this -> setDependencyOverrides ( $ this -> config ) ; $ this -> getPlugins ( $ this -> config ) ; $ connections = $ this -> getConnections ( $ this -> config ) ; $ this -> getClient ( ) -> run ( $ connections , $ autorun ) ; }
Initiates an event loop for the bot in which it will connect to servers and monitor those connections for events to forward to plugins .
9,482
protected function setDependencyOverrides ( array $ config ) { if ( isset ( $ config [ 'client' ] ) ) { $ this -> setClient ( $ config [ 'client' ] ) ; } if ( isset ( $ config [ 'logger' ] ) ) { $ this -> setLogger ( $ config [ 'logger' ] ) ; } if ( isset ( $ config [ 'parser' ] ) ) { $ this -> setParser ( $ config [ '...
Sets dependencies from configuration .
9,483
protected function getConnections ( array $ config ) { if ( ! isset ( $ config [ 'connections' ] ) ) { throw new \ RuntimeException ( 'Configuration must contain a "connections" key' ) ; } if ( ! is_array ( $ config [ 'connections' ] ) || ! $ config [ 'connections' ] ) { throw new \ RuntimeException ( 'Configuration "c...
Extracts connections from configuration .
9,484
protected function getPlugins ( array $ config ) { if ( ! isset ( $ config [ 'plugins' ] ) ) { throw new \ RuntimeException ( 'Configuration must contain a "plugins" key' ) ; } if ( ! is_array ( $ config [ 'plugins' ] ) ) { throw new \ RuntimeException ( 'Configuration "plugins" key must reference an array' ) ; } $ plu...
Extracts plugins from configuration .
9,485
protected function processPlugins ( array $ plugins , array $ processors , \ SplObjectStorage $ processedPlugins = null ) { if ( $ processedPlugins === null ) { $ processedPlugins = new \ SplObjectStorage ; } foreach ( $ plugins as $ plugin ) { if ( $ processedPlugins -> contains ( $ plugin ) ) { continue ; } $ process...
Processes a list of plugins for use .
9,486
protected function getPluginProcessors ( array $ config ) { $ processors = isset ( $ config [ 'pluginProcessors' ] ) ? $ config [ 'pluginProcessors' ] : $ this -> getDefaultPluginProcessors ( ) ; if ( ! is_array ( $ processors ) ) { throw new \ RuntimeException ( 'Configuration "pluginProcessors" key must reference an ...
Returns a list of processors for plugins .
9,487
protected function validatePluginEvents ( PluginInterface $ plugin ) { $ events = $ plugin -> getSubscribedEvents ( ) ; if ( ! is_array ( $ events ) ) { throw new \ RuntimeException ( 'Plugin of class ' . get_class ( $ plugin ) . ' has getSubscribedEvents() implementation' . ' that does not return an array' ) ; } forea...
Validates a plugin s event callbacks .
9,488
protected function registerClientSubscribers ( ClientInterface $ client ) { $ client -> on ( 'irc.received' , function ( $ message , $ write , $ connection ) { $ this -> processClientEvent ( 'irc.received' , $ message , $ connection , $ write ) ; } ) ; $ client -> on ( 'irc.sent' , function ( $ message , $ write , $ co...
Configures the client to emit events for specific types of messages .
9,489
public function processClientEvent ( $ event , array $ message , ConnectionInterface $ connection , WriteStream $ write ) { $ converter = $ this -> getConverter ( ) ; $ converted = $ converter -> convert ( $ message ) ; $ converted -> setConnection ( $ connection ) ; $ client = $ this -> getClient ( ) ; $ queue = $ thi...
Callback to process client events . Not intended to be called from outside this class .
9,490
public function processOutgoingEvents ( ConnectionInterface $ connection , WriteStream $ write ) { $ client = $ this -> getClient ( ) ; $ queue = $ this -> getEventQueueFactory ( ) -> getEventQueue ( $ connection ) ; $ client -> emit ( 'irc.sending.all' , [ $ queue ] ) ; while ( $ extracted = $ queue -> extract ( ) ) {...
Callback to process any queued outgoing events . Not intended to be called from outside thie class .
9,491
protected function getEventSubtype ( EventInterface $ event ) { $ subevent = '' ; if ( $ event instanceof CtcpEvent ) { $ subevent = 'ctcp.' . strtolower ( $ event -> getCtcpCommand ( ) ) ; } elseif ( $ event instanceof UserEvent ) { $ subevent = strtolower ( $ event -> getCommand ( ) ) ; } elseif ( $ event instanceof ...
Returns an event subtype corresponding to a given event object used to generate event names when emitting events .
9,492
protected function registerPluginSubscribers ( array $ plugins ) { $ client = $ this -> getClient ( ) ; foreach ( $ plugins as $ plugin ) { $ this -> validatePluginEvents ( $ plugin ) ; $ callbacks = $ plugin -> getSubscribedEvents ( ) ; foreach ( $ callbacks as $ event => $ callback ) { $ pluginCallback = [ $ plugin ,...
Registers event callbacks from plugins .
9,493
public function getMeta ( $ key = null , $ default = null ) { if ( $ key === null ) { return $ this -> meta ; } return isset ( $ this -> meta [ $ key ] ) ? $ this -> meta [ $ key ] : $ default ; }
Get Meta Data
9,494
public function setUpdatedAtValue ( \ DateTime $ updatedAt = null ) { if ( $ updatedAt == null && $ this -> updatedAt == null ) { $ this -> updatedAt = new \ DateTime ( ) ; } else if ( $ updatedAt instanceof \ DateTime ) { $ this -> updatedAt = $ updatedAt ; } else { $ this -> updatedAt = new \ DateTime ( ) ; } }
PrePersist and PreUpdate UpdatedAt - Value
9,495
public function has ( $ key ) { return isset ( $ this -> data [ $ key ] ) || array_key_exists ( $ key , $ this -> data ) ; }
Test if key was found in original JSON even if empty
9,496
public function create ( $ name ) { $ response = giga_facebook_post ( 'me/custom_labels' , compact ( 'name' ) ) ; if ( isset ( $ response -> error ) ) { $ message = isset ( $ response -> error -> error_user_msg ) ? $ response -> error -> error_user_msg : $ response -> message ; throw new \ Exception ( $ message ) ; } i...
Create new Facebook Label
9,497
public function addLead ( $ labelId , $ leadId ) { $ response = giga_facebook_post ( $ labelId . '/label' , [ 'user' => $ leadId ] ) ; return isset ( $ response -> success ) ; }
Add lead to Facebook label
9,498
public function addLeads ( $ labelId , array $ leadIds ) { $ batch = [ ] ; foreach ( $ leadIds as $ user ) { $ batch [ ] = [ 'method' => 'POST' , 'relative_url' => $ labelId . '/label' , 'body' => http_build_query ( compact ( 'user' ) ) ] ; } $ batch = json_encode ( $ batch ) ; return giga_facebook_post ( '' , compact ...
Add many leads to Facebook Label
9,499
public function removeLead ( $ labelId , $ leadId ) { $ response = giga_facebook_delete ( $ labelId . '/label' , [ 'user' => $ leadId ] ) ; return isset ( $ response -> success ) ; }
Remove lead from FB label