idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
35,600
protected function _deriveResourceName ( ) { $ inflectionType = $ this -> getConfig ( 'inflection' ) ; if ( $ inflectionType === null ) { $ inflectionType = $ this -> scope ( ) === 'entity' ? 'singular' : 'plural' ; } if ( $ inflectionType === 'singular' ) { return strtolower ( Inflector :: humanize ( Inflector :: sing...
Derive resource name
35,601
public function implementedEvents ( ) { $ events = parent :: implementedEvents ( ) ; $ events [ 'Crud.beforeRender' ] [ ] = [ 'callable' => [ $ this , 'publishSuccess' ] ] ; if ( method_exists ( $ this , 'viewVar' ) ) { $ events [ 'Crud.beforeRender' ] [ ] = [ 'callable' => [ $ this , 'publishViewVar' ] ] ; } return $ ...
Additional auxiliary events emitted if certain traits are loaded
35,602
protected function _checkRequestMethods ( ) { $ action = $ this -> _action ( ) ; $ apiConfig = $ action -> getConfig ( 'api' ) ; if ( ! isset ( $ apiConfig [ 'methods' ] ) ) { return false ; } $ request = $ this -> _request ( ) ; foreach ( $ apiConfig [ 'methods' ] as $ method ) { if ( $ request -> is ( $ method ) ) { ...
Check for allowed HTTP request types
35,603
protected function _exceptionResponse ( Event $ Event , $ exceptionConfig ) { $ exceptionConfig = array_merge ( $ this -> getConfig ( 'exception' ) , $ exceptionConfig ) ; $ class = $ exceptionConfig [ 'class' ] ; if ( $ exceptionConfig [ 'type' ] === 'validate' ) { $ exception = new $ class ( $ Event -> getSubject ( )...
Throw an exception based on API configuration
35,604
public function render ( Subject $ subject ) { $ this -> injectViewClasses ( ) ; $ this -> _ensureSuccess ( $ subject ) ; $ this -> _ensureData ( $ subject ) ; $ this -> _ensureSerialize ( ) ; return $ this -> _controller ( ) -> render ( ) ; }
Selects an specific Crud view class to render the output
35,605
protected function _ensureSerialize ( ) { $ controller = $ this -> _controller ( ) ; if ( isset ( $ controller -> viewVars [ '_serialize' ] ) ) { return ; } $ serialize = [ ] ; $ serialize [ ] = 'success' ; $ action = $ this -> _action ( ) ; if ( method_exists ( $ action , 'viewVar' ) ) { $ serialize [ 'data' ] = $ act...
Ensure _serialize is set in the view
35,606
public function injectViewClasses ( ) { $ controller = $ this -> _controller ( ) ; foreach ( $ this -> getConfig ( 'viewClasses' ) as $ type => $ class ) { $ controller -> RequestHandler -> setConfig ( 'viewClassMap' , [ $ type => $ class ] ) ; } }
Inject view classes into RequestHandler
35,607
public function viewClass ( $ type , $ class = null ) { if ( $ class === null ) { return $ this -> getConfig ( 'viewClasses.' . $ type ) ; } return $ this -> setConfig ( 'viewClasses.' . $ type , $ class ) ; }
Get or set a viewClass
35,608
protected function _bulk ( Query $ query = null ) { $ field = $ this -> getConfig ( 'field' ) ; $ value = $ this -> getConfig ( 'value' ) ; $ query -> update ( ) -> set ( [ $ field => $ value ] ) ; $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; return ( bool ) $ statement -> rowCount ( ) ; }
Handle a bulk value set
35,609
protected function _table ( ) { return $ this -> _controller ( ) -> loadModel ( null , $ this -> getConfig ( 'modelFactory' ) ? : $ this -> _controller ( ) -> getModelType ( ) ) ; }
Get a table instance
35,610
protected function _entity ( array $ data = null , array $ options = [ ] ) { if ( $ this -> _entity && empty ( $ data ) ) { return $ this -> _entity ; } return $ this -> _table ( ) -> newEntity ( $ data , $ options ) ; }
Get a fresh entity instance from the primary Table
35,611
public function injectSearch ( Event $ event ) { if ( ! in_array ( $ event -> getName ( ) , $ this -> getConfig ( 'enabled' ) ) ) { return ; } $ repository = $ this -> _table ( ) ; if ( $ repository instanceof Table && ! $ repository -> behaviors ( ) -> has ( 'Search' ) ) { throw new RuntimeException ( sprintf ( 'Missi...
Inject search conditions into the query object .
35,612
public function view ( $ view = null ) { if ( empty ( $ view ) ) { return $ this -> getConfig ( 'view' ) ? : $ this -> _request ( ) -> getParam ( 'action' ) ; } return $ this -> setConfig ( 'view' , $ view ) ; }
Change the view to be rendered
35,613
protected function _extractFinder ( ) { $ finder = $ this -> findMethod ( ) ; $ options = [ ] ; if ( is_array ( $ finder ) ) { $ options = ( array ) current ( $ finder ) ; $ finder = key ( $ finder ) ; } return [ $ finder , $ options ] ; }
Extracts the finder name and options out of the findMethod option .
35,614
protected function _findRecord ( $ id , Subject $ subject ) { $ repository = $ this -> _table ( ) ; list ( $ finder , $ options ) = $ this -> _extractFinder ( ) ; $ query = $ repository -> find ( $ finder , $ options ) ; $ query -> where ( [ current ( $ query -> aliasField ( $ repository -> getPrimaryKey ( ) ) ) => $ i...
Find a record from the ID
35,615
protected function _notFound ( $ id , Subject $ subject ) { $ subject -> set ( [ 'success' => false ] ) ; $ this -> _trigger ( 'recordNotFound' , $ subject ) ; $ message = $ this -> message ( 'recordNotFound' , compact ( 'id' ) ) ; $ exceptionClass = $ message [ 'class' ] ; throw new $ exceptionClass ( $ message [ 'tex...
Throw exception if a record is not found
35,616
public function setupLogging ( Event $ event ) { foreach ( $ this -> _getSources ( ) as $ connectionName ) { try { $ connection = $ this -> _getSource ( $ connectionName ) ; if ( method_exists ( $ connection , 'enableQueryLogging' ) ) { $ connection -> enableQueryLogging ( true ) ; } else { $ connection -> logQueries (...
Setup logging for all connections
35,617
public function beforeRender ( Event $ event ) { if ( ! Configure :: read ( 'debug' ) ) { return ; } $ this -> _action ( ) -> setConfig ( 'serialize.queryLog' , 'queryLog' ) ; $ this -> _controller ( ) -> set ( 'queryLog' , $ this -> _getQueryLogs ( ) ) ; }
Appends the query log to the JSON or XML output
35,618
protected function _getQueryLogs ( ) { $ sources = $ this -> _getSources ( ) ; $ queryLog = [ ] ; foreach ( $ sources as $ source ) { $ logger = $ this -> _getSource ( $ source ) -> getLogger ( ) ; if ( method_exists ( $ logger , 'getLogs' ) ) { $ queryLog [ $ source ] = $ logger -> getLogs ( ) ; } } return $ queryLog ...
Get the query logs for all sources
35,619
protected function _handle ( ) { $ ids = $ this -> _processIds ( ) ; $ subject = $ this -> _constructSubject ( $ ids ) ; $ event = $ this -> _trigger ( 'beforeBulk' , $ subject ) ; if ( $ event -> isStopped ( ) ) { return $ this -> _stopped ( $ subject ) ; } if ( $ this -> _bulk ( $ subject -> query ) ) { $ this -> _su...
Handle a bulk event
35,620
protected function _processIds ( ) { $ ids = $ this -> _controller ( ) -> request -> getData ( 'id' ) ; $ all = false ; if ( is_array ( $ ids ) ) { $ all = Hash :: get ( $ ids , '_all' , false ) ; unset ( $ ids [ '_all' ] ) ; } if ( ! is_array ( $ ids ) ) { throw new BadRequestException ( 'Bad request data' ) ; } if ( ...
Retrieves a list of ids to process
35,621
protected function _constructSubject ( array $ ids ) { $ repository = $ this -> _table ( ) ; list ( $ finder , $ options ) = $ this -> _extractFinder ( ) ; $ options = array_merge ( $ options , $ this -> _getFindConfig ( $ ids ) ) ; $ query = $ repository -> find ( $ finder , $ options ) ; $ subject = $ this -> _subjec...
Setup a query object for retrieving entities
35,622
protected function _bulk ( Query $ query = null ) { $ query = $ query -> delete ( ) ; $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; return ( bool ) $ statement -> rowCount ( ) ; }
Handle a bulk delete
35,623
protected function _bulk ( Query $ query = null ) { $ field = $ this -> getConfig ( 'field' ) ; $ expression = [ new QueryExpression ( sprintf ( '%1$s= NOT %1$s' , $ field ) ) ] ; $ query -> update ( ) -> set ( $ expression ) ; $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; return ( bool ) $ st...
Handle a bulk toggle
35,624
public function beforePaginate ( Event $ event ) { $ method = 'contain' ; if ( method_exists ( $ event -> getSubject ( ) -> query , 'getContain' ) ) { $ method = 'getContain' ; } $ contained = $ event -> getSubject ( ) -> query -> $ method ( ) ; if ( ! empty ( $ contained ) ) { return ; } $ models = $ this -> models ( ...
Automatically parse and contain related table classes
35,625
public function beforeRender ( Event $ event ) { $ entity = null ; if ( isset ( $ event -> getSubject ( ) -> entity ) ) { $ entity = $ event -> getSubject ( ) -> entity ; } $ this -> publishRelatedModels ( null , $ entity ) ; }
Fetches related models list and sets them to a variable for the view
35,626
public function publishRelatedModels ( $ action = null , $ entity = null ) { $ models = $ this -> models ( $ action ) ; if ( empty ( $ models ) ) { return ; } $ controller = $ this -> _controller ( ) ; foreach ( $ models as $ name => $ association ) { list ( , $ associationName ) = pluginSplit ( $ association -> getNam...
Find and publish all related models to the view for an action
35,627
public function models ( $ action = null ) { $ settings = $ this -> relatedModels ( null , $ action ) ; if ( $ settings === true ) { return $ this -> getAssociatedByType ( [ 'oneToOne' , 'manyToMany' , 'manyToOne' ] ) ; } if ( empty ( $ settings ) ) { return [ ] ; } if ( is_string ( $ settings ) ) { $ settings = [ $ se...
Gets the list of associated model lists to be fetched for an action
35,628
public function relatedModels ( $ related = null , $ action = null ) { if ( $ related === null ) { return $ this -> _action ( $ action ) -> getConfig ( 'relatedModels' ) ; } return $ this -> _action ( $ action ) -> setConfig ( 'relatedModels' , $ related , false ) ; }
Set or get the related models that should be found for the action
35,629
public function getAssociatedByType ( $ types = [ ] ) { $ return = [ ] ; $ table = $ this -> _table ( ) ; foreach ( $ table -> associations ( ) -> keys ( ) as $ association ) { $ associationClass = $ table -> associations ( ) -> get ( $ association ) ; if ( ! in_array ( $ associationClass -> type ( ) , $ types ) ) { co...
Get associated tables based on the current table instance based on their association type
35,630
public function getAssociatedByName ( $ names ) { $ return = [ ] ; $ table = $ this -> _table ( ) ; foreach ( $ names as $ association ) { $ associationClass = $ table -> associations ( ) -> get ( $ association ) ; if ( ! $ associationClass ) { throw new RuntimeException ( sprintf ( 'Table "%s" is not associated with "...
Get associated tables based on the current table instance based on their association name
35,631
public function viewVar ( $ name = null ) { if ( empty ( $ name ) ) { return $ this -> getConfig ( 'viewVar' ) ? : $ this -> _deriveViewVar ( ) ; } return $ this -> setConfig ( 'viewVar' , $ name ) ; }
Change the name of the view variable name of the data when its sent to the view
35,632
protected function _deriveViewVar ( ) { if ( $ this -> scope ( ) === 'table' ) { return Inflector :: variable ( $ this -> _controller ( ) -> getName ( ) ) ; } if ( $ this -> scope ( ) === 'entity' ) { return Inflector :: variable ( Inflector :: singularize ( $ this -> _controller ( ) -> getName ( ) ) ) ; } throw new Ex...
Derive the viewVar based on the scope of the action
35,633
protected function _deriveViewValue ( Event $ event ) { $ key = $ this -> _action ( ) -> subjectEntityKey ( ) ; return $ event -> getSubject ( ) -> { $ key } ; }
Derive the viewVar value based on the scope of the action as well as the Event being handled
35,634
public function normalizeArray ( array $ array ) { $ normal = [ ] ; foreach ( $ array as $ action => $ config ) { if ( is_string ( $ config ) ) { $ config = [ 'className' => $ config ] ; } if ( is_int ( $ action ) ) { list ( , $ action ) = pluginSplit ( $ config [ 'className' ] ) ; } $ action = Inflector :: variable ( ...
Normalize config array
35,635
public function initialize ( array $ config ) { parent :: initialize ( $ config ) ; $ this -> _action = $ this -> _controller -> request -> getParam ( 'action' ) ; $ this -> _request = $ this -> _controller -> request ; if ( ! isset ( $ this -> _controller -> dispatchComponents ) ) { $ this -> _controller -> dispatchCo...
Add self to list of components capable of dispatching an action .
35,636
public function execute ( $ controllerAction = null , $ args = [ ] ) { $ this -> _loadListeners ( ) ; $ this -> _action = $ controllerAction ? : $ this -> _action ; $ action = $ this -> _action ; if ( empty ( $ args ) ) { $ args = $ this -> _request -> getParam ( 'pass' ) ; } try { $ event = $ this -> trigger ( 'before...
Execute a Crud action
35,637
public function action ( $ name = null ) { if ( empty ( $ name ) ) { $ name = $ this -> _action ; } $ name = Inflector :: variable ( $ name ) ; return $ this -> _loadAction ( $ name ) ; }
Get a CrudAction object by action name .
35,638
public function view ( $ action , $ view = null ) { if ( is_array ( $ action ) ) { foreach ( $ action as $ realAction => $ realView ) { $ this -> action ( $ realAction ) -> view ( $ realView ) ; } return ; } $ this -> action ( $ action ) -> view ( $ view ) ; }
Map the view file to use for a controller action .
35,639
public function viewVar ( $ action , $ viewVar = null ) { if ( is_array ( $ action ) ) { foreach ( $ action as $ realAction => $ realViewVar ) { $ this -> action ( $ realAction ) -> viewVar ( $ realViewVar ) ; } return ; } $ this -> action ( $ action ) -> viewVar ( $ viewVar ) ; }
Change the viewVar name for one or multiple actions .
35,640
public function mapAction ( $ action , $ config = [ ] , $ enable = true ) { if ( is_string ( $ config ) ) { $ config = [ 'className' => $ config ] ; } $ action = Inflector :: variable ( $ action ) ; $ this -> setConfig ( 'actions.' . $ action , $ config ) ; if ( $ enable ) { $ this -> enable ( $ action ) ; } }
Map action to an internal request type .
35,641
public function on ( $ events , $ callback , $ options = [ ] ) { foreach ( ( array ) $ events as $ event ) { if ( ! strpos ( $ event , '.' ) ) { $ event = $ this -> _config [ 'eventPrefix' ] . '.' . $ event ; } $ this -> _eventManager -> on ( $ event , $ options , $ callback ) ; } }
Attaches an event listener function to the controller for Crud Events .
35,642
public function addListener ( $ name , $ className = null , $ config = [ ] ) { if ( strpos ( $ name , '.' ) !== false ) { list ( $ plugin , $ name ) = pluginSplit ( $ name ) ; $ className = $ plugin . '.' . Inflector :: camelize ( $ name ) ; } $ name = Inflector :: variable ( $ name ) ; $ this -> setConfig ( sprintf ( ...
Add a new listener to Crud
35,643
public function removeListener ( $ name ) { $ listeners = $ this -> getConfig ( 'listeners' ) ; if ( ! array_key_exists ( $ name , $ listeners ) ) { return false ; } if ( isset ( $ this -> _listenerInstances [ $ name ] ) ) { $ this -> _eventManager -> off ( $ this -> _listenerInstances [ $ name ] ) ; unset ( $ this -> ...
Remove a listener from Crud .
35,644
public function defaults ( $ type , $ name , $ config = null ) { if ( $ config !== null ) { if ( ! is_array ( $ name ) ) { $ name = [ $ name ] ; } foreach ( $ name as $ realName ) { $ this -> setConfig ( sprintf ( '%s.%s' , $ type , $ realName ) , $ config ) ; } return null ; } return $ this -> getConfig ( sprintf ( '%...
Set or get defaults for listeners and actions .
35,645
public function useModel ( $ modelName ) { $ this -> _controller -> loadModel ( $ modelName ) ; list ( , $ this -> _modelName ) = pluginSplit ( $ modelName ) ; }
Sets the model class to be used during the action execution .
35,646
protected function _loadListener ( $ name ) { if ( ! isset ( $ this -> _listenerInstances [ $ name ] ) ) { $ config = $ this -> getConfig ( 'listeners.' . $ name ) ; if ( empty ( $ config ) ) { throw new ListenerNotConfiguredException ( sprintf ( 'Listener "%s" is not configured' , $ name ) ) ; } $ className = App :: c...
Load a single event class attached to Crud .
35,647
protected function _loadAction ( $ name ) { if ( ! isset ( $ this -> _actionInstances [ $ name ] ) ) { $ config = $ this -> getConfig ( 'actions.' . $ name ) ; if ( empty ( $ config ) ) { throw new ActionNotConfiguredException ( sprintf ( 'Action "%s" has not been mapped' , $ name ) ) ; } $ className = App :: className...
Load a CrudAction instance .
35,648
protected function _isActionMapped ( ) { if ( ! empty ( $ this -> dispatchComponents ) ) { foreach ( $ this -> dispatchComponents as $ component => $ enabled ) { if ( empty ( $ enabled ) ) { continue ; } if ( ! method_exists ( $ this -> { $ component } , 'isActionMapped' ) ) { continue ; } if ( ! $ this -> { $ componen...
Check if an action can be dispatched using CRUD .
35,649
public function reader ( $ key , $ reader = null ) { if ( $ reader === null ) { return $ this -> getConfig ( 'readers.' . $ key ) ; } return $ this -> setConfig ( 'readers.' . $ key , $ reader ) ; }
Add or replace a reader
35,650
protected function _getUrl ( Subject $ subject , array $ url ) { foreach ( $ url as $ key => $ value ) { if ( ! is_array ( $ value ) ) { continue ; } if ( $ key === '?' ) { $ url [ $ key ] = $ this -> _getUrl ( $ subject , $ value ) ; continue ; } $ url [ $ key ] = $ this -> _getKey ( $ subject , $ value [ 0 ] , $ valu...
Get the new redirect URL
35,651
public function parseFromXml ( $ simpleXml ) { if ( ! isset ( $ simpleXml -> { 'order-items' } ) ) { return ; } if ( $ simpleXml -> { 'order-items' } -> children ( ) -> count ( ) < 1 ) { return ; } $ basketVersion = '' ; switch ( ( string ) $ simpleXml -> { 'payment-methods' } -> { 'payment-method' } [ 'name' ] ) { cas...
Parse simplexml and create basket object
35,652
private function parseFromXml ( $ simpleXml ) { if ( isset ( $ simpleXml -> { 'card-token' } -> { 'masked-account-number' } ) ) { $ this -> maskedPan = $ simpleXml -> { 'card-token' } -> { 'masked-account-number' } ; } if ( isset ( $ simpleXml -> { 'card-token' } -> { 'token-id' } ) ) { $ this -> token = $ simpleXml ->...
Parse card from response xml
35,653
public function getCreditCardUiWithData ( $ transaction , $ paymentAction , $ language = 'en' ) { $ config = $ this -> config -> get ( $ transaction :: NAME ) ; $ merchantAccountId = $ config -> getMerchantAccountId ( ) ; $ secret = $ config -> getSecret ( ) ; $ isThreeD = false ; $ amount = $ transaction -> getAmount ...
Get CreditCard Ui for Transaction
35,654
private function toSha256 ( $ fields , $ secret ) { $ hasData = '' ; foreach ( $ this -> getHashKeys ( ) as $ key ) { if ( isset ( $ fields [ $ key ] ) ) { $ hasData .= $ fields [ $ key ] ; } } $ hasData .= $ secret ; return hash ( 'sha256' , trim ( $ hasData ) ) ; }
Get calculated signature
35,655
public function cancel ( Transaction $ transaction ) { $ cancelResult = $ this -> process ( $ transaction , Operation :: CANCEL ) ; if ( $ transaction instanceof CreditCardTransaction && $ cancelResult -> getStatusCollection ( ) -> hasStatusCodes ( [ '500.1057' ] ) ) { return $ this -> process ( $ transaction , Operati...
If a failureResponse returns from the cancel process call with a specific status code which declares that the credit card amount has already been settled we try a refund process call .
35,656
private function processFallback ( CreditCardTransaction $ transaction , Response $ response ) { if ( ! $ response -> getStatusCollection ( ) -> hasStatusCodes ( [ '500.1072' , '500.1073' , '500.1074' ] ) ) { return $ response ; } $ transaction -> setThreeD ( false ) ; $ requestBody = $ this -> requestMapper -> map ( $...
If specific status codes which indicate an error during the credit card enrollment check are found in response we do a fallback from a 3 - D to an SSL credit card transaction
35,657
public function checkCredentials ( ) { try { $ requestHeader = array_merge_recursive ( $ this -> httpHeader , $ this -> config -> getShopHeader ( ) ) ; $ request = $ this -> messageFactory -> createRequest ( 'GET' , $ this -> config -> getBaseUrl ( ) . '/engine/rest/merchants/' , $ requestHeader ) ; $ request = $ this ...
We expect status code 404 for a successful authentication otherwise the endpoint will return 401 unauthorized
35,658
public function getGroupOfTransactions ( $ transactionId , $ paymentMethod ) { $ transaction = $ this -> getTransactionByTransactionId ( $ transactionId , $ paymentMethod ) ; if ( isset ( $ transaction [ 'payment' ] ) ) { $ transaction = $ transaction [ 'payment' ] ; } if ( isset ( $ transaction [ 'parent-transaction-i...
Recursively search for a parent transaction until it finds no parent - transaction - id anymore . Aggregate all of the results received in the group transaction and return them in ascending order by date .
35,659
protected function parseUserAgent ( $ userAgentString ) { $ parser = new WhichBrowser \ Parser ( $ userAgentString ) ; if ( ! $ parser -> isDetected ( ) ) { return ; } if ( $ parser -> isType ( 'mobile' ) ) { $ this -> setType ( 'mobile' ) ; } elseif ( $ parser -> isType ( 'tablet' ) ) { $ this -> setType ( 'tablet' ) ...
parse and map device type and os from user agent string
35,660
private function generateStatusCollection ( ) { $ collection = new StatusCollection ( ) ; if ( ! isset ( $ this -> simpleXml -> { 'statuses' } ) ) { throw new MalformedResponseException ( 'Missing statuses in response.' ) ; } $ statuses = $ this -> simpleXml -> { 'statuses' } ; if ( count ( $ statuses -> { 'status' } )...
get the collection of status returned by Wirecard s Payment Processing Gateway
35,661
private static function arrayFlatten ( $ array , $ prefix = '' ) { $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ result = $ result + self :: arrayFlatten ( $ value , $ prefix . $ key . '.' ) ; } else { $ result [ $ prefix . $ key ] = trim ( preg_replace ( '/\s+/' , ' '...
convert a multidimensional array into a simple one - dimensional array
35,662
private function setRequestedAmount ( ) { if ( $ this -> simpleXml -> { 'requested-amount' } -> count ( ) < 1 ) { return ; } $ this -> requestedAmount = new Amount ( ( float ) $ this -> simpleXml -> { 'requested-amount' } , ( string ) $ this -> simpleXml -> { 'requested-amount' } -> attributes ( ) -> currency ) ; }
Parse simplexml and create requestedAmount object
35,663
private function setCustomFields ( ) { $ customFieldCollection = new CustomFieldCollection ( ) ; if ( isset ( $ this -> simpleXml -> { 'custom-fields' } ) ) { foreach ( $ this -> simpleXml -> { 'custom-fields' } -> children ( ) as $ field ) { $ customField = $ this -> convertToCustomField ( $ field ) ; if ( ! is_null (...
parse simplexml to load all custom fields
35,664
private function convertToCustomField ( $ field ) { if ( ! empty ( $ field -> attributes ( ) ) ) { if ( isset ( $ field -> attributes ( ) -> { 'field-name' } ) && isset ( $ field -> attributes ( ) -> { 'field-value' } ) ) { $ rawName = ( string ) $ field -> attributes ( ) -> { 'field-name' } ; list ( $ normalizedName ,...
Convert the xml field into a CustomField object
35,665
private function splitFieldNameAndPrefix ( $ rawName ) { $ normalizedName = '' ; $ prefix = '' ; if ( ! empty ( $ rawName ) ) { if ( strpos ( $ rawName , CustomField :: DEFAULT_PREFIX ) === 0 ) { $ normalizedName = substr ( $ rawName , strlen ( CustomField :: DEFAULT_PREFIX ) ) ; $ prefix = CustomField :: DEFAULT_PREFI...
Auto detect the PHPSDK prefix for customfields
35,666
public function map ( $ response , Transaction $ transaction = null ) { $ this -> transaction = $ transaction ; $ decodedResponse = base64_decode ( $ response ) ; $ this -> xmlResponse = ( base64_encode ( $ decodedResponse ) === $ response ) ? $ decodedResponse : $ response ; $ oldErrorHandling = libxml_use_internal_er...
map the xml Response from Wirecard s Payment Processing Gateway to ResponseObjects
35,667
public function setRawCustomField ( $ customFieldKey , $ customFieldValue = null ) { $ customFields = $ this -> getCustomFields ( ) ; if ( empty ( $ customFields ) ) { $ customFields = new CustomFieldCollection ( ) ; } $ it = $ customFields -> getIterator ( ) ; foreach ( $ it as $ index => $ existingField ) { if ( $ ex...
Add a custom field without default prefix to the customfields
35,668
private function getAllSetData ( ) { $ data = $ this -> mappedProperties ( ) ; if ( isset ( $ data [ 'address' ] ) ) { $ address = $ data [ 'address' ] ; unset ( $ data [ 'address' ] ) ; $ data = array_merge ( $ data , $ address ) ; } return $ data ; }
Get all set data
35,669
public function process ( Transaction $ transaction , $ operation ) { $ response = parent :: process ( $ transaction , $ operation ) ; if ( $ response instanceof FailureResponse && $ operation == Operation :: CANCEL && $ transaction -> getBackendOperationForRefund ( ) ) { return parent :: process ( $ transaction , Oper...
Build in fallback for refund
35,670
public function getOrderState ( $ transaction_type ) { switch ( $ transaction_type ) { case Transaction :: TYPE_PENDING_CREDIT : case Transaction :: TYPE_PENDING_DEBIT : $ state = self :: TYPE_PENDING ; break ; case Transaction :: TYPE_CAPTURE_AUTHORIZATION : case Transaction :: TYPE_DEBIT : case Transaction :: TYPE_PU...
Return order state of the transaction
35,671
public function isFinal ( $ transaction_type ) { if ( in_array ( $ transaction_type , [ Transaction :: TYPE_CAPTURE_AUTHORIZATION , Transaction :: TYPE_DEBIT , Transaction :: TYPE_PURCHASE , Transaction :: TYPE_AUTHORIZATION , Transaction :: TYPE_PENDING_CREDIT , Transaction :: TYPE_PENDING_DEBIT , Transaction :: TYPE_...
Check if the transaction is final
35,672
protected function render ( Exception $ exception , array $ info , int $ code ) { $ view = $ this -> factory -> make ( "errors.{$code}" , $ info ) ; return $ view -> with ( 'exception' , $ exception ) -> render ( ) ; }
Render the page with given info and exception .
35,673
protected function getConfigItem ( string $ key ) { if ( $ this -> config === null ) { $ this -> config = $ this -> container -> config -> get ( 'exceptions' , [ ] ) ; } return array_get ( $ this -> config , $ key ) ; }
Get an item from the config .
35,674
protected function getResponse ( Request $ request , Exception $ exception , Exception $ transformed ) { $ id = $ this -> container -> make ( ExceptionIdentifier :: class ) -> identify ( $ exception ) ; $ flattened = FlattenException :: create ( $ transformed ) ; $ code = $ flattened -> getStatusCode ( ) ; $ headers = ...
Get the approprate response object .
35,675
protected function getFiltered ( array $ displayers , Request $ request , Exception $ original , Exception $ transformed , $ code ) { foreach ( $ this -> make ( ( array ) $ this -> getConfigItem ( 'filters' ) ) as $ filter ) { $ displayers = $ filter -> filter ( $ displayers , $ request , $ original , $ transformed , $...
Get the filtered list of displayers .
35,676
public function identify ( Exception $ exception ) { $ hash = spl_object_hash ( $ exception ) ; if ( isset ( $ this -> identification [ $ hash ] ) ) { return $ this -> identification [ $ hash ] ; } if ( count ( $ this -> identification ) >= 16 ) { array_shift ( $ this -> identification ) ; } return $ this -> identifica...
Identify the given exception .
35,677
protected function generate ( ) { $ hash = bin2hex ( random_bytes ( 16 ) ) ; $ timeHi = hexdec ( substr ( $ hash , 12 , 4 ) ) & 0x0fff ; $ timeHi &= ~ ( 0xf000 ) ; $ timeHi |= 4 << 12 ; $ clockSeqHi = hexdec ( substr ( $ hash , 16 , 2 ) ) & 0x3f ; $ clockSeqHi &= ~ ( 0xc0 ) ; $ clockSeqHi |= 0x80 ; $ params = [ substr ...
Generate a new uuid .
35,678
public static function get_project_milestones ( $ project , $ args = [ ] ) { $ request_url = sprintf ( self :: API_ROOT . 'repos/%s/milestones' , $ project ) ; $ args [ 'per_page' ] = 100 ; list ( $ body , $ headers ) = self :: request ( $ request_url , $ args ) ; return $ body ; }
Gets the milestones for a given project .
35,679
public static function get_release_by_tag ( $ project , $ tag , $ args = [ ] ) { $ request_url = sprintf ( self :: API_ROOT . 'repos/%s/releases/tags/%s' , $ project , $ tag ) ; $ args [ 'per_page' ] = 100 ; list ( $ body , $ headers ) = self :: request ( $ request_url , $ args ) ; return $ body ; }
Gets a release for a given project by its tag name .
35,680
public static function remove_label ( $ project , $ issue , $ label , $ args = [ ] ) { $ request_url = sprintf ( self :: API_ROOT . 'repos/%s/issues/%s/labels/%s' , $ project , $ issue , $ label ) ; $ headers [ 'http_verb' ] = 'DELETE' ; list ( $ body , $ headers ) = self :: request ( $ request_url , $ args , $ headers...
Removes a label from an issue .
35,681
public static function delete_label ( $ project , $ label , $ args = [ ] ) { $ request_url = sprintf ( self :: API_ROOT . 'repos/%s/labels/%s' , $ project , $ label ) ; $ headers [ 'http_verb' ] = 'DELETE' ; list ( $ body , $ headers ) = self :: request ( $ request_url , $ args , $ headers ) ; return $ body ; }
Delete a label from a repository .
35,682
public static function get_project_milestone_pull_requests ( $ project , $ milestone_id ) { $ request_url = sprintf ( self :: API_ROOT . 'repos/%s/issues' , $ project ) ; $ args = [ 'per_page' => 100 , 'milestone' => $ milestone_id , 'state' => 'all' , ] ; $ pull_requests = [ ] ; do { list ( $ body , $ headers ) = self...
Gets the pull requests assigned to a milestone of a given project .
35,683
public static function request ( $ url , $ args = [ ] , $ headers = [ ] ) { $ headers = array_merge ( $ headers , [ 'Accept' => 'application/vnd.github.v3+json' , 'User-Agent' => 'WP-CLI' , ] ) ; $ token = getenv ( 'GITHUB_TOKEN' ) ; if ( $ token ) { $ headers [ 'Authorization' ] = 'token ' . $ token ; } $ verb = 'GET'...
Makes a request to the GitHub API .
35,684
public static function format_header ( $ info ) { if ( is_array ( $ info [ 'message' ] ) ) { $ extra = array ( 'Type' => self :: $ log_levels [ $ info [ 'level' ] ] , 'File' => $ info [ 'message' ] [ 1 ] , 'Line' => $ info [ 'message' ] [ 2 ] ) ; $ info [ 'message' ] = $ info [ 'message' ] [ 0 ] ; } else { $ extra = ar...
Formats a log header to be sent .
35,685
public static function init ( ) { if ( ! isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) || preg_match ( '{\bFirePHP/\d+\.\d+\b}' , $ _SERVER [ 'HTTP_USER_AGENT' ] ) || isset ( $ _SERVER [ 'HTTP_X_FIREPHP_VERSION' ] ) ) { header ( 'X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2' ) ; header ( 'X-Wf-1-Plug...
Sends the initial headers if FirePHP is available then returns a closure that handles sending log messages .
35,686
public function convert_log_level ( $ level , $ reverse = false ) { if ( $ reverse ) { switch ( $ level ) { case Analog :: URGENT : return LogLevel :: EMERGENCY ; case Analog :: ALERT : return LogLevel :: ALERT ; case Analog :: CRITICAL : return LogLevel :: CRITICAL ; case Analog :: ERROR : return LogLevel :: ERROR ; c...
Converts from PSR - 3 log levels to Analog log levels .
35,687
private function _log ( $ level , $ message , $ context ) { Analog :: log ( $ this -> interpolate ( $ message , $ context ) , $ level ) ; }
Perform the logging to Analog after the log level has been converted .
35,688
public function addSettings ( array $ settings ) { foreach ( $ settings as $ key => $ value ) { $ this -> addSetting ( $ key , $ value ) ; } }
add ability to set multiple settings in one call
35,689
public function getSetting ( $ key ) { if ( ! isset ( $ this -> _settings [ $ key ] ) ) { return null ; } return $ this -> _settings [ $ key ] ; }
gets a setting
35,690
private static function get_struct ( $ message , $ level ) { if ( self :: $ machine === null ) { self :: $ machine = ( isset ( $ _SERVER [ 'SERVER_ADDR' ] ) ) ? $ _SERVER [ 'SERVER_ADDR' ] : 'localhost' ; } $ dt = new \ DateTime ( 'now' , new \ DateTimeZone ( self :: $ timezone ) ) ; return array ( 'machine' => self ::...
Get the log info as an associative array .
35,691
private static function write ( $ struct ) { $ handler = self :: handler ( ) ; if ( ! $ handler instanceof \ Closure ) { $ handler = \ Analog \ Handler \ File :: init ( $ handler ) ; } return $ handler ( $ struct ) ; }
Write a raw message to the log using a function or the default file logging .
35,692
public function error ( string $ message , string $ title = '' , array $ options = [ ] ) : self { return $ this -> addNotification ( self :: ERROR , $ message , $ title , $ options ) ; }
Shortcut for adding an error notification .
35,693
public function info ( string $ message , string $ title = '' , array $ options = [ ] ) : self { return $ this -> addNotification ( self :: INFO , $ message , $ title , $ options ) ; }
Shortcut for adding an info notification .
35,694
public function success ( string $ message , string $ title = '' , array $ options = [ ] ) : self { return $ this -> addNotification ( self :: SUCCESS , $ message , $ title , $ options ) ; }
Shortcut for adding a success notification .
35,695
public function warning ( string $ message , string $ title = '' , array $ options = [ ] ) : self { return $ this -> addNotification ( self :: WARNING , $ message , $ title , $ options ) ; }
Shortcut for adding a warning notification .
35,696
public function addNotification ( string $ type , string $ message , string $ title = '' , array $ options = [ ] ) : self { $ this -> notifications [ ] = [ 'type' => in_array ( $ type , $ this -> allowedTypes , true ) ? $ type : self :: WARNING , 'title' => $ this -> escapeSingleQuote ( $ title ) , 'message' => $ this ...
Add a notification .
35,697
public function render ( ) : string { $ toastr = '<script type="text/javascript">' . $ this -> options ( ) . $ this -> notificationsAsString ( ) . '</script>' ; $ this -> session -> forget ( self :: TOASTR_NOTIFICATIONS ) ; return $ toastr ; }
Render the notifications script tag .
35,698
public function notifications ( ) : array { return array_map ( function ( $ n ) { return $ this -> toastr ( $ n [ 'type' ] , $ n [ 'message' ] , $ n [ 'title' ] , $ n [ 'options' ] ) ; } , $ this -> session -> get ( self :: TOASTR_NOTIFICATIONS , [ ] ) ) ; }
map over all notifications and create an array of toastrs .
35,699
public function toastr ( string $ type , string $ message = '' , string $ title = '' , string $ options = '' ) : string { return "toastr.$type('$message', '$title', $options);" ; }
Create a single toastr .