idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
9,500 | public function ofLead ( $ leadId ) { $ response = giga_facebook_get ( $ leadId . '/custom_labels' ) ; if ( ! isset ( $ response -> data ) || ! is_array ( $ response -> data ) ) { return false ; } $ channels = $ response -> data ; $ channelIds = [ ] ; foreach ( $ channels as $ channel ) { $ channelIds [ ] = $ channel -... | Get all labels of lead |
9,501 | public function all ( ) { $ response = giga_facebook_get ( '/me/custom_labels?fields=name' ) ; $ channels = [ ] ; foreach ( $ response -> data as $ channel ) { $ channels [ $ channel -> id ] = $ channel -> name ; } return $ channels ; } | Get all label of a page |
9,502 | public function unexpected ( $ token , $ className = '\\JsPhpize\\Lexer\\Exception' ) { return new $ className ( 'Unexpected ' . $ token -> type . rtrim ( ' ' . ( $ token -> value ? : '' ) ) . $ this -> exceptionInfos ( ) , 8 ) ; } | Return a unexpected exception for a given token . |
9,503 | public function getApiPaths ( ) { $ paths = [ ] ; if ( $ apis = $ this -> get ( 'apis' ) ) { foreach ( $ apis as $ api ) { if ( isset ( $ api [ 'path' ] ) ) { $ paths [ ] = $ api [ 'path' ] ; } } } return $ paths ; } | Get all path strings in objects under apis |
9,504 | public function filter ( $ filter ) { preg_match_all ( "/(#\w+)/" , $ filter , $ entityNames ) ; preg_match_all ( "/(:\w+)/" , $ filter , $ positions ) ; $ entityName = is_array ( $ entityNames [ 0 ] ) && isset ( $ entityNames [ 0 ] [ 0 ] ) ? ltrim ( $ entityNames [ 0 ] [ 0 ] , '#' ) : null ; $ position = is_array ( $ ... | Get entities by their name or position |
9,505 | public function get ( $ field ) { if ( ! is_null ( $ this -> filtered ) && ! is_null ( $ this -> filtered [ 0 ] ) ) { return isset ( $ this -> filtered [ 0 ] [ 0 ] [ $ field ] ) ? $ this -> filtered [ 0 ] [ 0 ] [ $ field ] : null ; } } | Get a fields value |
9,506 | public function getPdt ( $ transactionID ) { $ this -> transactionID = $ transactionID ; $ pdtResponse = $ this -> _postData ( $ this -> pdtURL , array ( 'cmd' => '_notify-synch' , 'tx' => $ transactionID , 'at' => $ this -> pdtToken ) ) ; if ( $ pdtResponse === FALSE ) { return FALSE ; } $ this -> _logTransaction ( 'P... | The key functionality in this library . Gets the data from Paypal with a transaction id obtained from an IPN call . |
9,507 | function _postData ( $ url , $ postData ) { if ( $ this -> mockResponse !== null ) { return $ this -> mockResponse ; } $ postString = '' ; foreach ( $ postData as $ field => $ value ) { $ postString .= $ field . '=' . urlencode ( stripslashes ( $ value ) ) . '&' ; } $ curl = \ curl_init ( ) ; \ curl_setopt ( $ curl , C... | Sending data to PayPal PDT service |
9,508 | public function createFromCollection ( Collection $ collection ) { $ this -> operator = new CollectionOperator ( $ collection , $ this -> request ) ; $ this -> prepare ( ) ; return $ this ; } | Create the result based on a collection |
9,509 | private function filter ( ) { if ( $ this -> allowsFilter ( ) ) { if ( $ this -> hasFilters ( ) ) { $ tmp = [ ] ; foreach ( $ this -> filters as $ filter ) { if ( $ this -> isExcludedParameter ( $ filter [ 'key' ] ) ) { continue ; } $ tmp [ ] = $ filter ; } $ this -> filters = $ tmp ; return $ this -> operator -> filte... | Filter the result . Operator implements actual logic . |
9,510 | private function prepareConstant ( $ parameter ) { if ( ! $ this -> uriParser -> hasQueryParameter ( $ parameter ) ) { return ; } $ callback = [ $ this , $ this -> setterMethodName ( $ parameter ) ] ; $ callbackParameter = $ this -> uriParser -> queryParameter ( $ parameter ) ; call_user_func ( $ callback , $ callbackP... | Calls respective setXXX Method for the predefined parameters |
9,511 | protected function shouldSkipForEmptyUpdate ( FormInterface $ form , $ value , $ fieldDefinitionIdentifier ) { return $ value === null && ( $ form -> getRoot ( ) -> has ( "ezforms_skip_empty_update_{$fieldDefinitionIdentifier}" ) && $ form -> getRoot ( ) -> get ( "ezforms_skip_empty_update_{$fieldDefinitionIdentifier}"... | Returns if the update should be skipped for empty value . |
9,512 | private function parse_query_args ( $ atts ) { if ( ! is_array ( $ atts [ 'query_args' ] ) ) { $ arr = @ json_decode ( $ atts [ 'query_args' ] , true ) ; if ( is_array ( $ arr ) ) { $ atts [ 'query_args' ] = $ arr ; } } $ query_args = $ atts [ 'query_args' ] ; if ( is_numeric ( $ atts [ 'limit' ] ) && $ atts [ 'limit' ... | Parse simple query args . |
9,513 | public function toJsonResponse ( $ bodyKey = 'data' , $ options = 0 ) { return new JsonResponse ( array_merge ( [ $ bodyKey => $ this -> body ] , array_filter ( $ this -> responseData ) ) , $ this -> httpStatusCode , [ 'Content-Type' => 'application/vnd.api+json' ] , $ options ) ; } | Returns a JsonResponse with the set parameters and body . |
9,514 | public static function selectMatchList ( $ matchState ) { $ matchState = ( object ) $ matchState ; $ matchList = [ ] ; foreach ( $ matchState -> match as $ matchKey => $ matchItem ) { $ matchList [ $ matchKey ] = $ matchItem ; } return $ matchList ; } | Select a list of active matches . |
9,515 | public static function selectMatchListForGame ( $ matchState , $ gameKey ) { $ matchState = ( object ) $ matchState ; $ gameKey = ( string ) $ gameKey ; $ matchList = [ ] ; foreach ( $ matchState -> match as $ matchKey => $ matchItem ) { if ( $ matchItem -> gameKey != $ gameKey ) { continue ; } $ matchList [ $ matchKey... | Select a list of active matches for a game . |
9,516 | public static function selectMatchItem ( $ matchState , $ matchKey ) { $ matchState = ( object ) $ matchState ; $ matchKey = ( string ) $ matchKey ; $ matchItem = $ matchState -> match -> $ matchKey ; return $ matchItem ; } | Get details about a single match from a match - state as returned by the gameye api . |
9,517 | public static function selectLocationListForGame ( $ gameState , $ gameKey ) { $ gameState = ( object ) $ gameState ; $ gameKey = ( string ) $ gameKey ; $ locationList = [ ] ; foreach ( $ gameState -> game -> $ gameKey -> location as $ locationKey => $ hasLocation ) { if ( ! $ hasLocation ) { continue ; } $ locationIte... | Selects all locations for a given game . |
9,518 | public static function selectTemplateList ( $ templateState ) { $ templateState = ( object ) $ templateState ; $ templateList = [ ] ; foreach ( $ templateState -> template as $ templateKey => $ templateItem ) { $ templateList [ $ templateKey ] = $ templateItem ; } return $ templateList ; } | Select a list of templates . |
9,519 | public static function selectTemplateItem ( $ templateState , $ templateKey ) { $ templateState = ( object ) $ templateState ; $ templateKey = ( string ) $ templateKey ; $ templateItem = $ templateState -> template -> $ templateKey ; return $ templateItem ; } | Get details about a single template from a template - state as returned by the gameye api . |
9,520 | public static function selectTeamList ( $ statisticState ) { $ statisticState = ( object ) $ statisticState ; $ teamList = [ ] ; foreach ( $ statisticState -> team as $ teamKey => $ teamItem ) { $ teamList [ $ teamKey ] = $ teamItem ; } return $ teamList ; } | Get a list of all teams in the statistic - state . |
9,521 | public static function selectTeamItem ( $ statisticState , $ teamKey ) { $ statisticState = ( object ) $ statisticState ; $ teamKey = ( string ) $ teamKey ; $ teamItem = $ statisticState -> team -> $ teamKey ; return $ teamItem ; } | Get a single team from the statistic - state . |
9,522 | public static function selectPlayerList ( $ statisticState ) { $ statisticState = ( object ) $ statisticState ; $ playerList = [ ] ; foreach ( $ statisticState -> player as $ playerKey => $ playerItem ) { $ playerList [ $ playerKey ] = $ playerItem ; } return $ playerList ; } | List all players in the match . |
9,523 | public static function selectPlayerListForTeam ( $ statisticState , $ teamKey ) { $ statisticState = ( object ) $ statisticState ; $ playerList = [ ] ; foreach ( $ statisticState -> team -> $ teamKey -> player as $ playerKey => $ playerEnabled ) { $ playerItem = $ statisticState -> player -> $ playerKey ; $ playerList ... | Get a list if all players in a team . |
9,524 | public static function selectPlayerItem ( $ statisticState , $ playerKey ) { $ statisticState = ( object ) $ statisticState ; $ playerKey = ( string ) $ playerKey ; $ playerItem = $ statisticState -> player -> $ playerKey ; return $ playerItem ; } | Get a single player in the match . |
9,525 | public function output ( ) { $ lead = Conversation :: get ( 'lead' ) ; if ( isset ( $ this -> attributes [ 'id' ] ) ) { $ id = $ this -> attributes [ 'id' ] ; $ lead = LeadModel :: whereUserId ( $ id ) -> first ( ) ; } foreach ( $ this -> attributes as $ key => $ value ) { if ( $ key === 'id' ) { continue ; } return $ ... | Define the shortcode s output |
9,526 | private function verifyToken ( ) { $ received = Request :: getReceivedData ( ) ; if ( is_array ( $ received ) && isset ( $ received [ 'hub_verify_token' ] ) && strtolower ( $ received [ 'hub_verify_token' ] ) == 'gigaai' ) { echo $ received [ 'hub_challenge' ] ; exit ; } } | Verify token from Facebook |
9,527 | public function getUser ( $ lead_id ) { $ end_point = $ this -> getResource ( ) . "{$lead_id}?access_token=" . $ this -> getAccessToken ( ) ; $ data = giga_remote_get ( $ end_point ) ; return ( array ) $ data ; } | Get user data |
9,528 | public function sendSubscribeRequest ( $ attributes ) { $ token = isset ( $ attributes [ 'access_token' ] ) ? $ attributes [ 'access_token' ] : $ this -> getAccessToken ( ) ; $ page_id = $ attributes [ 'page_id' ] ; $ end_point = $ this -> getResource ( ) . '/' . $ page_id . '/subscribed_apps?access_token=' . $ token ;... | Send subscribe request to FB |
9,529 | public function formatIncomingRequest ( $ telegram ) { if ( ! empty ( $ telegram ) && is_array ( $ telegram ) ) { $ sender_id = null ; $ time = null ; if ( isset ( $ telegram [ 'callback_query' ] ) ) { $ message = $ telegram [ 'callback_query' ] ; $ sender_id = $ telegram [ 'callback_query' ] [ 'from' ] [ 'id' ] ; $ ti... | Convert Telegram to Facebook request |
9,530 | public function sendMessage ( $ body ) { $ action = 'sendMessage' ; $ telegram = [ 'chat_id' => $ body [ 'recipient' ] [ 'id' ] ] ; $ message = $ body [ 'message' ] ; if ( isset ( $ message [ 'text' ] ) ) { $ telegram [ 'text' ] = $ message [ 'text' ] ; } if ( isset ( $ message [ 'attachment' ] [ 'type' ] ) ) { $ conve... | Convert Facebook request back to Telegram request |
9,531 | private function callMethod ( $ method , $ params ) { $ params [ 'chat_id' ] = Conversation :: get ( 'lead_id' ) ; return giga_remote_post ( $ this -> getResource ( $ method ) , $ params ) ; } | Call Telegram method via HTTP |
9,532 | private function sendGeneric ( $ payload ) { foreach ( $ payload [ 'elements' ] as $ element ) { $ generic = [ ] ; if ( isset ( $ element [ 'image_url' ] ) ) { $ generic [ 'photo' ] = $ element [ 'image_url' ] ; $ generic [ 'caption' ] = $ element [ 'title' ] ; $ keyboard = $ this -> convertToInlineKeyboard ( $ element... | Convert Generic to Photo with Caption + Buttons |
9,533 | public function sendTyping ( ) { $ lead_id = Conversation :: get ( 'lead_id' ) ; $ body = [ 'chat_id' => $ lead_id , 'action' => 'typing' ] ; giga_remote_post ( $ this -> getResource ( 'sendChatAction' ) , $ body ) ; } | Send typing indicator |
9,534 | public function getUser ( $ lead_id ) { $ raw = Conversation :: get ( 'request_raw' ) ; if ( isset ( $ raw [ 'callback_query' ] ) ) { $ raw = $ raw [ 'callback_query' ] ; $ user = $ raw [ 'from' ] ; } else { $ user = $ raw [ 'message' ] [ 'from' ] ; } return [ 'user_id' => $ lead_id , 'first_name' => $ user [ 'first_na... | Method to get current user |
9,535 | public function addNode ( $ pattern , $ answers = null , $ attributes = [ ] ) { if ( is_array ( $ pattern ) && is_null ( $ answers ) ) { $ this -> addNodes ( $ pattern , $ attributes ) ; return null ; } $ type_pattern = $ this -> getNodeTypeAndPattern ( $ pattern ) ; list ( $ type , $ pattern ) = $ type_pattern ; if ( ... | Add Node to the Database |
9,536 | private function getNodeTypeAndPattern ( $ pattern ) { $ node_type = 'text' ; foreach ( [ 'payload' , 'default' , 'attachment' ] as $ type ) { if ( strpos ( $ pattern , $ type . ':' ) !== false ) { $ node_type = $ type ; $ pattern = str_replace ( $ node_type . ':' , '' , $ pattern ) ; } } if ( ! empty ( $ pattern ) && ... | Get Node type and Pattern |
9,537 | public function addNodes ( $ nodes , $ attributes = [ ] ) { foreach ( $ nodes as $ pattern => $ answers ) { $ this -> addNode ( $ pattern , $ answers , $ attributes ) ; } } | Add Multiple Nodes |
9,538 | public function persistNode ( array $ answers , $ node_type , $ pattern = null , $ attributes = [ ] ) { foreach ( $ answers as $ index => $ answer ) { if ( isset ( $ answer [ 'type' ] ) && isset ( $ answer [ 'content' ] ) && is_callable ( $ answer [ 'content' ] ) ) { $ answer [ 'content' ] = is_string ( $ answer [ 'con... | Add answer to node |
9,539 | public function parse ( $ answers ) { $ parsed = [ ] ; $ previous_index = 0 ; if ( $ this -> isSingularResponse ( $ answers ) ) { $ answers = [ $ answers ] ; } foreach ( $ answers as $ index => $ answer ) { if ( ! is_string ( $ answer ) && is_callable ( $ answer ) ) { $ answer = [ 'type' => 'callback' , 'content' => $ ... | Parse the answers to correct FB Format . |
9,540 | private function parseAttachmentMessage ( $ index , $ answer ) { $ templateType = null ; if ( isset ( $ answer [ 'type' ] ) ) { $ templateType = $ answer [ 'type' ] ; } $ attachment = $ index === 'attachment' ? $ answer : $ answer [ 'attachment' ] ; if ( isset ( $ attachment [ 'payload' ] ) && isset ( $ attachment [ 'p... | If message starts with attachment parameter . We ll keep everything inside that param and only check message type . |
9,541 | private function isSingularResponse ( $ answer ) { return ( is_string ( $ answer ) || is_callable ( $ answer ) || array_key_exists ( 'buttons' , $ answer ) || array_key_exists ( 'elements' , $ answer ) || ( is_array ( $ answer ) && isset ( $ answer [ 0 ] ) && is_array ( $ answer [ 0 ] ) && array_key_exists ( 'title' , ... | Check if answers input is single answer |
9,542 | public function addIntendedAction ( $ action ) { if ( empty ( $ this -> current_node -> type ) || $ this -> current_node -> type == 'welcome' ) { return ; } if ( is_callable ( $ action ) ) { $ related = $ this -> current_node ; $ then_node = $ this -> persistNode ( [ [ 'type' => 'callback' , 'content' => $ action , ] ,... | Add intended action for current node |
9,543 | public function taggedAs ( $ tag ) { if ( empty ( $ this -> current_node ) ) { return ; } $ this -> current_node -> tags = $ tag ; $ this -> current_node -> save ( ) ; } | Tag a node |
9,544 | public function normalize ( ) { $ url = $ this -> getMediaUrl ( $ this -> mediaType ) ; return [ 'type' => $ this -> mediaType , 'content' => [ 'attachment' => [ 'type' => $ this -> mediaType , 'payload' => [ 'url' => $ url , 'is_reusable' => true ] ] ] ] ; } | Convert to Facebook format to response |
9,545 | public function detectMediaType ( $ url ) { foreach ( $ this -> availableTypes as $ type ) { if ( starts_with ( $ url , $ type . ':' ) ) { return $ type ; } } if ( giga_match ( '%(.jpg|.png|.bmp|.gif|.jpeg|.tiff|.gif)%' , $ url ) ) { return 'image' ; } if ( giga_match ( '%(.avi|.flv|.mp4|.mkv|.3gp|.webm|.vob|.mov|.rm|.... | Guess media type from URL |
9,546 | public function expectedIs ( $ type ) { if ( is_array ( $ this -> body ) && isset ( $ this -> body [ 'attachment' ] ) && isset ( $ this -> body [ 'attachment' ] [ 'type' ] ) ) { return true ; } if ( is_string ( $ this -> body ) ) { $ fileExtension = $ this -> detectMediaType ( $ this -> body ) ; return $ fileExtension ... | Check current message format |
9,547 | public function getMediaUrl ( $ mediaType ) { $ url = $ this -> body ; if ( is_array ( $ this -> body ) && isset ( $ this -> body [ 'attachment' ] [ 'payload' ] [ 'url' ] ) && is_string ( $ this -> body [ 'attachment' ] [ 'payload' ] [ 'url' ] ) ) { $ url = $ this -> body [ 'attachment' ] [ 'payload' ] [ 'url' ] ; } $ ... | Get media URL |
9,548 | public function getManagerConfig ( $ name ) { if ( $ this -> managerBag -> has ( $ name ) ) { $ config = $ this -> managerBag -> get ( $ name ) ; if ( null === $ config [ 'template' ] ) { $ config [ 'template' ] = $ this -> defaultManagerConfig [ 'template' ] ; } } elseif ( class_exists ( $ name ) ) { $ config = $ this... | Get pagination manager config |
9,549 | protected function indent ( $ output , $ spaces = 3 , $ rewrap = false ) { if ( ! $ output ) { return '' ; } $ line = 78 ; $ spaces = str_pad ( ' ' , $ spaces ) ; if ( $ rewrap ) { $ existing_indent = '' ; if ( preg_match ( '/^( +)/' , $ output , $ matches ) ) { $ spaces .= $ matches [ 1 ] ; } $ output = preg_replace (... | Indents the given lines |
9,550 | private function load ( $ simulate = [ ] ) { $ stream = json_decode ( file_get_contents ( 'php://input' ) , true ) ; self :: $ received = ( ! empty ( $ stream ) ) ? $ stream : $ _REQUEST ; if ( ! empty ( $ simulate ) ) { self :: $ received = $ simulate ; } Conversation :: set ( 'request_raw' , self :: $ received ) ; $ ... | Setup data and run command based on received data |
9,551 | private function getReceivedData ( $ key = null ) { $ received = self :: $ received ; if ( $ key !== null ) { if ( is_array ( $ received ) && isset ( $ received [ $ key ] ) ) { return $ received [ $ key ] ; } if ( isset ( $ received -> $ key ) ) { return $ received -> $ key ; } return null ; } return is_object ( $ rece... | Get received request |
9,552 | private function sendMessages ( $ messages , $ attributes = [ ] , $ lead = null ) { $ accessToken = Config :: get ( 'access_token' ) ; if ( $ accessToken === null && $ lead !== null ) { $ instance = $ lead -> instance ( ) -> first ( ) ; if ( $ instance !== null ) { Config :: set ( $ instance -> meta ) ; } } $ batch = [... | Send multiple messages |
9,553 | private function getTypeAndPattern ( $ event ) { $ type = 'text' ; $ pattern = '' ; if ( isset ( $ event [ 'message' ] ) && isset ( $ event [ 'message' ] [ 'text' ] ) ) { $ pattern = $ event [ 'message' ] [ 'text' ] ; } if ( isset ( $ event [ 'message' ] ) && isset ( $ event [ 'message' ] [ 'attachments' ] ) ) { $ type... | Get Message Type and Pattern of an Event |
9,554 | protected function output ( ) { $ attrs = '' ; $ classes = 'fa-layers-text' ; $ transforms = '' ; if ( ! empty ( $ this -> classes ) && count ( $ this -> classes ) > 0 ) { $ classes .= ' ' . implode ( ' ' , $ this -> classes ) ; } if ( ! empty ( $ this -> attributes ) && count ( $ this -> attributes ) > 0 ) { foreach (... | Outputs the FontAwesomeText object as an HTML string |
9,555 | protected static function bootEloquentTypecastTrait ( ) { $ class = get_called_class ( ) ; $ instance = new $ class ( ) ; foreach ( $ instance -> getCastAttributes ( ) as $ attribute => $ type ) { static :: $ mutatorCache [ $ class ] [ ] = $ attribute ; } } | Boot the typecasting trait for a model which will add all our typecast - able attributes to the mutator cache . This way they get mutated without us needing to write a mutator function for each one . |
9,556 | protected function mutateAttribute ( $ key , $ value ) { if ( $ this -> isCastableAttribute ( $ key ) ) { return $ this -> castAttribute ( $ key , $ value ) ; } return parent :: mutateAttribute ( $ key , $ value ) ; } | Get the value of an attribute using its mutator . If the attribute is typecast - able then return the cast value instead . |
9,557 | public function setAttribute ( $ key , $ value ) { if ( $ this -> castOnSet ( ) && $ this -> isCastableAttribute ( $ key ) ) { $ value = $ this -> castAttribute ( $ key , $ value ) ; } return parent :: setAttribute ( $ key , $ value ) ; } | Set a given attribute on the model . If the attribute is typecast - able then cast the value before setting it . |
9,558 | protected function getAttributeValue ( $ key ) { $ value = parent :: getAttributeValue ( $ key ) ; if ( $ this -> isCastableAttribute ( $ key ) ) { $ value = $ this -> castAttribute ( $ key , $ value ) ; } return $ value ; } | Get a given attribute on the model . If the attribute is typecast - able then cast the value before getting it . |
9,559 | protected function castAttribute ( $ key , $ value ) { $ type = $ this -> cast [ $ key ] ; try { if ( is_null ( $ value ) ) { return null ; } if ( settype ( $ value , $ type ) ) { return $ value ; } throw new EloquentTypecastException ( "Value could not be cast to type \"$type\"" , 1 ) ; } catch ( \ Exception $ e ) { t... | Cast an attribute to a PHP variable type . |
9,560 | public function removePatterns ( $ removeFunction ) { $ this -> clearPatternsCache ( ) ; $ this -> options [ 'patterns' ] = array_filter ( $ this -> options [ 'patterns' ] , $ removeFunction ) ; return $ this ; } | Remove patterns using a filter function . |
9,561 | public function getPatterns ( ) { if ( ! $ this -> patternsCache ) { $ this -> patternsCache = $ this -> getOption ( 'patterns' ) ; usort ( $ this -> patternsCache , function ( Pattern $ first , Pattern $ second ) { return $ first -> priority - $ second -> priority ; } ) ; } return $ this -> patternsCache ; } | Return cached and ordered patterns list . |
9,562 | public function getHelperName ( $ key ) { $ helpers = $ this -> getOption ( 'helpers' , [ ] ) ; return is_array ( $ helpers ) && isset ( $ helpers [ $ key ] ) ? $ helpers [ $ key ] : $ key ; } | Retrieve the prefix of specific variables . |
9,563 | protected function createCountQuery ( array $ fields = [ ] , array $ criteria = [ ] , $ distinct = true ) { if ( $ this -> objectManager instanceof \ Doctrine \ ORM \ EntityManager ) { $ builder = $ this -> objectManager -> createQueryBuilder ( ) ; if ( empty ( $ fields ) ) { $ classMetadata = $ this -> objectManager -... | Create internal count items query |
9,564 | protected function createSelectQuery ( array $ fields = [ ] , array $ criteria = [ ] , array $ orderBy = [ ] , $ distinct = true ) { if ( $ this -> objectManager instanceof \ Doctrine \ ORM \ EntityManager ) { $ builder = $ this -> objectManager -> createQueryBuilder ( ) ; $ builder -> select ( empty ( $ fields ) ? 'p'... | Create internal select items query |
9,565 | protected function removeChar ( $ string , $ charStart = null , $ charEnd = null ) { if ( ! is_null ( $ charStart ) && ( is_string ( $ charStart ) || is_array ( $ charStart ) ) ) { if ( is_string ( $ charStart ) ) { $ charStart = [ $ charStart ] ; } foreach ( $ charStart as $ char ) { if ( substr ( $ string , 0 , 1 ) =... | Remove char at start or end position of a string . |
9,566 | protected function handleError ( $ type , $ message , $ file , $ line ) { throw new ResourceException ( sprintf ( '%s: "%s" in %s on line %d' , $ type , $ message , $ file , $ line ) ) ; } | Handle error and throw a new ResourceException . |
9,567 | protected function filterItems ( array $ items ) { $ data = [ ] ; foreach ( $ items as $ item ) { $ item = trim ( $ item ) ; if ( empty ( $ item ) ) { continue ; } $ item = $ this -> removeChar ( $ item , '[' , ']' ) ; if ( $ this -> itemIsSerialized ( $ item ) ) { $ data [ ] = unserialize ( $ item ) ; continue ; } if ... | Filter the items . |
9,568 | protected function parseArray ( $ data ) { $ pattern = '/(\[[^\[\]]*\])/' ; set_error_handler ( [ __CLASS__ , 'handleError' ] ) ; while ( true ) { if ( ! preg_match ( $ pattern , $ data , $ matches ) > 0 ) { break ; } $ stringMatches = trim ( $ matches [ 0 ] ) ; $ items = explode ( ',' , $ stringMatches ) ; $ currentDa... | Parse a string that represents an array statement to create an array data . |
9,569 | public function getEventQueue ( ConnectionInterface $ connection ) { if ( ! isset ( $ this -> queues [ $ connection ] ) ) { $ this -> queues [ $ connection ] = new EventQueue ; } return $ this -> queues [ $ connection ] ; } | Returns the event queue for a specified connection . |
9,570 | public function linkedUser ( $ props = [ ] ) { if ( ! $ this -> isLinked ( ) && isset ( $ props [ 'try_matching' ] ) && $ props [ 'try_matching' ] === true ) { return Matching :: matchCurrentLead ( ) ; } return $ this -> belongsTo ( $ this -> getUserModel ( ) , 'linked_account' , $ this -> getUserModelKey ( ) ) ; } | Laravel linked user |
9,571 | public function user ( $ props = [ ] ) { if ( ! $ this -> isLinked ( ) && isset ( $ props [ 'try_matching' ] ) && $ props [ 'try_matching' ] === true ) { return Matching :: matchCurrentLead ( ) ; } return $ this -> linkedUser ( ) -> first ( ) ; } | Linked user relationship |
9,572 | public function run ( ) { $ received = $ this -> request -> getReceivedData ( ) ; if ( ! $ received || empty ( $ received [ 'object' ] ) || $ received [ 'object' ] != 'page' ) { return ; } $ this -> received = $ received ; if ( ! isset ( $ received [ 'entry' ] ) ) { return ; } foreach ( $ received [ 'entry' ] as $ entr... | Run the bot |
9,573 | public function processEvent ( $ event ) { if ( isset ( $ event [ 'request_thread_control' ] ) ) { return $ this -> passToInbox ( ) ; } if ( isset ( $ event [ 'account_linking' ] ) ) { return AccountLinking :: process ( $ event ) ; } if ( ! isset ( $ event [ 'message' ] ) && ! isset ( $ event [ 'postback' ] ) ) { retur... | Process the event and response |
9,574 | private function initNlp ( $ message ) { if ( isset ( $ message [ 'nlp' ] ) && is_array ( $ message [ 'nlp' ] ) ) { $ this -> nlp = new Nlp ( $ message [ 'nlp' ] ) ; Conversation :: set ( 'nlp' , $ this -> nlp ) ; } } | Load NLP Data |
9,575 | public function response ( $ nodes , $ lead_id = null ) { foreach ( $ nodes as $ node ) { if ( ! empty ( $ node -> wait ) ) { $ lead = $ this -> conversation -> get ( 'lead' ) ; $ lead -> data ( '_wait' , $ node -> wait ) ; } $ answers = $ this -> parse ( $ node -> answers ) ; $ this -> request -> sendMessages ( $ answ... | Response sender message |
9,576 | public function findNodes ( $ message_type , $ ask ) { $ nodes = Node :: findByTypeAndPattern ( $ message_type , $ ask ) ; if ( $ nodes -> count ( ) === 0 ) { $ nodes = Node :: findByTypeAndPattern ( 'default' ) ; } return $ nodes -> filter ( function ( $ node ) { $ pageId = Conversation :: get ( 'page_id' ) ; return (... | Find a response for current request |
9,577 | private function responseIntendedAction ( ) { $ lead = $ this -> conversation -> get ( 'lead' ) ; $ waiting = $ lead -> _wait ; $ this -> conversation -> set ( 'previous_intended_action' , $ waiting ) ; if ( ! empty ( $ waiting ) ) { $ lead -> update ( [ '_wait' => false ] ) ; if ( is_numeric ( $ waiting ) ) { $ nodes ... | Response for intended actions |
9,578 | public function getLocation ( $ output = '' ) { $ attachments = $ this -> getAttachments ( ) ; $ location = new \ stdClass ( ) ; if ( ! empty ( $ attachments ) && isset ( $ attachments [ 0 ] [ 'type' ] ) && $ attachments [ 0 ] [ 'type' ] === 'location' ) { $ location = $ attachments [ 0 ] [ 'payload' ] -> coordinates ;... | Get user sent location |
9,579 | public function getAttachments ( ) { if ( $ this -> isUserMessage ( ) && isset ( $ this -> message -> attachments ) ) { return $ this -> message -> attachments ; } return null ; } | Get user attachments |
9,580 | public function getReceivedText ( ) { if ( $ this -> isUserMessage ( ) ) { return isset ( $ this -> message -> text ) ? $ this -> message -> text : '' ; } return '' ; } | Get user sent text |
9,581 | private function isUserMessage ( ) { if ( ! empty ( $ this -> message ) && isset ( $ this -> message [ 'metadata' ] ) ) { return $ this -> message [ 'metadata' ] != 'SENT_BY_GIGA_AI' ; } return true ; } | Check if current message is sent by user |
9,582 | public static function load ( $ body , $ flags = [ ] ) { $ instance = new static ( $ body ) ; if ( ! isset ( $ flags [ 'skip_detection' ] ) || ! $ flags [ 'skip_detection' ] ) { if ( ! $ instance -> expectedFormat ( ) ) { return false ; } } return $ instance -> normalize ( ) ; } | Load the message to parse and return |
9,583 | public static function parse ( $ answer ) { if ( ! is_array ( $ answer ) ) { return ; } foreach ( $ answer as $ key => $ value ) { $ parsed = is_array ( $ value ) ? self :: parse ( $ value ) : self :: process ( $ value ) ; if ( ! empty ( $ parsed ) ) { $ answer [ $ key ] = $ parsed ; } else { unset ( $ answer [ $ key ]... | Recursive parse shortcode from array |
9,584 | public function render ( $ input , $ filename = null , array $ variables = [ ] ) { if ( is_array ( $ filename ) ) { $ variables = $ filename ; $ filename = null ; } if ( ! in_array ( $ this -> stream , $ this -> streamsRegistered ) ) { $ this -> streamsRegistered [ ] = $ this -> stream ; if ( in_array ( $ this -> strea... | Compile and return the code execution result . |
9,585 | public function share ( $ variables , $ value = null ) { if ( ! is_array ( $ variables ) ) { $ variables = [ strval ( $ variables ) => $ value ] ; } $ this -> sharedVariables = array_merge ( $ this -> sharedVariables , $ variables ) ; } | Add a variable or an array of variables to be shared with all templates that will be rendered by the instance of Pug . |
9,586 | public function fulfillRequest ( ) { if ( ! $ this -> supportsMethod ( $ this -> request -> method ) ) { throw new Exception ( 'Method not allowed' , static :: ERROR_SCOPE | static :: ERROR_HTTP_METHOD_NOT_ALLOWED , BaseResponse :: HTTP_METHOD_NOT_ALLOWED ) ; } $ methodName = static :: methodHandlerName ( $ this -> req... | Fulfill the API request and return a response . |
9,587 | protected function loadRelatedModels ( Model $ model ) { $ relations = $ this -> exposedRelationsFromRequest ( $ model ) ; foreach ( $ relations as $ relation ) { if ( in_array ( $ relation , $ model -> relationsFromMethod ( ) ) ) { $ model -> $ relation = $ model -> $ relation ( ) ; continue ; } $ model -> load ( $ re... | Load a model s relations |
9,588 | protected function exposedRelationsFromRequest ( $ model = null ) { $ exposedRelations = static :: $ exposedRelations ; if ( count ( $ this -> request -> include ) == 0 ) { if ( $ model !== null && $ model instanceof Model ) { $ exposedRelations = array_intersect ( $ exposedRelations , $ model -> defaultExposedRelation... | Returns which requested resources are available to include . |
9,589 | protected function getIncludedModels ( $ models ) { $ links = new Collection ( ) ; $ models = $ models instanceof Collection ? $ models : [ $ models ] ; foreach ( $ models as $ model ) { foreach ( $ this -> exposedRelationsFromRequest ( $ model ) as $ relationName ) { $ value = static :: getModelsForRelation ( $ model ... | Iterate through result set to fetch the requested resources to include . |
9,590 | protected function getPaginationLinks ( $ paginator ) { $ links = [ ] ; $ links [ 'self' ] = urldecode ( $ paginator -> url ( $ paginator -> currentPage ( ) ) ) ; $ links [ 'first' ] = urldecode ( $ paginator -> url ( 1 ) ) ; $ links [ 'last' ] = urldecode ( $ paginator -> url ( $ paginator -> lastPage ( ) ) ) ; $ link... | Return pagination links as array |
9,591 | protected function getNonBreakingErrors ( ) { $ errors = [ ] ; $ unknownRelations = $ this -> unknownRelationsFromRequest ( ) ; if ( count ( $ unknownRelations ) > 0 ) { $ errors [ ] = [ 'code' => static :: ERROR_UNKNOWN_LINKED_RESOURCES , 'title' => 'Unknown included resource requested' , 'description' => 'These inclu... | Return errors which did not prevent the API from returning a result set . |
9,592 | public static function successfulHttpStatusCode ( $ method , $ model = null ) { if ( ( $ method === 'PATCH' || $ method === 'PUT' ) && $ model instanceof Model ) { if ( $ model -> isChanged ( ) ) { $ method = 'GET' ; } } switch ( $ method ) { case 'POST' : return BaseResponse :: HTTP_CREATED ; case 'PATCH' : case 'PUT'... | A method for getting the proper HTTP status code for a successful request |
9,593 | protected static function getModelsForRelation ( $ model , $ relationKey ) { if ( ! method_exists ( $ model , $ relationKey ) ) { throw new Exception ( 'Relation "' . $ relationKey . '" does not exist in model' , static :: ERROR_SCOPE | static :: ERROR_UNKNOWN_ID , BaseResponse :: HTTP_INTERNAL_SERVER_ERROR ) ; } $ rel... | Returns the models from a relationship . Will always return as array . |
9,594 | protected function handleSortRequest ( $ cols , $ model ) { foreach ( $ cols as $ col ) { $ dir = 'asc' ; if ( substr ( $ col , 0 , 1 ) == '-' ) { $ dir = 'desc' ; $ col = substr ( $ col , 1 ) ; } $ model = $ model -> orderBy ( $ col , $ dir ) ; } return $ model ; } | Function to handle sorting requests . |
9,595 | protected function parseRequestContent ( $ content , $ type ) { $ content = json_decode ( $ content , true ) ; if ( empty ( $ content [ 'data' ] ) ) { throw new Exception ( 'Payload either contains misformed JSON or missing "data" parameter.' , static :: ERROR_SCOPE | static :: ERROR_INVALID_ATTRS , BaseResponse :: HTT... | Parses content from request into an array of values . |
9,596 | protected function handlePaginationRequest ( $ request , $ model , $ total = null ) { $ page = $ request -> pageNumber ; $ perPage = $ request -> pageSize ; if ( ! $ total ) { $ total = $ model -> count ( ) ; } $ results = $ model -> forPage ( $ page , $ perPage ) -> get ( array ( '*' ) ) ; $ paginator = new LengthAwar... | Function to handle pagination requests . |
9,597 | protected function handleFilterRequest ( $ filters , $ model ) { foreach ( $ filters as $ key => $ value ) { $ model = $ model -> where ( $ key , '=' , $ value ) ; } return $ model ; } | Function to handle filtering requests . |
9,598 | protected function handleGetDefault ( Request $ request , $ model ) { $ total = null ; if ( empty ( $ request -> id ) ) { if ( ! empty ( $ request -> filter ) ) { $ model = $ this -> handleFilterRequest ( $ request -> filter , $ model ) ; } if ( ! empty ( $ request -> sort ) ) { if ( $ request -> pageNumber ) { $ total... | Default handling of GET request . Must be called explicitly in handleGet function . |
9,599 | protected function validateModelData ( Model $ model , Array $ values ) { $ validationResponse = $ model -> validateArray ( $ values ) ; if ( $ validationResponse === true ) { return true ; } throw new Exception \ Validation ( 'Bad Request' , static :: ERROR_SCOPE | static :: ERROR_HTTP_METHOD_NOT_ALLOWED , BaseRespons... | Validates passed data against a model Validation performed safely and only if model provides rules |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.