idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
49,600 | protected function _getAllowedActions ( ) { $ actions = $ this -> _action ( ) -> getConfig ( 'scaffold.actions' ) ; if ( $ actions === null ) { $ actions = array_keys ( $ this -> _crud ( ) -> getConfig ( 'actions' ) ) ; } $ extraActions = $ this -> _action ( ) -> getConfig ( 'scaffold.extra_actions' ) ? : [ ] ; $ allActions = array_merge ( $ this -> _normalizeActions ( $ actions ) , $ this -> _normalizeActions ( $ extraActions ) ) ; $ blacklist = ( array ) $ this -> _action ( ) -> getConfig ( 'scaffold.actions_blacklist' ) ; $ blacklist = array_combine ( $ blacklist , $ blacklist ) ; foreach ( $ this -> _crud ( ) -> getConfig ( 'actions' ) as $ action => $ config ) { if ( $ config [ 'className' ] === 'Crud.Lookup' ) { $ blacklist [ $ action ] = $ action ; } } return array_diff_key ( $ allActions , $ blacklist ) ; } | Returns a list of action configs that are allowed to be shown |
49,601 | protected function _normalizeActions ( $ actions ) { $ normalized = [ ] ; foreach ( $ actions as $ key => $ config ) { if ( is_array ( $ config ) ) { $ normalized [ $ key ] = $ config ; } else { $ normalized [ $ config ] = [ ] ; } } return $ normalized ; } | Convert mixed action configs to unified structure |
49,602 | protected function _associations ( array $ whitelist = [ ] ) { $ table = $ this -> _table ( ) ; $ associationConfiguration = [ ] ; $ associations = $ table -> associations ( ) ; $ keys = $ associations -> keys ( ) ; if ( ! empty ( $ whitelist ) ) { $ keys = array_intersect ( $ keys , array_map ( 'strtolower' , $ whitelist ) ) ; } foreach ( $ keys as $ associationName ) { $ association = $ associations -> get ( $ associationName ) ; $ type = $ association -> type ( ) ; if ( ! isset ( $ associationConfiguration [ $ type ] ) ) { $ associationConfiguration [ $ type ] = [ ] ; } $ assocKey = $ association -> getName ( ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'model' ] = $ assocKey ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'type' ] = $ type ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'primaryKey' ] = $ association -> getTarget ( ) -> getPrimaryKey ( ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'displayField' ] = $ association -> getTarget ( ) -> getDisplayField ( ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'foreignKey' ] = $ association -> getForeignKey ( ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'propertyName' ] = $ association -> getProperty ( ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'plugin' ] = pluginSplit ( $ association -> getClassName ( ) ) [ 0 ] ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'controller' ] = $ assocKey ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'entity' ] = Inflector :: singularize ( Inflector :: underscore ( $ assocKey ) ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] [ 'entities' ] = Inflector :: underscore ( $ assocKey ) ; $ associationConfiguration [ $ type ] [ $ assocKey ] = array_merge ( $ associationConfiguration [ $ type ] [ $ assocKey ] , $ this -> _action ( ) -> getConfig ( 'association.' . $ assocKey ) ? : [ ] ) ; } return $ associationConfiguration ; } | Returns associations for controllers models . |
49,603 | protected function _getActionGroups ( ) { $ action = $ this -> _action ( ) ; $ groups = $ action -> getConfig ( 'scaffold.action_groups' ) ? : [ ] ; $ groupedActions = [ ] ; foreach ( $ groups as $ group ) { $ groupedActions [ ] = array_keys ( Hash :: normalize ( $ group ) ) ; } $ groupedActions = ( new Collection ( $ groupedActions ) ) -> unfold ( ) -> toList ( ) ; $ groups [ 'primary' ] = array_diff ( array_keys ( $ this -> _getAllowedActions ( ) ) , $ groupedActions ) ; return $ groups ; } | Get action groups |
49,604 | protected function _getFormTabGroups ( array $ fields = [ ] ) { $ action = $ this -> _action ( ) ; $ groups = $ action -> getConfig ( 'scaffold.form_tab_groups' ) ; if ( empty ( $ groups ) ) { return [ ] ; } $ groupedFields = ( new Collection ( $ groups ) ) -> unfold ( ) -> toList ( ) ; $ unGroupedFields = array_diff ( array_keys ( $ fields ) , $ groupedFields ) ; if ( ! empty ( $ unGroupedFields ) ) { $ primayGroup = $ action -> getConfig ( 'scaffold.form_primary_tab' ) ? : __d ( 'crud' , 'Primary' ) ; $ groups = [ $ primayGroup => $ unGroupedFields ] + $ groups ; } return $ groups ; } | Get field tab groups |
49,605 | public function render ( array $ data , ContextInterface $ context ) { $ id = $ data [ 'id' ] ; $ name = $ data [ 'name' ] ; $ val = $ data [ 'val' ] ; $ type = $ data [ 'type' ] ; $ required = $ data [ 'required' ] ? 'required' : '' ; $ disabled = isset ( $ data [ 'disabled' ] ) && $ data [ 'disabled' ] ? 'disabled' : '' ; $ role = isset ( $ data [ 'role' ] ) ? $ data [ 'role' ] : 'datetime-picker' ; $ format = null ; $ locale = isset ( $ data [ 'locale' ] ) ? $ data [ 'locale' ] : I18n :: getLocale ( ) ; $ timezoneAware = Configure :: read ( 'CrudView.timezoneAwareDateTimeWidget' ) ; $ timestamp = null ; $ timezoneOffset = null ; if ( isset ( $ data [ 'data-format' ] ) ) { $ format = $ this -> _convertPHPToMomentFormat ( $ data [ 'data-format' ] ) ; } if ( ! ( $ val instanceof DateTimeInterface ) && ! empty ( $ val ) ) { switch ( $ type ) { case 'date' : case 'time' : $ val = Type :: build ( $ type ) -> marshal ( $ val ) ; break ; default : $ val = Type :: build ( 'datetime' ) -> marshal ( $ val ) ; } } if ( $ val && ! is_string ( $ val ) ) { if ( $ timezoneAware ) { $ timestamp = $ val -> format ( 'U' ) ; $ dateTimeZone = new DateTimeZone ( date_default_timezone_get ( ) ) ; $ timezoneOffset = ( $ dateTimeZone -> getOffset ( $ val ) / 60 ) ; } $ val = $ val -> format ( $ type === 'date' ? 'Y-m-d' : 'Y-m-d H:i:s' ) ; } if ( $ format === null ) { if ( $ type === 'date' ) { $ format = 'L' ; } elseif ( $ type === 'time' ) { $ format = 'LT' ; } else { $ format = 'L LT' ; } } $ icon = $ type === 'time' ? 'time' : 'calendar' ; $ widget = <<<html <div class="input-group $type"> <input type="text" class="form-control" name="$name" value="$val" id="$id" role="$role" data-locale="$locale" data-format="$format"html ; if ( $ timezoneAware && isset ( $ timestamp , $ timezoneOffset ) ) { $ widget .= <<<html data-timestamp="$timestamp" data-timezone-offset="$timezoneOffset"html ; } $ widget .= <<<html $required $disabled /> <label for="$id" class="input-group-addon"> <span class="glyphicon glyphicon-$icon"></span> </label> </div>html ; return $ widget ; } | Renders a date time widget . |
49,606 | public function usingAutomaticFormatGuessingAction ( $ name ) { $ format = $ this -> get ( 'request' ) -> get ( '_format' ) ; return $ this -> render ( sprintf ( 'PsPdfBundle:Example:usingAutomaticFormatGuessing.%s.twig' , $ format ) , array ( 'name' => $ name , ) ) ; } | Possible custom headers and external stylesheet file |
49,607 | public function examplesAction ( ) { $ kernelRootDir = $ this -> container -> getParameter ( 'kernel.root_dir' ) ; $ propablyPhpPdfExamplesFilePaths = array ( $ kernelRootDir . '/../vendor/PHPPdf/examples/index.php' , $ kernelRootDir . '/../vendor/psliwa/php-pdf/examples/index.php' ) ; foreach ( $ propablyPhpPdfExamplesFilePaths as $ propablyPhpPdfExamplesFilePath ) { if ( file_exists ( $ propablyPhpPdfExamplesFilePath ) ) { require $ propablyPhpPdfExamplesFilePath ; exit ( ) ; } } throw new NotFoundHttpException ( 'File with PHPPdf examples not found.' ) ; } | Standard examples of PHPPdf library |
49,608 | public function run ( ) { $ this -> echoLoadingTags ( ) ; $ assets = CoreAsset :: register ( $ this -> view ) ; if ( $ this -> theme === true ) { ThemeAsset :: register ( $ this -> view ) ; } if ( isset ( $ this -> options [ 'language' ] ) ) { $ assets -> language = $ this -> options [ 'language' ] ; } $ assets -> googleCalendar = $ this -> googleCalendar ; $ this -> clientOptions [ 'header' ] = $ this -> header ; $ this -> view -> registerJs ( implode ( "\n" , [ "jQuery('#{$this->options['id']}').fullCalendar({$this->getClientOptions()});" , ] ) , \ yii \ web \ View :: POS_READY ) ; } | Load the options and start the widget |
49,609 | private function echoLoadingTags ( ) { echo \ yii \ helpers \ Html :: beginTag ( 'div' , $ this -> options ) . "\n" ; echo \ yii \ helpers \ Html :: beginTag ( 'div' , [ 'class' => 'fc-loading' , 'style' => 'display:none;' ] ) ; echo \ yii \ helpers \ Html :: encode ( $ this -> loading ) ; echo \ yii \ helpers \ Html :: endTag ( 'div' ) . "\n" ; echo \ yii \ helpers \ Html :: endTag ( 'div' ) . "\n" ; } | Echo the tags to show the loading state for the calendar |
49,610 | private function parseLine ( $ line ) { if ( ! $ line ) { return array ( ) ; } $ line = trim ( $ line ) ; if ( ! $ line ) { return array ( ) ; } $ array = array ( ) ; $ group = $ this -> nodeContainsGroup ( $ line ) ; if ( $ group ) { $ this -> addGroup ( $ line , $ group ) ; $ line = $ this -> stripGroup ( $ line , $ group ) ; } if ( $ this -> startsMappedSequence ( $ line ) ) { return $ this -> returnMappedSequence ( $ line ) ; } if ( $ this -> startsMappedValue ( $ line ) ) { return $ this -> returnMappedValue ( $ line ) ; } if ( $ this -> isArrayElement ( $ line ) ) { return $ this -> returnArrayElement ( $ line ) ; } if ( $ this -> isPlainArray ( $ line ) ) { return $ this -> returnPlainArray ( $ line ) ; } return $ this -> returnKeyValuePair ( $ line ) ; } | Parses YAML code and returns an array for a node |
49,611 | private function setPropertyIfExists ( $ property , $ value ) { if ( property_exists ( $ this , $ property ) ) { if ( $ value == null ) { return $ this ; } $ action = new HpsBuilderAction ( $ property , array ( $ this , 'setProperty' ) ) ; $ action -> arguments = array ( $ property , $ value ) ; $ this -> addAction ( $ action ) ; } else { throw new HpsUnknownPropertyException ( $ this , $ property ) ; } return $ this ; } | Sets a property if it exists on the current object . |
49,612 | public function execute ( ) { parent :: execute ( ) ; $ returnSvc = new HpsDebitService ( $ this -> service -> servicesConfig ( ) ) ; return $ returnSvc -> returnDebit ( $ this -> transactionId , $ this -> amount , $ this -> trackData , $ this -> pinBlock , $ this -> allowDuplicates , $ this -> cardHolder , $ this -> encryptionData , $ this -> details , $ this -> clientTransactionId ) ; } | Creates a return transaction through the HpsDebitService |
49,613 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCreditAuth = $ xml -> createElement ( 'hps:PrePaidAddValue' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ this -> amount ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:AllowDup' , ( $ this -> allowDuplicates ? 'Y' : 'N' ) ) ) ; $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; if ( $ this -> card != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateManualEntry ( $ this -> card , $ xml ) ) ; } else if ( $ this -> trackData != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateTrackData ( $ this -> trackData , $ xml ) ) ; } else if ( $ this -> token != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateTokenData ( $ this -> token , $ xml ) ) ; } $ hpsBlock1 -> appendChild ( $ cardData ) ; $ hpsCreditAuth -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsCreditAuth ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'PrePaidAddValue' ) ; } | Creates an add value transaction through the HpsCreditService |
49,614 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCreditAccountVerify = $ xml -> createElement ( 'hps:CreditAccountVerify' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; if ( $ this -> cardHolder != null ) { $ hpsBlock1 -> appendChild ( $ this -> service -> _hydrateCardHolderData ( $ this -> cardHolder , $ xml ) ) ; } $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; if ( $ this -> card != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateManualEntry ( $ this -> card , $ xml , $ this -> cardPresent , $ this -> readerPresent ) ) ; if ( $ this -> card -> encryptionData != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateEncryptionData ( $ this -> card -> encryptionData , $ xml ) ) ; } } else if ( $ this -> token != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateTokenData ( $ this -> token , $ xml , $ this -> cardPresent , $ this -> readerPresent ) ) ; } else if ( $ this -> trackData != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateTrackData ( $ this -> trackData , $ xml ) ) ; if ( $ this -> trackData -> encryptionData != null ) { $ cardData -> appendChild ( $ this -> service -> _hydrateEncryptionData ( $ this -> trackData -> encryptionData , $ xml ) ) ; } } $ cardData -> appendChild ( $ xml -> createElement ( 'hps:TokenRequest' , ( $ this -> requestMultiUseToken ) ? 'Y' : 'N' ) ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; $ hpsCreditAccountVerify -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsCreditAccountVerify ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CreditAccountVerify' , $ this -> clientTransactionId ) ; } | Creates a verify transaction through the HpsCreditService |
49,615 | public function execute ( ) { parent :: execute ( ) ; $ replaceSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; return $ replaceSvc -> replace ( $ this -> oldCard , $ this -> newCard ) ; } | Creates a replace transaction through the HpsGiftCardService |
49,616 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCreditVoid = $ xml -> createElement ( 'hps:CreditVoid' ) ; $ hpsCreditVoid -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ this -> transactionId ) ) ; $ hpsTransaction -> appendChild ( $ hpsCreditVoid ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CreditVoid' , $ this -> clientTransactionId ) ; } | Creates a void transaction through the HpsCreditService |
49,617 | public function execute ( ) { parent :: execute ( ) ; $ addValueSvc = new HpsDebitService ( $ this -> service -> servicesConfig ( ) ) ; return $ addValueSvc -> addValue ( $ this -> amount , $ this -> currency , $ this -> trackData , $ this -> pinBlock , $ this -> encryptionData , $ this -> allowDuplicates , $ this -> cardHolder , $ this -> details , $ this -> clientTransactionId ) ; } | Creates a addValue transaction through the HpsDebitService |
49,618 | private function setUpValidations ( ) { $ this -> addValidation ( array ( $ this , 'amountNotNull' ) , 'HpsArgumentException' , 'AddValue needs an amount' ) -> addValidation ( array ( $ this , 'currencyNotNull' ) , 'HpsArgumentException' , 'AddValue needs an currency' ) -> addValidation ( array ( $ this , 'trackDataNotNull' ) , 'HpsArgumentException' , 'AddValue needs an trackData' ) -> addValidation ( array ( $ this , 'pinBlockNotNull' ) , 'HpsArgumentException' , 'AddValue needs an pinBlock' ) ; } | Setups up validations for building addValues . |
49,619 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsManageTokens = $ xml -> createElement ( 'hps:ManageTokens' ) ; $ hpsManageTokens -> appendChild ( $ xml -> createElement ( 'hps:TokenValue' , trim ( ( string ) $ this -> token ) ) ) ; $ hpsTokenActions = $ xml -> createElement ( 'hps:TokenActions' ) ; $ hpsSet = $ xml -> createElement ( 'hps:Set' ) ; $ hpsAttribute = $ xml -> createElement ( 'hps:Attribute' ) ; $ hpsAttribute -> appendChild ( $ xml -> createElement ( 'hps:Name' , 'ExpMonth' ) ) ; $ hpsAttribute -> appendChild ( $ xml -> createElement ( 'hps:Value' , ( string ) sprintf ( "%'.02d" , ( int ) $ this -> expMonth ) ) ) ; $ hpsSet -> appendChild ( $ hpsAttribute ) ; $ hpsAttribute = $ xml -> createElement ( 'hps:Attribute' ) ; $ hpsAttribute -> appendChild ( $ xml -> createElement ( 'hps:Name' , 'ExpYear' ) ) ; $ hpsAttribute -> appendChild ( $ xml -> createElement ( 'hps:Value' , ( string ) $ this -> expYear ) ) ; $ hpsSet -> appendChild ( $ hpsAttribute ) ; $ hpsTokenActions -> appendChild ( $ hpsSet ) ; $ hpsManageTokens -> appendChild ( $ hpsTokenActions ) ; $ hpsTransaction -> appendChild ( $ hpsManageTokens ) ; $ trans = $ this -> service -> _submitTransaction ( $ hpsTransaction , 'ManageTokens' , null ) ; $ trans -> responseCode = '00' ; $ trans -> responseText = '' ; return $ trans ; } | Creates an edit transaction through the HpsCreditService |
49,620 | public function execute ( ) { parent :: execute ( ) ; $ addValueSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ addValueSvc -> addValue ( $ this -> amount , $ this -> currency , $ this -> card ) ; } | Creates an addValue transaction through the HpsGiftCardService |
49,621 | public function execute ( ) { parent :: execute ( ) ; return $ this -> service -> _buildTransaction ( 'OVERRIDE' , $ this -> check , $ this -> amount , $ this -> clientTransactionId ) ; } | Creates an override transaction through the HpsCheckService |
49,622 | public function capture ( $ orderId , $ amount , HpsOrderData $ orderData = null ) { $ payload = array ( 'Amount' => $ this -> formatAmount ( $ amount ) , 'CurrencyCode' => $ this -> currencyStringToNumeric ( $ orderData -> currencyCode ) , 'OrderId' => $ orderId , 'OrderNumber' => $ orderData -> orderNumber , 'TransactionType' => 'WT' , ) ; return $ this -> submitTransaction ( $ payload , 'cmpi_capture' ) ; } | Responsible for settling funds from previous authorization transaction . Payment for the complete or partial amount of the authorization is available . Multiple captures can be processed against a single Authorization up to 100% of the authorization . |
49,623 | public function createSession ( $ amount , $ currency , HpsBuyerData $ buyer = null , HpsPaymentData $ payment = null , HpsShippingInfo $ shippingAddress = null , $ lineItems = null , HpsOrderData $ orderData = null ) { $ payload = array ( 'TransactionType' => 'WT' , 'OverridePaymentMethod' => 'MPPWLT' , 'Amount' => $ this -> formatAmount ( $ amount ) , 'CurrencyCode' => $ this -> currencyStringToNumeric ( $ currency ) , 'OverrideCheckoutType' => $ this -> getCheckoutType ( $ orderData ) , 'ConnectTimeout' => '10000' , 'TransactionMode' => 'S' , 'OrderNumber' => $ orderData -> orderNumber , 'IPAddress' => $ orderData -> ipAddress , 'BrowserHeader' => $ orderData -> browserHeader , 'UserAgent' => $ orderData -> userAgent , 'OriginUrl' => $ orderData -> originUrl , 'TermUrl' => $ orderData -> termUrl , ) ; if ( $ orderData -> orderId !== null ) { $ payload [ 'OrderId' ] = $ orderData -> orderId ; } if ( $ buyer !== null ) { $ payload = array_merge ( $ payload , $ this -> hydrateBuyerData ( $ buyer ) ) ; } if ( $ payment !== null ) { $ payload = array_merge ( $ payload , $ this -> hydratePaymentData ( $ payment ) ) ; } if ( $ shippingAddress !== null ) { $ payload = array_merge ( $ payload , $ this -> hydrateShippingInfo ( $ shippingAddress ) ) ; } if ( $ lineItems !== null ) { $ payload = array_merge ( $ payload , $ this -> hydrateLineItems ( $ lineItems ) ) ; } return $ this -> submitTransaction ( $ payload , 'cmpi_lookup' ) ; } | Responsible for initiating the MasterPass transaction . The Lookup Message is constructed and sent to the Centinel platform for processing . The Lookup Message requires transaction specific data elements to be formatted on the request message . Please refer to the Message API section for the complete list of required message elements . |
49,624 | public function preApproval ( $ longAccessToken , HpsOrderData $ orderData = null ) { $ payload = array ( 'LongAccessToken' => $ longAccessToken , 'SubMsgType' => 'cmpi_preapproval' , 'TransactionType' => 'WT' , ) ; return $ this -> submitTransaction ( $ payload , 'cmpi_baseserver_api' ) ; } | Gives Merchants the ability to provide the consumer the opportunity to pre - select their checkout options before completing checkout . |
49,625 | public function refund ( $ orderId , $ isPartial = false , $ amount = null , HpsOrderData $ orderData = null ) { $ payload = array ( 'Amount' => $ this -> formatAmount ( $ amount ) , 'CurrencyCode' => $ this -> currencyStringToNumeric ( $ orderData -> currencyCode ) , 'OrderId' => $ orderId , 'TransactionType' => 'WT' , ) ; return $ this -> submitTransaction ( $ payload , 'cmpi_refund' ) ; } | Responsible for crediting the consumer some portion or all of the original settlement amount . Multiple refunds can be processed against the original capture transaction . |
49,626 | public function void ( $ orderId , HpsOrderData $ orderData = null ) { $ payload = array ( 'OrderId' => $ orderId , ) ; return $ this -> submitTransaction ( $ payload , 'cmpi_void' ) ; } | Cancels an authorized transaction with MasterPass . Any hold on consumer funds will be removed when the transaction is voided . |
49,627 | protected function currencyStringToNumeric ( $ currency ) { if ( ! in_array ( strtolower ( $ currency ) , array_keys ( self :: $ currencyCodes ) ) ) { throw new HpsArgumentException ( 'Currency is not supported' , HpsExceptionCodes :: INVALID_CURRENCY ) ; } return self :: $ currencyCodes [ strtolower ( $ currency ) ] ; } | Converts a 3 - letter currency code to 3 - digit ISO 4217 version |
49,628 | protected function hydrateBuyerData ( HpsBuyerData $ buyer ) { return array ( 'BillingAddress1' => $ buyer -> address -> address , 'BillingCity' => $ buyer -> address -> city , 'BillingCountryCode' => $ buyer -> countryCode , 'BillingFirstName' => $ buyer -> firstName , 'BillingLastName' => $ buyer -> lastName , 'BillingMiddleName' => $ buyer -> middleName , 'BillingPhone' => $ buyer -> phoneNumber , 'BillingPostalCode' => $ buyer -> address -> zip , 'BillingState' => $ buyer -> address -> state , ) ; } | Converts HpsBuyerData into expected format for Cardinal |
49,629 | protected function hydrateLineItems ( $ items ) { $ result = array ( ) ; if ( $ items == null ) { return $ result ; } foreach ( $ items as $ i => $ item ) { $ result = array_merge ( $ result , array ( 'Item_Name_' . $ i => $ item -> name , 'Item_Desc_' . $ i => $ item -> description , 'Item_Price_' . $ i => $ this -> formatAmount ( $ item -> amount ) , 'Item_Quantity_' . $ i => $ item -> quantity , 'Item_SKU_' . $ i => $ item -> number , ) ) ; } return $ result ; } | Converts HpsLineItem s into expected format for Cardinal |
49,630 | protected function processGatewayResponse ( $ response ) { $ gatewayRspCode = isset ( $ response -> ErrorNo ) ? ( string ) $ response -> ErrorNo : null ; if ( $ gatewayRspCode == '0' ) { return ; } throw new HpsException ( ( string ) $ response -> ErrorDesc ) ; } | Processes the response from Cardinal |
49,631 | protected function processProcessorResponse ( $ response ) { $ statusCode = isset ( $ response -> StatusCode ) ? ( string ) $ response -> StatusCode : null ; if ( $ statusCode == null || $ statusCode == 'Y' ) { return ; } throw new HpsException ( ( string ) $ response -> ErrorDesc ) ; } | Processes the response from MasterPass |
49,632 | protected function submitTransaction ( $ request , $ txnType ) { $ request = array_merge ( $ request , array ( 'MsgType' => $ txnType ) ) ; $ response = $ this -> doRequest ( $ request ) ; $ this -> processGatewayResponse ( $ response ) ; $ this -> processProcessorResponse ( $ response ) ; $ result = null ; switch ( $ txnType ) { case 'cmpi_lookup' : $ result = HpsCardinalMPILookupResponse :: fromObject ( $ response ) ; break ; case 'cmpi_authenticate' : $ result = HpsCardinalMPIAuthenticateResponse :: fromObject ( $ response ) ; break ; case 'cmpi_baseserver_api' : $ result = HpsCardinalMPIPreapprovalResponse :: fromObject ( $ response ) ; break ; case 'cmpi_authorize' : $ result = HpsCardinalMPIAuthorizeResponse :: fromObject ( $ response ) ; break ; case 'cmpi_capture' : $ result = HpsCardinalMPICaptureResponse :: fromObject ( $ response ) ; break ; case 'cmpi_refund' : $ result = HpsCardinalMPIRefundResponse :: fromObject ( $ response ) ; break ; case 'cmpi_void' : $ result = HpsCardinalMPIVoidResponse :: fromObject ( $ response ) ; break ; case 'cmpi_add_order_number' : $ result = HpsCardinalMPIAddOrderNumberResponse :: fromObject ( $ response ) ; break ; } return $ result ; } | Submits a transaction to the gateway |
49,633 | public function execute ( ) { parent :: execute ( ) ; if ( $ this -> transactionId <= 0 ) { throw new HpsArgumentException ( 'Invalid Transaction Id' , HpsExceptionCodes :: INVALID_ORIGINAL_TRANSACTION ) ; } $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsReportTxnDetail = $ xml -> createElement ( 'hps:ReportTxnDetail' ) ; $ hpsReportTxnDetail -> appendChild ( $ xml -> createElement ( 'hps:TxnId' , $ this -> transactionId ) ) ; $ hpsTransaction -> appendChild ( $ hpsReportTxnDetail ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'ReportTxnDetail' ) ; } | Creates a get transaction through the HpsCreditService |
49,634 | public function execute ( ) { parent :: execute ( ) ; HpsInputValidation :: checkAmount ( $ this -> amount ) ; $ this -> currency = strtolower ( $ this -> currency ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsGiftSale = $ xml -> createElement ( 'hps:GiftCardSale' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ this -> amount ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } $ cardData = $ this -> service -> _hydrateGiftCardData ( $ this -> card , $ xml ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; if ( in_array ( $ this -> currency , array ( 'points' , 'usd' ) ) ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Currency' , strtoupper ( $ this -> currency ) ) ) ; } if ( $ this -> gratuity != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:GratuityAmtInfo' , $ this -> gratuity ) ) ; } if ( $ this -> tax != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:TaxAmtInfo' , $ this -> tax ) ) ; } $ hpsGiftSale -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsGiftSale ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'GiftCardSale' ) ; } | Creates a sale transaction through the HpsGiftCardService |
49,635 | public function execute ( ) { parent :: execute ( ) ; $ balanceSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ balanceSvc -> balance ( $ this -> card ) ; } | Creates a balance transaction through the HpsGiftCardService |
49,636 | public function execute ( ) { parent :: execute ( ) ; HpsInputValidation :: checkAmount ( $ this -> amount ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsRecurringBilling = $ xml -> createElement ( 'hps:RecurringBilling' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:AllowDup' , 'Y' ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ this -> amount ) ) ; if ( $ this -> cardHolder != null ) { $ hpsBlock1 -> appendChild ( $ this -> service -> _hydrateCardHolderData ( $ this -> cardHolder , $ xml ) ) ; } if ( $ this -> details != null ) { $ hpsBlock1 -> appendChild ( $ this -> service -> _hydrateAdditionalTxnFields ( $ this -> details , $ xml ) ) ; } if ( $ this -> card != null ) { $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; $ cardData -> appendChild ( $ this -> service -> _hydrateManualEntry ( $ this -> card , $ xml ) ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; } else if ( $ this -> token != null ) { $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; $ cardData -> appendChild ( $ this -> service -> _hydrateTokenData ( $ this -> token , $ xml ) ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; } else if ( $ this -> paymentMethodKey != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:PaymentMethodKey' , $ this -> paymentMethodKey ) ) ; } $ recurringData = $ xml -> createElement ( 'hps:RecurringData' ) ; if ( $ this -> schedule != null ) { $ id = $ this -> schedule ; if ( $ this -> schedule instanceof HpsPayPlanSchedule ) { $ id = $ this -> schedule -> scheduleIdentifier ; } $ recurringData -> appendChild ( $ xml -> createElement ( 'hps:ScheduleID' , $ id ) ) ; } $ recurringData -> appendChild ( $ xml -> createElement ( 'hps:OneTime' , ( $ this -> oneTime ? 'Y' : 'N' ) ) ) ; $ hpsBlock1 -> appendChild ( $ recurringData ) ; $ hpsRecurringBilling -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsRecurringBilling ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'RecurringBilling' , ( isset ( $ this -> details -> clientTransactionId ) ? $ this -> details -> clientTransactionId : null ) ) ; } | Creates a recurring billing transaction through the HpsCreditService |
49,637 | public function execute ( ) { parent :: execute ( ) ; $ rewardSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ rewardSvc -> reward ( $ this -> card , $ this -> amount , $ this -> currency , $ this -> gratuity , $ this -> tax ) ; } | Creates a reward transaction through the HpsGiftCardService |
49,638 | public function addContext ( Context $ context ) { $ contexts = $ this -> get ( 'contextOut' ) ; $ contexts [ ] = $ context ; $ this -> add ( 'contextOut' , $ contexts ) ; } | Add a context to the response . |
49,639 | public function execute ( ) { parent :: execute ( ) ; HpsInputValidation :: checkAmount ( $ this -> amount ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCheckSale = $ xml -> createElement ( 'hps:CheckSale' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , sprintf ( "%0.2f" , round ( $ this -> amount , 3 ) ) ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:CheckAction' , 'SALE' ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:PaymentMethodKey' , $ this -> paymentMethodKey ) ) ; $ recurringData = $ xml -> createElement ( 'hps:RecurringData' ) ; if ( $ this -> schedule != null ) { $ scheduleKey = $ this -> schedule ; if ( $ this -> schedule instanceof HpsPayPlanSchedule ) { $ scheduleKey = $ this -> schedule -> scheduleKey ; } $ recurringData -> appendChild ( $ xml -> createElement ( 'hps:ScheduleID' , $ scheduleKey ) ) ; } $ recurringData -> appendChild ( $ xml -> createElement ( 'hps:OneTime' , ( $ this -> oneTime ? 'Y' : 'N' ) ) ) ; $ hpsBlock1 -> appendChild ( $ recurringData ) ; $ hpsCheckSale -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsCheckSale ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CheckSale' ) ; } | Creates a sale transaction through the HpsCheckService |
49,640 | public function execute ( ) { parent :: execute ( ) ; $ voidSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; return $ voidSvc -> void ( $ this -> transactionId ) ; } | Creates a void transaction through the HpsGiftCardService |
49,641 | public function execute ( ) { parent :: execute ( ) ; $ reverseSvc = new HpsDebitService ( $ this -> service -> servicesConfig ( ) ) ; return $ reverseSvc -> reverse ( $ this -> transactionId , $ this -> amount , $ this -> trackData , $ this -> authorizedAmount , $ this -> encryptionData , $ this -> details , $ this -> clientTransactionId ) ; } | Creates a reverse transaction through the HpsDebitService |
49,642 | public function sale ( HpsCheck $ check , $ amount , $ clientTransactionId = null ) { return $ this -> _buildTransaction ( 'SALE' , $ check , $ amount , $ clientTransactionId ) ; } | A Sale transaction is used to process transactions using bank account information as the payment method . The transaction service can be used to perform a Sale or Return transaction by indicating the Check Action . |
49,643 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCreditAddToBatch = $ xml -> createElement ( 'hps:CreditAddToBatch' ) ; $ hpsCreditAddToBatch -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ this -> transactionId ) ) ; if ( $ this -> amount != null ) { $ amount = sprintf ( "%0.2f" , round ( $ this -> amount , 3 ) ) ; $ hpsCreditAddToBatch -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ amount ) ) ; } if ( $ this -> gratuity != null ) { $ hpsCreditAddToBatch -> appendChild ( $ xml -> createElement ( 'hps:GratuityAmtInfo' , $ this -> gratuity ) ) ; } if ( $ this -> directMarketData != null && $ this -> directMarketData -> invoiceNumber != null ) { $ hpsCreditAddToBatch -> appendChild ( $ this -> _hydrateDirectMarketData ( $ this -> directMarketData , $ xml ) ) ; } $ hpsTransaction -> appendChild ( $ hpsCreditAddToBatch ) ; $ response = $ this -> service -> doRequest ( $ hpsTransaction ) ; $ this -> _processChargeGatewayResponse ( $ response , 'CreditAddToBatch' ) ; return $ this -> service -> get ( $ this -> transactionId ) -> execute ( ) ; } | Creates a capture transaction through the HpsCreditService |
49,644 | public function execute ( ) { parent :: execute ( ) ; $ reverseSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ reverseSvc -> reverse ( isset ( $ this -> card ) ? $ this -> card : $ this -> transactionId , $ this -> amount , $ this -> currency ) ; } | Creates a reverse transaction through the HpsGiftCardService |
49,645 | protected function cardOrTransactionId ( $ actionCounts ) { return ( isset ( $ actionCounts [ 'card' ] ) && $ actionCounts [ 'card' ] == 1 && ( ! isset ( $ actionCounts [ 'transactionId' ] ) || isset ( $ actionCounts [ 'transactionId' ] ) && $ actionCounts [ 'transactionId' ] == 0 ) ) || ( isset ( $ actionCounts [ 'transactionId' ] ) && $ actionCounts [ 'transactionId' ] == 1 && ( ! isset ( $ actionCounts [ 'card' ] ) || isset ( $ actionCounts [ 'card' ] ) && $ actionCounts [ 'card' ] == 0 ) ) ; } | Ensures a card has been set . |
49,646 | public function execute ( ) { parent :: execute ( ) ; $ activateSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ activateSvc -> activate ( $ this -> amount , $ this -> currency , $ this -> card ) ; } | Creates an activate transaction through the HpsGiftCardService |
49,647 | public function addValue ( $ amount , $ currency , $ trackData , $ pinBlock , HpsEncryptionData $ encryptionData = null , $ allowDuplicates = false , HpsCardHolder $ cardHolder = null , HpsTransactionDetails $ details = null , $ clientTransactionId = null ) { HpsInputValidation :: checkAmount ( $ amount ) ; HpsInputValidation :: checkCurrency ( $ currency ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsGiftCard = $ xml -> createElement ( 'hps:DebitAddValue' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:TrackData' , $ trackData ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:AllowDup' , ( $ allowDuplicates ? 'Y' : 'N' ) ) ) ; if ( $ cardHolder != null ) { $ hpsBlock1 -> appendChild ( $ this -> _hydrateCardHolderData ( $ cardHolder , $ xml ) ) ; } $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ amount ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:PinBlock' , $ pinBlock ) ) ; if ( $ encryptionData != null ) { $ hpsBlock1 -> appendChild ( $ this -> _hydrateEncryptionData ( $ encryptionData , $ xml ) ) ; } if ( $ details != null ) { $ hpsBlock1 -> appendChild ( $ this -> _hydrateAdditionalTxnFields ( $ details , $ xml ) ) ; } $ hpsGiftCard -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsGiftCard ) ; return $ this -> _submitTransaction ( $ hpsTransaction , 'DebitAddValue' , $ clientTransactionId ) ; } | The Debit Add Value transaction adds value to a stored value card . The transaction is placed in the current open batch . If a batch is not open this transaction creates an open batch . |
49,648 | public function reverse ( $ transactionId , $ amount , $ trackData , $ authorizedAmount = null , HpsEncryptionData $ encryptionData = null , HpsTransactionDetails $ details = null , $ clientTransactionId = null ) { HpsInputValidation :: checkAmount ( $ amount ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsGiftCard = $ xml -> createElement ( 'hps:DebitReversal' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ transactionId ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:TrackData' , $ trackData ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ amount ) ) ; if ( $ encryptionData != null ) { $ hpsBlock1 -> appendChild ( $ this -> _hydrateEncryptionData ( $ encryptionData , $ xml ) ) ; } if ( $ details != null ) { $ hpsBlock1 -> appendChild ( $ this -> _hydrateAdditionalTxnFields ( $ details , $ xml ) ) ; } if ( isset ( $ authorizedAmount ) ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:authAmt' , $ authorizedAmount ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:authAmtSpecified' , true ) ) ; } $ hpsGiftCard -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsGiftCard ) ; $ rsp = $ this -> _submitTransaction ( $ hpsTransaction , 'DebitReversal' , $ clientTransactionId ) ; $ rsp -> responseCode = '00' ; $ rsp -> responseText = '' ; return $ rsp ; } | A Debit Reversal transaction reverses a Debit Charge or Debit Return transaction . |
49,649 | public function onlyOnePaymentMethod ( $ actionCounts ) { return ( isset ( $ actionCounts [ 'card' ] ) && $ actionCounts [ 'card' ] == 1 && ( ! isset ( $ actionCounts [ 'token' ] ) || isset ( $ actionCounts [ 'token' ] ) && $ actionCounts [ 'token' ] == 0 ) && ( ! isset ( $ actionCounts [ 'transactionId' ] ) || isset ( $ actionCounts [ 'transactionId' ] ) == 0 ) ) || ( isset ( $ actionCounts [ 'token' ] ) && $ actionCounts [ 'token' ] == 1 && ( ! isset ( $ actionCounts [ 'card' ] ) || isset ( $ actionCounts [ 'card' ] ) && $ actionCounts [ 'card' ] == 0 ) && ( ! isset ( $ actionCounts [ 'transactionId' ] ) || isset ( $ actionCounts [ 'transactionId' ] ) == 0 ) ) || ( isset ( $ actionCounts [ 'transactionId' ] ) && $ actionCounts [ 'transactionId' ] == 1 && ( ! isset ( $ actionCounts [ 'card' ] ) || isset ( $ actionCounts [ 'card' ] ) && $ actionCounts [ 'card' ] == 0 ) && ( ! isset ( $ actionCounts [ 'token' ] ) || isset ( $ actionCounts [ 'token' ] ) == 0 ) ) ; } | Ensures there is only one payment method and checks that there is only one card one token or one transactionId in use . |
49,650 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsGiftAlias = $ xml -> createElement ( 'hps:GiftCardAlias' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Action' , $ this -> action ) ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Alias' , $ this -> alias ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } $ cardData = $ this -> service -> _hydrateGiftCardData ( $ this -> card , $ xml ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; $ hpsGiftAlias -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsGiftAlias ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'GiftCardAlias' ) ; } | Creates an alias transaction through the HpsGiftCardService |
49,651 | public function run ( $ cmd ) { $ cmd = "{$this->phpBinaryPath} {$this->file} $cmd" ; $ cmd = $ this -> isWindows ( ) === true ? $ cmd = "start /b {$cmd}" : $ cmd = "{$cmd} > /dev/null 2>&1 &" ; pclose ( popen ( $ cmd , 'r' ) ) ; return true ; } | Running console command on background . |
49,652 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsPosCreditCPCEdit = $ xml -> createElement ( 'hps:CreditCPCEdit' ) ; $ hpsPosCreditCPCEdit -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ this -> transactionId ) ) ; $ hpsPosCreditCPCEdit -> appendChild ( $ this -> service -> _hydrateCPCData ( $ this -> cpcData , $ xml ) ) ; $ hpsTransaction -> appendChild ( $ hpsPosCreditCPCEdit ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CreditCPCEdit' ) ; } | Creates a cpcEdit transaction through the HpsCreditService |
49,653 | public function execute ( ) { parent :: execute ( ) ; HpsInputValidation :: checkCurrency ( $ this -> currency ) ; HpsInputValidation :: checkAmount ( $ this -> amount ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCreditReversal = $ xml -> createElement ( 'hps:CreditReversal' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ this -> amount ) ) ; if ( $ this -> authAmount != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:AuthAmt' , $ this -> authAmount ) ) ; } if ( $ this -> card != null ) { $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; $ cardData -> appendChild ( $ this -> service -> _hydrateManualEntry ( $ this -> card , $ xml ) ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; } else if ( $ this -> token != null ) { $ cardData = $ xml -> createElement ( 'hps:CardData' ) ; $ cardData -> appendChild ( $ this -> service -> _hydrateTokenData ( $ this -> token , $ xml ) ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; } else { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ this -> transactionId ) ) ; } if ( $ this -> details != null ) { $ hpsBlock1 -> appendChild ( $ this -> service -> _hydrateAdditionalTxnFields ( $ this -> details , $ xml ) ) ; } $ hpsCreditReversal -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsCreditReversal ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CreditReversal' , ( isset ( $ this -> details -> clientTransactionId ) ? $ this -> details -> clientTransationId : null ) ) ; } | Creates a reverse transaction through the HpsCreditService |
49,654 | public function execute ( ) { parent :: execute ( ) ; date_default_timezone_set ( "UTC" ) ; $ dateFormat = 'Y-m-d\TH:i:s.00\Z' ; $ current = new DateTime ( ) ; $ currentTime = $ current -> format ( $ dateFormat ) ; HpsInputValidation :: checkDateNotFuture ( $ this -> startDate ) ; HpsInputValidation :: checkDateNotFuture ( $ this -> endDate ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsReportActivity = $ xml -> createElement ( 'hps:ReportActivity' ) ; $ hpsReportActivity -> appendChild ( $ xml -> createElement ( 'hps:RptStartUtcDT' , $ this -> startDate ) ) ; $ hpsReportActivity -> appendChild ( $ xml -> createElement ( 'hps:RptEndUtcDT' , $ this -> endDate ) ) ; $ hpsTransaction -> appendChild ( $ hpsReportActivity ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'ReportActivity' ) ; } | Creates a listTransactions transaction through the HpsCreditService |
49,655 | public function execute ( ) { parent :: execute ( ) ; $ deactivateSvc = new HpsGiftCardService ( $ this -> service -> servicesConfig ( ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } return $ deactivateSvc -> deactivate ( $ this -> card ) ; } | Creates a deactivate transaction through the HpsGiftCardService |
49,656 | public function execute ( ) { parent :: execute ( ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsCheckVoid = $ xml -> createElement ( 'hps:CheckVoid' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; if ( $ this -> transactionId != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:GatewayTxnId' , $ this -> transactionId ) ) ; } else if ( $ this -> clientTransactionId != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:ClientTxnId' , $ this -> clientTransactionId ) ) ; } $ hpsCheckVoid -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsCheckVoid ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'CheckVoid' ) ; } | Creates a void transaction through the HpsCheckService |
49,657 | public function onlyOneTransactionId ( $ actionCounts ) { return ( isset ( $ actionCounts [ 'transactionId' ] ) && $ actionCounts [ 'transactionId' ] == 1 && ( ! isset ( $ actionCounts [ 'clientTransactionId' ] ) || isset ( $ actionCounts [ 'clientTransactionId' ] ) && $ actionCounts [ 'clientTransactionId' ] == 0 ) ) || ( isset ( $ actionCounts [ 'clientTransactionId' ] ) && $ actionCounts [ 'clientTransactionId' ] == 1 && ( ! isset ( $ actionCounts [ 'transactionId' ] ) || isset ( $ actionCounts [ 'transactionId' ] ) && $ actionCounts [ 'transactionId' ] == 0 ) ) ; } | Ensures there is only one transaction id and checks that there is only one transactionId or one clientTransactionId in use . Both cannot be used . |
49,658 | public static function checkPhoneNumber ( $ phoneNumber ) { $ phoneNumber = self :: cleanPhoneNumber ( $ phoneNumber ) ; if ( ! empty ( $ phoneNumber ) && strlen ( $ phoneNumber ) > self :: $ _inputFldMaxLength [ 'PhoneNumber' ] ) { $ errorMessage = 'The value for phone number can be no more than ' . self :: $ _inputFldMaxLength [ 'PhoneNumber' ] . ' characters, Please try again after making corrections' ; throw new HpsInvalidRequestException ( HpsExceptionCodes :: INVALID_PHONE_NUMBER , $ errorMessage ) ; } return $ phoneNumber ; } | This method clears the user input and return the phone number in correct format or throw an exception |
49,659 | public static function checkZipCode ( $ zipCode ) { $ zipCode = self :: cleanZipCode ( $ zipCode ) ; if ( ! empty ( $ zipCode ) && strlen ( $ zipCode ) > self :: $ _inputFldMaxLength [ 'ZipCode' ] ) { $ errorMessage = 'The value for zip code can be no more than ' . self :: $ _inputFldMaxLength [ 'ZipCode' ] . ' characters, Please try again after making corrections' ; throw new HpsInvalidRequestException ( HpsExceptionCodes :: INVALID_ZIP_CODE , $ errorMessage ) ; } return $ zipCode ; } | This method clears the user input and return the Zip code in correct format or throw an exception |
49,660 | public static function checkCardHolderData ( $ value , $ type = '' ) { $ value = filter_var ( trim ( $ value ) , FILTER_SANITIZE_SPECIAL_CHARS ) ; if ( ! empty ( self :: $ _inputFldMaxLength [ $ type ] ) && strlen ( $ value ) > self :: $ _inputFldMaxLength [ $ type ] ) { $ errorMessage = "The value for $type can be no more than " . self :: $ _inputFldMaxLength [ $ type ] . ' characters, Please try again after making corrections' ; throw new HpsInvalidRequestException ( HpsExceptionCodes :: INVALID_INPUT_LENGTH , $ errorMessage ) ; } return $ value ; } | This method clears the user input and return the user input in correct format or throw an exception |
49,661 | public static function checkEmailAddress ( $ value ) { $ value = filter_var ( trim ( $ value ) , FILTER_SANITIZE_EMAIL ) ; if ( ! empty ( $ value ) && filter_var ( $ value , FILTER_VALIDATE_EMAIL ) === false ) { throw new HpsInvalidRequestException ( HpsExceptionCodes :: INVALID_EMAIL_ADDRESS , 'Invalid email address' ) ; } if ( ! empty ( self :: $ _inputFldMaxLength [ 'Email' ] ) && strlen ( $ value ) > self :: $ _inputFldMaxLength [ 'Email' ] ) { $ errorMessage = "The value for Email can be no more than " . self :: $ _inputFldMaxLength [ 'Email' ] . ' characters, Please try again after making corrections' ; throw new HpsInvalidRequestException ( HpsExceptionCodes :: INVALID_INPUT_LENGTH , $ errorMessage ) ; } return $ value ; } | This method clears the user input and return the email in correct format or throw an exception |
49,662 | public function execute ( ) { parent :: execute ( ) ; $ chargeSvc = new HpsDebitService ( $ this -> service -> servicesConfig ( ) ) ; return $ chargeSvc -> charge ( $ this -> amount , $ this -> currency , $ this -> trackData , $ this -> pinBlock , $ this -> encryptionData , $ this -> allowDuplicates , $ this -> cashBackAmount , $ this -> allowPartialAuth , $ this -> cardHolder , $ this -> details , $ this -> clientTransactionId ) ; } | Creates a charge transaction through the HpsDebitService |
49,663 | public function loadFiles ( array $ files , $ type = 'yaml' ) { $ set = $ this -> createFixtureSet ( ) ; foreach ( $ files as $ file ) { $ set -> addFile ( $ file , $ type ) ; } $ set -> setDoPersist ( false ) ; return $ this -> load ( $ set ) ; } | Loads entites from file does _not_ persist them . |
49,664 | public function addProcessor ( ProcessorInterface $ processor ) { $ this -> processors [ ] = $ processor ; $ this -> logDebug ( 'Added processor: ' . get_class ( $ processor ) ) ; } | Adds a processor for processing a entity before and after persisting . |
49,665 | public function addProvider ( $ provider ) { $ this -> providers [ ] = $ provider ; $ this -> providers = array_unique ( $ this -> providers , SORT_REGULAR ) ; $ this -> logDebug ( 'Added provider: ' . get_class ( $ provider ) ) ; } | Adds a provider for Faker . |
49,666 | protected function configureLoader ( LoaderInterface $ loader ) { if ( $ loader instanceof Base ) { $ loader -> setORM ( $ this -> getORM ( ) ) ; if ( $ this -> logger ) { $ loader -> setLogger ( $ this -> logger ) ; } } if ( is_callable ( array ( $ loader , 'addProvider' ) ) ) { $ loader -> addProvider ( $ this -> providers ) ; } else { $ loader -> setProviders ( $ this -> providers ) ; } } | Sets all needed options and dependencies to a loader . |
49,667 | protected function initSeedFromSet ( FixtureSet $ set ) { if ( is_numeric ( $ set -> getSeed ( ) ) ) { mt_srand ( $ set -> getSeed ( ) ) ; $ this -> logDebug ( 'Initialized with seed ' . $ set -> getSeed ( ) ) ; } else { mt_srand ( ) ; $ this -> logDebug ( 'Initialized with random seed' ) ; } } | Initializes the seed for random numbers given by a fixture set . |
49,668 | protected function recreateSchema ( ) { $ schemaTool = $ this -> getSchemaTool ( ) ; $ schemaTool -> dropSchema ( ) ; $ schemaTool -> createSchema ( ) ; $ this -> logDebug ( 'Recreated Schema' ) ; } | Will drop and create the current ORM Schema . |
49,669 | protected function persistObjects ( ORMInterface $ persister , array $ objects ) { foreach ( $ this -> processors as $ proc ) { foreach ( $ objects as $ obj ) { $ proc -> preProcess ( $ obj ) ; } } $ persister -> persist ( $ objects ) ; foreach ( $ this -> processors as $ proc ) { foreach ( $ objects as $ obj ) { $ proc -> postProcess ( $ obj ) ; } } } | Persists given objects using ORM persister and calls registered processors . |
49,670 | public function getLoader ( $ type , $ locale ) { switch ( $ type ) { case 'yaml' : return $ this -> newLoaderYaml ( $ locale ) ; case 'php' : return $ this -> newLoaderPHP ( $ locale ) ; } throw new \ InvalidArgumentException ( "Unknown loader type '$type'." ) ; } | Returns a loader for a specific type and locale . |
49,671 | private function getSchemaToolServiceIdForCurrentConfig ( array $ currentManagerConfig , ContainerBuilder $ container ) { if ( ! empty ( $ currentManagerConfig [ 'schema_tool' ] ) ) { return $ currentManagerConfig [ 'schema_tool' ] ; } $ serviceId = sprintf ( 'h4cc_alice_fixtures.orm.schema_tool.%s' , $ this -> getCleanDoctrineConfigName ( $ currentManagerConfig [ 'doctrine' ] ) ) ; if ( ! $ container -> has ( $ serviceId ) ) { $ schemaToolDefinition = new Definition ( ) ; $ schemaToolDefinition -> setClass ( $ this -> getSchemaToolClass ( $ currentManagerConfig [ 'doctrine' ] ) ) ; $ schemaToolDefinition -> setArguments ( array ( new Reference ( $ this -> getCleanDoctrineConfigName ( $ currentManagerConfig [ 'doctrine' ] ) ) ) ) ; $ container -> setDefinition ( $ serviceId , $ schemaToolDefinition ) ; } return $ serviceId ; } | Will return the configured schema_tool service id or will define a default one lazy and return its id . |
49,672 | public function recognize ( $ filename , array $ languages = null , $ pageSegMode = self :: PAGE_SEG_MODE_AUTOMATIC_OCR ) { if ( $ pageSegMode < 0 || $ pageSegMode > 10 ) { throw new \ InvalidArgumentException ( 'Page seg mode must be between 0 and 10' ) ; } $ tempFile = tempnam ( sys_get_temp_dir ( ) , 'tesseract' ) ; $ arguments = array ( $ filename , $ tempFile , '-psm' , $ pageSegMode ) ; if ( null !== $ languages ) { $ arguments [ ] = '-l' ; $ arguments [ ] = implode ( '+' , $ languages ) ; } $ this -> execute ( $ arguments ) ; $ recognizedText = trim ( \ file_get_contents ( $ tempFile . '.txt' ) ) ; if ( file_exists ( $ tempFile ) ) { unlink ( $ tempFile ) ; } if ( file_exists ( $ tempFile . '.txt' ) ) { unlink ( $ tempFile . '.txt' ) ; } return $ recognizedText ; } | Perform OCR on an image file |
49,673 | protected function execute ( array $ arguments ) { \ array_unshift ( $ arguments , $ this -> path ) ; $ builder = ProcessBuilder :: create ( $ arguments ) ; $ process = $ builder -> getProcess ( ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { throw CommandException :: factory ( $ process ) ; } return $ process -> getOutput ( ) ? $ process -> getOutput ( ) : $ process -> getErrorOutput ( ) ; } | Execute command and return output |
49,674 | public function serialize ( $ value ) { $ this -> reset ( ) ; $ serializedData = $ this -> serializeData ( $ value ) ; $ encoded = json_encode ( $ serializedData , $ this -> calculateEncodeOptions ( ) ) ; if ( $ encoded === false || json_last_error ( ) != JSON_ERROR_NONE ) { if ( json_last_error ( ) != JSON_ERROR_UTF8 ) { throw new JsonSerializerException ( 'Invalid data to encode to JSON. Error: ' . json_last_error ( ) ) ; } $ serializedData = $ this -> encodeNonUtf8ToUtf8 ( $ serializedData ) ; $ encoded = json_encode ( $ serializedData , $ this -> calculateEncodeOptions ( ) ) ; if ( $ encoded === false || json_last_error ( ) != JSON_ERROR_NONE ) { throw new JsonSerializerException ( 'Invalid data to encode to JSON. Error: ' . json_last_error ( ) ) ; } } return $ this -> processEncodedValue ( $ encoded ) ; } | Serialize the value in JSON |
49,675 | public function unserialize ( $ value ) { $ this -> reset ( ) ; $ data = json_decode ( $ value , true ) ; if ( $ data === null && json_last_error ( ) != JSON_ERROR_NONE ) { throw new JsonSerializerException ( 'Invalid JSON to unserialize.' ) ; } if ( mb_strpos ( $ value , static :: UTF8ENCODED_IDENTIFIER_KEY ) !== false ) { $ data = $ this -> decodeNonUtf8FromUtf8 ( $ data ) ; } return $ this -> unserializeData ( $ data ) ; } | Unserialize the value from JSON |
49,676 | public function setUnserializeUndeclaredPropertyMode ( $ value ) { $ availableOptions = [ static :: UNDECLARED_PROPERTY_MODE_SET , static :: UNDECLARED_PROPERTY_MODE_IGNORE , static :: UNDECLARED_PROPERTY_MODE_EXCEPTION ] ; if ( ! in_array ( $ value , $ availableOptions ) ) { throw new InvalidArgumentException ( 'Invalid value.' ) ; } $ this -> undefinedAttributeMode = $ value ; return $ this ; } | Set unserialization mode for undeclared class properties |
49,677 | protected function extractObjectData ( $ value , $ ref , $ properties ) { $ data = array ( ) ; foreach ( $ properties as $ property ) { try { $ propRef = $ ref -> getProperty ( $ property ) ; $ propRef -> setAccessible ( true ) ; $ data [ $ property ] = $ propRef -> getValue ( $ value ) ; } catch ( ReflectionException $ e ) { $ data [ $ property ] = $ value -> $ property ; } } return $ data ; } | Extract the object data |
49,678 | protected function parseProcessors ( array $ config ) : array { $ processors = [ ] ; if ( isset ( $ config [ 'processors' ] ) && is_array ( $ config [ 'processors' ] ) ) { foreach ( $ config [ 'processors' ] as $ processor ) { $ processors [ ] = $ processor ; } } return $ processors ; } | Extract the processors from the given configuration . |
49,679 | public function createAdmin ( $ login , $ password , $ roles = array ( ) ) { $ login = urlencode ( $ login ) ; $ data = ( string ) $ password ; if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } if ( strlen ( $ data ) < 1 ) { throw new InvalidArgumentException ( "Password can't be empty" ) ; } $ url = '/_node/' . urlencode ( $ this -> node ) . '/_config/admins/' . urlencode ( $ login ) ; try { $ raw = $ this -> client -> query ( "PUT" , $ url , array ( ) , json_encode ( $ data ) ) ; } catch ( Exception $ e ) { throw $ e ; } $ resp = Couch :: parseRawResponse ( $ raw ) ; if ( $ resp [ 'status_code' ] != 200 ) { throw new CouchException ( $ raw ) ; } $ dsn = $ this -> client -> dsn_part ( ) ; $ dsn [ "user" ] = $ login ; $ dsn [ "pass" ] = $ password ; $ client = new CouchClient ( $ this -> build_url ( $ dsn ) , $ this -> usersdb , $ this -> client -> options ( ) ) ; $ user = new stdClass ( ) ; $ user -> name = $ login ; $ user -> type = "user" ; $ user -> roles = $ roles ; $ user -> _id = "org.couchdb.user:" . $ login ; return $ client -> storeDoc ( $ user ) ; } | Creates a new CouchDB server administrator |
49,680 | public function deleteAdmin ( $ login ) { $ login = urlencode ( $ login ) ; if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } try { $ client = new CouchClient ( $ this -> client -> dsn ( ) , $ this -> usersdb ) ; $ doc = $ client -> getDoc ( "org.couchdb.user:" . $ login ) ; $ client -> deleteDoc ( $ doc ) ; } catch ( Exception $ e ) { } $ url = '/_node/' . urlencode ( $ this -> node ) . '/_config/admins/' . urlencode ( $ login ) ; $ raw = $ this -> client -> query ( "DELETE" , $ url ) ; $ resp = Couch :: parseRawResponse ( $ raw ) ; if ( $ resp [ 'status_code' ] != 200 ) { throw new CouchException ( $ raw ) ; } return $ resp [ "body" ] ; } | Permanently removes a CouchDB Server administrator |
49,681 | public function deleteUser ( $ login ) { if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } $ client = new CouchClient ( $ this -> client -> dsn ( ) , $ this -> usersdb ) ; $ doc = $ client -> getDoc ( "org.couchdb.user:" . $ login ) ; return $ client -> deleteDoc ( $ doc ) ; } | Permanently removes a CouchDB User |
49,682 | public function getUser ( $ login ) { if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } $ client = new CouchClient ( $ this -> client -> dsn ( ) , $ this -> usersdb , $ this -> client -> options ( ) ) ; return $ client -> getDoc ( "org.couchdb.user:" . $ login ) ; } | returns the document of a user |
49,683 | public function getAllUsers ( $ include_docs = false ) { $ client = new CouchClient ( $ this -> client -> dsn ( ) , $ this -> usersdb , $ this -> client -> options ( ) ) ; if ( $ include_docs ) { $ client -> include_docs ( true ) ; } return $ client -> startkey ( "org.couchdb.user:" ) -> endkey ( "org.couchdb.user?" ) -> getAllDocs ( ) -> rows ; } | returns all users |
49,684 | public function addRoleToUser ( $ user , $ role ) { if ( is_string ( $ user ) ) { $ user = $ this -> getUser ( $ user ) ; } elseif ( ! property_exists ( $ user , "_id" ) || ! property_exists ( $ user , "roles" ) ) { throw new InvalidArgumentException ( "user parameter should be the login or a user document" ) ; } if ( ! in_array ( $ role , $ user -> roles ) ) { $ user -> roles [ ] = $ role ; $ client = clone ( $ this -> client ) ; $ client -> useDatabase ( $ this -> usersdb ) ; $ client -> storeDoc ( $ user ) ; } return true ; } | Add a role to a user document |
49,685 | public function getSecurity ( ) { $ dbname = $ this -> client -> getDatabaseName ( ) ; $ raw = $ this -> client -> query ( "GET" , "/" . $ dbname . "/_security" ) ; $ resp = Couch :: parseRawResponse ( $ raw ) ; if ( $ resp [ 'status_code' ] != 200 ) { throw new CouchException ( $ raw ) ; } if ( ! property_exists ( $ resp [ 'body' ] , "admins" ) ) { $ resp [ "body" ] -> admins = new stdClass ( ) ; $ resp [ "body" ] -> admins -> names = array ( ) ; $ resp [ "body" ] -> admins -> roles = array ( ) ; $ resp [ "body" ] -> readers = new stdClass ( ) ; $ resp [ "body" ] -> readers -> names = array ( ) ; $ resp [ "body" ] -> readers -> roles = array ( ) ; } return $ resp [ 'body' ] ; } | returns the security object of a database |
49,686 | public function setSecurity ( $ security ) { if ( ! is_object ( $ security ) ) { throw new InvalidArgumentException ( "Security should be an object" ) ; } $ dbname = $ this -> client -> getDatabaseName ( ) ; $ raw = $ this -> client -> query ( "PUT" , "/" . $ dbname . "/_security" , array ( ) , json_encode ( $ security ) ) ; $ resp = Couch :: parseRawResponse ( $ raw ) ; if ( $ resp [ 'status_code' ] == 200 ) { return $ resp [ 'body' ] ; } throw new CouchException ( $ raw ) ; } | set the security object of a database |
49,687 | public function addDatabaseReaderUser ( $ login ) { if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } $ sec = $ this -> getSecurity ( ) ; if ( in_array ( $ login , $ sec -> readers -> names ) ) { return true ; } array_push ( $ sec -> readers -> names , $ login ) ; $ back = $ this -> setSecurity ( $ sec ) ; if ( is_object ( $ back ) && property_exists ( $ back , "ok" ) && $ back -> ok == true ) { return true ; } return false ; } | add a user to the list of readers for the current database |
49,688 | public function addDatabaseReaderRole ( $ role ) { if ( strlen ( $ role ) < 1 ) { throw new InvalidArgumentException ( "Role can't be empty" ) ; } $ sec = $ this -> getSecurity ( ) ; if ( in_array ( $ role , $ sec -> readers -> roles ) ) { return true ; } array_push ( $ sec -> readers -> roles , $ role ) ; $ back = $ this -> setSecurity ( $ sec ) ; if ( is_object ( $ back ) && property_exists ( $ back , "ok" ) && $ back -> ok == true ) { return true ; } return false ; } | add a role to the list of readers for the current database |
49,689 | final public function getFunctionName ( \ Twig_Node_Module $ module ) { if ( null === $ this -> functionNamingStrategy ) { $ this -> functionNamingStrategy = new DefaultFunctionNamingStrategy ( ) ; } return $ this -> functionNamingStrategy -> getFunctionName ( $ module ) ; } | Returns the function name for the given template name . |
49,690 | private static function encodeUrl ( $ url ) { $ url_parsed = parse_url ( $ url ) ; $ scheme = $ url_parsed [ 'scheme' ] . '://' ; $ host = $ url_parsed [ 'host' ] ; $ port = ( isset ( $ url_parsed [ 'port' ] ) ? $ url_parsed [ 'port' ] : null ) ; $ path = ( isset ( $ url_parsed [ 'path' ] ) ? $ url_parsed [ 'path' ] : null ) ; $ query = ( isset ( $ url_parsed [ 'query' ] ) ? $ url_parsed [ 'query' ] : null ) ; if ( $ query != null ) { $ query = '?' . http_build_query ( self :: getArrayFromQuerystring ( $ url_parsed [ 'query' ] ) ) ; } if ( $ port && $ port [ 0 ] != ":" ) { $ port = ":" . $ port ; } $ result = $ scheme . $ host . $ port . $ path . $ query ; return $ result ; } | Ensure that a URL is encoded and safe to use with cURL |
49,691 | private function get_headers_from_curl_response ( $ headers ) { $ headers = explode ( "\r\n" , $ headers ) ; array_shift ( $ headers ) ; foreach ( $ headers as $ line ) { if ( strstr ( $ line , ': ' ) ) { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ result [ $ key ] = $ value ; } } return $ result ; } | Retrieve the cURL response headers from the header string and convert it into an array |
49,692 | public static function getName ( $ type ) { switch ( $ type ) { case static :: T_UNSPECIFIED : return 'Unspecified/unknown address' ; case static :: T_RESERVED : return 'Reserved/internal use only' ; case static :: T_THISNETWORK : return 'Refer to source hosts on "this" network' ; case static :: T_LOOPBACK : return 'Internet host loopback address' ; case static :: T_ANYCASTRELAY : return 'Relay anycast address' ; case static :: T_LIMITEDBROADCAST : return '"Limited broadcast" destination address' ; case static :: T_MULTICAST : return 'Multicast address assignments - Indentify a group of interfaces' ; case static :: T_LINKLOCAL : return '"Link local" address, allocated for communication between hosts on a single link' ; case static :: T_LINKLOCAL_UNICAST : return 'Link local unicast / Linked-scoped unicast' ; case static :: T_DISCARDONLY : return 'Discard only' ; case static :: T_DISCARD : return 'Discard' ; case static :: T_PRIVATENETWORK : return 'For use in private networks' ; case static :: T_PUBLIC : return 'Public address' ; default : return $ type === null ? 'Unknown type' : sprintf ( 'Unknown type (%s)' , $ type ) ; } } | Get the name of a type . |
49,693 | public function getAddressType ( AddressInterface $ address ) { $ result = null ; if ( $ this -> range -> contains ( $ address ) ) { foreach ( $ this -> exceptions as $ exception ) { $ result = $ exception -> getAddressType ( $ address ) ; if ( $ result !== null ) { break ; } } if ( $ result === null ) { $ result = $ this -> type ; } } return $ result ; } | Get the assigned type for a specific address . |
49,694 | public function getRangeType ( RangeInterface $ range ) { $ myStart = $ this -> range -> getComparableStartString ( ) ; $ rangeEnd = $ range -> getComparableEndString ( ) ; if ( $ myStart > $ rangeEnd ) { $ result = null ; } else { $ myEnd = $ this -> range -> getComparableEndString ( ) ; $ rangeStart = $ range -> getComparableStartString ( ) ; if ( $ myEnd < $ rangeStart ) { $ result = null ; } elseif ( $ rangeStart < $ myStart || $ rangeEnd > $ myEnd ) { $ result = false ; } else { $ result = null ; foreach ( $ this -> exceptions as $ exception ) { $ result = $ exception -> getRangeType ( $ range ) ; if ( $ result !== null ) { break ; } } if ( $ result === null ) { $ result = $ this -> getType ( ) ; } } } return $ result ; } | Get the assigned type for a specific address range . |
49,695 | public static function get6to4 ( ) { if ( self :: $ sixToFour === null ) { self :: $ sixToFour = self :: fromString ( '2002::/16' ) ; } return self :: $ sixToFour ; } | Get the 6to4 address IPv6 address range . |
49,696 | public static function fromString ( $ address , $ mayIncludePort = true ) { $ result = null ; if ( is_string ( $ address ) && strpos ( $ address , '.' ) ) { $ rx = '([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})' ; if ( $ mayIncludePort ) { $ rx .= '(?::\d+)?' ; } $ matches = null ; if ( preg_match ( '/^' . $ rx . '$/' , $ address , $ matches ) ) { $ ok = true ; $ nums = array ( ) ; for ( $ i = 1 ; $ ok && $ i <= 4 ; ++ $ i ) { $ ok = false ; $ n = ( int ) $ matches [ $ i ] ; if ( $ n >= 0 && $ n <= 255 ) { $ ok = true ; $ nums [ ] = ( string ) $ n ; } } if ( $ ok ) { $ result = new static ( implode ( '.' , $ nums ) ) ; } } } return $ result ; } | Parse a string and returns an IPv4 instance if the string is valid or null otherwise . |
49,697 | public static function fromBytes ( array $ bytes ) { $ result = null ; if ( count ( $ bytes ) === 4 ) { $ chunks = array_map ( function ( $ byte ) { return ( is_int ( $ byte ) && $ byte >= 0 && $ byte <= 255 ) ? ( string ) $ byte : false ; } , $ bytes ) ; if ( in_array ( false , $ chunks , true ) === false ) { $ result = new static ( implode ( '.' , $ chunks ) ) ; } } return $ result ; } | Parse an array of bytes and returns an IPv4 instance if the array is valid or null otherwise . |
49,698 | public function toIPv6 ( ) { $ myBytes = $ this -> getBytes ( ) ; return IPv6 :: fromString ( '2002:' . sprintf ( '%02x' , $ myBytes [ 0 ] ) . sprintf ( '%02x' , $ myBytes [ 1 ] ) . ':' . sprintf ( '%02x' , $ myBytes [ 2 ] ) . sprintf ( '%02x' , $ myBytes [ 3 ] ) . '::' ) ; } | Create an IPv6 representation of this address . |
49,699 | public static function addressFromString ( $ address , $ mayIncludePort = true , $ mayIncludeZoneID = true ) { $ result = null ; if ( $ result === null ) { $ result = Address \ IPv4 :: fromString ( $ address , $ mayIncludePort ) ; } if ( $ result === null ) { $ result = Address \ IPv6 :: fromString ( $ address , $ mayIncludePort , $ mayIncludeZoneID ) ; } return $ result ; } | Parse an IP address string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.