idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
58,100 | public function handle ( ) { if ( ! ( $ this -> exception instanceof \ ErrorException ) ) { $ this -> quit = true ; } else { switch ( $ this -> exception -> getSeverity ( ) ) { case E_ERROR : case E_CORE_ERROR : case E_USER_ERROR : $ this -> quit = true ; } } return self :: get_html ( $ this -> exception ) ; } | Handle an error with the most basic handler |
58,101 | public static function get_subject ( $ exception ) { $ application = null ; try { $ application = \ Skeleton \ Core \ Application :: get ( ) ; } catch ( \ Exception $ e ) { } if ( $ application === null ) { $ hostname = 'unknown' ; $ name = 'unknown' ; } else { $ hostname = $ application -> hostname ; $ name = $ applic... | Produce a subject based on the error |
58,102 | public static function get_html ( $ exception ) { $ subject = self :: get_subject ( $ exception ) ; if ( $ exception instanceof \ ErrorException ) { $ error_type = \ Skeleton \ Error \ Util \ Misc :: translate_error_code ( $ exception -> getSeverity ( ) ) ; } else { $ error_type = 'Exception' ; } $ error_info = '' ; $ ... | Produce some HTML around the error |
58,103 | public function loadRelFor ( Models $ models , $ relName , $ flags = null ) { $ rel = $ this -> getRelOrError ( $ relName ) ; $ foreign = $ rel -> loadModelsIfAvailable ( $ models , $ flags ) ; $ rel -> linkModels ( $ models , $ foreign , function ( AbstractLink $ link ) { $ class = get_class ( $ link -> getModel ( ) )... | Load models for a given relation . |
58,104 | public function loadAllRelsFor ( Models $ models , array $ rels , $ flags = null ) { $ rels = Arr :: toAssoc ( $ rels ) ; foreach ( $ rels as $ relName => $ childRels ) { $ foreign = $ this -> loadRelFor ( $ models , $ relName , $ flags ) ; if ( $ childRels ) { $ rel = $ this -> getRel ( $ relName ) ; $ rel -> getRepo ... | Load all the models for the provided relations . This is the meat of the eager loading |
58,105 | public function updateModels ( Models $ models ) { foreach ( $ models as $ model ) { if ( $ model -> isSoftDeleted ( ) ) { $ this -> dispatchBeforeEvent ( $ model , Event :: DELETE ) ; } else { $ this -> dispatchBeforeEvent ( $ model , Event :: UPDATE ) ; $ this -> dispatchBeforeEvent ( $ model , Event :: SAVE ) ; } } ... | Call all the events associated with model updates . Perform the update itself . |
58,106 | public function deleteModels ( Models $ models ) { foreach ( $ models as $ model ) { $ this -> dispatchBeforeEvent ( $ model , Event :: DELETE ) ; } $ this -> deleteAll ( ) -> executeModels ( $ models ) ; foreach ( $ models as $ model ) { $ this -> dispatchAfterEvent ( $ model , Event :: DELETE ) ; } return $ this ; } | Call all the events associated with model deletion . Perform the deletion itself . |
58,107 | public function insertModels ( Models $ models ) { foreach ( $ models as $ model ) { $ this -> dispatchBeforeEvent ( $ model , Event :: INSERT ) ; $ this -> dispatchBeforeEvent ( $ model , Event :: SAVE ) ; } $ this -> insertAll ( ) -> executeModels ( $ models ) ; foreach ( $ models as $ model ) { $ model -> resetOrigi... | Call all the events associated with model insertion . Perform the insertion itself . |
58,108 | protected function build ( OutputInterface $ output ) { $ this -> command -> run ( $ this -> input , $ output ) ; $ this -> lastBuild = new DateTime ( ) ; } | Run the build command |
58,109 | public static function setUp ( NodeName $ nodeName , array $ tasks , array $ config = array ( ) ) { $ instance = new static ( ) ; $ instance -> assertConfig ( $ config ) ; $ processId = ProcessId :: generate ( ) ; $ taskList = TaskList :: scheduleTasks ( TaskListId :: linkWith ( $ nodeName , $ processId ) , $ tasks ) ;... | Creates new process from given tasks and config |
58,110 | public function receiveMessage ( $ message , WorkflowEngine $ workflowEngine ) { if ( $ message instanceof WorkflowMessage ) { if ( MessageNameUtils :: isProcessingCommand ( $ message -> messageName ( ) ) ) { $ this -> perform ( $ workflowEngine , $ message ) ; return ; } $ this -> assertTaskEntryExists ( $ message -> ... | A Process can start or continue with the next step after it has received a message |
58,111 | public function assertIsEmpty ( $ value , $ message = '%s must not be empty' , $ exception = 'Asserts' ) { if ( isset ( $ value ) === false || empty ( $ value ) ) { $ this -> throwException ( $ exception , $ message , $ value ) ; } } | Verifies that the specified condition is not empty . The assertion fails if the condition is empty . |
58,112 | private static function makeCallable ( $ expression ) { if ( ! array_key_exists ( $ expression , static :: $ map ) ) { $ return = "return ($expression);" ; try { $ lambda = create_function ( static :: $ signature , $ return ) ; } catch ( \ ParseError $ ex ) { $ lambda = false ; } finally { if ( false === $ lambda ) { t... | Given a string expression turn that into an anonymous function . Cache the result so as to keep memory impacts low . |
58,113 | public function setCookie ( $ cookieName , $ value = null , $ expire = null ) { if ( $ expire !== null ) { $ expire = time ( ) + ( 60 * 60 * $ expire ) ; } if ( setcookie ( $ cookieName , $ this -> encodeCookie ( $ value ) , $ expire , "/" ) ) { return true ; } else { return false ; } } | Sets a cookie in the user s browser |
58,114 | public function getCookie ( $ cookieName ) { if ( isset ( $ _COOKIE [ $ cookieName ] ) ) { return $ this -> decodeCookie ( $ _COOKIE [ $ cookieName ] ) ; } else { return false ; } } | Check if a cookie is set and returns its content |
58,115 | public function taggedWith ( $ tag ) { $ results = [ ] ; if ( isset ( $ this -> tags [ $ tag ] ) ) { foreach ( $ this -> tags [ $ tag ] as $ view ) { $ results [ ] = $ view ; } } return $ results ; } | Return all the views for a given tag . |
58,116 | private function registerFilters ( ) { $ filters = config ( 'app.render_filters' , [ ] ) ; foreach ( $ filters as $ filter ) { $ filter = app ( $ filter ) ; if ( $ filter instanceof FilterContract ) { $ this -> twigEnvironment -> addFilter ( new \ Twig_SimpleFilter ( $ filter -> getName ( ) , $ filter -> getFilter ( ) ... | Registers the template filters . |
58,117 | public function addPath ( $ path ) { try { $ this -> twigFileLoader -> addPath ( $ path ) ; } catch ( \ Twig_Error_Loader $ e ) { throw new InvalidPathException ( $ e -> getMessage ( ) ) ; } } | Adds a path to the template environment . |
58,118 | public function getData ( ) { $ systemInformation = [ ] ; $ systemInformation [ 'newup_version' ] = Application :: VERSION ; return $ this -> dataArray + $ systemInformation + $ this -> collectData ( ) ; } | Gets the environment data . |
58,119 | public function render ( $ templateName ) { try { return $ this -> twigEnvironment -> render ( $ templateName , $ this -> getData ( ) ) ; } catch ( SecurityException $ e ) { throw new SecurityException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } catch ( \ Twig_Error_Runtime $ e ) { throw new RuntimeExcepti... | Renders a template by name . |
58,120 | public function renderString ( $ templateString ) { try { return $ this -> twigStringEnvironment -> render ( $ templateString , $ this -> getData ( ) ) ; } catch ( SecurityException $ e ) { throw new SecurityException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } catch ( \ Twig_Error_Runtime $ e ) { throw ne... | Renders a string as a template . |
58,121 | public function collectData ( ) { $ collectedData = [ ] ; foreach ( $ this -> dataCollectors as $ collector ) { $ collectedData = $ collectedData + $ collector -> collect ( ) ; } return $ collectedData ; } | Collects all data from data collectors . |
58,122 | public static function instance ( ) : NumberSyntax { if ( self :: $ instance === null ) self :: $ instance = new NumberSyntax ; return self :: $ instance ; } | Returns the NumberSyntax instance . |
58,123 | public function set_hostname ( $ hostname , $ port_number = null ) { if ( $ this -> override_hostname ) { $ this -> hostname = $ hostname ; if ( $ port_number ) { $ this -> port_number = $ port_number ; $ this -> hostname .= ':' . ( string ) $ this -> port_number ; } } return $ this ; } | Set the hostname to connect to . This is useful for alternate services that are API - compatible with AWS but run from a different hostname . |
58,124 | public function set_cache_config ( $ location , $ gzip = true ) { if ( is_array ( $ location ) ) { $ this -> cache_class = 'CacheMC' ; } else { $ type = strtolower ( substr ( $ location , 0 , 3 ) ) ; switch ( $ type ) { case 'apc' : $ this -> cache_class = 'CacheAPC' ; break ; case 'xca' : $ this -> cache_class = 'Cach... | Set the caching configuration to use for response caching . |
58,125 | public function batch ( CFBatchRequest & $ queue = null ) { if ( $ queue ) { $ this -> batch_object = $ queue ; } elseif ( $ this -> internal_batch_object ) { $ this -> batch_object = & $ this -> internal_batch_object ; } else { $ this -> internal_batch_object = new $ this -> batch_class ( ) ; $ this -> batch_object = ... | Specifies that the intended request should be queued for a later batch request . |
58,126 | public function send ( $ clear_after_send = true ) { if ( $ this -> use_batch_flow ) { $ this -> use_batch_flow = false ; if ( ! $ this -> use_cache_flow ) { $ response = $ this -> batch_object -> send ( ) ; $ parsed_data = array_map ( array ( $ this , 'parse_callback' ) , $ response ) ; $ parsed_data = new CFArray ( $... | Executes the batch request queue by sending all queued requests . |
58,127 | public function parse_callback ( $ response , $ headers = null ) { if ( isset ( $ response -> body ) ) { if ( is_string ( $ response -> body ) ) { $ body = $ response -> body ; } else { return $ response ; } } elseif ( is_string ( $ response ) ) { $ body = $ response ; } else { return $ response ; } if ( isset ( $ head... | Parses a response body into a PHP object if appropriate . |
58,128 | public static function autoloader ( $ class ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR ; if ( strstr ( $ class , 'Amazon' ) ) { $ path .= 'services' . DIRECTORY_SEPARATOR . str_ireplace ( 'Amazon' , '' , strtolower ( $ class ) ) . '.class.php' ; } elseif ( strstr ( $ class , 'CF' ) ) { $ path .= 'utilities... | Automatically load classes that aren t included . |
58,129 | public function html ( $ data ) { if ( is_array ( $ data ) ) { echo $ this -> json ( $ data ) ; } else { echo $ data ; } if ( $ this -> app -> config ( 'session.enable' ) ) { $ this -> session -> create ( 'previous_uri' , $ _SERVER [ 'REQUEST_URI' ] ) ; $ this -> session -> create ( 'planet_oldInput' , null ) ; } } | To response with html |
58,130 | public function json ( $ data , $ status = 200 ) { $ this -> header ( 'Content-Type: application/json' ) ; $ this -> statusCode ( $ status ) ; return json_encode ( $ data ) ; } | To response with json |
58,131 | public function download ( $ path , $ removeDownloadedFile = false ) { if ( ! file_exists ( $ path ) ) { throw new Exception ( "File [ $path ] not found." ) ; } $ filename = pathinfo ( $ path , PATHINFO_BASENAME ) ; header ( "Content-Description: File Transfer" ) ; header ( "Content-Type: application/octet-stream" ) ; ... | Http Response to download file |
58,132 | protected function updateDeploymentScript ( ) { $ this -> info ( 'Updating deployment script for site ' . $ this -> site . '...' ) ; $ this -> url = $ this -> obtainAPIURLEndpoint ( 'update_deployment_script_uri' ) ; if ( ! File :: exists ( $ this -> file ) ) { $ this -> error ( "File " . $ this -> file . " doesn't exi... | Update deployment script . |
58,133 | protected function obtainAPIURLEndpoint ( $ type ) { $ uri = str_replace ( '{forgeserver}' , $ this -> server , config ( 'forge-publish.' . $ type ) ) ; $ uri = str_replace ( '{forgesite}' , $ this -> site , $ uri ) ; return config ( 'forge-publish.url' ) . $ uri ; } | Obtain API URL endpoint . |
58,134 | public function onTwigView ( ViewEvent $ event ) { $ view = $ event -> getView ( ) ; if ( function_exists ( 'drupal_add_library' ) && $ view instanceof TwigView ) { drupal_add_library ( 'calista' , 'calista_page' ) ; } } | Add JS libraries |
58,135 | public function run ( ) { $ res1 = $ this -> gcPersistent ( ) ; $ res2 = $ this -> gcUserLinks ( ) ; $ res3 = $ this -> gcActive ( ) ; return $ res1 && $ res2 && $ res3 ; } | Runs the auth garbage collection . |
58,136 | private function gcPersistent ( ) { return ( bool ) $ this -> app [ 'database' ] -> getDefault ( ) -> delete ( 'PersistentSessions' ) -> where ( 'created_at' , U :: unixToDb ( time ( ) - PersistentSession :: $ sessionLength ) , '<' ) -> execute ( ) ; } | Clears out expired persistent sessions . |
58,137 | private function gcUserLinks ( ) { return ( bool ) $ this -> app [ 'database' ] -> getDefault ( ) -> delete ( 'UserLinks' ) -> where ( 'type' , UserLink :: FORGOT_PASSWORD ) -> where ( 'created_at' , U :: unixToDb ( time ( ) - UserLink :: $ forgotLinkTimeframe ) , '<' ) -> execute ( ) ; } | Clears out expired user links . |
58,138 | public static function singleton ( $ sessionID = FALSE ) { if ( self :: $ _instance === FALSE ) { self :: $ _instance = new static ( $ sessionID ) ; } return self :: $ _instance ; } | Return a single object instance |
58,139 | public function query ( string $ sql , array $ params = [ ] ) { X :: logger ( ) -> trace ( "$sql with params " . $ this -> serializeArray ( $ params ) ) ; try { $ st = $ this -> pdo -> prepare ( $ sql ) ; if ( $ st === false ) { $ e = $ this -> pdo -> errorInfo ( ) ; throw new DataBaseException ( $ e [ 2 ] , $ e [ 1 ] ... | run sql and return the result |
58,140 | public function getAvatarTag ( $ size = 96 , $ alt = null ) { return get_avatar ( $ this -> getId ( ) , $ size , null , $ alt ? : $ this -> getDisplayName ( ) ) ; } | Get an image tag for this author s avatar . |
58,141 | public function syntax ( Syntax $ value = null ) : Syntax { if ( null === $ value ) { return $ this -> syntax ; } $ this -> syntax = $ value ; return $ this ; } | Item syntax getter and setter . |
58,142 | public function separator ( string $ value = null ) { if ( null === $ value ) { return $ this -> separator ; } $ this -> separator = $ value ; return $ this ; } | Separator getter and setter . |
58,143 | public function parse ( string $ text ) : array { $ index = 0 ; $ items = Text :: split ( $ text , $ this -> separator ) ; $ array = [ ] ; try { foreach ( $ items as $ item ) { $ array [ ] = $ this -> syntax -> parse ( $ item ) ; $ index += strlen ( $ item ) + 1 ; } } catch ( ParseException $ e ) { $ extra = [ 'type' =... | Transforms a string to array based on the syntax or throws a ParseException . |
58,144 | public function dump ( $ values ) : string { if ( ! is_array ( $ values ) ) throw new DumpException ( $ this , $ values , self :: ERROR ) ; $ items = [ ] ; $ index = 0 ; try { foreach ( $ values as $ key => $ value ) { $ index = $ key ; $ items [ ] = $ this -> syntax -> dump ( $ value ) ; } } catch ( DumpException $ e ... | Converts the given array to a string based on the syntax or throws a DumpException . |
58,145 | protected function settings ( $ key = false ) { if ( $ this -> settings == false ) { return false ; } if ( $ key == false ) { return $ this -> settings ; } if ( isset ( $ this -> settings [ $ key ] ) ) { return $ this -> settings [ $ key ] ; } return false ; } | - > merchantSettings |
58,146 | public function handle ( Request $ request ) { try { $ restRequest = new RestRequest ( $ this -> config , $ request -> getMethod ( ) , $ request -> getUri ( ) , $ request -> getContent ( ) ) ; $ restResponse = $ this -> adapter -> processRequest ( $ restRequest ) ; } catch ( \ Exception $ e ) { if ( true === $ this -> ... | Processes an incoming Request object routes it to the adapter and returns a response . |
58,147 | protected function loadContainer ( array $ config = [ ] , $ environment = null ) { $ this -> container = new Container ; $ this -> configureContainerInternal ( ) ; $ this -> configureContainer ( $ this -> container , $ config , $ environment ) ; return $ this -> container -> get ( 'instantiator' ) ; } | Setup the Dependency Injection Container |
58,148 | protected function configureContainerInternal ( ) { $ this -> container -> add ( 'instantiator' , function ( ) { return function ( $ name ) { return $ this -> container -> get ( $ name ) ; } ; } ) ; $ this -> container -> add ( \ Weave \ Middleware \ Middleware :: class ) -> withArgument ( \ Weave \ Middleware \ Middle... | Configure s the internal Weave requirements . |
58,149 | public function register ( ) { $ this -> app -> singleton ( Grammar :: class ) ; $ this -> app -> singleton ( Lexer :: class ) ; $ this -> app -> singleton ( Parser :: class ) ; $ this -> app -> singleton ( IntToRomanFilter :: class ) ; $ this -> app -> singleton ( RomanToIntFilter :: class ) ; $ this -> app -> resolvi... | Register Romans Services |
58,150 | static public function shellColor ( $ color , $ string , $ conditional = true ) { if ( ! $ conditional ) { return $ string ; } $ color = self :: shellColorCode ( $ color ) ; return $ color . $ string . self :: shellColorCode ( 'plain' ) ; } | Wraps string in bash shell color escape sequences for the provided color . |
58,151 | static public function fromCamel ( $ str ) { $ str [ 0 ] = strtolower ( $ str [ 0 ] ) ; return preg_replace_callback ( '/([A-Z])/' , function ( $ char ) { return "_" . strtolower ( $ char [ 1 ] ) ; } , $ str ) ; } | Converts camel - case to corresponding underscores . |
58,152 | static public function toCamel ( $ str , $ capitalise_first_char = false ) { if ( $ capitalise_first_char ) { $ str [ 0 ] = strtoupper ( $ str [ 0 ] ) ; } return preg_replace_callback ( '/_([a-z])/' , function ( $ char ) { return strtoupper ( $ char [ 1 ] ) ; } , $ str ) ; } | Converts underscores to a corresponding camel - case string . |
58,153 | public function deleteSession ( $ clientId , $ ownerType , $ ownerId ) { DB :: table ( 'oauth_sessions' ) -> where ( 'client_id' , $ clientId ) -> where ( 'owner_type' , $ ownerType ) -> where ( 'owner_id' , $ ownerId ) -> delete ( ) ; } | Delete a session |
58,154 | public function associateRedirectUri ( $ sessionId , $ redirectUri ) { DB :: table ( 'oauth_session_redirects' ) -> insert ( array ( 'session_id' => $ sessionId , 'redirect_uri' => $ redirectUri , 'created_at' => Carbon :: now ( ) , 'updated_at' => Carbon :: now ( ) ) ) ; } | Associate a redirect URI with a session |
58,155 | public function associateAccessToken ( $ sessionId , $ accessToken , $ expireTime ) { return DB :: table ( 'oauth_session_access_tokens' ) -> insertGetId ( array ( 'session_id' => $ sessionId , 'access_token' => $ accessToken , 'access_token_expires' => $ expireTime , 'created_at' => Carbon :: now ( ) , 'updated_at' =>... | Associate an access token with a session |
58,156 | public function associateRefreshToken ( $ accessTokenId , $ refreshToken , $ expireTime , $ clientId ) { DB :: table ( 'oauth_session_refresh_tokens' ) -> insert ( array ( 'session_access_token_id' => $ accessTokenId , 'refresh_token' => $ refreshToken , 'refresh_token_expires' => $ expireTime , 'client_id' => $ client... | Associate a refresh token with a session |
58,157 | public function associateAuthCode ( $ sessionId , $ authCode , $ expireTime ) { $ id = DB :: table ( 'oauth_session_authcodes' ) -> insertGetId ( array ( 'session_id' => $ sessionId , 'auth_code' => $ authCode , 'auth_code_expires' => $ expireTime , 'created_at' => Carbon :: now ( ) , 'updated_at' => Carbon :: now ( ) ... | Assocate an authorization code with a session |
58,158 | public function validateAuthCode ( $ clientId , $ redirectUri , $ authCode ) { $ result = DB :: table ( 'oauth_sessions' ) -> select ( 'oauth_sessions.id as session_id' , 'oauth_session_authcodes.id as authcode_id' ) -> join ( 'oauth_session_authcodes' , 'oauth_sessions.id' , '=' , 'oauth_session_authcodes.session_id' ... | Validate an authorization code |
58,159 | public function validateAccessToken ( $ accessToken ) { $ result = DB :: table ( 'oauth_session_access_tokens' ) -> select ( 'oauth_session_access_tokens.session_id as session_id' , 'oauth_sessions.client_id as client_id' , 'oauth_clients.secret as client_secret' , 'oauth_sessions.owner_id as owner_id' , 'oauth_session... | Validate an access token |
58,160 | public function validateRefreshToken ( $ refreshToken , $ clientId ) { $ result = DB :: table ( 'oauth_session_refresh_tokens' ) -> where ( 'refresh_token' , $ refreshToken ) -> where ( 'client_id' , $ clientId ) -> where ( 'refresh_token_expires' , '>=' , time ( ) ) -> first ( ) ; return ( is_null ( $ result ) ) ? fal... | Validate a refresh token |
58,161 | public function getAccessToken ( $ accessTokenId ) { $ result = DB :: table ( 'oauth_session_access_tokens' ) -> where ( 'id' , $ accessTokenId ) -> first ( ) ; return ( is_null ( $ result ) ) ? false : ( array ) $ result ; } | Get an access token by ID |
58,162 | public function associateScope ( $ accessTokenId , $ scopeId ) { DB :: table ( 'oauth_session_token_scopes' ) -> insert ( array ( 'session_access_token_id' => $ accessTokenId , 'scope_id' => $ scopeId , 'created_at' => Carbon :: now ( ) , 'updated_at' => Carbon :: now ( ) ) ) ; } | Associate a scope with an access token |
58,163 | public function getScopes ( $ accessToken ) { $ scopeResults = DB :: table ( 'oauth_session_token_scopes' ) -> select ( 'oauth_scopes.*' ) -> join ( 'oauth_session_access_tokens' , 'oauth_session_token_scopes.session_access_token_id' , '=' , 'oauth_session_access_tokens.id' ) -> join ( 'oauth_scopes' , 'oauth_session_t... | Get all associated access tokens for an access token |
58,164 | public function getAuthCodeScopes ( $ oauthSessionAuthCodeId ) { $ scopesResults = DB :: table ( 'oauth_session_authcode_scopes' ) -> where ( 'oauth_session_authcode_id' , '=' , $ oauthSessionAuthCodeId ) -> get ( ) ; $ scopes = array ( ) ; foreach ( $ scopesResults as $ key => $ scope ) { $ scopes [ $ key ] = get_obje... | Get the scopes associated with an auth code |
58,165 | public function append ( $ content , $ create = false ) { if ( $ this -> writeable !== true || empty ( $ content ) ) return false ; if ( strpos ( $ this -> _option , 'a' ) === false ) { if ( ! empty ( $ this -> fp ) ) fclose ( $ this -> fp ) ; $ this -> open_fp ( ( is_bool ( $ create ) && $ create === true ? 'a+' : 'a'... | appends to a file based + create if wanted |
58,166 | public function change_owner ( $ owner ) { if ( empty ( $ owner ) || ! is_int ( $ owner ) || $ this -> owner != getmyuid ( ) ) return false ; if ( ! empty ( $ this -> fp ) ) fclose ( $ this -> fp ) ; if ( chown ( $ this -> path . $ this -> filename , $ owner ) ) { return $ this -> open ( $ this -> path . $ this -> file... | changes file owner |
58,167 | public function change_group ( $ group ) { if ( empty ( $ group ) || ! is_int ( $ group ) ) return false ; if ( chgrp ( $ this -> path . $ this -> filename , $ group ) ) { return $ this -> open ( $ this -> path . $ this -> filename ) ; } return false ; } | changes the group |
58,168 | private function _extract_file_extension ( ) { if ( empty ( $ this -> filename ) ) return false ; if ( ! empty ( $ this -> mime_type ) ) { $ array = explode ( '/' , $ this -> mime_type ) ; $ this -> file_extension = array_pop ( $ array ) ; } else { if ( strpos ( $ this -> filename , '.' ) !== false ) { $ array = explod... | extracts the extension of the current file |
58,169 | private function _extract_filename ( ) { if ( empty ( $ this -> file ) ) return false ; $ tmp_array = explode ( '/' , $ this -> file ) ; $ count = ( int ) count ( $ tmp_array ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ i + 1 == $ count ) { $ this -> filename = ( string ) $ tmp_array [ 0 ] ; } array_shift ( $ ... | gets the filename of the file |
58,170 | private function _get_path ( ) { if ( empty ( $ this -> file ) && is_string ( $ this -> file ) ) return false ; if ( strpos ( $ this -> file , '/' ) !== false ) { $ path = explode ( '/' , $ this -> file ) ; array_pop ( $ path ) ; $ this -> path = ( string ) implode ( '/' , $ path ) . '/' ; } elseif ( strpos ( '\\' , $ ... | gets the filename out of the entered path |
58,171 | public function open ( $ filename ) { if ( ! is_file ( $ filename ) ) return false ; $ this -> file = @ ( string ) $ filename ; $ this -> group = @ ( int ) filegroup ( $ filename ) ; $ this -> owner = @ ( int ) fileowner ( $ filename ) ; $ this -> size = @ ( int ) filesize ( $ filename ) ; $ this -> type = @ ( string )... | gets all the information about the file |
58,172 | function open_fp ( $ option = 'r' ) { if ( empty ( $ option ) || ! is_string ( $ option ) ) return false ; switch ( true ) { case ( strpos ( $ option , 'r' ) !== false ) : $ mode = LOCK_SH ; break ; case ( strpos ( $ option , 'a' ) !== false || strpos ( $ option , 'w' ) !== false ) : $ mode = LOCK_EX ; break ; default ... | opens a filepointer |
58,173 | public function read ( ) { if ( $ this -> readable !== true ) return false ; if ( ! empty ( $ this -> fp ) && is_resource ( $ this -> fp ) ) fclose ( $ this -> fp ) ; $ this -> open_fp ( 'r' ) ; if ( filesize ( $ this -> file ) == 0 ) return false ; $ this -> lock ( LOCK_SH ) ; $ content = ( string ) fread ( $ this -> ... | read the current content of the file |
58,174 | public static function getArgumentSpecifications ( ) { $ specs = new OptionCollection ; $ specs -> add ( 'd|dir:' , 'Tests directory path' ) -> isa ( 'String' ) ; $ specs -> add ( 's|subdir+' , 'Optional, subdirectory pattern, can be used multiple times as OR expression' ) -> isa ( 'String' ) -> defaultValue ( null ) ;... | Get argument specifications |
58,175 | public function colored ( $ text , $ color ) { $ colors = [ 'black' => '0;30' , 'red' => '0;31' , 'green' => '0;32' , 'blue' => '1;34' , 'yellow' => '1;33' ] ; $ c = ( array_key_exists ( $ color , $ colors ) ? $ colors [ $ color ] : $ colors [ 'black' ] ) ; if ( $ this -> arguments -> { 'no-colors' } ) { return $ text ... | Returned colored text |
58,176 | public function mergePackageLoader ( $ directory ) { if ( $ vendor = $ this -> findVendor ( $ directory ) ) { $ this -> mergeComposerNamespaces ( $ vendor ) ; $ this -> mergeComposerPsr4 ( $ vendor ) ; $ this -> mergeComposerClassMap ( $ vendor ) ; } } | Autoloads a packages dependencies by merging them with the current auto - loader . |
58,177 | private function mergeComposerNamespaces ( $ vendor ) { if ( $ namespaceFile = $ this -> findComposerDirectory ( $ vendor , 'autoload_namespaces.php' ) ) { $ this -> log -> debug ( 'Located autoload_namespaces.php file' , [ 'path' => $ namespaceFile ] ) ; $ map = require $ namespaceFile ; foreach ( $ map as $ namespace... | Merges the dependencies namespaces . |
58,178 | private function mergeComposerPsr4 ( $ vendor ) { if ( $ psr4Autoload = $ this -> findComposerDirectory ( $ vendor , 'autoload_psr4.php' ) ) { $ this -> log -> debug ( 'Located autoload_psr4.php file' , [ 'path' => $ psr4Autoload ] ) ; $ map = require $ psr4Autoload ; foreach ( $ map as $ namespace => $ path ) { $ this... | Merges the dependencies PSR - 4 namespaces . |
58,179 | private function mergeComposerClassMap ( $ vendor ) { if ( $ composerClassMap = $ this -> findComposerDirectory ( $ vendor , 'autoload_classmap.php' ) ) { $ this -> log -> debug ( 'Located autoload_classmap.php file' , [ 'path' => $ composerClassMap ] ) ; $ classMap = require $ composerClassMap ; if ( $ classMap ) { $ ... | Merges the dependencies class maps . |
58,180 | private function findComposerDirectory ( $ vendor , $ file = '' ) { $ composerDirectory = $ this -> normalizePath ( $ vendor . '/composer/' . $ file ) ; if ( $ this -> files -> exists ( $ composerDirectory ) ) { return $ composerDirectory ; } return false ; } | Finds the composer directory . |
58,181 | private function findVendor ( $ directory ) { $ vendorDirectory = $ this -> normalizePath ( $ directory . '/_newup_vendor' ) ; if ( $ this -> files -> exists ( $ vendorDirectory ) && $ this -> files -> isDirectory ( $ vendorDirectory ) ) { return $ vendorDirectory ; } return false ; } | Gets the vendor directory location if it exists . |
58,182 | public function disconnect ( $ drop = false ) { $ this -> handler -> onClose ( $ this ) ; parent :: disconnect ( $ drop ) ; } | Disconnects client from server . It also notifies clients handler about that fact . |
58,183 | public function ping ( $ payload = null ) { if ( $ payload === null ) { $ payload = microtime ( true ) ; } elseif ( isset ( $ payload [ 125 ] ) ) { throw new LengthException ( "Ping payload cannot be larger than 125 bytes" ) ; } $ this -> currentPingFrame = new DataFrame ( $ this -> logger ) ; $ this -> currentPingFram... | Sends PING frame to connected client . |
58,184 | public function isJson ( ) { if ( ! $ this -> endsWith ( '}' ) && ! $ this -> endsWith ( ']' ) ) { return false ; } return ! is_null ( json_decode ( $ this -> str ) ) ; } | Returns true if the string is JSON false otherwise . |
58,185 | public function setFileClassname ( $ classname = null ) { if ( $ classname === null ) { $ this -> fileClass = null ; } elseif ( ! class_exists ( $ classname ) ) { throw ClassDoesNotExistException :: create ( $ classname ) ; } else { $ this -> fileClass = ( string ) $ classname ; } return $ this ; } | Set file classname |
58,186 | public function setController ( $ controller ) { if ( ! is_callable ( $ controller ) ) { throw new \ LogicException ( sprintf ( 'The controller must be a callable (%s given).' , gettype ( $ controller ) ) ) ; } $ this -> controller = $ controller ; } | Sets a controller |
58,187 | public function headers ( $ key = null , $ fallback = null ) { return $ key ? $ this -> request -> headers -> get ( $ key , $ fallback ) : $ this -> request -> headers ; } | Get a request header value |
58,188 | private function callActon ( $ sName , array $ aArgs ) { if ( empty ( $ aArgs ) ) { $ this -> ctrl -> { $ sName } ( ) ; } else { $ oMethod = new \ ReflectionMethod ( $ this -> ctrl , $ sName ) ; $ oMethod -> invokeArgs ( $ this -> ctrl , $ aArgs ) ; } } | It calls the controller action with passage the parameters if necessary . |
58,189 | protected function processAuth ( $ sName , array $ aArgs ) { if ( class_exists ( '\extensions\core\Auth' ) ) { $ oAuth = new \ extensions \ core \ Auth ( $ this -> ctrl -> getRequest ( ) ) ; $ oAuth -> run ( ) ; if ( $ oAuth -> isValid ( ) ) { $ this -> callActon ( $ sName , $ aArgs ) ; } else { $ oAuth -> onFail ( ) ;... | The method calls user s auth checking on successful complition of which it invokes the target controller and the onFail method of Auth class in other case . |
58,190 | public function getValidator ( ) { if ( ! isset ( $ this -> validator ) ) { $ this -> validator = new ArgsValidator ( $ this -> arguments_spec , $ this -> parsed_args ) ; } return $ this -> validator ; } | get the validator for these values |
58,191 | public function offsetGet ( $ key ) { $ resolved_key = $ this -> arguments_spec -> normalizeOptionName ( $ key ) ; if ( $ resolved_key === null ) { if ( isset ( $ this -> merged_arg_values [ $ key ] ) ) { return parent :: offsetGet ( $ key ) ; } } if ( isset ( $ this -> merged_arg_values [ $ resolved_key ] ) ) { return... | returns the argument or option value |
58,192 | public function offsetExists ( $ key ) { $ resolved_key = $ this -> arguments_spec -> normalizeOptionName ( $ key ) ; if ( $ resolved_key === null ) { return isset ( $ this -> merged_arg_values [ $ key ] ) ; } return isset ( $ this -> merged_arg_values [ $ resolved_key ] ) ; } | returns true if the argument or option value exists |
58,193 | protected function extractAllLongOpts ( ArgumentsSpec $ arguments_spec , $ parsed_args ) { $ long_opts = array ( ) ; foreach ( $ parsed_args [ 'options' ] as $ option_name => $ value ) { if ( $ long_option_name = $ arguments_spec -> normalizeOptionName ( $ option_name ) ) { $ long_opts [ $ long_option_name ] = $ value ... | builds argument values by long option name |
58,194 | protected function _getStoreConfigValue ( $ configKey , $ store , $ asFlag ) { foreach ( $ this -> _configModels as $ configModel ) { if ( $ configModel -> hasKey ( $ configKey ) ) { $ configMethod = $ asFlag ? 'getStoreConfigFlag' : 'getStoreConfig' ; return Mage :: $ configMethod ( $ configModel -> getPathForKey ( $ ... | Search through registered config models for one that knows about the key and get the actual config path from it for the lookup . |
58,195 | public function getConfigFlag ( $ configKey , $ store = null ) { $ store = count ( func_get_args ( ) ) > 1 ? $ store : $ this -> getStore ( ) ; return $ this -> _getStoreConfigValue ( $ configKey , $ store , true ) ; } | Get the configuration value represented by the given configKey |
58,196 | public function getConfig ( $ configKey , $ store = null ) { $ store = count ( func_get_args ( ) ) > 1 ? $ store : $ this -> getStore ( ) ; return $ this -> _getStoreConfigValue ( $ configKey , $ store , false ) ; } | Get the configuration flag value represented by the given configKey |
58,197 | protected function dump ( Route $ route , $ name ) { if ( ! $ route -> isVisible ( ) ) { return ; } if ( ! in_array ( 'GET' , $ route -> getMethods ( ) ) ) { throw new Exception ( sprintf ( 'Only GET mehtod supported, "%s" given.' , $ name ) ) ; } if ( $ route -> hasContent ( ) ) { if ( $ route -> isList ( ) ) { if ( $... | Dump route content to destination file |
58,198 | protected function buildPaginatedRoute ( Route $ route , $ name ) { $ contentType = $ route -> getContent ( ) ; $ contents = $ this -> app [ 'content_repository' ] -> listContents ( $ contentType ) ; $ paginator = new Paginator ( $ contents , $ route -> getPerPage ( ) ) ; $ this -> logger -> log ( sprintf ( 'Building r... | Build paginated route |
58,199 | protected function buildListRoute ( Route $ route , $ name ) { $ contentType = $ route -> getContent ( ) ; $ contents = $ this -> app [ 'content_repository' ] -> listContents ( $ contentType ) ; $ this -> logger -> log ( sprintf ( 'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>' , $ ... | Build list route |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.