idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
43,200
public function add ( $ prefix , $ paths , $ prepend = false ) { if ( ! $ prefix ) { if ( $ prepend ) { $ this -> fallbackDirs = array_merge ( ( array ) $ paths , $ this -> fallbackDirs ) ; } else { $ this -> fallbackDirs = array_merge ( $ this -> fallbackDirs , ( array ) $ paths ) ; } return ; } if ( ! isset ( $ this ...
Registers a set of classes merging with any others previously set .
43,201
public function set ( $ prefix , $ paths ) { if ( ! $ prefix ) { $ this -> fallbackDirs = ( array ) $ paths ; return ; } $ this -> prefixes [ $ prefix ] = ( array ) $ paths ; }
Registers a set of classes replacing any others previously set .
43,202
public function getTaxonomyType ( ) { $ taxonomy = $ this -> getTaxonomy ( ) ; if ( $ taxonomy -> Type ( ) && $ taxonomy -> Type ( ) -> exists ( ) ) { return $ taxonomy -> Type ( ) -> Name ; } return '' ; }
Get the type of the top - level ancestor if it is set
43,203
public function execute ( Observer $ observer ) { if ( ! $ this -> scopeConfig -> getValue ( self :: CONFIG_PATH_REDIRECT_TO_CHECKOUT , ScopeInterface :: SCOPE_STORE ) ) { return ; } $ request = $ observer -> getData ( 'request' ) ; $ request -> setParam ( 'return_url' , $ this -> url -> getUrl ( 'checkout' ) ) ; }
Redirects directly to checkout on adding product if we re configured to do so .
43,204
public function getList ( ) { if ( $ this -> modelClass === TaxonomyTerm :: class ) { $ list = parent :: getList ( ) ; return $ list -> filter ( 'ParentID' , '0' ) ; } return parent :: getList ( ) ; }
If terms are the models being managed filter for only top - level terms - no children
43,205
private function disableAuthentication ( $ jsLayout ) { if ( $ this -> scopeConfig -> getValue ( self :: CONFIG_DISABLE_LOGIN_PATH , ScopeInterface :: SCOPE_STORE ) ) { unset ( $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'authentication' ] ) ; } return $ jsLayout ; }
Disables authentication modal .
43,206
private function changeCartItemsSortOrder ( $ jsLayout ) { if ( $ this -> scopeConfig -> getValue ( self :: CONFIG_MOVE_CART_ITEMS_PATH , ScopeInterface :: SCOPE_STORE ) ) { $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'sidebar' ] [ 'children' ] [ 'summary' ] [ 'children' ] [ 'cart_items' ] [ 'sortOrder'...
Changes cart items to be above totals in the cart summary .
43,207
private function disableDiscountComponent ( $ jsLayout ) { if ( $ this -> scopeConfig -> getValue ( self :: CONFIG_DISABLE_DISCOUNT_PATH , ScopeInterface :: SCOPE_STORE ) ) { unset ( $ jsLayout [ 'components' ] [ 'checkout' ] [ 'children' ] [ 'steps' ] [ 'children' ] [ 'billing-step' ] [ 'children' ] [ 'payment' ] [ 'c...
Disables the discount component after payment step .
43,208
private function doGetStatements ( $ url , array $ urlParameters = array ( ) ) { $ request = $ this -> requestHandler -> createRequest ( 'get' , $ url , $ urlParameters ) ; $ response = $ this -> requestHandler -> executeRequest ( $ request , array ( 200 ) ) ; $ contentType = $ response -> getHeader ( 'Content-Type' ) ...
Fetch one or more Statements .
43,209
protected function doStoreDocument ( $ method , $ uri , $ urlParameters , Document $ document ) { $ request = $ this -> requestHandler -> createRequest ( $ method , $ uri , $ urlParameters , $ this -> documentDataSerializer -> serializeDocumentData ( $ document -> getData ( ) ) ) ; $ this -> requestHandler -> executeRe...
Stores a document .
43,210
protected function doGetDocument ( $ uri , array $ urlParameters ) { $ request = $ this -> requestHandler -> createRequest ( 'get' , $ uri , $ urlParameters ) ; $ response = $ this -> requestHandler -> executeRequest ( $ request , array ( 200 ) ) ; $ document = $ this -> deserializeDocument ( ( string ) $ response -> g...
Returns a document .
43,211
public function __isset ( $ key ) { $ getter = 'get' . str_replace ( '_' , '' , $ key ) ; return method_exists ( $ this , $ getter ) && null !== $ this -> __get ( $ key ) ; }
Test if a configuration property is null
43,212
protected function handleProcessFlag ( Envelope $ envelope , DeliveryResult $ flag ) { $ this -> countMessagesConsumed ++ ; switch ( $ flag ) { case DeliveryResult :: MSG_REJECT ( ) : $ this -> queue -> nack ( $ envelope -> getDeliveryTag ( ) , Constants :: AMQP_NOPARAM ) ; $ this -> logger -> debug ( 'Rejected message...
Handle process flag
43,213
protected function ack ( ) { $ this -> queue -> ack ( $ this -> lastDeliveryTag , Constants :: AMQP_MULTIPLE ) ; $ this -> lastDeliveryTag = null ; $ delta = $ this -> timestampLastMessage - $ this -> timestampLastAck ; $ this -> logger -> info ( sprintf ( 'Acknowledged %d messages at %.0f msg/s' , $ this -> countMessa...
Acknowledge all deferred messages
43,214
protected function nackAll ( $ requeue = false ) { $ delta = $ this -> timestampLastMessage - $ this -> timestampLastAck ; $ this -> logger -> info ( sprintf ( 'Not acknowledged %d messages at %.0f msg/s' , $ this -> countMessagesUnacked , $ delta ? $ this -> countMessagesUnacked / $ delta : 0 ) ) ; $ flags = Constants...
Send nack for all deferred messages
43,215
protected function ackOrNackBlock ( ) { if ( ! $ this -> lastDeliveryTag ) { return ; } $ result = $ this -> flushDeferred ( ) ; switch ( $ result ) { case FlushDeferredResult :: MSG_ACK ( ) : $ this -> ack ( ) ; break ; case FlushDeferredResult :: MSG_REJECT ( ) : $ this -> nackAll ( false ) ; break ; case FlushDeferr...
Handle deferred acknowledgments
43,216
protected function sendReply ( Response $ response , Envelope $ envelope ) { $ attributes = [ 'content_type' => 'application/json' , 'content_encoding' => 'UTF-8' , 'delivery_mode' => 2 , 'correlation_id' => $ envelope -> getCorrelationId ( ) , 'app_id' => $ this -> appId , 'headers' => [ 'jsonrpc' => JsonRpcResponse :...
Send reply to rpc client
43,217
public function setScnAuthAdapterChain ( \ ZfcUser \ Authentication \ Adapter \ AdapterChain $ chain ) { $ this -> scnAuthAdapterChain = $ chain ; return $ this ; }
Set the scnAuthAdapterChain
43,218
protected function bitbucketToLocalUser ( $ userProfile ) { $ localUser = $ this -> instantiateLocalUser ( ) ; $ localUser -> setDisplayName ( $ userProfile -> displayName ) -> setPassword ( __FUNCTION__ ) -> setEmail ( $ userProfile -> email ) ; $ this -> insert ( $ localUser , 'github' , $ userProfile ) ; return $ lo...
BitBucket to Local User
43,219
public function insert ( $ entity , $ tableName = null , HydratorInterface $ hydrator = null ) { return parent :: insert ( $ entity , $ tableName , $ hydrator ) ; }
Proxy to parent protected method
43,220
public function addRequest ( Request $ request ) { $ attributes = $ this -> createAttributes ( $ request ) ; $ exchange = $ this -> getExchange ( $ request -> server ( ) ) ; $ message = json_encode ( $ request -> params ( ) ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new Exception \ InvalidArgumentExcept...
Add a request to rpc client
43,221
public function getResponseCollection ( float $ timeout = 0 ) : ResponseCollection { if ( $ timeout < $ this -> timeout ) { $ timeout = $ this -> timeout ; } $ now = microtime ( true ) ; $ responseCollection = new JsonRpcResponseCollection ( ) ; do { $ message = $ this -> queue -> get ( Constants :: AMQP_AUTOACK ) ; if...
Get response collection
43,222
private function findPredicateForObject ( \ EasyRdf_Graph $ graph , $ object ) { $ properties = $ graph -> reversePropertyUris ( $ object ) ; foreach ( $ properties as $ p ) { return $ p ; } return null ; }
Locate the predicate for an object in a graph .
43,223
public function getByUri ( Request $ request ) { if ( ! $ request -> headers -> has ( 'X-Islandora-URI' ) ) { return new Response ( 'Require the X-Islandora-URI header' , 400 ) ; } $ uri = $ request -> headers -> get ( 'X-Islandora-URI' ) ; if ( is_array ( $ uri ) ) { $ uri = reset ( $ uri ) ; } $ uri = $ this -> urlMa...
Find the opposite URI for the on provided in X - Islandora - URI .
43,224
private function getFfmpegFormat ( array $ content_types ) { $ content_type = null ; foreach ( $ content_types as $ type ) { if ( in_array ( $ type , $ this -> mimetypes ) ) { $ content_type = $ type ; break ; } } if ( $ content_type === null ) { $ this -> log -> info ( 'No matching content-type, falling back to defaul...
Filters through an array of acceptable content - types and returns a FFmpeg format .
43,225
protected function createNode ( $ uuid , $ jsonld_url , $ token = null ) { $ fedora_url = $ this -> gemini -> mintFedoraUrl ( $ uuid , $ token ) ; $ headers = empty ( $ token ) ? [ ] : [ 'Authorization' => $ token ] ; $ drupal_response = $ this -> drupal -> get ( $ jsonld_url , [ 'headers' => $ headers ] ) ; $ jsonld =...
Creates a new LDP - RS in Fedora from a Node .
43,226
protected function updateNode ( $ jsonld_url , $ fedora_url , $ token = null ) { $ headers = empty ( $ token ) ? [ ] : [ 'Authorization' => $ token ] ; $ headers [ 'Accept' ] = 'application/ld+json' ; $ fedora_response = $ this -> fedora -> getResource ( $ fedora_url , $ headers ) ; $ status = $ fedora_response -> getS...
Updates an existing LDP - RS in Fedora from a Node .
43,227
protected function processJsonld ( array $ jsonld , $ drupal_url , $ fedora_url ) { $ resource = array_filter ( $ jsonld [ '@graph' ] , function ( array $ elem ) use ( $ drupal_url ) { return $ elem [ '@id' ] == $ drupal_url ; } ) ; $ resource [ 0 ] [ '@id' ] = $ fedora_url ; return $ resource ; }
Normalizes Drupal jsonld into a shape Fedora understands .
43,228
protected function getFirstPredicate ( array $ jsonld , $ predicate , $ value = true ) { $ key = $ value ? '@value' : '@id' ; $ malformed = empty ( $ jsonld ) || ! isset ( $ jsonld [ 0 ] [ $ predicate ] ) || empty ( $ jsonld [ 0 ] [ $ predicate ] ) || ! isset ( $ jsonld [ 0 ] [ $ predicate ] [ 0 ] [ $ key ] ) ; if ( $ ...
Gets the first value for a predicate in a JSONLD array .
43,229
protected function getModifiedTimestamp ( array $ jsonld ) { $ modified = $ this -> getFirstPredicate ( $ jsonld , $ this -> modifiedDatePredicate ) ; if ( empty ( $ modified ) ) { throw new \ RuntimeException ( "Could not parse {$this->modifiedDatePredicate} from " . json_encode ( $ jsonld ) , 500 ) ; } $ date = \ Dat...
Extracts a modified date from jsonld and returns it as a timestamp .
43,230
protected function getLinkHeader ( $ response , $ rel_name , $ type = null ) { $ parsed = Psr7 \ parse_header ( $ response -> getHeader ( "Link" ) ) ; foreach ( $ parsed as $ header ) { $ has_relation = isset ( $ header [ 'rel' ] ) && $ header [ 'rel' ] == $ rel_name ; $ has_type = $ type ? isset ( $ header [ 'type' ] ...
Gets a Link header with the supplied rel name .
43,231
protected function makeDir ( $ dir ) { $ dirPath = base_path ( 'app/' . ltrim ( $ dir , '/' ) ) ; if ( ! File :: exists ( $ dirPath ) ) { File :: makeDirectory ( $ dirPath ) ; } }
Make directory if it doesn t already exist .
43,232
public function fakeContent ( ) { if ( ( bool ) Config :: getOption ( "plugins.faker.enabled" ) ) { $ fakedContent = $ this -> recursiveWalk ( Data :: get ( ) ) ; Data :: replaceStore ( $ fakedContent ) ; } }
Fake some content . Replace the entire store .
43,233
public function settings ( $ passed = null ) { if ( is_array ( $ passed ) ) { return $ this -> setSettings ( $ passed ) ; } elseif ( ! is_null ( $ passed ) ) { $ settings = $ this -> getSettingsInstance ( ) ; return $ settings -> get ( $ passed ) ; } return $ this -> getSettingsInstance ( ) ; }
If passed is string get settings class for the resource or return value for given key . If passed is array set the key value pair .
43,234
protected function getSettingsInstance ( ) { if ( isset ( $ this -> settings ) ) { return $ this -> settings ; } $ settingsConfig = $ this -> getSettingsConfig ( ) ; return $ this -> settings = new Settings ( $ settingsConfig , $ this ) ; }
Get settings off this or create new instance .
43,235
protected function getSettingsConfig ( ) { if ( isset ( $ this -> settingsConfig ) ) { $ fullNamespace = $ this -> settingsConfig ; } else { $ className = $ this -> getShortClassName ( ) ; $ fullNamespace = NameResolver :: makeConfigFileName ( $ className ) ; } if ( class_exists ( $ fullNamespace ) ) { return new $ ful...
Get the settings class name .
43,236
public function setSettingsByRequest ( ) { $ allAllowedSettings = array_keys ( $ this -> allSettings ( ) -> toArray ( ) ) ; return $ this -> settings ( ) -> set ( request ( ) -> only ( $ allAllowedSettings ) ) ; }
Set all allowed settings by Request .
43,237
public function defaultSetting ( $ key = null ) { if ( ! is_null ( $ key ) ) { return $ this -> settings ( ) -> getDefault ( $ key ) ; } return $ this -> settings ( ) -> allDefaults ( ) ; }
Get all default settings or default setting for single key if given .
43,238
public function allowedSetting ( $ key = null ) { if ( ! is_null ( $ key ) ) { return $ this -> settings ( ) -> getAllowed ( $ key ) ; } return $ this -> settings ( ) -> allAllowed ( ) ; }
Get all allowed settings or allowed settings for single ke if given .
43,239
protected function createImage ( Throwable $ error ) { $ type = get_class ( $ error ) ; $ code = $ error -> getCode ( ) ; $ message = $ error -> getMessage ( ) ; $ size = 200 ; $ image = imagecreatetruecolor ( $ size , $ size ) ; $ textColor = imagecolorallocate ( $ image , 255 , 255 , 255 ) ; imagestring ( $ image , 5...
Create an image resource from an error
43,240
public function validate ( $ rule , $ value ) { $ arguments = $ this -> buildArgumentArray ( $ rule , $ value ) ; $ method = $ this -> makeRuleMethod ( $ rule ) ; if ( $ this -> userDefinedExists ( $ method ) ) { $ class = NameResolver :: makeRulesFileName ( ) ; return call_user_func_array ( [ $ class , $ method ] , $ ...
Validate the value given for the rule .
43,241
protected function makeRuleMethod ( $ rule ) { if ( strpos ( $ rule , '=' ) !== false ) { $ rule = explode ( '=' , $ rule ) [ 0 ] ; } return 'rule' . ucfirst ( $ rule ) ; }
Make method name used to validate rule .
43,242
protected function userDefinedExists ( $ method ) { $ userDefined = NameResolver :: makeRulesFileName ( ) ; return class_exists ( $ userDefined ) && method_exists ( $ userDefined , $ method ) ; }
User defined rule method exists .
43,243
protected function buildArgumentArray ( $ rule , $ value ) { $ argumentString = explode ( '=' , $ rule ) ; $ arguments = [ $ value ] ; if ( isset ( $ argumentString [ 1 ] ) ) { return array_merge ( $ arguments , explode ( ',' , $ argumentString [ 1 ] ) ) ; } return $ arguments ; }
Build argument array from rule and value .
43,244
public function addFormatters ( FormatterInterface ... $ formatters ) : self { foreach ( $ formatters as $ formatter ) { foreach ( $ formatter -> contentTypes ( ) as $ contentType ) { $ this -> formatters [ $ contentType ] = $ formatter ; } } return $ this ; }
Add additional error formatters
43,245
public function isValid ( $ key , $ value ) { $ settings = collect ( $ this -> getRegistered ( ) -> get ( $ key , [ 'allowed' => [ ] ] ) ) ; $ allowed = $ settings -> get ( 'allowed' ) ; if ( ! is_array ( $ allowed ) && $ rule = $ this -> ruleValidator -> isRule ( $ allowed ) ) { return $ this -> ruleValidator -> valid...
Return true if key and value are registered values .
43,246
public function all ( ) { $ saved = $ this -> allSaved ( ) ; return $ this -> allDefaults ( ) -> map ( function ( $ value , $ key ) use ( $ saved ) { if ( $ saved -> has ( $ key ) ) { return $ saved -> get ( $ key ) ; } return $ value ; } ) ; }
Return all settings used by resource including defaults .
43,247
public function set ( array $ attributes ) { collect ( $ attributes ) -> each ( function ( $ value , $ key ) { $ this -> setKeyValue ( $ key , $ value ) ; } ) ; if ( $ this -> resource -> relationLoaded ( 'propertyBag' ) ) { $ this -> resource -> load ( 'propertyBag' ) ; } return $ this -> sync ( ) ; }
Update or add multiple values to the settings table .
43,248
protected function setKeyValue ( $ key , $ value ) { $ this -> validateKeyValue ( $ key , $ value ) ; if ( $ this -> isDefault ( $ key , $ value ) && $ this -> isSaved ( $ key ) ) { return $ this -> deleteRecord ( $ key ) ; } elseif ( $ this -> isDefault ( $ key , $ value ) ) { return ; } elseif ( $ this -> isSaved ( $...
Set a value to a key in local and database settings .
43,249
protected function createRecord ( $ key , $ value ) { return $ this -> propertyBag ( ) -> save ( new PropertyBag ( [ 'key' => $ key , 'value' => $ this -> valueToJson ( $ value ) , ] ) ) ; }
Create a new PropertyBag record .
43,250
protected function updateRecord ( $ key , $ value ) { $ record = $ this -> getByKey ( $ key ) ; $ record -> value = $ this -> valueToJson ( $ value ) ; $ record -> save ( ) ; return $ record ; }
Update a PropertyBag record .
43,251
protected function getByKey ( $ key ) { return $ this -> propertyBag ( ) -> where ( 'resource_id' , $ this -> resource -> getKey ( ) ) -> where ( 'key' , $ key ) -> first ( ) ; }
Get a property bag record by key .
43,252
protected function getAllSettingsFlat ( ) { return $ this -> getAllSettings ( ) -> flatMap ( function ( Model $ model ) { return [ $ model -> key => json_decode ( $ model -> value ) [ 0 ] ] ; } ) ; }
Get all settings as a flat collection .
43,253
protected function getAllSettings ( ) { if ( $ this -> resource -> relationLoaded ( 'propertyBag' ) ) { return $ this -> resource -> propertyBag ; } return $ this -> propertyBag ( ) -> where ( 'resource_id' , $ this -> resource -> getKey ( ) ) -> get ( ) ; }
Retrieve all settings from database .
43,254
public function get ( $ key ) { return $ this -> allSaved ( ) -> get ( $ key , function ( ) use ( $ key ) { return $ this -> getDefault ( $ key ) ; } ) ; }
Get value from settings by key . Get registered default if not set .
43,255
public function getQuery ( $ param , $ defaultValue = null , $ filters = array ( ) ) { return $ this -> fetchInputValue ( $ this -> input [ self :: INPUT_METHOD_QUERY ] , $ param , $ defaultValue , $ filters ) ; }
Returns the GET data parameter associated with the specified key .
43,256
public function getPost ( $ param , $ defaultValue = null , $ filters = array ( ) ) { return $ this -> fetchInputValue ( $ this -> input [ self :: INPUT_METHOD_POST ] , $ param , $ defaultValue , $ filters ) ; }
Returns the POST data parameter associated with the specified key .
43,257
public function getBody ( ) { if ( null !== $ this -> input [ self :: INPUT_METHOD_BODY ] ) { return $ this -> input [ self :: INPUT_METHOD_BODY ] ; } if ( is_resource ( $ this -> stream ) && 'stream' === get_resource_type ( $ this -> stream ) ) { $ streamData = stream_get_contents ( $ this -> stream ) ; } elseif ( is_...
Returns the input stream data for the current request
43,258
public function getAllInput ( ) { return array_merge ( $ this -> input [ self :: INPUT_METHOD_QUERY ] , $ this -> input [ self :: INPUT_METHOD_POST ] ) ; }
Returns an array of all the input parameters from the query and post data .
43,259
private function fetchInputValue ( $ array , $ param , $ defaultValue , $ filters ) { $ value = isset ( $ array [ $ param ] ) ? $ array [ $ param ] : $ defaultValue ; return $ this -> applyInputFilters ( $ value , is_array ( $ filters ) ? $ filters : array ( $ filters ) ) ; }
Fetches the input value from the given array or the default value . Also applies any requested filters .
43,260
private function applyInputFilters ( $ value , $ filters ) { foreach ( $ filters as $ filter ) { if ( is_string ( $ filter ) && isset ( self :: $ filterCallbacks [ $ filter ] ) ) { $ value = call_user_func ( self :: $ filterCallbacks [ $ filter ] , $ value ) ; } } return $ value ; }
Applies the array of filters against the input value .
43,261
public function setProxy ( $ host , $ port = false ) { $ this -> options [ CURLOPT_PROXY ] = $ host ; if ( $ port ) { $ this -> options [ CURLOPT_PROXYPORT ] = $ port ; } }
Push outgoing requests through the specified proxy server .
43,262
private function checkResponse ( $ ch ) { $ this -> responseInfo = curl_getinfo ( $ ch ) ; if ( curl_errno ( $ ch ) ) { throw new Net_Http_NetworkError ( curl_error ( $ ch ) , curl_errno ( $ ch ) ) ; } if ( $ this -> failOnError ) { $ status = $ this -> getStatus ( ) ; if ( $ status >= 400 && $ status <= 499 ) { throw ...
Check the response for possible errors . If failOnError is true then throw a protocol level exception . Network errors are always raised as exceptions .
43,263
private function processRequestsForAccessDenial ( array $ requests ) { foreach ( $ requests as $ request ) { $ controller = $ request -> getController ( ) ; $ action = $ request -> getAction ( ) ; if ( false === $ this -> isServiceEnabledForCrossOrigin ( $ controller , $ action ) ) { throw new AccessDeniedException ( '...
Processes the list of requests to check if any should be blocked due to CORS policy .
43,264
private function addHeadersForOptionsRequests ( ) { $ maxAge = self :: MAX_AGE ; if ( isset ( $ this -> options [ self :: HEADER_MAX_AGE ] ) ) { $ maxAge = intval ( $ this -> options [ self :: HEADER_MAX_AGE ] ) ; } @ header ( self :: HEADER_MAX_AGE . ': ' . $ maxAge ) ; $ allowedHeaders = self :: $ allowedHeaders ; if...
Adds additional headers for the OPTIONS http verb .
43,265
public function isAppropriate ( $ components ) { $ components = array_values ( array_filter ( array_map ( 'trim' , $ components ) , 'strlen' ) ) ; $ this -> options = array ( ) ; if ( count ( $ components ) < 5 ) { return false ; } if ( $ components [ 1 ] !== '--task' || $ components [ 3 ] !== '--action' ) { return fal...
Determines whether the current handler is appropriate for the given path components .
43,266
protected function getRouteInfo ( $ verb , $ path , $ useCache = false ) { if ( ! $ useCache || ! isset ( $ this -> routeInfo ) ) { $ dispatcher = $ this -> getDispatcher ( $ this -> getRoutes ( ) ) ; $ this -> routeInfo = $ dispatcher -> dispatch ( strtoupper ( $ verb ) , $ path ) ; } return $ this -> routeInfo ; }
Returns the array of route info from the routing library .
43,267
private function getDispatcher ( $ routes ) { $ verbs = self :: $ allHttpVerbs ; $ f = function ( RouteCollector $ collector ) use ( $ routes , $ verbs ) { foreach ( $ routes as $ pattern => $ route ) { if ( is_array ( $ route ) ) { foreach ( $ route as $ verb => $ callback ) { $ collector -> addRoute ( strtoupper ( $ ...
Returns an instance of the FastRoute dispatcher .
43,268
public function renderView ( $ viewVariables , $ template ) { $ encoder = $ this -> handler -> getEncoder ( ) ; if ( method_exists ( $ encoder , 'renderView' ) ) { return $ encoder -> renderView ( $ template , array_merge ( $ this -> viewContext , ( array ) $ viewVariables ) ) ; } else { throw new Exception ( 'The curr...
Renders the view for the given controller and action .
43,269
protected function extractPathFromBasePath ( $ path , $ options ) { if ( isset ( $ options [ self :: KEY_BASE_PATH ] ) ) { $ pos = strpos ( $ path , $ options [ self :: KEY_BASE_PATH ] ) ; if ( false !== $ pos ) { $ path = substr ( $ path , $ pos + strlen ( $ options [ self :: KEY_BASE_PATH ] ) ) ; } } if ( empty ( $ p...
Returns the new path with the base path extracted .
43,270
private function determineControllerAndAction ( & $ controller , & $ actionName ) { $ request = $ this -> getRequest ( ) ; $ this -> invokePluginsHook ( 'beforeControllerSelected' , array ( $ this , $ request ) ) ; $ controllerDiKey = $ request -> getController ( ) ; try { $ controller = $ this -> getServiceProvider ( ...
Determines the exact controller instance and action name to be invoked by the request .
43,271
protected function invokeControllerAction ( AbstractController $ controller , $ action ) { $ this -> invokePluginsHook ( 'beforeActionInvoked' , array ( $ this , $ this -> getRequest ( ) , $ controller , $ action ) ) ; $ response = $ controller -> $ action ( $ this -> routeParams ) ; if ( null === $ response ) { $ resp...
Invokes the actual controller action and returns the response .
43,272
private function configureViewEncoder ( $ options , $ controller , $ action ) { if ( isset ( $ options [ self :: KEY_VIEWS ] ) ) { $ this -> encoder = new TwigViewEncoder ( $ options [ self :: KEY_VIEWS ] , sprintf ( '%s/%s.twig' , $ controller , $ action ) ) ; } else { $ this -> encoder = new NullEncoder ( ) ; } }
Configures the view encoder based on the current options .
43,273
public function offsetSet ( $ key , $ value ) { if ( null === $ key ) { throw new \ Exception ( 'Config values must contain a key.' ) ; } $ this -> config [ $ key ] = $ value ; }
Sets the value associated with the given key .
43,274
public function get ( $ key , $ defaultValue = null ) { return $ this -> offsetExists ( $ key ) ? $ this -> offsetGet ( $ key ) : $ defaultValue ; }
Returns the value associated with the given key . An optional default value can be provided and will be returned if no value is associated with the key .
43,275
public function supportsControllerAndAction ( $ controller , $ action ) { if ( null === $ this -> blacklist ) { if ( null === $ this -> whitelist ) { return true ; } if ( ! isset ( $ this -> whitelist [ $ controller ] ) ) { return false ; } if ( is_array ( $ this -> whitelist [ $ controller ] ) ) { return in_array ( $ ...
Returns whether or not the given controller and action requested should invoke this plugin .
43,276
public function handleRoute ( $ environment = null ) { if ( null === $ environment ) { $ environment = PHP_SAPI ; } switch ( $ environment ) { case 'cli' : case 'phpdbg' : $ components = empty ( $ _SERVER [ 'argv' ] ) ? array ( ) : $ _SERVER [ 'argv' ] ; return $ this -> handleCliRoute ( $ components ) . PHP_EOL ; defa...
Handles the standard route . Determines the execution environment and makes the appropriate call .
43,277
public function handleHttpRoute ( $ path , $ query , $ post , $ verb ) { $ this -> logger -> debug ( "SnappyRouter: Handling HTTP route: $path" ) ; return $ this -> invokeHandler ( false , array ( $ path , $ query , $ post , $ verb ) ) ; }
Handles routing an HTTP request directly .
43,278
public function handleCliRoute ( $ pathComponents ) { $ this -> logger -> debug ( "SnappyRouter: Handling CLI route: " . implode ( "/" , $ pathComponents ) ) ; return $ this -> invokeHandler ( true , array ( $ pathComponents ) ) ; }
Handles routing a CLI request directly .
43,279
private function handleInvocationException ( $ exception , $ activeHandler , $ isCli ) { $ this -> logger -> debug ( sprintf ( "SnappyRouter: caught exception while invoking handler: %s (%d)" , $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ) ; if ( null !== $ activeHandler ) { $ activeHandler -> invokePl...
Attempts to mop up after an exception during handler invocation .
43,280
private function parseConfig ( ) { $ diClass = $ this -> config -> get ( Config :: KEY_DI ) ; if ( class_exists ( $ diClass ) ) { $ di = new $ diClass ( ) ; if ( $ di instanceof DiInterface ) { Di :: setDefault ( $ di ) ; } } Di :: getDefault ( ) -> set ( self :: KEY_CONFIG , $ this -> config ) ; $ this -> setupHandler...
Parses the config sets up the default DI and registers the config in the DI .
43,281
private function setupHandlers ( $ handlers ) { $ this -> handlers = array ( ) ; foreach ( $ handlers as $ handlerClass => $ handlerDetails ) { $ options = array ( ) ; if ( isset ( $ handlerDetails [ Config :: KEY_OPTIONS ] ) ) { $ options = ( array ) $ handlerDetails [ Config :: KEY_OPTIONS ] ; } if ( isset ( $ handle...
helper to setup the array of handlers
43,282
public function get ( $ element , $ useCache = true ) { if ( $ useCache && isset ( $ this -> elements [ $ element ] ) ) { return $ this -> elements [ $ element ] ; } if ( isset ( $ this -> elementMap [ $ element ] ) ) { if ( is_callable ( $ this -> elementMap [ $ element ] ) ) { $ this -> elements [ $ element ] = call_...
Returns the element associated with the specified key .
43,283
public function set ( $ key , $ element ) { unset ( $ this -> elements [ $ key ] ) ; $ this -> elementMap [ $ key ] = $ element ; return $ this ; }
Assigns a specific element to the given key . This method will override any previously assigned element for the given key .
43,284
public static function getDefault ( ) { if ( isset ( self :: $ instance ) ) { return self :: $ instance ; } self :: $ instance = new self ( ) ; return self :: $ instance ; }
Returns the current default DI instance .
43,285
private function getServiceFromPath ( $ path ) { $ path = implode ( '/' , array_filter ( array_map ( 'trim' , explode ( '/' , $ path ) ) , 'strlen' ) ) ; if ( isset ( $ this -> options [ self :: KEY_BASE_PATH ] ) ) { $ basePathPosition = strpos ( $ path , $ this -> options [ self :: KEY_BASE_PATH ] ) ; if ( false !== $...
Determine the service to load via the ServiceProvider based on path
43,286
private function processPayload ( $ service , $ verb , $ post ) { $ this -> batch = is_array ( $ post ) ; if ( false === $ this -> batch ) { $ post = array ( $ post ) ; } $ this -> requests = array_map ( function ( $ payload ) use ( $ service , $ verb ) { return new JsonRpcRequest ( $ service , $ payload , $ verb ) ; }...
Processes the payload POST data and sets up the array of requests .
43,287
private function invokeMethod ( $ service , JsonRpcRequest $ request ) { if ( false === $ request -> isValid ( ) ) { return new JsonRpcResponse ( null , new Exception ( 'The JSON sent is not a valid Request object' , self :: ERR_INVALID_REQUEST ) ) ; } $ action = $ request -> getAction ( ) ; $ this -> invokePluginsHook...
Invokes a method on a service class based on the raw JSON - RPC request .
43,288
public function setStatusCode ( $ statusCode ) { $ statusCode = intval ( $ statusCode ) ; $ this -> statusCode = ( $ statusCode > 0 ) ? $ statusCode : self :: RESPONSE_OK ; return $ this ; }
Sets the HTTP status code associated with this response .
43,289
public function setBody ( $ content , $ mime ) { $ this -> parameters = $ content ; $ this -> setMime ( $ mime ) ; return $ this ; }
Set the entire body of a POST or PUT request . The provided MIME type must reflect the content format of the string .
43,290
public function setPlugins ( $ plugins ) { $ this -> plugins = array ( ) ; foreach ( $ plugins as $ key => $ plugin ) { $ pluginClass = $ plugin ; if ( is_array ( $ plugin ) ) { if ( ! isset ( $ plugin [ Config :: KEY_CLASS ] ) ) { throw new PluginException ( 'Invalid or missing class for plugin ' . $ key ) ; } elseif ...
Sets the current list of plugins .
43,291
private function sortPlugins ( $ plugins ) { usort ( $ plugins , function ( $ a , $ b ) { return $ a -> getExecutionOrder ( ) - $ b -> getExecutionOrder ( ) ; } ) ; return $ plugins ; }
sorts the list of plugins according to their execution order
43,292
public function invokePluginsHook ( $ hook , $ args ) { foreach ( $ this -> getPlugins ( ) as $ plugin ) { if ( method_exists ( $ plugin , $ hook ) ) { call_user_func_array ( array ( $ plugin , $ hook ) , $ args ) ; } } }
Invokes the plugin hook against all the listed plugins .
43,293
public function setService ( $ key , $ service ) { $ this -> set ( $ key , $ service ) ; unset ( $ this -> instanceCache [ $ key ] ) ; return $ this ; }
Specifies the mapping between the given key and service .
43,294
public function getServiceInstance ( $ key , $ useCache = true ) { if ( $ useCache && isset ( $ this -> instanceCache [ $ key ] ) ) { return $ this -> instanceCache [ $ key ] ; } switch ( $ this -> provisioningMode ) { case self :: PROVISIONING_MODE_NAMESPACES : $ this -> instanceCache [ $ key ] = $ this -> getServiceF...
Returns an instance of the specified service .
43,295
public function setNamespaces ( $ namespaces ) { $ this -> set ( self :: KEY_NAMESPACES , $ namespaces ) ; $ this -> provisioningMode = self :: PROVISIONING_MODE_NAMESPACES ; return $ this ; }
Sets the list of namespaces and switches to namespace provisioning mode .
43,296
public function setFolders ( $ folders ) { $ this -> set ( self :: KEY_FOLDERS , $ folders ) ; $ this -> provisioningMode = self :: PROVISIONING_MODE_FOLDERS ; return $ this ; }
Sets the list of folders and switches to folder provisioning mode .
43,297
private function getServiceFromServiceList ( $ controllerClass ) { $ serviceClass = $ this -> get ( $ controllerClass ) ; if ( is_string ( $ serviceClass ) && ! class_exists ( $ serviceClass ) ) { require_once $ serviceClass ; $ serviceClass = $ controllerClass ; } elseif ( is_array ( $ serviceClass ) ) { if ( isset ( ...
Returns an instance of the specified controller using the existing the explicitly specified services list .
43,298
private function findFileInFolderRecursively ( $ file , $ folder ) { $ dir = dir ( $ folder ) ; while ( false !== ( $ item = $ dir -> read ( ) ) ) { if ( '.' === $ item || '..' === $ item ) { continue ; } $ fullPath = $ folder . DIRECTORY_SEPARATOR . $ item ; if ( 0 === strcasecmp ( $ item , $ file ) ) { return $ fullP...
Scan for the specific file recursively .
43,299
public function getParameters ( ) { if ( isset ( $ this -> payload -> params ) ) { return is_array ( $ this -> payload -> params ) ? $ this -> payload -> params : array ( $ this -> payload -> params ) ; } return array ( ) ; }
Get request parameters .