idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
12,500 | public function group ( ) : Stage \ Group { $ stage = new Stage \ Group ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping . |
12,501 | public function indexStats ( ) : Stage \ IndexStats { $ stage = new Stage \ IndexStats ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Returns statistics regarding the use of each index for the collection . |
12,502 | public function limit ( int $ limit ) : Stage \ Limit { $ stage = new Stage \ Limit ( $ this , $ limit ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Limits the number of documents passed to the next stage in the pipeline . |
12,503 | public function matchExpr ( ) : QueryExpr { $ expr = new QueryExpr ( $ this -> dm ) ; $ expr -> setClassMetadata ( $ this -> class ) ; return $ expr ; } | Returns a query expression to be used in match stages |
12,504 | public function out ( string $ from ) : Stage \ Out { $ stage = new Stage \ Out ( $ this , $ from , $ this -> dm ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Takes the documents returned by the aggregation pipeline and writes them to a specified collection . This must be the last stage in the pipeline . |
12,505 | public function project ( ) : Stage \ Project { $ stage = new Stage \ Project ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Passes along the documents with only the specified fields to the next stage in the pipeline . The specified fields can be existing fields from the input documents or newly computed fields . |
12,506 | public function redact ( ) : Stage \ Redact { $ stage = new Stage \ Redact ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Restricts the contents of the documents based on information stored in the documents themselves . |
12,507 | public function replaceRoot ( $ expression = null ) : Stage \ ReplaceRoot { $ stage = new Stage \ ReplaceRoot ( $ this , $ this -> dm , $ this -> class , $ expression ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Promotes a specified document to the top level and replaces all other fields . |
12,508 | public function sample ( int $ size ) : Stage \ Sample { $ stage = new Stage \ Sample ( $ this , $ size ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Randomly selects the specified number of documents from its input . |
12,509 | public function skip ( int $ skip ) : Stage \ Skip { $ stage = new Stage \ Skip ( $ this , $ skip ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline . |
12,510 | public function sortByCount ( string $ expression ) : Stage \ SortByCount { $ stage = new Stage \ SortByCount ( $ this , $ expression , $ this -> dm , $ this -> class ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Groups incoming documents based on the value of a specified expression then computes the count of documents in each distinct group . |
12,511 | public function unwind ( string $ fieldName ) : Stage \ Unwind { $ stage = new Stage \ Unwind ( $ this , $ this -> getDocumentPersister ( ) -> prepareFieldName ( $ fieldName ) ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Deconstructs an array field from the input documents to output a document for each element . Each output document is the input document with the value of the array field replaced by the element . |
12,512 | private function applyFilters ( array $ query ) : array { $ documentPersister = $ this -> dm -> getUnitOfWork ( ) -> getDocumentPersister ( $ this -> class -> name ) ; $ query = $ documentPersister -> addDiscriminatorToPreparedQuery ( $ query ) ; $ query = $ documentPersister -> addFilterToPreparedQuery ( $ query ) ; return $ query ; } | Applies filters and discriminator queries to the pipeline |
12,513 | private function storeCurrentItem ( ) : void { $ key = $ this -> iterator -> key ( ) ; if ( $ key === null ) { return ; } $ this -> items [ $ key ] = $ this -> iterator -> current ( ) ; } | Stores the current item in the cache . |
12,514 | public function avg ( $ expression1 , ... $ expressions ) : self { $ this -> expr -> avg ( empty ( $ expressions ) ? $ expression1 : func_get_args ( ) ) ; return $ this ; } | Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key . Ignores nun - numeric values . |
12,515 | public function stdDevSamp ( $ expression1 , ... $ expressions ) : self { $ this -> expr -> stdDevSamp ( empty ( $ expressions ) ? $ expression1 : func_get_args ( ) ) ; return $ this ; } | Calculates the sample standard deviation of the input values . |
12,516 | public function sum ( $ expression1 , ... $ expressions ) : self { $ this -> expr -> sum ( empty ( $ expressions ) ? $ expression1 : func_get_args ( ) ) ; return $ this ; } | Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key . Ignores nun - numeric values . |
12,517 | public function expression ( $ value ) : self { $ this -> requiresCurrentField ( __METHOD__ ) ; $ this -> expr [ $ this -> currentField ] = $ this -> ensureArray ( $ value ) ; return $ this ; } | Allows any expression to be used as a field value . |
12,518 | public function field ( string $ fieldName ) : self { $ fieldName = $ this -> getDocumentPersister ( ) -> prepareFieldName ( $ fieldName ) ; $ this -> currentField = $ fieldName ; return $ this ; } | Set the current field for building the expression . |
12,519 | public function addToSet ( $ valueOrExpression ) : self { if ( $ valueOrExpression instanceof Expr ) { $ valueOrExpression = $ valueOrExpression -> getQuery ( ) ; } $ this -> requiresCurrentField ( ) ; $ this -> newObj [ '$addToSet' ] [ $ this -> currentField ] = $ valueOrExpression ; return $ this ; } | Append one or more values to the current array field only if they do not already exist in the array . |
12,520 | public function equals ( $ value ) : self { if ( $ this -> currentField ) { $ this -> query [ $ this -> currentField ] = $ value ; } else { $ this -> query = $ value ; } return $ this ; } | Specify an equality match for the current field . |
12,521 | public function inc ( $ value ) : self { $ this -> requiresCurrentField ( ) ; $ this -> newObj [ '$inc' ] [ $ this -> currentField ] = $ value ; return $ this ; } | Increment the current field . |
12,522 | public function includesReferenceTo ( object $ document ) : self { $ this -> requiresCurrentField ( ) ; $ mapping = $ this -> getReferenceMapping ( ) ; $ reference = $ this -> dm -> createReference ( $ document , $ mapping ) ; $ storeAs = $ mapping [ 'storeAs' ] ?? null ; $ keys = [ ] ; switch ( $ storeAs ) { case ClassMetadata :: REFERENCE_STORE_AS_ID : $ this -> query [ $ mapping [ 'name' ] ] = $ reference ; return $ this ; break ; case ClassMetadata :: REFERENCE_STORE_AS_REF : $ keys = [ 'id' => true ] ; break ; case ClassMetadata :: REFERENCE_STORE_AS_DB_REF : case ClassMetadata :: REFERENCE_STORE_AS_DB_REF_WITH_DB : $ keys = [ '$ref' => true , '$id' => true , '$db' => true ] ; if ( $ storeAs === ClassMetadata :: REFERENCE_STORE_AS_DB_REF ) { unset ( $ keys [ '$db' ] ) ; } if ( isset ( $ mapping [ 'targetDocument' ] ) ) { unset ( $ keys [ '$ref' ] , $ keys [ '$db' ] ) ; } break ; default : throw new InvalidArgumentException ( sprintf ( 'Reference type %s is invalid.' , $ storeAs ) ) ; } foreach ( $ keys as $ key => $ value ) { $ this -> query [ $ mapping [ 'name' ] ] [ '$elemMatch' ] [ $ key ] = $ reference [ $ key ] ; } return $ this ; } | Checks that the current field includes a reference to the supplied document . |
12,523 | public function not ( $ expression ) : self { return $ this -> operator ( '$not' , $ expression instanceof Expr ? $ expression -> getQuery ( ) : $ expression ) ; } | Negates an expression for the current field . |
12,524 | private function getReferenceMapping ( ) : array { $ this -> requiresCurrentField ( ) ; assert ( $ this -> currentField !== null ) ; try { return $ this -> class -> getFieldMapping ( $ this -> currentField ) ; } catch ( MappingException $ e ) { if ( empty ( $ this -> class -> discriminatorMap ) ) { throw $ e ; } $ mapping = null ; $ foundIn = null ; foreach ( $ this -> class -> discriminatorMap as $ child ) { $ childClass = $ this -> dm -> getClassMetadata ( $ child ) ; if ( ! $ childClass -> hasAssociation ( $ this -> currentField ) ) { continue ; } if ( $ foundIn !== null && $ mapping !== null && $ mapping !== $ childClass -> getFieldMapping ( $ this -> currentField ) ) { throw MappingException :: referenceFieldConflict ( $ this -> currentField , $ foundIn -> name , $ childClass -> name ) ; } $ mapping = $ childClass -> getFieldMapping ( $ this -> currentField ) ; $ foundIn = $ childClass ; } if ( $ mapping === null ) { throw MappingException :: mappingNotFoundInClassNorDescendants ( $ this -> class -> name , $ this -> currentField ) ; } return $ mapping ; } } | Gets reference mapping for current field from current class or its descendants . |
12,525 | public function set ( $ name , Location $ location ) { return $ this -> cache -> put ( $ name , $ location -> toArray ( ) , $ this -> expires ) ; } | Store an item in cache . |
12,526 | public function registerGeoIpService ( ) { $ this -> app -> singleton ( 'geoip' , function ( $ app ) { return new GeoIP ( $ app -> config -> get ( 'geoip' , [ ] ) , $ app [ 'cache' ] ) ; } ) ; } | Register currency provider . |
12,527 | public function getService ( ) { if ( $ this -> service === null ) { $ config = $ this -> config ( 'services.' . $ this -> config ( 'service' ) , [ ] ) ; $ class = Arr :: pull ( $ config , 'class' ) ; if ( $ class === null ) { throw new Exception ( 'The GeoIP service is not valid.' ) ; } $ this -> service = new $ class ( $ config ) ; } return $ this -> service ; } | Get service instance . |
12,528 | private function isValid ( $ ip ) { if ( ! filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) && ! filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE ) ) { return false ; } return true ; } | Checks if the ip is valid . |
12,529 | public function get ( $ url , array $ query = [ ] , array $ headers = [ ] ) { return $ this -> execute ( 'GET' , $ this -> buildGetUrl ( $ url , $ query ) , [ ] , $ headers ) ; } | Perform a get request . |
12,530 | private function parseHeaders ( $ headers ) { $ result = [ ] ; foreach ( preg_split ( "/\\r\\n|\\r|\\n/" , $ headers ) as $ row ) { $ header = explode ( ':' , $ row , 2 ) ; if ( count ( $ header ) == 2 ) { $ result [ $ header [ 0 ] ] = trim ( $ header [ 1 ] ) ; } else { $ result [ ] = $ header [ 0 ] ; } } return $ result ; } | Parse string headers into array |
12,531 | private function getUrl ( $ url ) { if ( parse_url ( $ url , PHP_URL_SCHEME ) === null ) { $ url = Arr :: get ( $ this -> config , 'base_uri' ) . $ url ; } return $ url ; } | Get request URL . |
12,532 | private function buildGetUrl ( $ url , array $ query = [ ] ) { $ query = array_merge ( Arr :: get ( $ this -> config , 'query' , [ ] ) , $ query ) ; if ( $ query = http_build_query ( $ query ) ) { $ url .= strpos ( $ url , '?' ) ? $ query : "?{$query}" ; } return $ url ; } | Build a GET request string . |
12,533 | public function createForId ( $ customerId , array $ options = [ ] , array $ filters = [ ] ) { $ this -> parentId = $ customerId ; return parent :: rest_create ( $ options , $ filters ) ; } | Create a subscription for a Customer ID |
12,534 | public function createForId ( $ profileId , $ methodId , array $ data = [ ] ) { $ this -> parentId = $ profileId ; $ resource = $ this -> getResourcePath ( ) . '/' . urlencode ( $ methodId ) ; $ body = null ; if ( count ( $ data ) > 0 ) { $ body = json_encode ( $ data ) ; } $ result = $ this -> client -> performHttpCall ( self :: REST_CREATE , $ resource , $ body ) ; return ResourceFactory :: createFromApiResult ( $ result , new Method ( $ this -> client ) ) ; } | Enable a method for the provided Profile ID . |
12,535 | public function createFor ( $ profile , $ methodId , array $ data = [ ] ) { return $ this -> createForId ( $ profile -> id , $ methodId , $ data ) ; } | Enable a method for the provided Profile object . |
12,536 | public function deleteForId ( $ profileId , $ methodId , array $ data = [ ] ) { $ this -> parentId = $ profileId ; return $ this -> rest_delete ( $ methodId , $ data ) ; } | Disable a method for the provided Profile ID . |
12,537 | public function deleteFor ( $ profile , $ methodId , array $ data = [ ] ) { return $ this -> deleteForId ( $ profile -> id , $ methodId , $ data ) ; } | Disable a method for the provided Profile object . |
12,538 | public function payments ( ) { return $ this -> client -> customerPayments -> listFor ( $ this , null , null , $ this -> getPresetOptions ( ) ) ; } | Get all payments for this customer |
12,539 | public function subscriptions ( ) { return $ this -> client -> subscriptions -> listFor ( $ this , null , null , $ this -> getPresetOptions ( ) ) ; } | Get all subscriptions for this customer |
12,540 | public function mandates ( ) { return $ this -> client -> mandates -> listFor ( $ this , null , null , $ this -> getPresetOptions ( ) ) ; } | Get all mandates for this customer |
12,541 | public function hasValidMandate ( ) { $ mandates = $ this -> mandates ( ) ; foreach ( $ mandates as $ mandate ) { if ( $ mandate -> isValid ( ) ) { return true ; } } return false ; } | Helper function to check for mandate with status valid |
12,542 | public function hasValidMandateForMethod ( $ method ) { $ mandates = $ this -> mandates ( ) ; foreach ( $ mandates as $ mandate ) { if ( $ mandate -> method === $ method && $ mandate -> isValid ( ) ) { return true ; } } return false ; } | Helper function to check for specific payment method mandate with status valid |
12,543 | private function getPresetOptions ( ) { $ options = [ ] ; if ( $ this -> client -> usesOAuth ( ) ) { $ options [ "testmode" ] = $ this -> mode === "test" ? true : false ; } return $ options ; } | When accessed by oAuth we want to pass the testmode by default |
12,544 | public function listForId ( $ orderId , array $ parameters = [ ] ) { $ this -> parentId = $ orderId ; return parent :: rest_list ( null , null , $ parameters ) ; } | Return all shipments for the provided Order id . |
12,545 | public function chargebacks ( ) { if ( ! isset ( $ this -> _links -> chargebacks -> href ) ) { return new ChargebackCollection ( $ this -> client , 0 , null ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_GET , $ this -> _links -> chargebacks -> href ) ; return ResourceFactory :: createCursorResourceCollection ( $ this -> client , $ result -> _embedded -> chargebacks , Chargeback :: class , $ result -> _links ) ; } | Retrieves all chargebacks associated with this profile |
12,546 | public function methods ( ) { if ( ! isset ( $ this -> _links -> methods -> href ) ) { return new MethodCollection ( 0 , null ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_GET , $ this -> _links -> methods -> href ) ; return ResourceFactory :: createCursorResourceCollection ( $ this -> client , $ result -> _embedded -> methods , Method :: class , $ result -> _links ) ; } | Retrieves all methods activated on this profile |
12,547 | public function enableMethod ( $ methodId , array $ data = [ ] ) { return $ this -> client -> profileMethods -> createFor ( $ this , $ methodId , $ data ) ; } | Enable a payment method for this profile . |
12,548 | public function disableMethod ( $ methodId , array $ data = [ ] ) { return $ this -> client -> profileMethods -> deleteFor ( $ this , $ methodId , $ data ) ; } | Disable a payment method for this profile . |
12,549 | public function refunds ( ) { if ( ! isset ( $ this -> _links -> refunds -> href ) ) { return new RefundCollection ( $ this -> client , 0 , null ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_GET , $ this -> _links -> refunds -> href ) ; return ResourceFactory :: createCursorResourceCollection ( $ this -> client , $ result -> _embedded -> refunds , Refund :: class , $ result -> _links ) ; } | Retrieves all refunds associated with this profile |
12,550 | public function getCheckoutUrl ( ) { if ( empty ( $ this -> _links -> checkout ) ) { return null ; } return $ this -> _links -> checkout -> href ; } | Get the checkout URL where the customer can complete the payment . |
12,551 | public function captures ( ) { if ( ! isset ( $ this -> _links -> captures -> href ) ) { return new CaptureCollection ( $ this -> client , 0 , null ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_GET , $ this -> _links -> captures -> href ) ; return ResourceFactory :: createCursorResourceCollection ( $ this -> client , $ result -> _embedded -> captures , Capture :: class , $ result -> _links ) ; } | Retrieves all captures associated with this payment |
12,552 | public function getChargeback ( $ chargebackId , array $ parameters = [ ] ) { return $ this -> client -> paymentChargebacks -> getFor ( $ this , $ chargebackId , $ parameters ) ; } | Retrieves a specific chargeback for this payment . |
12,553 | public function refund ( $ data = [ ] ) { $ resource = "payments/" . urlencode ( $ this -> id ) . "/refunds" ; $ body = null ; if ( count ( $ data ) > 0 ) { $ body = json_encode ( $ data ) ; } $ result = $ this -> client -> performHttpCall ( MollieApiClient :: HTTP_POST , $ resource , $ body ) ; return ResourceFactory :: createFromApiResult ( $ result , new Refund ( $ this -> client ) ) ; } | Issue a refund for this payment . |
12,554 | public function get ( $ paymentId , array $ parameters = [ ] ) { if ( empty ( $ paymentId ) || strpos ( $ paymentId , self :: RESOURCE_ID_PREFIX ) !== 0 ) { throw new ApiException ( "Invalid payment ID: '{$paymentId}'. A payment ID should start with '" . self :: RESOURCE_ID_PREFIX . "'." ) ; } return parent :: rest_read ( $ paymentId , $ parameters ) ; } | Retrieve a single payment from Mollie . |
12,555 | public function page ( $ from = null , $ limit = null , array $ parameters = [ ] ) { return $ this -> rest_list ( $ from , $ limit , $ parameters ) ; } | Retrieves a collection of Payments from Mollie . |
12,556 | public function refund ( Payment $ payment , $ data = [ ] ) { $ resource = "{$this->getResourcePath()}/" . urlencode ( $ payment -> id ) . "/refunds" ; $ body = null ; if ( count ( $ data ) > 0 ) { $ body = json_encode ( $ data ) ; } $ result = $ this -> client -> performHttpCall ( self :: REST_CREATE , $ resource , $ body ) ; return ResourceFactory :: createFromApiResult ( $ result , new Refund ( $ this -> client ) ) ; } | Issue a refund for the given payment . |
12,557 | public static function createFromApiResult ( $ apiResult , BaseResource $ resource ) { foreach ( $ apiResult as $ property => $ value ) { $ resource -> { $ property } = $ value ; } return $ resource ; } | Create resource object from Api result |
12,558 | public function revoke ( ) { if ( ! isset ( $ this -> _links -> self -> href ) ) { return $ this ; } $ body = null ; if ( $ this -> client -> usesOAuth ( ) ) { $ body = json_encode ( [ "testmode" => $ this -> mode === "test" ? true : false ] ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_DELETE , $ this -> _links -> self -> href , $ body ) ; return $ result ; } | Revoke the mandate |
12,559 | public function allAvailable ( array $ parameters = [ ] ) { $ url = 'methods/all' . $ this -> buildQueryString ( $ parameters ) ; $ result = $ this -> client -> performHttpCall ( 'GET' , $ url ) ; return ResourceFactory :: createBaseResourceCollection ( $ this -> client , $ result -> _embedded -> methods , Method :: class , $ result -> _links ) ; } | Retrieve all available methods for the organization including activated and not yet activated methods . The results are not paginated . Make sure to include the profileId parameter if using an OAuth Access Token . |
12,560 | public function get ( $ methodId , array $ parameters = [ ] ) { if ( empty ( $ methodId ) ) { throw new ApiException ( "Method ID is empty." ) ; } return parent :: rest_read ( $ methodId , $ parameters ) ; } | Retrieve a payment method from Mollie . |
12,561 | public function get ( $ organizationId , array $ parameters = [ ] ) { if ( empty ( $ organizationId ) ) { throw new ApiException ( "Organization ID is empty." ) ; } return parent :: rest_read ( $ organizationId , $ parameters ) ; } | Retrieve an organization from Mollie . |
12,562 | protected function rest_read ( $ id , array $ filters ) { if ( empty ( $ id ) ) { throw new ApiException ( "Invalid resource id." ) ; } $ id = urlencode ( $ id ) ; $ result = $ this -> client -> performHttpCall ( self :: REST_READ , "{$this->getResourcePath()}/{$id}" . $ this -> buildQueryString ( $ filters ) ) ; return ResourceFactory :: createFromApiResult ( $ result , $ this -> getResourceObject ( ) ) ; } | Retrieves a single object from the REST API . |
12,563 | protected function rest_delete ( $ id , array $ body = [ ] ) { if ( empty ( $ id ) ) { throw new ApiException ( "Invalid resource id." ) ; } $ id = urlencode ( $ id ) ; $ result = $ this -> client -> performHttpCall ( self :: REST_DELETE , "{$this->getResourcePath()}/{$id}" , $ this -> parseRequestBody ( $ body ) ) ; if ( $ result === null ) { return null ; } return ResourceFactory :: createFromApiResult ( $ result , $ this -> getResourceObject ( ) ) ; } | Sends a DELETE request to a single Molle API object . |
12,564 | protected function rest_list ( $ from = null , $ limit = null , array $ filters ) { $ filters = array_merge ( [ "from" => $ from , "limit" => $ limit ] , $ filters ) ; $ apiPath = $ this -> getResourcePath ( ) . $ this -> buildQueryString ( $ filters ) ; $ result = $ this -> client -> performHttpCall ( self :: REST_LIST , $ apiPath ) ; $ collection = $ this -> getResourceCollectionObject ( $ result -> count , $ result -> _links ) ; foreach ( $ result -> _embedded -> { $ collection -> getCollectionResourceName ( ) } as $ dataResult ) { $ collection [ ] = ResourceFactory :: createFromApiResult ( $ dataResult , $ this -> getResourceObject ( ) ) ; } return $ collection ; } | Get a collection of objects from the REST API . |
12,565 | final public function next ( ) { if ( ! $ this -> hasNext ( ) ) { return null ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_GET , $ this -> _links -> next -> href ) ; $ collection = new static ( $ this -> client , $ result -> count , $ result -> _links ) ; foreach ( $ result -> _embedded -> { $ collection -> getCollectionResourceName ( ) } as $ dataResult ) { $ collection [ ] = ResourceFactory :: createFromApiResult ( $ dataResult , $ this -> createResourceObject ( ) ) ; } return $ collection ; } | Return the next set of resources when available |
12,566 | public function get ( $ profileId , array $ parameters = [ ] ) { if ( $ profileId === 'me' ) { return $ this -> getCurrent ( $ parameters ) ; } return $ this -> rest_read ( $ profileId , $ parameters ) ; } | Retrieve a Profile from Mollie . |
12,567 | public function get ( $ lineId ) { foreach ( $ this as $ line ) { if ( $ line -> id === $ lineId ) { return $ line ; } } return null ; } | Get a specific order line . Returns null if the order line cannot be found . |
12,568 | public function cancel ( ) { if ( ! isset ( $ this -> _links -> self -> href ) ) { return $ this ; } $ body = null ; if ( $ this -> client -> usesOAuth ( ) ) { $ body = json_encode ( [ "testmode" => $ this -> mode === "test" ? true : false ] ) ; } $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_DELETE , $ this -> _links -> self -> href , $ body ) ; return ResourceFactory :: createFromApiResult ( $ result , new Subscription ( $ this -> client ) ) ; } | Cancels this subscription |
12,569 | public function getShipment ( $ shipmentId , array $ parameters = [ ] ) { return $ this -> client -> shipments -> getFor ( $ this , $ shipmentId , $ parameters ) ; } | Retrieve a specific shipment for this order . |
12,570 | public function createPayment ( $ data , $ filters = [ ] ) { return $ this -> client -> orderPayments -> createFor ( $ this , $ data , $ filters ) ; } | Create a new payment for this Order . |
12,571 | public function payments ( ) { if ( ! isset ( $ this -> _embedded , $ this -> _embedded -> payments ) ) { return null ; } return ResourceFactory :: createCursorResourceCollection ( $ this -> client , $ this -> _embedded -> payments , Payment :: class ) ; } | Retrieve the payments for this order . Requires the order to be retrieved using the embed payments parameter . |
12,572 | public function cancelForId ( $ orderId , array $ data ) { if ( ! isset ( $ data , $ data [ 'lines' ] ) || ! is_array ( $ data [ 'lines' ] ) ) { throw new ApiException ( "A lines array is required." ) ; } $ this -> parentId = $ orderId ; $ this -> client -> performHttpCall ( self :: REST_DELETE , "{$this->getResourcePath()}" , $ this -> parseRequestBody ( $ data ) ) ; return null ; } | Cancel lines for the provided order id . The data array must contain a lines array . You can pass an empty lines array if you want to cancel all eligible lines . Returns null if successful . |
12,573 | public function update ( ) { if ( ! isset ( $ this -> _links -> self -> href ) ) { return $ this ; } $ body = json_encode ( [ "tracking" => $ this -> tracking , ] ) ; $ result = $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_PATCH , $ this -> _links -> self -> href , $ body ) ; return ResourceFactory :: createFromApiResult ( $ result , new Shipment ( $ this -> client ) ) ; } | Save changes made to this shipment . |
12,574 | public function cancel ( ) { $ this -> client -> performHttpCallToFullUrl ( MollieApiClient :: HTTP_DELETE , $ this -> _links -> self -> href ) ; return null ; } | Cancel the refund . Returns null if successful . |
12,575 | public function performHttpCallToFullUrl ( $ httpMethod , $ url , $ httpBody = null ) { if ( empty ( $ this -> apiKey ) ) { throw new ApiException ( "You have not set an API key or OAuth access token. Please use setApiKey() to set the API key." ) ; } $ userAgent = implode ( ' ' , $ this -> versionStrings ) ; if ( $ this -> usesOAuth ( ) ) { $ userAgent .= " OAuth/2.0" ; } $ headers = [ 'Accept' => "application/json" , 'Authorization' => "Bearer {$this->apiKey}" , 'User-Agent' => $ userAgent , ] ; if ( function_exists ( "php_uname" ) ) { $ headers [ 'X-Mollie-Client-Info' ] = php_uname ( ) ; } $ request = new Request ( $ httpMethod , $ url , $ headers , $ httpBody ) ; try { $ response = $ this -> httpClient -> send ( $ request , [ 'http_errors' => false ] ) ; } catch ( GuzzleException $ e ) { throw ApiException :: createFromGuzzleException ( $ e ) ; } if ( ! $ response ) { throw new ApiException ( "Did not receive API response." ) ; } return $ this -> parseResponseBody ( $ response ) ; } | Perform an http call to a full url . This method is used by the resource specific classes . |
12,576 | private function parseResponseBody ( ResponseInterface $ response ) { $ body = ( string ) $ response -> getBody ( ) ; if ( empty ( $ body ) ) { if ( $ response -> getStatusCode ( ) === self :: HTTP_NO_CONTENT ) { return null ; } throw new ApiException ( "No response body found." ) ; } $ object = @ json_decode ( $ body ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new ApiException ( "Unable to decode Mollie response: '{$body}'." ) ; } if ( $ response -> getStatusCode ( ) >= 400 ) { throw ApiException :: createFromResponse ( $ response ) ; } return $ object ; } | Parse the PSR - 7 Response body |
12,577 | public function get ( $ orderId , array $ parameters = [ ] ) { if ( empty ( $ orderId ) || strpos ( $ orderId , self :: RESOURCE_ID_PREFIX ) !== 0 ) { throw new ApiException ( "Invalid order ID: '{$orderId}'. An order ID should start with '" . self :: RESOURCE_ID_PREFIX . "'." ) ; } return parent :: rest_read ( $ orderId , $ parameters ) ; } | Retrieve a single order from Mollie . |
12,578 | protected function viewValue ( FieldItemInterface $ item ) { $ field = $ item -> getFieldDefinition ( ) ; if ( $ field -> get ( 'field_type' ) == 'daterange' ) { $ value = $ item -> start_date ; } else { $ value = $ item -> date ; } $ build = [ '#theme' => 'calendar_item_date' , '#datetime' => $ value , '#attached' => [ 'library' => [ 'govcms8_calendar_item/calendar_item' , ] , ] , ] ; return $ build ; } | Generate the output appropriate for one field item . |
12,579 | public static function bytesToString ( $ bytes ) { $ units = array_map ( 't' , [ 'bytes' , 'KB' , 'MB' , 'GB' , 'TB' ] ) ; while ( $ bytes > 1024 ) { $ bytes /= 1024 ; array_shift ( $ units ) ; } return $ bytes . ' ' . reset ( $ units ) ; } | Converts a number of bytes into a human - readable string . |
12,580 | public function getFileExtensions ( $ check_access = FALSE , array $ bundles = [ ] ) { $ extensions = '' ; $ storage = $ this -> entityTypeManager -> getStorage ( 'media_type' ) ; $ media_types = $ storage -> loadMultiple ( $ bundles ? : NULL , $ check_access ) ; foreach ( $ media_types as $ media_type ) { $ field = $ media_type -> getSource ( ) -> getSourceFieldDefinition ( $ media_type ) ; if ( is_a ( $ field -> getItemDefinition ( ) -> getClass ( ) , FileItem :: class , TRUE ) ) { $ extensions .= $ field -> getSetting ( 'file_extensions' ) . ' ' ; } } $ extensions = preg_split ( '/,?\s+/' , rtrim ( $ extensions ) ) ; return array_unique ( $ extensions ) ; } | Returns all file extensions accepted by bundles that use file fields . |
12,581 | public function getBundleFromInput ( $ value , $ check_access = TRUE , array $ bundles = [ ] ) { $ media_types = $ this -> entityTypeManager -> getStorage ( 'media_type' ) -> loadMultiple ( $ bundles ? : NULL , $ check_access ) ; ksort ( $ media_types ) ; foreach ( $ media_types as $ media_type ) { $ source = $ media_type -> getSource ( ) ; if ( $ source instanceof InputMatchInterface && $ source -> appliesTo ( $ value , $ media_type ) ) { return $ media_type ; } } throw new IndeterminateBundleException ( $ value ) ; } | Returns the first media bundle that can accept an input value . |
12,582 | public function createFromInput ( $ value , array $ bundles = [ ] ) { $ entity = $ this -> entityTypeManager -> getStorage ( 'media' ) -> create ( [ 'bundle' => $ this -> getBundleFromInput ( $ value , TRUE , $ bundles ) -> id ( ) , ] ) ; $ field = static :: getSourceField ( $ entity ) ; if ( $ field ) { $ field -> setValue ( $ value ) ; } return $ entity ; } | Creates a media entity from an input value . |
12,583 | public static function useFile ( MediaInterface $ entity , FileInterface $ file , $ replace = FILE_EXISTS_RENAME ) { $ field = static :: getSourceField ( $ entity ) ; $ field -> setValue ( $ file ) ; $ destination = '' ; $ destination .= static :: prepareFileDestination ( $ entity ) ; if ( substr ( $ destination , - 1 ) != '/' ) { $ destination .= '/' ; } $ destination .= $ file -> getFilename ( ) ; if ( $ destination == $ file -> getFileUri ( ) ) { return $ file ; } else { $ file = file_move ( $ file , $ destination , $ replace ) ; if ( $ file ) { $ field -> setValue ( $ file ) ; return $ file ; } else { return FALSE ; } } } | Attaches a file entity to a media entity . |
12,584 | public static function prepareFileDestination ( MediaInterface $ entity ) { $ item = static :: getSourceField ( $ entity ) -> first ( ) ; $ dir = $ item -> getUploadLocation ( ) ; $ is_ready = file_prepare_directory ( $ dir , FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS ) ; if ( $ is_ready ) { return $ dir ; } else { throw new \ RuntimeException ( 'Could not prepare ' . $ dir . ' for writing' ) ; } } | Prepares the destination directory for a file attached to a media entity . |
12,585 | public static function getSourceField ( MediaInterface $ entity ) { $ field = $ entity -> getSource ( ) -> getSourceFieldDefinition ( $ entity -> bundle -> entity ) ; return $ field ? $ entity -> get ( $ field -> getName ( ) ) : NULL ; } | Returns the media entity s source field item list . |
12,586 | public static function validate ( array & $ element , FormStateInterface $ form_state ) { if ( $ element [ '#value' ] ) { $ file = File :: load ( $ element [ '#value' ] ) ; $ errors = file_validate ( $ file , $ element [ '#upload_validators' ] ) ; if ( $ errors ) { foreach ( $ errors as $ error ) { $ form_state -> setError ( $ element , ( string ) $ error ) ; } static :: delete ( $ element ) ; } } } | Validates the uploaded file . |
12,587 | public static function delete ( array $ element ) { if ( $ element [ '#value' ] ) { $ file = File :: load ( $ element [ '#value' ] ) ; $ file -> delete ( ) ; $ uri = $ file -> getFileUri ( ) ; if ( file_exists ( $ uri ) ) { \ Drupal :: service ( 'file_system' ) -> unlink ( $ uri ) ; } } } | Deletes the file referenced by the element . |
12,588 | protected function doEncode ( array $ input , array $ keys = [ ] ) { $ output = [ ] ; foreach ( $ input as $ key => $ value ) { $ keys [ ] = $ key ; if ( is_array ( $ value ) ) { if ( $ this -> isAssociative ( $ value ) ) { $ output = array_merge ( $ output , $ this -> doEncode ( $ value , $ keys ) ) ; } else { foreach ( $ value as $ j ) { $ output [ ] = $ this -> keysToString ( $ keys ) . '[] = ' . $ j ; } } } else { $ output [ ] = $ this -> keysToString ( $ keys ) . ' = ' . $ value ; } array_pop ( $ keys ) ; } return $ output ; } | Recursively serializes data to legacy make format . |
12,589 | protected function keysToString ( array $ keys ) { $ head = array_shift ( $ keys ) ; if ( $ keys ) { return $ head . '[' . implode ( '][' , $ keys ) . ']' ; } else { return $ head ; } } | Transforms an key path to a string . |
12,590 | public function parse ( $ data ) { $ info = [ ] ; if ( preg_match_all ( ' @^\s* # Start at the beginning of a line, ignoring leading whitespace ((?: [^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets, \[[^\[\]]*\] # unless they are balanced and not nested )+?) \s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space) (?: ("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes (\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes ([^\r\n]*?) # Non-quoted string )\s*$ # Stop at the next end of a line, ignoring trailing whitespace @msx' , $ data , $ matches , PREG_SET_ORDER ) ) { foreach ( $ matches as $ match ) { $ i = 0 ; foreach ( [ 'key' , 'value1' , 'value2' , 'value3' ] as $ var ) { $ $ var = isset ( $ match [ ++ $ i ] ) ? $ match [ $ i ] : '' ; } if ( isset ( $ key ) && isset ( $ value1 ) && isset ( $ value2 ) && isset ( $ value3 ) ) { $ value = stripslashes ( substr ( $ value1 , 1 , - 1 ) ) . stripslashes ( substr ( $ value2 , 1 , - 1 ) ) . $ value3 ; $ keys = preg_split ( '/\]?\[/' , rtrim ( $ key , ']' ) ) ; $ last = array_pop ( $ keys ) ; $ parent = & $ info ; foreach ( $ keys as $ key ) { if ( $ key == '' ) { $ key = count ( $ parent ) ; } if ( ! isset ( $ parent [ $ key ] ) || ! is_array ( $ parent [ $ key ] ) ) { $ parent [ $ key ] = [ ] ; } $ parent = & $ parent [ $ key ] ; } if ( preg_match ( '/^\w+$/i' , $ value ) && defined ( $ value ) ) { $ value = constant ( $ value ) ; } if ( $ last == '' ) { $ last = count ( $ parent ) ; } $ parent [ $ last ] = $ value ; } } } return $ info ; } | Parses data in Drupal s . info format . |
12,591 | protected function isLibrary ( array $ package ) { if ( $ package [ 'name' ] == 'swiftmailer/swiftmailer' ) { $ package [ 'type' ] = 'drupal-library' ; } $ package_types = [ 'drupal-library' , 'bower-asset' , 'npm-asset' , ] ; return ( in_array ( $ package [ 'type' ] , $ package_types ) && array_key_exists ( $ package [ 'name' ] , $ this -> rootPackage -> getRequires ( ) ) ) ; } | Determines if a package is an asset library . |
12,592 | protected function isGovCMSTheme ( array $ package ) { if ( $ package [ 'name' ] == 'govcms-custom/govcms8_uikit' || $ package [ 'name' ] == 'govcms-custom/govcms8_uikit_starter' ) { return FALSE ; } $ package_types = [ 'drupal-theme' , ] ; return ( in_array ( $ package [ 'type' ] , $ package_types ) && array_key_exists ( $ package [ 'name' ] , $ this -> rootPackage -> getRequires ( ) ) ) ; } | Determines if a package is a GovCMS theme . |
12,593 | public static function process ( array $ element , FormStateInterface $ form_state ) { $ element [ 'fid' ] = [ '#type' => 'hidden' , ] ; $ element [ 'upload' ] = $ element [ 'remove' ] = [ '#type' => 'submit' , '#is_button' => TRUE , '#limit_validation_errors' => [ $ element [ '#parents' ] , ] , '#weight' => 100 , ] ; $ element [ 'upload' ] [ '#value' ] = t ( 'Upload' ) ; $ element [ 'upload' ] [ '#submit' ] [ ] = [ static :: class , 'upload' ] ; $ element [ 'remove' ] [ '#value' ] = t ( 'Remove' ) ; $ element [ 'remove' ] [ '#submit' ] [ ] = [ static :: class , 'remove' ] ; $ key = array_merge ( $ element [ '#parents' ] , [ 'fid' ] ) ; $ fid = $ form_state -> getValue ( $ key ) ; if ( $ fid ) { $ element [ 'fid' ] [ '#value' ] = $ fid ; $ element [ 'file' ] = [ '#theme' => 'file_link' , '#file' => File :: load ( $ fid ) , ] ; $ element [ 'upload' ] [ '#access' ] = FALSE ; } else { $ element [ 'file' ] = [ '#type' => 'upload' , '#title' => $ element [ '#title' ] , '#upload_location' => $ element [ '#upload_location' ] , '#upload_validators' => $ element [ '#upload_validators' ] , ] ; $ element [ 'remove' ] [ '#access' ] = FALSE ; } return $ element ; } | Processes the element . |
12,594 | public static function el ( array & $ form , FormStateInterface $ form_state ) { $ trigger = $ form_state -> getTriggeringElement ( ) ; return NestedArray :: getValue ( $ form , array_slice ( $ trigger [ '#array_parents' ] , 0 , - 1 ) ) ; } | Returns the root element for a triggering element . |
12,595 | public static function upload ( array & $ form , FormStateInterface $ form_state ) { $ el = static :: el ( $ form , $ form_state ) ; $ form_state -> setValueForElement ( $ el [ 'fid' ] , $ el [ 'file' ] [ '#value' ] ) ; NestedArray :: setValue ( $ form_state -> getUserInput ( ) , $ el [ 'fid' ] [ '#parents' ] , $ el [ 'file' ] [ '#value' ] ) ; $ form_state -> setRebuild ( ) ; } | Handles form submission when the Upload button is clicked . |
12,596 | public static function remove ( array & $ form , FormStateInterface $ form_state ) { $ el = static :: el ( $ form , $ form_state ) ; Upload :: delete ( $ el [ 'fid' ] ) ; $ form_state -> setValueForElement ( $ el [ 'fid' ] , NULL ) ; NestedArray :: setValue ( $ form_state -> getUserInput ( ) , $ el [ 'fid' ] [ '#parents' ] , NULL ) ; $ form_state -> setRebuild ( ) ; } | Handles form submission when the Remove button is clicked . |
12,597 | public function mergeCanadian ( array $ a , array $ b ) { $ a += $ b ; foreach ( $ a as $ k => $ v ) { if ( is_array ( $ v ) && isset ( $ b [ $ k ] ) && is_array ( $ b [ $ k ] ) ) { $ a [ $ k ] = static :: mergeCanadian ( $ a [ $ k ] , $ b [ $ k ] ) ; } } return $ a ; } | Recursively merges arrays using the + method . |
12,598 | public static function order ( array & $ values , array $ keys ) { $ keys = array_values ( $ keys ) ; uksort ( $ values , function ( $ a , $ b ) use ( $ keys ) { return array_search ( $ a , $ keys ) - array_search ( $ b , $ keys ) ; } ) ; } | Puts an associative array into an arbitrary order . |
12,599 | public static function disableButtons ( array $ element ) { if ( isset ( $ element [ '#type' ] ) ) { $ element [ '#access' ] = ! in_array ( $ element [ '#type' ] , [ 'button' , 'submit' , 'image_button' , ] ) ; } foreach ( RenderElement :: children ( $ element ) as $ key ) { if ( is_array ( $ element [ $ key ] ) ) { $ element [ $ key ] = static :: disableButtons ( $ element [ $ key ] ) ; } } return $ element ; } | Pre - render function to disable all buttons in a renderable element . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.