idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
53,000 | public function setCapacity ( $ capacity ) { if ( $ capacity !== NULL ) { if ( ! is_float ( $ capacity ) && ! is_int ( $ capacity ) ) { throw new InvalidArgumentException ( 'Invalid capacity given - must be numeric' ) ; } if ( $ capacity < 0 ) { throw new InvalidArgumentException ( 'Capacity must not be negative' ) ; }... | set new total capacity of this edge |
53,001 | public function destroy ( ) { $ this -> getGraph ( ) -> removeEdge ( $ this ) ; foreach ( $ this -> getVertices ( ) as $ vertex ) { $ vertex -> removeEdge ( $ this ) ; } } | destroy edge and remove reference from vertices and graph |
53,002 | public static function factoryFromEdges ( $ edges , Vertex $ startVertex ) { $ vertices = array ( $ startVertex ) ; $ vertexCurrent = $ startVertex ; foreach ( $ edges as $ edge ) { $ vertexCurrent = $ edge -> getVertexToFrom ( $ vertexCurrent ) ; $ vertices [ ] = $ vertexCurrent ; } return new self ( $ vertices , $ ed... | construct new walk from given start vertex and given array of edges |
53,003 | public static function factoryCycleFromPredecessorMap ( array $ predecessors , Vertex $ vertex , $ by = null , $ desc = false ) { $ vid = $ vertex -> getId ( ) ; $ startVertices = array ( ) ; do { if ( ! isset ( $ predecessors [ $ vid ] ) ) { throw new InvalidArgumentException ( 'Predecessor map is incomplete and does ... | create new cycle instance from given predecessor map |
53,004 | public static function factoryCycleFromVertices ( $ vertices , $ by = null , $ desc = false ) { $ cycle = self :: factoryFromVertices ( $ vertices , $ by , $ desc ) ; if ( $ cycle -> getEdges ( ) -> isEmpty ( ) ) { throw new InvalidArgumentException ( 'Cycle with no edges can not exist' ) ; } if ( $ cycle -> getVertice... | create new cycle instance with edges between given vertices |
53,005 | public static function factoryCycleFromEdges ( $ edges , Vertex $ startVertex ) { $ cycle = self :: factoryFromEdges ( $ edges , $ startVertex ) ; if ( $ cycle -> getVertices ( ) -> getVertexLast ( ) !== $ startVertex ) { throw new InvalidArgumentException ( 'The given array of edges does not represent a cycle' ) ; } r... | create new cycle instance with vertices connected by given edges |
53,006 | public function createGraph ( ) { $ graph = $ this -> getGraph ( ) -> createGraphCloneEdges ( $ this -> getEdges ( ) ) ; $ vertices = $ this -> getVertices ( ) -> getMap ( ) ; foreach ( $ graph -> getVertices ( ) -> getMap ( ) as $ vid => $ vertex ) { if ( ! isset ( $ vertices [ $ vid ] ) ) { $ vertex -> destroy ( ) ; ... | create new graph clone with only vertices and edges actually in the walk |
53,007 | public function getAlternatingSequence ( ) { $ edges = $ this -> edges -> getVector ( ) ; $ vertices = $ this -> vertices -> getVector ( ) ; $ ret = array ( ) ; for ( $ i = 0 , $ l = count ( $ this -> edges ) ; $ i < $ l ; ++ $ i ) { $ ret [ ] = $ vertices [ $ i ] ; $ ret [ ] = $ edges [ $ i ] ; } $ ret [ ] = $ vertice... | get alternating sequence of vertex edge vertex edge ... vertex |
53,008 | public function getAttributes ( ) { $ attributes = array ( ) ; $ len = strlen ( $ this -> prefix ) ; foreach ( $ this -> bag -> getAttributes ( ) as $ name => $ value ) { if ( strpos ( $ name , $ this -> prefix ) === 0 ) { $ attributes [ substr ( $ name , $ len ) ] = $ value ; } } return $ attributes ; } | get an array of all attributes |
53,009 | public function setAttributes ( array $ attributes ) { foreach ( $ attributes as $ name => $ value ) { $ this -> bag -> setAttribute ( $ this -> prefix . $ name , $ value ) ; } } | set an array of additional attributes |
53,010 | public function parseFile ( $ filename , $ uri_root = '' , $ returnRoot = false ) { if ( ! file_exists ( $ filename ) ) { $ this -> Error ( sprintf ( 'File `%s` not found.' , $ filename ) ) ; } if ( ! $ returnRoot && ! empty ( $ uri_root ) && basename ( $ uri_root ) == basename ( $ filename ) ) { $ uri_root = dirname (... | Parse a Less string from a given file |
53,011 | private function MatchQuoted ( $ quote_char , $ i ) { $ matched = '' ; while ( $ i < $ this -> input_len ) { $ c = $ this -> input [ $ i ] ; if ( $ c === '\\' ) { $ matched .= $ c . $ this -> input [ $ i + 1 ] ; $ i += 2 ; continue ; } if ( $ c === $ quote_char ) { $ this -> pos = $ i + 1 ; $ this -> skipWhitespace ( 0... | When PCRE JIT is enabled in php regular expressions don t work for matching quoted strings |
53,012 | public static function CleanCache ( ) { static $ clean = false ; if ( $ clean || empty ( Less_Cache :: $ cache_dir ) ) { return ; } $ clean = true ; $ remove_types = array ( 'lesscache' => 1 , 'list' => 1 , 'less' => 1 , 'map' => 1 ) ; $ files = scandir ( Less_Cache :: $ cache_dir ) ; if ( ! $ files ) { return ; } $ ch... | Delete unused less . php files |
53,013 | public function PathAndUri ( ) { $ evald_path = $ this -> getPath ( ) ; if ( $ evald_path ) { $ import_dirs = array ( ) ; if ( Less_Environment :: isPathRelative ( $ evald_path ) ) { $ import_dirs [ $ this -> currentFileInfo [ 'currentDirectory' ] ] = $ this -> currentFileInfo [ 'uri_root' ] ; } else { $ import_dirs [ ... | Using the import directories get the full absolute path and uri of the import |
53,014 | public function enable ( ) { global $ wp_filesystem ; $ plugin = $ GLOBALS [ 'redisObjectCache' ] ; if ( $ plugin -> object_cache_dropin_exists ( ) ) { if ( $ plugin -> validate_object_cache_dropin ( ) ) { WP_CLI :: line ( __ ( 'Redis object cache already enabled.' , 'redis-cache' ) ) ; } else { WP_CLI :: error ( __ ( ... | Enables the Redis object cache . |
53,015 | public function disable ( ) { global $ wp_filesystem ; $ plugin = $ GLOBALS [ 'redisObjectCache' ] ; if ( ! $ plugin -> object_cache_dropin_exists ( ) ) { WP_CLI :: error ( __ ( 'No object cache drop-in found.' , 'redis-cache' ) ) ; } else { if ( ! $ plugin -> validate_object_cache_dropin ( ) ) { WP_CLI :: error ( __ (... | Disables the Redis object cache . |
53,016 | public function update_dropin ( ) { global $ wp_filesystem ; WP_Filesystem ( ) ; if ( $ wp_filesystem -> copy ( WP_PLUGIN_DIR . '/redis-cache/includes/object-cache.php' , WP_CONTENT_DIR . '/object-cache.php' , true ) ) { WP_CLI :: success ( __ ( 'Updated object cache drop-in and enabled Redis object cache.' , 'redis-ca... | Updates the Redis object cache drop - in . |
53,017 | public function make ( $ options ) { if ( is_string ( $ options ) ) { return $ this -> makeFromUrl ( $ options ) ; } if ( is_array ( $ options ) ) { return $ this -> makeFromArray ( $ options ) ; } if ( $ options instanceof Closure ) { return $ this -> makeFromClosure ( $ options ) ; } throw new ConfigurationException ... | Create a new condition . |
53,018 | protected function getConditionTypeClass ( $ condition_type ) { if ( ! isset ( $ this -> condition_types [ $ condition_type ] ) ) { return null ; } return $ this -> condition_types [ $ condition_type ] ; } | Get condition class for condition type . |
53,019 | protected function parseNegatedCondition ( $ type , $ arguments ) { $ negated_type = substr ( $ type , strlen ( static :: NEGATE_CONDITION_PREFIX ) ) ; $ arguments = array_merge ( [ $ negated_type ] , $ arguments ) ; $ type = 'negate' ; $ condition = call_user_func ( [ $ this , 'make' ] , $ arguments ) ; return [ 'type... | Parse a negated condition and its arguments . |
53,020 | protected function parseConditionOptions ( $ options ) { $ type = $ options [ 0 ] ; $ arguments = array_values ( array_slice ( $ options , 1 ) ) ; if ( $ this -> isNegatedCondition ( $ type ) ) { return $ this -> parseNegatedCondition ( $ type , $ arguments ) ; } if ( ! $ this -> conditionTypeRegistered ( $ type ) ) { ... | Parse the condition type and its arguments from an options array . |
53,021 | protected function makeFromArray ( $ options ) { if ( count ( $ options ) === 0 ) { throw new ConfigurationException ( 'No condition type specified.' ) ; } if ( is_array ( $ options [ 0 ] ) ) { return $ this -> makeFromArrayOfConditions ( $ options ) ; } $ condition_options = $ this -> parseConditionOptions ( $ options... | Create a new condition from an array . |
53,022 | protected function makeFromArrayOfConditions ( $ options ) { $ conditions = array_map ( function ( $ condition ) { if ( $ condition instanceof ConditionInterface ) { return $ condition ; } return $ this -> make ( $ condition ) ; } , $ options ) ; return new MultipleCondition ( $ conditions ) ; } | Create a new condition from an array of conditions . |
53,023 | public function merge ( $ old , $ new ) { if ( empty ( $ old ) ) { if ( empty ( $ new ) ) { return null ; } return $ this -> condition ( $ new ) ; } else if ( empty ( $ new ) ) { return $ this -> condition ( $ old ) ; } return $ this -> mergeConditions ( $ this -> condition ( $ old ) , $ this -> condition ( $ new ) ) ;... | Merge group condition attribute . |
53,024 | public function mergeConditions ( ConditionInterface $ old , ConditionInterface $ new ) { if ( $ old instanceof UrlCondition && $ new instanceof UrlCondition ) { return $ old -> concatenate ( $ new -> getUrl ( ) , $ new -> getUrlWhere ( ) ) ; } return $ this -> makeFromArrayOfConditions ( [ $ old , $ new ] ) ; } | Merge condition instances . |
53,025 | public function expandMiddleware ( $ middleware ) { $ classes = [ ] ; foreach ( $ middleware as $ item ) { $ classes = array_merge ( $ classes , $ this -> expandMiddlewareMolecule ( $ item ) ) ; } return $ classes ; } | Expand array of middleware into an array of fully qualified class names . |
53,026 | public function expandMiddlewareGroup ( $ group ) { if ( ! isset ( $ this -> middleware_groups [ $ group ] ) ) { throw new ConfigurationException ( 'Unknown middleware group "' . $ group . '" used.' ) ; } $ middleware = $ this -> middleware_groups [ $ group ] ; if ( in_array ( $ group , $ this -> middleware_groups_with... | Expand a middleware group into an array of fully qualified class names . |
53,027 | public function expandMiddlewareMolecule ( $ middleware ) { $ pieces = explode ( ':' , $ middleware , 2 ) ; if ( count ( $ pieces ) > 1 ) { return [ array_merge ( [ $ this -> expandMiddlewareAtom ( $ pieces [ 0 ] ) ] , explode ( ',' , $ pieces [ 1 ] ) ) ] ; } if ( isset ( $ this -> middleware_groups [ $ middleware ] ) ... | Expand middleware into an array of fully qualified class names and any companion arguments . |
53,028 | public function expandMiddlewareAtom ( $ middleware ) { if ( isset ( $ this -> middleware [ $ middleware ] ) ) { return $ this -> middleware [ $ middleware ] ; } if ( class_exists ( $ middleware ) ) { return $ middleware ; } throw new ConfigurationException ( 'Unknown middleware "' . $ middleware . '" used.' ) ; } | Expand a single middleware a fully qualified class name . |
53,029 | public function applyQueryFilter ( $ request , $ query_vars ) { $ condition = $ this -> getCondition ( ) ; if ( $ this -> getQueryFilter ( ) === null ) { return $ query_vars ; } if ( ! $ condition instanceof UrlCondition ) { throw new ConfigurationException ( 'Only routes with URL condition can use queries. ' . 'Make s... | Apply the query filter if any . |
53,030 | public function mergeConditionAttribute ( $ old , $ new ) { try { $ condition = $ this -> condition_factory -> merge ( $ old , $ new ) ; } catch ( ConfigurationException $ e ) { throw new ConfigurationException ( 'Route condition is not a valid route string or condition.' ) ; } return $ condition ; } | Merge the condition attribute . |
53,031 | public function mergeQueryAttribute ( $ old , $ new ) { if ( $ new === null ) { return $ old ; } if ( $ old === null ) { return $ new ; } return function ( $ query_vars ) use ( $ old , $ new ) { return call_user_func ( $ new , call_user_func ( $ old , $ query_vars ) ) ; } ; } | Merge the handler attribute taking the latest value . |
53,032 | public function mergeAttributes ( $ old , $ new ) { $ attributes = [ 'methods' => $ this -> mergeMethodsAttribute ( ( array ) Arr :: get ( $ old , 'methods' , [ ] ) , ( array ) Arr :: get ( $ new , 'methods' , [ ] ) ) , 'condition' => $ this -> mergeConditionAttribute ( Arr :: get ( $ old , 'condition' , null ) , Arr :... | Merge attributes into route . |
53,033 | public function group ( $ attributes , $ routes ) { $ this -> pushGroup ( $ attributes ) ; if ( is_string ( $ routes ) ) { require_once $ routes ; } else { $ routes ( ) ; } $ this -> popGroup ( ) ; } | Create a route group . |
53,034 | protected function routeCondition ( $ condition ) { if ( $ condition === null ) { throw new ConfigurationException ( 'No route condition specified. Did you miss to call url() or where()?' ) ; } if ( ! $ condition instanceof ConditionInterface ) { $ condition = $ this -> condition_factory -> make ( $ condition ) ; } ret... | Make a route condition . |
53,035 | public function route ( $ attributes ) { $ attributes = $ this -> mergeAttributes ( $ this -> getGroup ( ) , $ attributes ) ; $ methods = Arr :: get ( $ attributes , 'methods' , [ ] ) ; $ condition = Arr :: get ( $ attributes , 'condition' , null ) ; $ handler = Arr :: get ( $ attributes , 'handler' , '' ) ; $ namespac... | Make a route . |
53,036 | protected function getResponse ( $ response ) { if ( is_string ( $ response ) ) { return Response :: output ( $ response ) ; } if ( is_array ( $ response ) ) { return Response :: json ( $ response ) ; } if ( $ response instanceof ResponsableInterface ) { return $ response -> toResponse ( ) ; } return $ response ; } | Convert a user returned response to a ResponseInterface instance if possible . Return the original value if unsupported . |
53,037 | public function getContext ( $ key = null , $ default = null ) { if ( $ key === null ) { return $ this -> context ; } return Arr :: get ( $ this -> context , $ key , $ default ) ; } | Get context values . |
53,038 | public function with ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> context = array_merge ( $ this -> getContext ( ) , $ key ) ; } else { $ this -> context [ $ key ] = $ value ; } return $ this ; } | Add context values . |
53,039 | public static function getPath ( RequestInterface $ request ) { $ url = $ request -> getUrl ( ) ; $ relative_url = substr ( $ url , strlen ( home_url ( '/' ) ) ) ; $ relative_url = static :: addLeadingSlash ( $ relative_url ) ; $ relative_url = preg_replace ( '~\?.*~' , '' , $ relative_url ) ; $ relative_url = static :... | Get the path for the request relative to the home url |
53,040 | public function methods ( $ methods ) { $ methods = array_merge ( $ this -> getAttribute ( 'methods' , [ ] ) , $ methods ) ; return $ this -> attribute ( 'methods' , $ methods ) ; } | Match requests using one of the specified methods . |
53,041 | public function where ( $ condition ) { if ( ! $ condition instanceof ConditionInterface ) { $ condition = func_get_args ( ) ; } $ condition = $ this -> router -> mergeConditionAttribute ( $ this -> getAttribute ( 'condition' ) , $ condition ) ; return $ this -> attribute ( 'condition' , $ condition ) ; } | Set the condition attribute . |
53,042 | public function middleware ( $ middleware ) { $ middleware = array_merge ( ( array ) $ this -> getAttribute ( 'middleware' , [ ] ) , ( array ) $ middleware ) ; return $ this -> attribute ( 'middleware' , $ middleware ) ; } | Set the middleware attribute . |
53,043 | public function query ( $ query ) { $ query = $ this -> router -> mergeQueryAttribute ( $ this -> getAttribute ( 'query' , null ) , $ query ) ; return $ this -> attribute ( 'query' , $ query ) ; } | Set the query attribute . |
53,044 | public function handle ( $ handler = '' ) { if ( ! empty ( $ handler ) ) { $ this -> attribute ( 'handler' , $ handler ) ; } $ this -> router -> addRoute ( $ this -> router -> route ( $ this -> getAttributes ( ) ) ) ; } | Create a route . |
53,045 | public function getMiddlewarePriorityForMiddleware ( $ middleware ) { if ( is_array ( $ middleware ) ) { $ middleware = $ middleware [ 0 ] ; } $ increasing_priority = array_reverse ( $ this -> middleware_priority ) ; $ priority = array_search ( $ middleware , $ increasing_priority ) ; return $ priority !== false ? ( in... | Get priority for a specific middleware . This is in reverse compared to definition order . Middleware with unspecified priority will yield - 1 . |
53,046 | public function sortMiddleware ( $ middleware ) { $ sorted = $ middleware ; usort ( $ sorted , function ( $ a , $ b ) use ( $ middleware ) { $ a_priority = $ this -> getMiddlewarePriorityForMiddleware ( $ a ) ; $ b_priority = $ this -> getMiddlewarePriorityForMiddleware ( $ b ) ; $ priority = $ b_priority - $ a_priorit... | Sort array of fully qualified middleware class names by priority in ascending order . |
53,047 | public function extendConfig ( $ container , $ key , $ default ) { $ config = isset ( $ container [ WPEMERGE_CONFIG_KEY ] ) ? $ container [ WPEMERGE_CONFIG_KEY ] : [ ] ; $ config = Arr :: get ( $ config , $ key , $ default ) ; if ( $ config !== $ default && is_array ( $ config ) && is_array ( $ default ) ) { $ config =... | Extends the WP Emerge config in the container with a new key . |
53,048 | public function run ( RequestInterface $ request , $ arguments ) { return $ this -> executeMiddleware ( $ this -> middleware , $ request , function ( ) use ( $ arguments ) { return call_user_func_array ( [ $ this -> getHandler ( ) , 'execute' ] , $ arguments ) ; } ) ; } | Get a response for the given request . |
53,049 | public function filterRequest ( $ query_vars ) { $ routes = $ this -> router -> getRoutes ( ) ; foreach ( $ routes as $ route ) { if ( ! $ route instanceof HasQueryFilterInterface ) { continue ; } if ( ! $ route -> isSatisfied ( $ this -> request ) ) { continue ; } $ query_vars = $ route -> applyQueryFilter ( $ this ->... | Filter the main query vars . |
53,050 | public function filterTemplateInclude ( $ view ) { global $ wp_query ; $ response = $ this -> handle ( $ this -> request , [ $ view ] ) ; if ( $ response instanceof ResponseInterface ) { if ( $ response -> getStatusCode ( ) === 404 ) { $ wp_query -> set_404 ( ) ; } return WPEMERGE_DIR . DIRECTORY_SEPARATOR . 'src' . DI... | Filter the main template file . |
53,051 | public function registerAjaxAction ( ) { if ( ! defined ( 'DOING_AJAX' ) || ! DOING_AJAX ) { return ; } $ action = $ this -> request -> post ( 'action' , $ this -> request -> get ( 'action' ) ) ; $ action = sanitize_text_field ( $ action ) ; add_action ( "wp_ajax_{$action}" , [ $ this , 'actionAjax' ] ) ; add_action ( ... | Register ajax action to hook into current one . |
53,052 | public function actionAjax ( ) { $ response = $ this -> handle ( $ this -> request , [ '' ] ) ; if ( ! $ response instanceof ResponseInterface ) { return ; } Response :: respond ( $ response ) ; wp_die ( '' , '' , [ 'response' => null ] ) ; } | Act on ajax action . |
53,053 | public function registerAdminAction ( ) { global $ pagenow ; if ( $ pagenow !== 'admin.php' ) { return ; } $ page_hook = $ this -> getAdminPageHook ( ) ; $ hook_suffix = $ this -> getAdminHook ( $ page_hook ) ; add_action ( "load-{$hook_suffix}" , [ $ this , 'actionAdminLoad' ] ) ; add_action ( $ hook_suffix , [ $ this... | Register admin action to hook into current one . |
53,054 | public function actionAdminLoad ( ) { $ response = $ this -> handle ( $ this -> request , [ '' ] ) ; if ( ! $ response instanceof ResponseInterface ) { return ; } if ( ! headers_sent ( ) ) { Response :: sendHeaders ( $ response ) ; } } | Act on admin action load . |
53,055 | public function actionAdmin ( ) { $ response = $ this -> app -> resolve ( WPEMERGE_RESPONSE_KEY ) ; if ( $ response === null ) { return ; } Response :: sendBody ( $ response ) ; } | Act on admin action . |
53,056 | public function getTokenFromRequest ( RequestInterface $ request ) { if ( $ request -> get ( $ this -> key ) ) { return $ request -> get ( $ this -> key ) ; } if ( $ request -> post ( $ this -> key ) ) { return $ request -> post ( $ this -> key ) ; } if ( $ request -> headers ( $ this -> header ) ) { return $ request -... | Get the csrf token from a request . |
53,057 | public function isValidToken ( $ token , $ action = - 1 ) { $ action = $ action === - 1 ? session_id ( ) : $ action ; $ lifetime = ( int ) wp_verify_nonce ( $ token , $ action ) ; return ( $ lifetime > 0 && $ lifetime <= $ this -> maximum_lifetime ) ; } | Check if a token is valid . |
53,058 | public function setUrl ( $ url ) { if ( $ url !== static :: WILDCARD ) { $ url = UrlUtility :: addLeadingSlash ( UrlUtility :: addTrailingSlash ( $ url ) ) ; } $ this -> url = $ url ; } | Set the url for this condition . |
53,059 | public function concatenate ( $ url , $ where = [ ] ) { if ( $ this -> getUrl ( ) === static :: WILDCARD || $ url === static :: WILDCARD ) { return new static ( static :: WILDCARD ) ; } $ leading = UrlUtility :: addLeadingSlash ( UrlUtility :: removeTrailingSlash ( $ this -> getUrl ( ) ) , true ) ; $ trailing = UrlUtil... | Append a url to this one returning a new instance . |
53,060 | protected function replacePatternParameterWithPlaceholder ( $ matches , & $ parameters ) { $ name = $ matches [ 'name' ] ; $ optional = ! empty ( $ matches [ 'optional' ] ) ; $ replacement = '/(?P<' . $ name . '>' . $ this -> parameter_pattern . ')' ; if ( $ optional ) { $ replacement = '(?:' . $ replacement . ')?' ; }... | Validation pattern replace callback . |
53,061 | public function getValidationPattern ( $ url , $ wrap = true ) { $ parameters = [ ] ; $ validation_pattern = preg_replace_callback ( $ this -> url_pattern , function ( $ matches ) use ( & $ parameters ) { return $ this -> replacePatternParameterWithPlaceholder ( $ matches , $ parameters ) ; } , $ url ) ; $ validation_p... | Get pattern to test whether normal urls match the parameter - based one . |
53,062 | protected function makeView ( $ name , $ filepath ) { $ view = ( new PhpView ( ) ) -> setName ( $ name ) -> setFilepath ( $ filepath ) ; $ layout = $ this -> getViewLayout ( $ view ) ; if ( $ layout !== null ) { $ view -> setLayout ( $ layout ) ; } return $ view ; } | Create a view instance . |
53,063 | protected function getViewLayout ( PhpView $ view ) { $ layout_headers = array_filter ( get_file_data ( $ view -> getFilepath ( ) , [ 'App Layout' ] ) ) ; if ( empty ( $ layout_headers ) ) { return null ; } $ layout_file = trim ( $ layout_headers [ 0 ] ) ; if ( ! $ this -> exists ( $ layout_file ) ) { throw new ViewNot... | Create a view instance for the given view s layout header if any . |
53,064 | protected function resolveFilepath ( $ view ) { $ view = $ this -> resolveRelativeFilepath ( $ view ) ; $ file = $ this -> resolveFromCustomFilepath ( $ view ) ; if ( ! $ file ) { $ file = $ this -> resolveFromThemeFilepath ( $ view ) ; } if ( ! $ file ) { $ file = $ this -> resolveFromAbsoluteFilepath ( $ view ) ; } i... | Resolve a view name to an absolute filepath . |
53,065 | protected function resolveRelativeFilepath ( $ view ) { $ normalized_view = MixedType :: normalizePath ( $ view ) ; $ paths = [ STYLESHEETPATH , TEMPLATEPATH ] ; foreach ( $ paths as $ path ) { $ path = MixedType :: addTrailingSlash ( $ path ) ; if ( substr ( $ normalized_view , 0 , strlen ( $ path ) ) === $ path ) { r... | Resolve an absolute view to a relative one if possible . |
53,066 | protected function resolveFromCustomFilepath ( $ view ) { $ directory = $ this -> getDirectory ( ) ; if ( $ directory === '' ) { return '' ; } $ file = MixedType :: normalizePath ( $ directory . DIRECTORY_SEPARATOR . $ view ) ; if ( ! file_exists ( $ file ) ) { $ file .= '.php' ; } ; return file_exists ( $ file ) ? $ f... | Resolve a view if it exists in the custom views directory . |
53,067 | protected function resolveFromThemeFilepath ( $ view ) { $ file = locate_template ( $ view , false ) ; if ( ! $ file ) { $ file = locate_template ( $ view . '.php' , false ) ; } return $ file ; } | Resolve a view if it exists in the current theme . |
53,068 | public function get ( $ key , $ default = null ) { return Arr :: get ( $ this -> flash -> get ( $ this -> flash_key , [ ] ) , $ key , $ default ) ; } | Get request value for key from the previous request . |
53,069 | protected function compose ( ) { $ context = $ this -> getContext ( ) ; $ this -> with ( [ 'global' => View :: getGlobals ( ) ] ) ; View :: compose ( $ this ) ; $ this -> with ( $ context ) ; return $ this ; } | Compose the context . |
53,070 | protected function render ( ) { $ __context = $ this -> getContext ( ) ; ob_start ( ) ; extract ( $ __context , EXTR_OVERWRITE ) ; include $ this -> getFilepath ( ) ; return ob_get_clean ( ) ; } | Render the view to a string . |
53,071 | public function addGlobals ( $ globals ) { foreach ( $ globals as $ key => $ value ) { $ this -> addGlobal ( $ key , $ value ) ; } } | Set an array of global variables . |
53,072 | public function getComposersForView ( $ view ) { $ view = ViewEngine :: canonical ( $ view ) ; $ composers = [ ] ; foreach ( $ this -> composers as $ composer ) { if ( in_array ( $ view , $ composer [ 'views' ] , true ) ) { $ composers [ ] = $ composer [ 'composer' ] ; } } return $ composers ; } | Get view composer . |
53,073 | public function addComposer ( $ views , $ composer ) { $ views = array_map ( function ( $ view ) { return ViewEngine :: canonical ( $ view ) ; } , MixedType :: toArray ( $ views ) ) ; $ handler = new Handler ( $ composer , 'compose' , '\\App\\ViewComposers\\' ) ; $ this -> composers [ ] = [ 'views' => $ views , 'compos... | Add view composer . |
53,074 | public function compose ( ViewInterface $ view ) { $ composers = $ this -> getComposersForView ( $ view -> getName ( ) ) ; foreach ( $ composers as $ composer ) { $ composer -> execute ( $ view ) ; } } | Get the composed context for a view . Passes all arguments to the composer . |
53,075 | public function setStore ( & $ store ) { if ( ! $ this -> isValidStore ( $ store ) ) { return ; } $ this -> store = & $ store ; if ( ! isset ( $ this -> store [ $ this -> store_key ] ) ) { $ this -> store [ $ this -> store_key ] = [ static :: CURRENT_KEY => [ ] , static :: NEXT_KEY => [ ] , ] ; } $ this -> flashed = $ ... | Set the store for flash messages . |
53,076 | protected function getFromRequest ( $ request_key , $ key = null , $ default = [ ] ) { $ this -> validateStore ( ) ; if ( $ key === null ) { return Arr :: get ( $ this -> flashed , $ request_key , $ default ) ; } return Arr :: get ( $ this -> flashed [ $ request_key ] , $ key , $ default ) ; } | Get the entire store or the values for a key for a request . |
53,077 | protected function addToRequest ( $ request_key , $ key , $ new_items ) { $ this -> validateStore ( ) ; $ new_items = MixedType :: toArray ( $ new_items ) ; $ items = MixedType :: toArray ( $ this -> get ( $ key , [ ] ) ) ; $ this -> flashed [ $ request_key ] [ $ key ] = array_merge ( $ items , $ new_items ) ; } | Add values for a key for a request . |
53,078 | protected function clearFromRequest ( $ request_key , $ key = null ) { $ this -> validateStore ( ) ; $ keys = $ key === null ? array_keys ( $ this -> flashed [ $ request_key ] ) : [ $ key ] ; foreach ( $ keys as $ k ) { unset ( $ this -> flashed [ $ request_key ] [ $ k ] ) ; } } | Remove all values or values for a key from a request . |
53,079 | public function shift ( ) { $ this -> validateStore ( ) ; $ this -> flashed [ static :: CURRENT_KEY ] = $ this -> flashed [ static :: NEXT_KEY ] ; $ this -> flashed [ static :: NEXT_KEY ] = [ ] ; } | Shift current store and replace it with next store . |
53,080 | public static function addTrailingSlash ( $ path , $ slash = DIRECTORY_SEPARATOR ) { $ path = static :: normalizePath ( $ path , $ slash ) ; $ path = preg_replace ( '~' . preg_quote ( $ slash , '~' ) . '*$~' , $ slash , $ path ) ; return $ path ; } | Ensure path has a trailing slash . |
53,081 | public static function removeTrailingSlash ( $ path , $ slash = DIRECTORY_SEPARATOR ) { $ path = static :: normalizePath ( $ path , $ slash ) ; $ path = preg_replace ( '~' . preg_quote ( $ slash , '~' ) . '+$~' , '' , $ path ) ; return $ path ; } | Ensure path does not have a trailing slash . |
53,082 | public function sendHeaders ( ResponseInterface $ response ) { header ( sprintf ( 'HTTP/%s %s %s' , $ response -> getProtocolVersion ( ) , $ response -> getStatusCode ( ) , $ response -> getReasonPhrase ( ) ) ) ; foreach ( $ response -> getHeaders ( ) as $ name => $ values ) { foreach ( $ values as $ value ) { header (... | Send a request s headers to the client . |
53,083 | protected function getBody ( ResponseInterface $ response ) { $ body = $ response -> getBody ( ) ; if ( $ body -> isSeekable ( ) ) { $ body -> rewind ( ) ; } return $ body ; } | Get a response s body stream so it is ready to be read . |
53,084 | protected function getBodyContentLength ( ResponseInterface $ response ) { $ content_length = $ response -> getHeaderLine ( 'Content-Length' ) ; if ( ! $ content_length ) { $ body = $ this -> getBody ( $ response ) ; $ content_length = $ body -> getSize ( ) ; } if ( ! is_numeric ( $ content_length ) ) { $ content_lengt... | Get a response s body s content length . |
53,085 | public function sendBody ( ResponseInterface $ response , $ chunk_size = 4096 ) { $ body = $ this -> getBody ( $ response ) ; $ content_length = $ this -> getBodyContentLength ( $ response ) ; if ( $ content_length > 0 ) { $ this -> sendBodyWithLength ( $ body , $ content_length , $ chunk_size ) ; } else { $ this -> se... | Send a request s body to the client . |
53,086 | protected function sendBodyWithoutLength ( StreamInterface $ body , $ chunk_size ) { while ( ! $ body -> eof ( ) ) { echo $ body -> read ( $ chunk_size ) ; if ( connection_status ( ) !== CONNECTION_NORMAL ) { break ; } } } | Send a body with an unknown length to the client . |
53,087 | protected function sendBodyWithLength ( StreamInterface $ body , $ length , $ chunk_size ) { $ content_left = $ length ; while ( $ content_left > 0 ) { $ read = min ( $ chunk_size , $ content_left ) ; if ( $ read <= 0 ) { break ; } echo $ body -> read ( $ read ) ; $ content_left -= $ read ; if ( connection_status ( ) !... | Send a body with a known length to the client . |
53,088 | public function output ( $ output ) { $ response = $ this -> response ( ) ; $ response = $ response -> withBody ( Psr7 \ stream_for ( $ output ) ) ; return $ response ; } | Get a cloned response with the passed string as the body . |
53,089 | public function json ( $ data ) { $ response = $ this -> response ( ) ; $ response = $ response -> withHeader ( 'Content-Type' , 'application/json' ) ; $ response = $ response -> withBody ( Psr7 \ stream_for ( wp_json_encode ( $ data ) ) ) ; return $ response ; } | Get a cloned response json encoding the passed data as the body . |
53,090 | public function getBindingForFile ( $ file ) { $ engine_key = $ this -> default ; foreach ( $ this -> bindings as $ suffix => $ engine ) { if ( substr ( $ file , - strlen ( $ suffix ) ) === $ suffix ) { $ engine_key = $ engine ; break ; } } return $ engine_key ; } | Get the engine key binding for a specific file |
53,091 | public function back ( $ fallback = '' , $ status = 302 ) { $ url = $ this -> request -> headers ( 'Referer' ) ; if ( empty ( $ url ) ) { $ url = $ fallback ; } if ( empty ( $ url ) ) { $ url = $ this -> request -> getUrl ( ) ; } return $ this -> to ( $ url , $ status ) ; } | Get a response redirecting back to the referrer or a fallback . |
53,092 | public function bootstrap ( $ config = [ ] , $ run = true ) { $ this -> renderConfigurationExceptions ( function ( ) use ( $ config , $ run ) { if ( $ this -> isBootstrapped ( ) ) { throw new ConfigurationException ( static :: class . ' already bootstrapped.' ) ; } $ container = $ this -> getContainer ( ) ; $ this -> l... | Bootstrap the application . WordPress after_setup_theme action is a good place to call this . |
53,093 | protected function loadConfig ( Container $ container , $ config ) { $ container [ WPEMERGE_CONFIG_KEY ] = array_merge ( $ container [ WPEMERGE_CONFIG_KEY ] , $ config ) ; } | Load config into the service container . |
53,094 | protected function loadServiceProviders ( Container $ container ) { $ container [ WPEMERGE_SERVICE_PROVIDERS_KEY ] = array_merge ( $ this -> service_providers , $ container [ WPEMERGE_CONFIG_KEY ] [ 'providers' ] ) ; $ service_providers = array_map ( function ( $ service_provider ) { if ( ! is_subclass_of ( $ service_p... | Register and bootstrap all service providers . |
53,095 | protected function registerServiceProviders ( $ service_providers , Container $ container ) { foreach ( $ service_providers as $ provider ) { $ provider -> register ( $ container ) ; } } | Register all service providers . |
53,096 | protected function bootstrapServiceProviders ( $ service_providers , Container $ container ) { foreach ( $ service_providers as $ provider ) { $ provider -> bootstrap ( $ container ) ; } } | Bootstrap all service providers . |
53,097 | protected function loadRoutes ( $ web = '' , $ admin = '' , $ ajax = '' ) { if ( defined ( 'DOING_AJAX' ) && DOING_AJAX ) { $ this -> loadRoutesFile ( $ ajax , [ 'namespace' => '\\App\\Controllers\\Ajax\\' , 'middleware' => [ 'ajax' ] , ] ) ; return ; } if ( is_admin ( ) ) { $ this -> loadRoutesFile ( $ admin , [ 'name... | Load route definition files depending on the current request . |
53,098 | protected function loadRoutesFile ( $ file , $ attributes ) { if ( empty ( $ file ) ) { return ; } Route :: attributes ( $ attributes ) -> group ( $ file ) ; } | Load a route definition file applying attributes to all routes defined within . |
53,099 | public function resolve ( $ key ) { $ this -> verifyBootstrap ( ) ; if ( ! isset ( $ this -> getContainer ( ) [ $ key ] ) ) { return null ; } return $ this -> getContainer ( ) [ $ key ] ; } | Resolve a dependency from the IoC container . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.