idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
5,500 | private function createResponse ( BuzzResponse $ response ) { $ body = $ response -> getContent ( ) ; return $ this -> responseFactory -> createResponse ( $ response -> getStatusCode ( ) , null , $ this -> getBuzzHeaders ( $ response ) , $ body , number_format ( $ response -> getProtocolVersion ( ) , 1 ) ) ; } | Converts a Buzz response into a PSR response . |
5,501 | private function addPsrHeadersToBuzzRequest ( RequestInterface $ request , BuzzRequest $ buzzRequest ) { $ headers = $ request -> getHeaders ( ) ; foreach ( $ headers as $ name => $ values ) { foreach ( $ values as $ header ) { $ buzzRequest -> addHeader ( $ name . ': ' . $ header ) ; } } } | Apply headers on a Buzz request . |
5,502 | private function getBuzzHeaders ( BuzzResponse $ response ) { $ buzzHeaders = $ response -> getHeaders ( ) ; unset ( $ buzzHeaders [ 0 ] ) ; $ headers = [ ] ; foreach ( $ buzzHeaders as $ headerLine ) { list ( $ name , $ value ) = explode ( ':' , $ headerLine , 2 ) ; $ headers [ $ name ] = trim ( $ value ) ; } return $... | Get headers from a Buzz response . |
5,503 | private function assertRequestHasValidBody ( RequestInterface $ request ) { $ validMethods = [ BuzzRequestInterface :: METHOD_POST , BuzzRequestInterface :: METHOD_PUT , BuzzRequestInterface :: METHOD_DELETE , BuzzRequestInterface :: METHOD_PATCH , BuzzRequestInterface :: METHOD_OPTIONS , ] ; if ( $ this -> client inst... | Assert that the request has a valid body based on the request method . |
5,504 | public function getPaymentStatus ( ) { if ( isset ( $ this -> data -> ewallet -> status ) ) { return ( string ) $ this -> data -> ewallet -> status ; } } | Get raw payment status . |
5,505 | public function onStart ( swoole_server $ server ) { if ( version_compare ( SWOOLE_VERSION , '1.9.5' , '<' ) ) { file_put_contents ( $ this -> pidFile , $ server -> master_pid ) ; $ this -> pid = $ server -> master_pid ; } process_rename ( $ this -> name . ' master' ) ; $ this -> output -> writeln ( sprintf ( "Listen: ... | Base start handle . Storage process id . |
5,506 | public function call ( $ verb , $ endpoint , $ options = [ ] ) { if ( $ this -> validMethod ( $ verb ) ) { $ headers = isset ( $ options [ 'headers' ] ) ? $ options [ 'headers' ] : [ ] ; $ body = isset ( $ options [ 'body' ] ) ? $ options [ 'body' ] : null ; $ pv = isset ( $ options [ 'protocol_version' ] ) ? $ options... | Make the call to Eventbrite only synchronous calls at present . |
5,507 | public function parseResponse ( ResponseInterface $ response ) { $ body = $ response -> getBody ( ) -> getContents ( ) ; return [ 'code' => $ response -> getStatusCode ( ) , 'headers' => $ response -> getHeaders ( ) , 'body' => ( $ this -> isValidJson ( $ body ) ) ? json_decode ( $ body , true ) : $ body , ] ; } | Parses the response from |
5,508 | public function canConnect ( ) { $ data = $ this -> get ( self :: CURRENT_USER_ENDPOINT ) ; if ( strpos ( $ data [ 'code' ] , '2' ) === 0 ) { return true ; } return false ; } | Checks if the class can connect to the Eventbrite API . |
5,509 | public function whereSuit ( string $ name ) { $ name = rtrim ( $ name , 's' ) ; return $ this -> filter ( function ( Card $ card ) use ( $ name ) { return $ card -> suit ( ) -> equals ( call_user_func ( Suit :: class . '::' . $ name ) ) ; } ) ; } | Get cards where Suit value is ... |
5,510 | public function whereValue ( int $ value ) { return $ this -> filter ( function ( Card $ card ) use ( $ value ) { return $ card -> value ( ) === $ value ; } ) ; } | Get cards where Card Value is .. |
5,511 | public function sortByValue ( $ sort = SORT_NUMERIC ) { return $ this -> groupBy ( function ( Card $ card ) { return $ card -> value ( ) ; } ) -> map ( function ( CardCollection $ valueGroup ) { return $ valueGroup -> sortBySuitValue ( ) ; } ) -> flatten ( ) -> sortBy ( function ( Card $ card ) { return $ card -> value... | Sort cards by their value and then by Suit . |
5,512 | public function groupByValue ( ) { return $ this -> sortByDesc ( function ( Card $ card ) { return $ card -> value ( ) ; } , SORT_NUMERIC ) -> groupBy ( function ( Card $ card ) { return $ card -> value ( ) ; } ) -> sortByDesc ( function ( $ group ) { return count ( $ group ) ; } , SORT_NUMERIC ) -> values ( ) ; } | Group cards by the value and sort by highest card count first . |
5,513 | public function uniqueByValue ( ) { return $ this -> sortByDesc ( function ( Card $ card ) { return $ card -> value ( ) ; } , SORT_NUMERIC ) -> groupBy ( function ( Card $ card ) { return $ card -> value ( ) ; } ) -> map ( function ( $ group ) { return $ group -> first ( ) ; } ) -> reverse ( ) -> values ( ) ; } | Filter out duplicate card values out of the collection . |
5,514 | public function switchAceValue ( ) { return $ this -> map ( function ( Card $ card ) { if ( $ card -> isAce ( ) === false ) { return $ card ; } return new Card ( 14 , $ card -> suit ( ) ) ; } ) ; } | Replaces any Aces found in the collection with values of 14 . |
5,515 | public function name ( ) { switch ( $ this -> suit ) { case static :: CLUB : $ suit = static :: CLUB_LONG_NAME ; break ; case static :: DIAMOND : $ suit = static :: DIAMOND_LONG_NAME ; break ; case static :: HEART : $ suit = static :: HEART_LONG_NAME ; break ; default : case static :: SPADE : $ suit = static :: SPADE_L... | Get the suit name . |
5,516 | public function symbol ( ) { switch ( $ this -> suit ) { case static :: CLUB : $ symbol = self :: CLUB_SYMBOL ; break ; case static :: DIAMOND : $ symbol = self :: DIAMOND_SYMBOL ; break ; case static :: HEART : $ symbol = self :: HEART_SYMBOL ; break ; default : case static :: SPADE : $ symbol = self :: SPADE_SYMBOL ;... | Get the suit symbol . |
5,517 | public function sendData ( $ data ) { $ httpResponse = $ this -> sendRequest ( 'GET' , '/gateways' , json_encode ( $ data ) ) ; $ this -> response = new RestFetchPaymentMethodsResponse ( $ this , json_decode ( $ httpResponse -> getBody ( ) -> getContents ( ) , true ) ) ; return $ this -> response ; } | Execute the API request . |
5,518 | public function toArray ( ) { return [ 'title' => $ this -> title , 'description' => $ this -> description , 'content' => $ this -> content , 'authors' => array_map ( function ( $ author ) { return $ author -> toArray ( ) ; } , isset ( $ this -> authors ) ? $ this -> authors : [ ] ) , 'date' => $ this -> date , 'permal... | Return basic item data . Authors in array |
5,519 | public function setCurlOption ( $ option , $ value ) { curl_setopt ( $ this -> ch , $ option , $ value ) ; $ this -> curl_options [ $ option ] = $ value ; return $ this ; } | Setter Curl option |
5,520 | public function sendData ( $ data ) { $ httpResponse = $ this -> sendRequest ( 'get' , '/orders/' . $ data [ 'transactionId' ] ) ; $ this -> response = new RestCompletePurchaseResponse ( $ this , json_decode ( $ httpResponse -> getBody ( ) -> getContents ( ) , true ) ) ; return $ this -> response ; } | Send the API request . |
5,521 | public function getPaymentMethods ( ) { $ paymentMethods = array ( ) ; foreach ( $ this -> data [ 'data' ] as $ method ) { $ paymentMethods [ ] = new PaymentMethod ( $ method [ 'id' ] , $ method [ 'description' ] ) ; } return $ paymentMethods ; } | Get the returned list of payment methods . |
5,522 | protected function getPaymentData ( ) { $ data = array ( 'cancel_url' => $ this -> getCancelUrl ( ) , 'close_window' => $ this -> getCloseWindow ( ) , 'notification_url' => $ this -> getNotifyUrl ( ) , 'redirect_url' => $ this -> getReturnUrl ( ) , ) ; return array_filter ( $ data ) ; } | Get the payment options . |
5,523 | public function getCustomerData ( ) { $ data = array ( 'disable_send_mail' => $ this -> getSendMail ( ) , 'locale' => $ this -> getLocale ( ) , ) ; if ( is_null ( $ this -> getCard ( ) ) ) { return array_filter ( $ data ) ; } $ cardData = array ( 'address1' => $ this -> getCard ( ) -> getAddress1 ( ) , 'address2' => $ ... | Customer information . |
5,524 | protected function getItemBagData ( ) { $ items = array ( ) ; $ itemBag = $ this -> getItems ( ) ; if ( ! empty ( $ itemBag ) ) { foreach ( $ itemBag -> all ( ) as $ item ) { $ items [ ] = array ( 'name' => $ item -> getName ( ) , 'description' => $ item -> getDescription ( ) , 'quantity' => $ item -> getQuantity ( ) ,... | Get itembag data . |
5,525 | private function get ( ServerRequestInterface $ request ) { $ middleware = current ( $ this -> middleware ) ; next ( $ this -> middleware ) ; if ( $ middleware === false ) { return $ middleware ; } if ( is_array ( $ middleware ) ) { $ conditions = $ middleware ; $ middleware = array_pop ( $ conditions ) ; foreach ( $ c... | Return the next available middleware in the stack . |
5,526 | private static function createMiddlewareFromClosure ( Closure $ handler ) : MiddlewareInterface { return new class ( $ handler ) implements MiddlewareInterface { private $ handler ; public function __construct ( Closure $ handler ) { $ this -> handler = $ handler ; } public function process ( ServerRequestInterface $ r... | Create a middleware from a closure |
5,527 | public function setAllowedSchemes ( $ allowedSchemes ) { if ( empty ( $ allowedSchemes ) ) { throw new \ InvalidArgumentException ( "Allowed schemes cannot be empty." ) ; } $ allowedSchemes = ( array ) $ allowedSchemes ; $ c = count ( $ allowedSchemes ) ; for ( $ i = 0 ; $ i < $ c ; ++ $ i ) { if ( empty ( $ allowedSch... | Set the allowed schemes . |
5,528 | public function reset ( ) { $ this -> domain = null ; $ this -> fragment = null ; $ this -> hostname = null ; $ this -> ipv4 = null ; $ this -> ipv6 = null ; $ this -> password = null ; $ this -> path = null ; $ this -> port = null ; $ this -> query = null ; $ this -> scheme = null ; $ this -> tld = null ; $ this -> ur... | Reset all properties to their defaults . |
5,529 | public function draw ( ) { if ( $ this -> count ( ) == 0 ) { throw new \ UnderflowException ( 'No more cards in the deck!' ) ; } $ card = array_pop ( $ this -> cards ) ; $ this -> cardsDrawn [ ] = $ card ; return $ card ; } | Draw a card from the deck . |
5,530 | public function drawHand ( $ size = 1 ) { $ hand = [ ] ; for ( $ i = 0 ; $ i < $ size ; ++ $ i ) { $ hand [ ] = $ this -> draw ( ) ; } return $ hand ; } | Draw a hand of cards from the deck . |
5,531 | public function reset ( ) { $ this -> cards = array_merge ( $ this -> cards , $ this -> cardsDrawn ) ; $ this -> cardsDrawn = [ ] ; } | ReAdds cards from the drawn pile back to the main deck . |
5,532 | public function clearWatch ( ) { foreach ( $ this -> watchDir as $ wd ) { inotify_rm_watch ( $ this -> inotify , $ wd ) ; } $ this -> watchDir = [ ] ; } | Clear all watching . |
5,533 | public function setCURL ( $ const ) { $ this -> _curl_options = $ const + $ this -> _curl_options ; $ this -> _curl = curl_init ( ) ; curl_setopt_array ( $ this -> _curl , $ this -> _curl_options ) ; return $ this ; } | Custom CURL settings |
5,534 | protected function _getURLs ( ) { if ( $ this -> _post ) { $ this -> _sendPost ( ) ; } if ( $ this -> _fill_urls ) { $ this -> _getFillURLs ( ) ; } if ( is_array ( $ this -> _urls ) == false OR count ( $ this -> _urls ) < 1 ) { return false ; } foreach ( $ this -> _urls as $ name => $ url ) { $ this -> _setHTML ( $ url... | Starts the process to load pages and saves the matching results . |
5,535 | protected function _getMatch ( $ key = 0 ) { foreach ( $ this -> _regex [ 'match' ] as $ name => $ regex ) { if ( is_array ( $ regex ) ) { $ this -> _setFile ( $ name , $ regex , $ key , 1 , $ name ) ; } else { $ match = $ this -> _filter ( $ regex , $ this -> _html , 1 , $ name ) ; $ this -> _output [ $ key ] [ $ name... | Find and save the results of the current page . |
5,536 | protected function _getFillURLs ( ) { foreach ( $ this -> _fill_urls [ 'keywords' ] as $ name => $ keyword ) { $ content = $ this -> _getCURL ( $ this -> _fill_urls [ 'query' ] . $ keyword ) ; if ( isset ( $ this -> _fill_urls [ 'to' ] ) && $ this -> _fill_urls [ 'to' ] == 'matches' ) { $ url = $ this -> _filterAll ( $... | Get the URL from eg . a search engine . |
5,537 | protected function _getCURL ( $ url ) { curl_setopt ( $ this -> _curl , CURLOPT_URL , $ url ) ; $ content = curl_exec ( $ this -> _curl ) ; return $ content ; } | Load the data from the URL . |
5,538 | protected function _filterAll ( $ regex , $ content , $ i = 1 , $ key = '' ) { if ( @ preg_match_all ( $ regex , $ content , $ matches ) === false ) { return false ; } $ result = isset ( $ matches [ $ i ] ) ? $ matches [ $ i ] : $ matches [ 0 ] ; if ( isset ( $ this -> _callback [ '_all_' ] ) ) { foreach ( $ this -> _c... | Apply the regular expression to the content and return all matches . |
5,539 | protected function _filter ( $ regex , $ content , $ i = 1 , $ key = '' ) { if ( @ preg_match ( $ regex , $ content , $ match ) == 1 ) { $ result = isset ( $ match [ $ i ] ) ? $ match [ $ i ] : $ match [ 0 ] ; if ( isset ( $ this -> _callback [ '_all_' ] ) ) { foreach ( $ this -> _callback [ '_all_' ] as $ filter ) { $... | Apply the regular expression to the content and return first match . |
5,540 | public function find ( $ floor_id , array $ params = [ ] ) { if ( ! is_integer ( $ floor_id ) && ! is_numeric ( $ floor_id ) ) { throw new DmmSDKException ( 'a correct floor id must be set when call Series API.' ) ; } $ params [ 'floor_id' ] = $ floor_id ; return $ this -> get ( "/SeriesSearch" , $ params ) ; } | Sends a request to Series API and returns the result . |
5,541 | function getActionForTag ( $ tag ) { $ tag = strtoupper ( $ tag ) ; foreach ( $ this -> ignoreElements -> resourceContent as $ ignoreElement ) { if ( $ ignoreElement === $ tag ) { return 0 ; } } foreach ( $ this -> linkElements -> resourceContent as $ linkElement ) { if ( $ linkElement === $ tag ) { return 1 ; } } fore... | Returns the applicable action for a given HTML tag |
5,542 | function parse ( $ html ) { $ dom = new \ DOMDocument ( ) ; libxml_use_internal_errors ( true ) ; $ dom -> loadHTML ( $ html ) ; $ xpath = new \ DOMXPath ( $ dom ) ; $ this -> ignoreElements = new ResourceProvider ( "html_tag_actions/ignore.lst" ) ; $ this -> linkElements = new ResourceProvider ( "html_tag_actions/link... | Begins traversal of the HTML document |
5,543 | public static function getProperties ( Reader $ reader , ReflectionClass $ class ) { $ props = $ class -> getProperties ( ) ; $ result = [ ] ; foreach ( $ props as $ property ) { if ( $ property -> isStatic ( ) ) { continue ; } $ exclude = $ reader -> getPropertyAnnotation ( $ property , Annotation \ Exclude :: class )... | Returns all available properties of an object |
5,544 | protected function getField ( $ name ) { $ name = ltrim ( $ name , '/' ) ; foreach ( $ this -> fields as $ field ) { if ( preg_match ( '#^' . ltrim ( $ field -> getName ( ) , '/' ) . '$#' , $ name ) ) { return $ field ; } } return null ; } | Returns the property defined by the name |
5,545 | public function detectHttpClientHandler ( ) { $ handler = null ; if ( class_exists ( 'GuzzleHttp\Client' ) ) { $ handler = new GuzzleHttpClient ( ) ; } elseif ( function_exists ( 'curl_init' ) ) { $ handler = new CurlHttpClient ( ) ; } else { $ handler = new StreamHttpClient ( ) ; } return $ handler ; } | Detects which HTTP client handler to use . |
5,546 | public function sendRequest ( DmmRequest $ request ) { if ( get_class ( $ request ) === 'Dmm\DmmRequest' ) { $ request -> validateCredentials ( ) ; } list ( $ url , $ method , $ headers , $ body ) = $ this -> prepareRequestMessage ( $ request ) ; $ timeOut = static :: DEFAULT_REQUEST_TIMEOUT ; $ rawResponse = $ this ->... | Makes the request to API and returns the result . |
5,547 | public function addFakes ( $ columns = [ 'extras' ] ) { foreach ( $ columns as $ key => $ column ) { $ column_contents = $ this -> { $ column } ; if ( ! is_object ( $ this -> { $ column } ) ) { $ column_contents = json_decode ( $ this -> { $ column } ) ; } if ( count ( $ column_contents ) ) { foreach ( $ column_content... | Add fake fields as regular attributes even though they are stored as JSON . |
5,548 | public function withFakes ( $ columns = [ ] ) { $ model = '\\' . get_class ( $ this ) ; if ( ! count ( $ columns ) ) { if ( property_exists ( $ model , 'fakeColumns' ) ) { $ columns = $ this -> fakeColumns ; } else { $ columns = [ 'extras' ] ; } } $ this -> addFakes ( $ columns ) ; return $ this ; } | Return the entity with fake fields as attributes . |
5,549 | public function allTranslations ( ) { $ model = '\\' . get_class ( $ this ) ; $ translations = $ this -> translations ( ) ; $ all_translations = new Collection ( ) ; if ( $ this -> translation_of ) { $ original = $ model :: find ( $ this -> translation_of ) ; $ all_translations = $ all_translations -> push ( $ original... | get translations plus current item plus original |
5,550 | public function pointer ( $ pointer ) { $ pointer = new Pointer ( $ pointer ) ; $ data = $ pointer -> evaluate ( $ this -> data ) ; if ( $ data !== null ) { return $ data ; } else { throw new RuntimeException ( 'Could not resolve pointer ' . $ pointer -> getPath ( ) ) ; } } | Resolves a json pointer on the document and returns the fitting array fragment . Throws an exception if the pointer could not be resolved |
5,551 | public static function extractFromURL ( $ url ) { $ html = file_get_contents ( $ url ) ; if ( $ html === FALSE ) { return ; } return self :: extractFromHTML ( $ html , $ url ) ; } | Extracts an article directly from a URL |
5,552 | public static function extractFromHTML ( $ rawHTMLPage , $ source = "" ) { $ parser = new HTMLParser ( ) ; $ article = $ parser -> parse ( $ rawHTMLPage ) ; Filters \ TitleFilter :: filter ( $ article ) ; Filters \ EndBlockFilter :: filter ( $ article ) ; Filters \ NumberOfWordsFilter :: filter ( $ article ) ; Filters ... | Extracts an article from HTML |
5,553 | protected static function loadClass ( $ entity , $ type ) { if ( strpos ( $ type , '.' ) ) { list ( $ prefix , $ type ) = explode ( '.' , $ type ) ; } else { $ prefix = 'Joomla' ; } $ class = ucfirst ( $ prefix ) . '\\Form\\' . ucfirst ( $ entity ) ; if ( strpos ( $ type , '\\' ) ) { $ class .= '\\' . StringHelper :: u... | Load a class for one of the form s entities of a particular type . |
5,554 | public function setEndpoint ( $ endpoint ) { $ filterParams = [ 'affiliate_id' , 'api_id' ] ; $ this -> endpoint = DmmUrlManipulator :: removeParamsFromUrl ( $ endpoint , $ filterParams ) ; return $ this ; } | Set the endpoint for this request . |
5,555 | public function getParams ( ) { $ params = $ this -> params ; $ credential = $ this -> getCredential ( ) ; if ( $ credential ) { $ params [ 'affiliate_id' ] = $ credential -> getAffiliateId ( ) ; $ params [ 'api_id' ] = $ credential -> getApiId ( ) ; } return $ params ; } | Generate and return the params for this request . |
5,556 | public function getUrl ( ) { $ this -> validateMethod ( ) ; $ endpoint = DmmUrlManipulator :: forceSlashPrefix ( $ this -> getEndpoint ( ) ) ; $ url = $ endpoint ; if ( $ this -> getMethod ( ) !== 'POST' ) { $ params = $ this -> getParams ( ) ; $ url = DmmUrlManipulator :: appendParamsToUrl ( $ url , $ params ) ; } ret... | Generate and return the URL for this request . |
5,557 | protected function pageTypeOptions ( ) { $ pageTypes = [ ] ; $ classes = ArrayLib :: valueKey ( SiteTree :: page_type_classes ( ) ) ; unset ( $ classes [ 'VirtualPage' ] ) ; unset ( $ classes [ 'ErrorPage' ] ) ; unset ( $ classes [ 'RedirectorPage' ] ) ; foreach ( $ classes as $ pageTypeClass ) { $ pageTypes [ $ pageTy... | Returns a sorted array suitable for a dropdown with pagetypes and their translated name . |
5,558 | public function Pages ( ) { $ pages = SiteTree :: get ( ) ; $ types = $ this -> PageTypes -> getValue ( ) ; if ( count ( $ types ) ) { $ pages = $ pages -> filter ( 'ClassName' , $ types ) ; } $ parents = $ this -> PageParents ( ) -> column ( 'ID' ) ; if ( count ( $ parents ) ) { $ pages = $ pages -> filter ( 'ParentID... | Returns a list of pages this BlockSet features on . |
5,559 | public function forTemplate ( ) { if ( $ this -> BlockArea ) { $ template = [ $ this -> class . '_' . $ this -> BlockArea ] ; if ( SSViewer :: hasTemplate ( $ template ) ) { return $ this -> renderWith ( $ template ) ; } } return $ this -> renderWith ( $ this -> ClassName , $ this -> getController ( ) ) ; } | Renders this block with appropriate templates looks for templates that match BlockClassName_AreaName falls back to BlockClassName . |
5,560 | public function pagesAffectedByChanges ( ) { $ pages = $ this -> Pages ( ) ; $ urls = [ ] ; foreach ( $ pages as $ page ) { $ urls [ ] = $ page -> Link ( ) ; } return $ urls ; } | Get a list of URL s to republish when this block changes if using StaticPublisher module . |
5,561 | public function isPublishedNice ( ) { $ field = DBBoolean :: create ( 'isPublished' ) ; $ field -> setValue ( $ this -> isPublished ( ) ) ; return $ field -> Nice ( ) ; } | Check if this block has been published . |
5,562 | public function CSSClasses ( $ stopAtClass = 'DataObject' ) { $ classes = strtolower ( parent :: CSSClasses ( $ stopAtClass ) ) ; if ( ! empty ( $ classes ) && ( $ prefix = $ this -> blockManager -> getPrefixDefaultCSSClasses ( ) ) ) { $ classes = $ prefix . str_replace ( ' ' , " {$prefix}" , $ classes ) ; } if ( $ thi... | CSS Classes to apply to block element in template . |
5,563 | public function extract ( Document $ document , Uri $ ref ) { $ uri = $ this -> resolver -> resolve ( $ document -> getBaseUri ( ) , $ ref ) ; $ doc = $ this -> getDocument ( $ uri , $ document ) ; $ result = $ doc -> pointer ( $ uri -> getFragment ( ) ) ; $ baseUri = $ doc -> getBaseUri ( ) ; array_walk_recursive ( $ ... | Extracts an array part from the document |
5,564 | public function index ( ) { if ( isset ( $ this -> crud [ 'view_table_permission' ] ) && ! $ this -> crud [ 'view_table_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } $ model = $ this -> crud [ 'model' ] ; if ( property_exists ( $ model , 'translatable' ) ) { $ this -> data [ 'entries' ] = $ model :: where ( 'tra... | Display all rows in the database for this entity . |
5,565 | public function create ( ) { if ( isset ( $ this -> crud [ 'add_permission' ] ) && ! $ this -> crud [ 'add_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } if ( isset ( $ this -> data [ 'crud' ] [ 'create_fields' ] ) ) { $ this -> crud [ 'fields' ] = $ this -> data [ 'crud' ] [ 'create_fields' ] ; } $ this -> prepa... | Show the form for creating inserting a new row . |
5,566 | public function storeCrud ( StoreRequest $ request = null ) { if ( isset ( $ this -> crud [ 'add_permission' ] ) && ! $ this -> crud [ 'add_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } $ model = $ this -> crud [ 'model' ] ; $ values_to_store = $ this -> compactFakeFields ( \ Request :: all ( ) ) ; $ item = $ mo... | Store a newly created resource in the database . |
5,567 | public function updateCrud ( UpdateRequest $ request = null ) { if ( isset ( $ this -> crud [ 'edit_permission' ] ) && ! $ this -> crud [ 'edit_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } $ model = $ this -> crud [ 'model' ] ; $ this -> prepareFields ( $ model :: find ( \ Request :: input ( 'id' ) ) ) ; $ item... | Update the specified resource in the database . |
5,568 | public function reorder ( $ lang = false ) { if ( isset ( $ this -> crud [ 'reorder_permission' ] ) && ! $ this -> crud [ 'reorder_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } if ( $ lang == false ) { $ lang = \ Lang :: locale ( ) ; } $ model = $ this -> crud [ 'model' ] ; if ( property_exists ( $ model , 'tran... | Reorder the items in the database using the Nested Set pattern . |
5,569 | public function saveReorder ( ) { if ( isset ( $ this -> crud [ 'reorder_permission' ] ) && ! $ this -> crud [ 'reorder_permission' ] ) { abort ( 403 , 'Not allowed.' ) ; } $ model = $ this -> crud [ 'model' ] ; $ count = 0 ; $ all_entries = \ Request :: input ( 'tree' ) ; if ( count ( $ all_entries ) ) { foreach ( $ a... | Save the new order using the Nested Set pattern . |
5,570 | public function translateItem ( $ id , $ lang ) { $ model = $ this -> crud [ 'model' ] ; $ this -> data [ 'entry' ] = $ model :: find ( $ id ) ; $ existing_translation = $ this -> data [ 'entry' ] -> translation ( $ lang ) ; if ( $ existing_translation ) { $ new_entry = $ existing_translation ; } else { $ new_entry_att... | Duplicate an existing item into another language and open it for editing . |
5,571 | protected function compactFakeFields ( $ request ) { $ this -> prepareFields ( ) ; $ fake_field_columns_to_encode = [ ] ; foreach ( $ this -> crud [ 'fields' ] as $ k => $ field ) { if ( isset ( $ this -> crud [ 'fields' ] [ $ k ] [ 'fake' ] ) && $ this -> crud [ 'fields' ] [ $ k ] [ 'fake' ] == true ) { if ( isset ( $... | Refactor the request array to something that can be passed to the model s create or update function . The resulting array will only include the fields that are stored in the database and their values plus the _token and redirect_after_save variables . |
5,572 | protected function prepareColumns ( ) { if ( ! isset ( $ this -> crud [ 'columns' ] ) ) { abort ( 500 , "CRUD columns are not defined." ) ; } if ( ! is_array ( $ this -> crud [ 'columns' ] ) ) { $ current_columns_array = explode ( "," , $ this -> crud [ 'columns' ] ) ; $ proper_columns_array = array ( ) ; foreach ( $ c... | If it s not an array of array and it s a simple array create a proper array of arrays for it |
5,573 | protected function prepareFields ( $ entry = false ) { if ( ! isset ( $ this -> crud [ 'fields' ] ) ) { if ( isset ( $ this -> crud [ 'create_fields' ] ) ) { $ this -> crud [ 'fields' ] = $ this -> crud [ 'create_fields' ] ; } elseif ( isset ( $ this -> crud [ 'update_fields' ] ) ) { $ this -> crud [ 'fields' ] = $ thi... | Prepare the fields to be shown stored updated or created . |
5,574 | private function getHeaderSize ( ) { $ headerSize = $ this -> dmmCurl -> getinfo ( CURLINFO_HEADER_SIZE ) ; if ( $ this -> needsCurlProxyFix ( ) ) { if ( preg_match ( '/Content-Length: (\d+)/' , $ this -> rawResponse , $ m ) ) { $ headerSize = mb_strlen ( $ this -> rawResponse ) - $ m [ 1 ] ; } elseif ( stripos ( $ thi... | Return proper header size |
5,575 | private function needsCurlProxyFix ( ) { $ ver = $ this -> dmmCurl -> version ( ) ; $ version = $ ver [ 'version_number' ] ; return $ version < self :: CURL_PROXY_QUIRK_VER ; } | Detect versions of Curl which report incorrect header lengths when using Proxies . |
5,576 | private static function stringStartsWithResourceEntry ( $ blockText , $ resource ) { foreach ( $ resource -> resourceContent as $ resourceEntry ) { if ( EndBlockFilter :: stringStartsWith ( $ blockText , $ resourceEntry ) ) { return true ; } } return false ; } | Checks all resources entries against block text for a starts with qualifier |
5,577 | private static function stringContainsResourceEntry ( $ blockText , $ resource ) { foreach ( $ resource -> resourceContent as $ resourceEntry ) { if ( EndBlockFilter :: stringContains ( $ blockText , $ resourceEntry ) ) { return true ; } } return false ; } | Checks all resource entries against block text for a contains qualifier |
5,578 | private static function stringMatchesResourceEntry ( $ blockText , $ resource ) { foreach ( $ resource -> resourceContent as $ resourceEntry ) { if ( $ blockText === $ resourceEntry ) { return true ; } } return false ; } | Checks all resource entries against block text for a complete match |
5,579 | private static function stringStartsWithNumberFollowedByResource ( $ inString , $ resource ) { $ followingTextArray = $ resource -> resourceContent ; $ count = 0 ; foreach ( str_split ( $ inString ) as $ character ) { if ( EndBlockFilter :: characterIsDigit ( $ character ) ) { $ count ++ ; } else { break ; } } if ( $ c... | Checks if text matches a specific format i . e 23 comments |
5,580 | public function loadResource ( $ resourceName ) { $ resourceLocation = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR . $ resourceName ; $ this -> resourceContent = $ this -> readResourceToArray ( $ resourceLocation ) ; } | Loads resource into memory by name only into this instance s resourceContent |
5,581 | public function loadResourceDirectory ( $ directoryName ) { $ resourceLocation = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR . $ directoryName ; $ results = array ( ) ; foreach ( scandir ( $ resourceLocation ) as $ file ) { if ( ( ( $ temp = strlen ( $ file ) - ... | Loads all resources found in a directory into memory by name only into this instance s resourceContent |
5,582 | protected function getInput ( ) { $ html = array ( ) ; $ attr = '' ; $ select = new HtmlSelect ; try { $ select -> setText ( $ this -> getText ( ) ) ; } catch ( \ RuntimeException $ exception ) { } $ attr .= $ this -> element [ 'class' ] ? ' class="' . ( string ) $ this -> element [ 'class' ] . '"' : '' ; if ( ( string... | Method to get the field input markup for a generic list . |
5,583 | public function getApiKey ( $ decoded = false ) { return ( $ decoded === false ) ? $ this -> apiKey : base64_decode ( $ this -> apiKey ) ; } | Get the currently set API key |
5,584 | public function setApiKey ( $ apiKey ) { $ key = base64_decode ( $ apiKey , true ) ; if ( $ key === false ) { throw new \ InvalidArgumentException ( 'Invalid API key' ) ; } $ this -> apiKey = $ key ; return $ this ; } | Set the API key |
5,585 | public function getHost ( ) { if ( $ this -> host === null ) { $ host = $ this -> hosts [ mt_rand ( 0 , count ( $ this -> hosts ) - 1 ) ] ; $ this -> setHost ( $ host ) ; return $ host ; } else { return $ this -> host ; } } | Get the host for the request If one is not set it returns a random one from the host set |
5,586 | public function generateSignature ( $ data , $ key = null ) { if ( $ key === null ) { $ key = $ this -> getApiKey ( ) ; if ( $ key === null || empty ( $ key ) ) { throw new \ InvalidArgumentException ( 'Invalid API key!' ) ; } } $ query = http_build_query ( $ data ) ; $ query = utf8_encode ( str_replace ( '%3A' , ':' ,... | Geenrate the signature for the request values |
5,587 | public function check ( $ otp , $ multi = false ) { $ otp = trim ( $ otp ) ; if ( strlen ( $ otp ) < 32 || strlen ( $ otp ) > 48 ) { throw new \ InvalidArgumentException ( 'Invalid OTP length' ) ; } $ this -> setOtp ( $ otp ) ; $ this -> setYubikeyId ( ) ; $ clientId = $ this -> getClientId ( ) ; if ( $ clientId === nu... | Check the One - time Password with API request |
5,588 | public function generateNonce ( ) { if ( function_exists ( 'openssl_random_pseudo_bytes' ) === true ) { $ hash = md5 ( openssl_random_pseudo_bytes ( 32 ) ) ; } else { $ hash = md5 ( uniqid ( mt_rand ( ) ) ) ; } return $ hash ; } | Generate a good nonce for the request |
5,589 | public function validateResponseSignature ( \ Yubikey \ Response $ response ) { $ params = array ( ) ; foreach ( $ response -> getProperties ( ) as $ property ) { $ value = $ response -> $ property ; if ( $ value !== null ) { $ params [ $ property ] = $ value ; } } ksort ( $ params ) ; $ signature = $ this -> generateS... | Validate the signature on the response |
5,590 | protected function initDefaultElements ( ) { if ( ! isset ( $ this -> elements [ 'bulk-actions' ] ) ) { if ( $ this -> bulkActionsPrompt === null ) { $ this -> bulkActionsPrompt = $ this -> t ( 'widget' , 'Bulk Actions' ) ; } if ( empty ( $ this -> bulkActionsItems ) ) { $ this -> bulkActionsItems = [ $ this -> t ( 'wi... | Initializes the default elements . |
5,591 | protected function renderElements ( $ template ) { return preg_replace_callback ( '/\\{([\w\-\/]+)\\}/' , function ( $ matches ) { $ name = $ matches [ 1 ] ; if ( isset ( $ this -> elements [ $ name ] ) ) { if ( $ name === 'bulk-actions' && $ this -> grid !== null ) { $ id = $ this -> options [ 'id' ] ; $ this -> view ... | Renders elements . |
5,592 | public function setUrl ( $ url ) { if ( filter_var ( $ url , FILTER_VALIDATE_URL ) !== $ url ) { throw new \ Exception ( 'Invalid URL: ' . $ url ) ; } $ this -> url = $ url ; } | Set the URL location for the request |
5,593 | public function getHeadersAsString ( ResponseInterface $ response ) { $ headers = $ response -> getHeaders ( ) ; $ rawHeaders = [ ] ; foreach ( $ headers as $ name => $ values ) { $ rawHeaders [ ] = $ name . ": " . implode ( ", " , $ values ) ; } return implode ( "\r\n" , $ rawHeaders ) ; } | Returns the Guzzle array of headers as a string . |
5,594 | public function traverse ( $ data , SchemaInterface $ schema , VisitorInterface $ visitor = null ) { $ this -> pathStack = [ ] ; $ this -> recCount = - 1 ; if ( $ visitor === null ) { $ visitor = new NullVisitor ( ) ; } return $ this -> recTraverse ( $ data , $ schema -> getDefinition ( ) , $ visitor ) ; } | Traverses through the data and validates it according to the provided schema . Calls also the visitor methods for each type |
5,595 | public function calculateDensities ( ) { if ( $ this -> numWordsInWrappedLines == 0 ) { $ this -> numWordsInWrappedLines = $ this -> numWords ; $ this -> numWrappedLines = 1 ; } $ this -> textDensity = $ this -> numWordsInWrappedLines / $ this -> numWrappedLines ; $ this -> linkDensity = $ this -> numWords == 0 ? 0 : $... | Calculates the text and link densities for this block |
5,596 | public function addExisting ( ) { $ classes = $ this -> blockManager -> getBlockClasses ( ) ; $ this -> addComponent ( $ add = new GridFieldAddExistingSearchButton ( ) ) ; $ add -> setSearchList ( Block :: get ( ) -> filter ( array ( 'ClassName' => array_keys ( $ classes ) , ) ) ) ; return $ this ; } | Add the GridFieldAddExistingSearchButton component to this grid config . |
5,597 | public function getAreas ( $ keyAsValue = true ) { $ areas = $ this -> config ( ) -> get ( 'areas' ) ; $ areas = $ keyAsValue ? ArrayLib :: valuekey ( array_keys ( $ areas ) ) : $ areas ; if ( count ( $ areas ) ) { foreach ( $ areas as $ k => $ v ) { $ areas [ $ k ] = $ keyAsValue ? FormField :: name_to_label ( $ k ) :... | Gets an array of all areas defined for blocks . |
5,598 | public function compileHeader ( array $ headers ) { $ header = [ ] ; foreach ( $ headers as $ k => $ v ) { $ header [ ] = $ k . ': ' . $ v ; } return implode ( "\r\n" , $ header ) ; } | Formats the headers for use in the stream wrapper . |
5,599 | private static function execution_time ( ) { if ( self :: $ execution_time === 0 ) { self :: $ execution_time = - microtime ( true ) ; } else { self :: $ execution_time += microtime ( true ) ; } return self :: $ execution_time ; } | Get and set execution time |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.