idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
230,300 | public function monthFieldRow ( IFormModel $ model , $ property , array $ options = [ ] ) { $ element = $ this -> getField ( $ model , $ property ) ; $ options [ 'id' ] = $ element [ 'id' ] ; return Html :: openTag ( 'div' , $ this -> getBlock ( 'block' , $ options ) ) . Html :: label ( $ model -> getLabel ( $ property... | Render month field row |
230,301 | public function weekFieldRow ( IFormModel $ model , $ property , array $ options = [ ] ) { $ element = $ this -> getField ( $ model , $ property ) ; $ options [ 'id' ] = $ element [ 'id' ] ; return Html :: openTag ( 'div' , $ this -> getBlock ( 'block' , $ options ) ) . Html :: label ( $ model -> getLabel ( $ property ... | Render week field row |
230,302 | public static function makeFile ( $ file , $ chmod = 0777 , $ touchTime = null ) { if ( ! file_exists ( $ file ) ) { if ( ! is_dir ( dirname ( $ file ) ) ) { mkdir ( dirname ( $ file ) , 0777 , true ) ; } $ h = fopen ( $ file , 'w' ) ; if ( $ h ) { fclose ( $ h ) ; } unset ( $ h ) ; if ( null !== $ touchTime ) { touch ... | Recursively generate directories if not existent and place a empty file inside it . |
230,303 | public static function normalizeUrl ( $ url ) { if ( ! class_exists ( 'URLNormalizer' ) ) { require_once ( realpath ( __DIR__ . '/../../classes' ) . '/URLNormalizer.php' ) ; } $ un = new \ URLNormalizer ( ) ; $ un -> setUrl ( $ url ) ; return $ un -> normalize ( ) ; } | Use Glen Scotts UrlNormalizer to normalize the passed url . |
230,304 | public static function encrypt ( $ string , $ key ) { $ result = '' ; for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i ++ ) { $ char = substr ( $ string , $ i , 1 ) ; $ keychar = substr ( $ key , ( $ i % strlen ( $ key ) ) - 1 , 1 ) ; $ char = chr ( ord ( $ char ) + ord ( $ keychar ) ) ; $ result .= $ char ; } return ba... | Basic encryption method . |
230,305 | public static function decrypt ( $ string , $ key ) { $ result = '' ; $ string = base64_decode ( $ string ) ; for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i ++ ) { $ char = substr ( $ string , $ i , 1 ) ; $ keychar = substr ( $ key , ( $ i % strlen ( $ key ) ) - 1 , 1 ) ; $ char = chr ( ord ( $ char ) - ord ( $ keycha... | Basic decryption method . |
230,306 | public static function getPathsBase ( & $ a , & $ b , $ modify = false , $ DS = DIRECTORY_SEPARATOR ) { if ( $ modify ) { $ str1 = & $ a ; $ str2 = & $ b ; } else { $ str1 = $ a ; $ str2 = $ b ; } $ str1 = explode ( $ DS , self :: unify_slashes ( $ str1 , $ DS ) ) ; $ str2 = explode ( $ DS , self :: unify_slashes ( $ s... | Return the folder on with the both given paths split . |
230,307 | public static function buildDir ( $ path , $ chmod = 0775 ) { deprecated ( 'mkdir($dir, null, true);' ) ; if ( is_dir ( $ path ) ) { return true ; } $ dir = DIRECTORY_SEPARATOR ; foreach ( explode ( DIRECTORY_SEPARATOR , self :: unify_slashes ( $ path , DIRECTORY_SEPARATOR , true ) ) as $ f ) { if ( empty ( $ f ) ) { c... | Checks if the given Path is existent and generates missing folders . |
230,308 | public static function arrayWrap ( $ input , $ wrap ) { $ w1 = '' ; $ w2 = '' ; if ( is_array ( $ wrap ) ) { $ w1 = $ wrap [ 0 ] ; if ( isset ( $ wrap [ 1 ] ) ) { $ w2 = $ wrap [ 1 ] ; } } elseif ( ! is_string ( $ wrap ) ) { throw new \ Exception ( sprintf ( 'Invalid Type %s for $wrap' , gettype ( $ wrap ) ) , 1 ) ; re... | Wrap each entry of an array |
230,309 | public static function post ( $ url , $ params ) { if ( ! is_array ( $ params ) ) { $ params = self :: ar ( $ params ) ; } $ query = http_build_query ( $ params ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , count ( $ params ) ) ; curl_setopt ( $ ch , CURLOPT... | Performs a post request to given url passing given parameters . |
230,310 | public static function ar ( $ a , $ b = null , $ deep = false ) { $ r = array ( ) ; if ( is_array ( $ a ) || is_object ( $ a ) ) { foreach ( $ a as $ k => $ v ) { if ( $ deep == true && ( is_array ( $ v ) || is_object ( $ v ) ) ) { $ v = self :: ar ( $ v , null , true ) ; } $ r [ $ k ] = $ v ; } } elseif ( is_string ( ... | Converts arrays objects integers or strings into arrays . |
230,311 | public static function pq ( $ html , $ contentType = null ) { self :: initPhpQuery ( ) ; return \ phpQuery :: newDocument ( $ html , $ contentType ) ; } | Sets a new DOM for PHPQuery . |
230,312 | public static function switchVars ( array $ vars ) { $ i = 0 ; foreach ( $ vars as $ k => $ v ) { if ( $ i == 0 ) { $ pk = $ k ; $ pv = $ v ; } else { return array ( $ pk => $ v , $ k => $ pv ) ; } $ i ++ ; } } | Switches the first two variables of an array while leaving its keys . |
230,313 | public static function get_randomString ( $ length = 12 , $ type = 'pAan' , $ additional = '' ) { $ sources = array ( 'p' => '!#$%&()=?*+-_:.;,<>' , 'a' => 'abcdefghijklmnopqrstuvwxyz' , 'A' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' , 'n' => '1234567890' ) ; $ source = '' ; foreach ( $ sources as $ k => $ s ) { if ( strstr ( $ t... | Generates a passwordish random string |
230,314 | public static function get_browserObj ( ) { if ( ! class_exists ( '\Ikimea\Browser\Browser' ) ) { throw new THETOOLSException ( "Browser Class could not be loaded" ) ; } if ( self :: $ s_BrowserObj === null ) { self :: $ s_BrowserObj = new \ Ikimea \ Browser \ Browser ; self :: $ s_browserVersion = self :: $ s_BrowserO... | Generates and caches the Browser - Object |
230,315 | public static function minify ( $ string , $ noSpace = false ) { $ string = preg_replace ( "/\s+/" , ' ' , $ string ) ; return $ noSpace ? str_replace ( ' ' , '' , $ string ) : $ string ; } | deletes linebreaks and tabs from string |
230,316 | public static function replace_subdomain ( $ url , $ newSubdomain ) { $ url = parse_url ( $ url ) ; if ( substr_count ( $ url [ 'host' ] , '.' ) >= 2 ) { $ url [ 'host' ] = ( str_replace ( substr ( $ url [ 'host' ] , 0 , strpos ( $ url [ 'host' ] , '.' ) ) , $ newSubdomain , $ url [ 'host' ] ) ) ; } else { $ url [ 'hos... | Replaces the subdomain of given url or adds it . |
230,317 | public static function unparse_url ( $ parsedUrl ) { $ scheme = isset ( $ parsedUrl [ 'scheme' ] ) ? $ parsedUrl [ 'scheme' ] . '://' : '' ; $ host = isset ( $ parsedUrl [ 'host' ] ) ? $ parsedUrl [ 'host' ] : '' ; $ port = isset ( $ parsedUrl [ 'port' ] ) ? ':' . $ parsedUrl [ 'port' ] : '' ; $ user = isset ( $ parsed... | reverses the result array of parse_url into an url string . |
230,318 | public static function get_currentUrl ( $ filter = array ( ) , $ queryFilter = array ( ) , $ queryFilterMethod = 'remove' ) { if ( ! is_array ( $ filter ) && ! empty ( $ filter ) ) { $ filter = array ( $ filter ) ; } if ( ! empty ( self :: $ fakeCurrentUrl ) ) { $ pageURL = self :: $ fakeCurrentUrl ; } else { $ pageURL... | curPageURL returns the current url |
230,319 | public static function recursive_get ( $ obj , $ path ) { foreach ( explode ( '|' , $ path ) as $ key ) { if ( is_object ( $ obj ) ) { if ( isset ( $ obj -> $ key ) ) { $ obj = $ obj -> $ key ; } else { return null ; } } elseif ( isset ( $ obj [ $ key ] ) ) { $ obj = $ obj [ $ key ] ; } else { return null ; } } return ... | Handy function to dive into an array or object without knowing what it is nested keys can be separated by a pipe so it s possible to get a deeper key with only one call |
230,320 | public static function recursive_unset ( & $ obj , $ path ) { $ i = 1 ; foreach ( ( $ l = explode ( '|' , $ path ) ) as $ key ) { if ( is_object ( $ obj ) ) { if ( isset ( $ obj -> $ key ) ) { if ( count ( $ l ) === $ i ) { unset ( $ obj -> $ key ) ; return true ; } $ obj = & $ obj -> $ key ; } else { return false ; } ... | Handy function to unset a deep value of a class or an array . |
230,321 | public static function unSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '/' , false , false , $ unify ) ; } | remove potential slash from the end of the string . |
230,322 | public static function unDS ( $ str , $ unify = false ) { return self :: _slash ( $ str , DIRECTORY_SEPARATOR , false , false , $ unify ) ; } | remove potential DIRECTORY_SEPARATOR from the end of the string . |
230,323 | public static function unBackSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '\\' , false , false , $ unify ) ; } | remove potential backslash from the end of the string . |
230,324 | public static function slash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '/' , false , true , $ unify ) ; } | add slash to the end of the string . |
230,325 | public static function DS ( $ str , $ unify = false ) { return self :: _slash ( $ str , DIRECTORY_SEPARATOR , false , true , $ unify ) ; } | add DIRECTORY_SEPARATOR to the end of the string . |
230,326 | public static function backSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '\\' , false , true , $ unify ) ; } | add backslash to the end of the string . |
230,327 | public static function unPreSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '/' , true , false , $ unify ) ; } | remove potential slash from the front of the string . |
230,328 | public static function unPreDS ( $ str , $ unify = false ) { return self :: _slash ( $ str , DIRECTORY_SEPARATOR , true , false , $ unify ) ; } | remove potential DIRECTORY_SEPARATOR from the front of the string . |
230,329 | public static function unPreBackSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '\\' , true , false , $ unify ) ; } | remove potential backslash from the front of the string . |
230,330 | public static function preSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '/' , true , true , $ unify ) ; } | add slash to the front of the string . |
230,331 | public static function preDS ( $ str , $ unify = false ) { return self :: _slash ( $ str , DIRECTORY_SEPARATOR , true , true , $ unify ) ; } | add DIRECTORY_SEPARATOR to the front of the string . |
230,332 | public static function preBackSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '\\' , true , true , $ unify ) ; } | add backslash to the front of the string . |
230,333 | public static function is_cleanPath ( $ path , $ clean = false , $ regex = '!_-\w\/\\\ ' ) { if ( $ clean === true ) { $ path = self :: get_directPath ( $ path ) ; } if ( preg_match ( '/[^' . $ regex . ']/' , $ path ) ) { return false ; } return $ path ; } | Checks if the path has invalid characters . |
230,334 | public static function get_static_var ( $ classname , $ key ) { $ vars = get_class_vars ( $ classname ) ; if ( isset ( $ vars [ $ key ] ) ) { return $ vars [ $ key ] ; } } | Getter for Static Variables of Named Classes |
230,335 | public static function get_dirArray ( $ dir , $ filenameKey = false , $ filter = null , $ positive = false ) { if ( empty ( $ filter ) ) { $ filter = array ( '.' , '_' ) ; } elseif ( is_object ( $ filter ) ) { $ filter = self :: ar ( $ filter , null , true ) ; } elseif ( ! is_array ( $ filter ) ) { $ filter = array ( $... | returns an array of files in a specific folder excluding files starting with . or _ |
230,336 | public static function getRequiredArgsError ( $ args , $ requiredArgs ) { if ( ! is_array ( $ args ) && ! is_object ( $ args ) ) { return sprintf ( __ ( 'invalid type "%s" for $args' , 'themaster' ) , gettype ( $ args ) ) ; } if ( ! is_array ( $ requiredArgs ) && ! is_object ( $ args ) ) { return sprintf ( __ ( 'invali... | Checks if Array 1 has all required keys specified by Array 2 |
230,337 | public static function filter_urlQuery ( & $ url , $ filterArr , $ method = null , array $ add = array ( ) ) { if ( $ method === null ) { $ method = 'remove' ; } $ pUrl = parse_url ( $ url ) ; $ qry ; if ( isset ( $ pUrl [ 'query' ] ) ) { parse_str ( $ pUrl [ 'query' ] , $ qry ) ; } else { $ qry = array ( ) ; } self ::... | Parses an url adds and removes get - query arguments and rebuilds the url . |
230,338 | public static function filter_data ( & $ data , $ filterArr , $ method = null , $ add = false ) { if ( $ method === null ) { $ method = 'keep' ; } foreach ( $ data as $ k => $ v ) { if ( ( $ method == 'remove' && in_array ( $ k , $ filterArr ) ) || ( $ method == 'keep' && ! in_array ( $ k , $ filterArr ) ) ) { if ( is_... | Filters entries of an array . |
230,339 | public static function merge_data ( $ a , $ b ) { $ args = func_get_args ( ) ; $ t = $ args [ 0 ] ; $ array = is_array ( $ t ) ; foreach ( $ args as $ k => $ a ) { $ args [ $ k ] = self :: ar ( $ a ) ; } $ args = call_user_func_array ( 'array_merge' , $ args ) ; if ( ! $ array ) { $ args = self :: sc ( $ args ) ; } ret... | Allows merging of arrays and objects . same usage as array_merge . |
230,340 | public static function merge_data_recursive ( $ a , $ b ) { $ args = func_get_args ( ) ; $ t = $ args [ 0 ] ; $ array = is_array ( $ t ) ; foreach ( $ args as $ k => $ a ) { $ args [ $ k ] = self :: ar ( $ a , null , true ) ; } $ args = call_user_func_array ( 'array_merge_recursive' , $ args ) ; if ( ! $ array ) { $ ar... | Allows deep merging of arrays and objects . same usage as array_merge_recursive . |
230,341 | public function driver ( $ driver = null ) { $ shortener = $ this -> app [ 'config' ] [ 'shortener' ] ; $ driver = $ driver ? : $ shortener [ 'default' ] ; $ driverMethod = 'create' . ucfirst ( $ driver ) . 'Driver' ; if ( method_exists ( $ this , $ driverMethod ) ) { return $ this -> { $ driverMethod } ( $ shortener )... | Get a shortener driver instance . |
230,342 | public function validate ( $ value ) { $ result = Ok :: unit ( ) ; foreach ( $ this -> allowedTypes as $ type ) { $ typeChecker = preg_match ( '/^&/' , $ type ) ? $ this -> getCustomType ( $ type ) : $ this -> createProperty ( $ type ) ; $ result = $ typeChecker -> validate ( $ value ) ; if ( $ result instanceof Ok ) {... | Tells if a given value adhere s to one of the property s allowed types . |
230,343 | protected function getCustomType ( $ type ) { $ root = $ this ; while ( $ cur = $ root -> getParent ( ) ) { $ root = $ cur ; } $ customTypes = $ root -> getSchema ( ) -> getCustomTypes ( ) ; $ type = ltrim ( $ type , '&' ) ; if ( isset ( $ customTypes [ $ type ] ) ) { return $ customTypes [ $ type ] ; } throw new Excep... | Retrieves a custom type definition by name that will be used to proxy the property s validation to . |
230,344 | protected function createProperty ( $ type ) { return $ this -> getSchema ( ) -> getFactory ( ) -> createProperty ( [ 'type' => $ type , 'name' => $ this -> getName ( ) . '_item' , 'required' => true ] , $ this -> getSchema ( ) , $ this ) ; } | Creates a child - property that will be used as a proxy - target for the parent property s validation . |
230,345 | public function parse ( $ raw ) { $ lines = explode ( "\n" , $ raw ) ; preg_match ( '/HTTP\/(\d\.\d) (\d\d\d) (.*)/' , $ lines [ 0 ] , $ statusLine ) ; $ response = ( new Response ( ) ) -> withProtocolVersion ( $ statusLine [ 1 ] ) -> withStatus ( $ statusLine [ 2 ] , $ statusLine [ 3 ] ) ; unset ( $ lines [ 0 ] ) ; fo... | Parses a Raw HTTP response and converts it into a response object |
230,346 | public function getNick ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_NICK ) ; } | Returns the nickname of the user represented by this identity . |
230,347 | public function getIdent ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_IDENT ) ; } | Returns the identity string of the user represented by this identity . |
230,348 | public function getHost ( $ canonical ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_HOST , array ( $ canonical ) ) ; } | Returns the host of the user represented by this identity . |
230,349 | public function getMask ( $ canonical ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_MASK , array ( $ canonical ) ) ; } | Returns a mask which can later be used to match against this user . |
230,350 | public function isOn ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_ISON ) ; } | Indicates whether the person associated with this token is still connected . |
230,351 | public function getInput ( ) { $ options = $ this -> htmlOptions ; $ options [ 'class' ] = ( isset ( $ options [ 'class' ] ) ? $ options [ 'class' ] . ' ' : '' ) . 'input autocomplete' ; $ options [ 'autc_ajax' ] = ( $ this -> ajaxUpdate ? '1' : '0' ) ; $ options [ 'autc_url' ] = $ this -> ajaxURL ; $ options [ 'autc_f... | Get the input ; |
230,352 | public function init ( $ config = [ ] ) { foreach ( $ config as $ key => $ value ) { switch ( $ key ) { case 'level' : $ this -> _level = ( int ) $ value ; break ; case 'mailer' : $ this -> _mailer = $ value ; break ; case 'formatter' : $ this -> _formatter = new $ value ( ) ; break ; default : break ; } } } | Initialises the handler . |
230,353 | public static function normalizePath ( $ path ) { $ path = rtrim ( $ path , '/' ) ; $ path = rtrim ( $ path , '\\' ) ; $ path .= DIRECTORY_SEPARATOR ; return $ path ; } | Normalize a path for insertion in the stack |
230,354 | public function resolve ( $ name ) { if ( preg_match ( '#\.\.[\\\/]#' , $ name ) ) { throw new Exception \ DomainException ( 'Requested asset may not include parent directory traversal ("../", "..\\" notation)' ) ; } if ( ! count ( $ this -> paths ) ) { return null ; } $ files = array ( ) ; foreach ( $ this -> paths as... | Retrieve the filesystem path to a view script |
230,355 | public function cmdGetProductClassField ( ) { $ result = $ this -> getListProductClassField ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableProductClassField ( $ result ) ; $ this -> output ( ) ; } | Callback for product - class - field - get command |
230,356 | public function cmdUpdateProductClassField ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ;... | Callback for product - class - field - update command |
230,357 | protected function getListProductClassField ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { return $ this -> product_class_field -> getList ( array ( 'limit' => $ this -> getLimit ( ) ) ) ; } if ( $ this -> getParam ( 'class' ) ) { return $ this -> product_class_field -> getList ( array ( 'product_cla... | Returns an array of product class fields |
230,358 | protected function addProductClassField ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> product_class_field -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new product class field |
230,359 | protected function updateProductClassField ( $ product_class_field_id ) { if ( ! $ this -> isError ( ) && ! $ this -> product_class_field -> update ( $ product_class_field_id , $ this -> getSubmitted ( ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } } | Updates a product class field |
230,360 | protected function submitAddProductClassField ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'product_class_field' ) ; $ this -> addProductClassField ( ) ; } | Add a new product class field at once |
230,361 | protected function wizardAddProductClassField ( ) { $ this -> validatePrompt ( 'product_class_id' , $ this -> text ( 'Product class' ) , 'product_class_field' ) ; $ this -> validatePrompt ( 'field_id' , $ this -> text ( 'Field ID' ) , 'product_class_field' ) ; $ this -> validatePrompt ( 'required' , $ this -> text ( 'R... | Add a new product class field step by step |
230,362 | private function searchRedirect ( ) : void { $ pathway = $ this -> getPathInfo ( ) ; $ routing = App :: $ Properties -> getAll ( 'Routing' ) ; if ( ! Any :: isArray ( $ routing ) || ! isset ( $ routing [ 'Redirect' ] ) || ! Any :: isArray ( $ routing [ 'Redirect' ] ) ) { return ; } if ( array_key_exists ( $ pathway , $... | Check if current url in redirect map |
230,363 | private function setPathdata ( ? array $ pathArray = null ) : void { if ( ! Any :: isArray ( $ pathArray ) || count ( $ pathArray ) < 1 ) { return ; } $ this -> controller = ucfirst ( Str :: lowerCase ( array_shift ( $ pathArray ) ) ) ; if ( count ( $ pathArray ) > 0 ) { $ this -> action = ucfirst ( Str :: lowerCase ( ... | Working with path array data |
230,364 | public function add ( $ key , $ value = null ) { $ this -> _view -> with ( $ key , $ value ) ; return $ this ; } | Adds data to the view class that will pass on to the view . |
230,365 | public function withErrors ( $ validator ) { foreach ( $ validator -> errors ( ) as $ key => $ value ) { if ( count ( $ value ) > 1 ) { for ( $ i = 0 ; $ i < count ( $ value ) ; $ i ++ ) { $ data [ $ key ] [ $ i ] = $ value [ $ i ] ; } } else { $ data [ $ key ] = $ value [ 0 ] ; } $ this -> _errors -> add ( ( object ) ... | Flash errors grabbed from a request . |
230,366 | public function renderWithData ( $ path , $ data = [ ] ) { foreach ( $ data as $ key => $ value ) { $ this -> add ( $ key , $ value ) ; } $ this -> render ( $ path ) ; return $ this ; } | Renders a view with data to pass on to the view . |
230,367 | public function redirectWith ( $ url , $ data ) { $ this -> _session -> flash ( 'redirect_data' , $ data ) ; $ this -> redirect ( $ url ) ; } | Redirects to a URL with data passed in as a temp flash session . |
230,368 | public function group ( $ name , $ data = [ ] ) { $ app = 'App\Groups\\' . ucwords ( $ name ) ; $ core = 'Scara\Http\Groups\\' . ucwords ( $ name ) ; if ( class_exists ( $ app ) ) { $ class = new $ app ( ) ; } else { if ( class_exists ( $ core ) ) { $ class = new $ core ( ) ; } else { throw new \ Exception ( "$name gro... | Loads in a group for given controller method . |
230,369 | public function load ( Router $ router , $ basepath ) { $ loader = new RouteLoader ( ) ; $ loader -> registerRouter ( $ router ) ; $ this -> _route = $ loader -> getRequestedRoute ( $ basepath ) ; if ( isset ( $ this -> _route [ 'method' ] ) && $ this -> _route [ 'method' ] == $ _SERVER [ 'REQUEST_METHOD' ] ) { $ contr... | Loads the controller with the requested route . |
230,370 | public function loadErrorPage ( $ errorType ) { switch ( $ errorType ) { case 'notfound' : $ code = '404' ; break ; case 'badrequest' : $ code = '400' ; break ; default : $ code = $ errorType ; break ; } require_once \ Config :: from ( 'app' ) -> get ( 'errors' ) ; if ( isset ( $ errors ) ) { foreach ( $ errors as $ er... | Loads a requested error page . |
230,371 | protected function getReflectionMethod ( $ class , $ name ) { $ reflectionClass = new ReflectionClass ( $ class ) ; $ method = $ reflectionClass -> getMethod ( $ name ) ; $ method -> setAccessible ( true ) ; return $ method ; } | Gets a reflection method object . |
230,372 | protected function getReflectionProperty ( $ objectOrClass , $ name ) { $ reflectionClass = new ReflectionClass ( $ objectOrClass ) ; $ property = $ reflectionClass -> getProperty ( ( string ) $ name ) ; $ property -> setAccessible ( true ) ; return $ property ; } | Gets a reflection property object . |
230,373 | protected function setPropertyValue ( $ object , $ propertyName , $ value ) { $ this -> getReflectionProperty ( $ object , $ propertyName ) -> setValue ( $ object , $ value ) ; return $ this ; } | Sets value in object property . |
230,374 | protected function getPath ( $ path ) { $ hasHttp = strpos ( $ path , 'http' ) ; if ( false === $ hasHttp || $ hasHttp !== 0 ) { return $ this -> options [ 'base_url' ] . $ path ; } return $ path ; } | Generate a complete URL using the option base_url |
230,375 | public static function createRequest ( $ method , $ path , $ body = [ ] , array $ headers = [ ] ) { return new Request ( $ method , $ path , $ body , $ headers ) ; } | Generate a request object |
230,376 | private function _escape ( $ value , $ htmlEntities = false ) { if ( get_magic_quotes_gpc ( ) ) { if ( $ htmlEntities ) { return htmlspecialchars ( $ value ) ; } return $ value ; } if ( is_array ( $ value ) ) { return array_map ( function ( $ n ) use ( $ htmlEntities ) { $ val = stripslashes ( $ n ) ; if ( $ htmlEntiti... | escape string value . |
230,377 | public static function map ( RecordInterface $ source , $ destination , array $ rules ) { if ( ! is_object ( $ destination ) ) { throw new InvalidArgumentException ( 'Destination must be an object' ) ; } $ data = $ source -> getProperties ( ) ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , '_' ) !== fa... | Method which can map all fields of a record to an arbitrary class by calling the fitting setter methods if available |
230,378 | public function hash ( string $ data , $ file = false ) { if ( $ file === false ) { return $ this -> hashContent ( $ data ) ; } return $ this -> hashFile ( $ file ) ; } | Hash by message |
230,379 | private function hashFile ( string $ filename ) { $ hash = hash_hmac_file ( $ this -> algorithm , $ filename , $ this -> key ) ; return $ this -> validate ( $ hash ) ; } | Hash by filename |
230,380 | private function hashContent ( string $ data ) { $ hash = hash_hmac ( $ this -> algorithm , $ data , $ this -> key ) ; return $ this -> validate ( $ hash ) ; } | Hash by content |
230,381 | public function json ( array $ array = [ ] , int $ code = null ) { $ this -> data = $ array ; if ( $ code != null ) { $ this -> code = $ code ; header ( 'HTTP/1.1 ' . $ this -> code ) ; return $ this -> send ( ) ; } return $ this ; } | Attach json data |
230,382 | public function withHeaders ( array $ array , int $ code = null ) { foreach ( $ array as $ field => $ i ) { array_push ( $ this -> headers , $ field . ': ' . $ i ) ; } if ( $ code != null ) { $ this -> code = $ code ; header ( 'HTTP/1.1 ' . $ this -> code ) ; return $ this -> send ( ) ; } return $ this ; } | Set response header s |
230,383 | public function view ( string $ path , array $ data = [ ] , bool $ return = false ) { if ( $ this -> headers !== [ 'Content-Type: application/json' ] ) { foreach ( $ this -> headers as $ header ) { header ( $ header ) ; } } return View :: make ( $ path , $ data , $ return ) ; } | Return a view response |
230,384 | public function download ( string $ location , ? string $ filename = null , ? array $ headers = [ ] ) { if ( ! file_exists ( $ location ) ) { header ( "HTTP/1.1 404 Not Found" ) ; return ; } $ size = filesize ( $ location ) ; $ time = date ( 'r' , filemtime ( $ location ) ) ; $ fm = @ fopen ( $ location , 'rb' ) ; if (... | Reads the requested portion of a file and sends its contents to the client with the appropriate headers . This HTTP_RANGE compatible read file function is necessary for allowing streaming media to be skipped around in . |
230,385 | public function resolveString ( $ value , array $ resolving = array ( ) ) { if ( preg_match ( '/^%([^%\s]+)%$/' , $ value , $ match ) ) { $ key = $ match [ 1 ] ; $ lcKey = strtolower ( $ key ) ; if ( isset ( $ resolving [ $ lcKey ] ) ) { throw new ParameterCircularReferenceException ( array_keys ( $ resolving ) ) ; } $... | Resolves parameters inside a string . |
230,386 | static function contents ( $ directory ) { if ( ! self :: exists ( $ directory ) ) return null ; $ dircontents = [ ] ; $ contents = scandir ( $ directory ) ; foreach ( $ contents as $ content ) { if ( $ content != '.' && $ content != '..' ) { array_push ( $ dircontents , $ content ) ; } } return $ dircontents ; } | Returns the contents of directory |
230,387 | public static function getInstance ( $ cloneInstance = false ) : Factory { if ( $ cloneInstance === true || self :: $ cloneInstances === true ) { return clone self :: $ sharedFactoryInstance ; } return self :: $ sharedFactoryInstance ; } | Get a new instance of the Factory class . |
230,388 | public function newInstance ( $ className , $ namespace = 'FuzeWorks\\' ) : self { $ instanceName = strtolower ( $ className ) ; $ className = $ namespace . ucfirst ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not load new instance of '" . $ instanceName . "'. ... | Create a new instance of one of the loaded classes . It reloads the class . It does NOT clone it . |
230,389 | public function cloneInstance ( $ className ) : self { $ instanceName = strtolower ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not clone instance of '" . $ instanceName . "'. Instance was not found." , 1 ) ; } $ this -> { $ instanceName } = clone $ this -> { $... | Clone an instance of one of the loaded classes . It clones the class . It does NOT re - create it . |
230,390 | public function removeInstance ( $ className ) : self { $ instanceName = strtolower ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not remove instance of '" . $ instanceName . "'. Instance was not found." , 1 ) ; } unset ( $ this -> { $ instanceName } ) ; return ... | Remove an instance of one of the loaded classes . |
230,391 | protected function mergeMessages ( array $ customMessages = [ ] , array $ attributes = [ ] ) { $ globalMessages = [ ] ; if ( self :: $ globalMessageInstance instanceof MessageInterface ) { $ globalMessages = self :: $ globalMessageInstance -> getMessages ( ) ; } $ ruleMessages = Variable :: getDefaultRuleMessages ( ) ;... | Merge rule messages & custom messages & attributes |
230,392 | public function toCmsRequest ( Request $ request ) { $ cmsRequest = ( new CmsRequest ) -> duplicate ( $ request -> query -> all ( ) , $ request -> request -> all ( ) , $ request -> attributes -> all ( ) , $ request -> cookies -> all ( ) , $ request -> files -> all ( ) , $ request -> server -> all ( ) ) ; $ cmsRequest -... | Creates a CmsRequest out of an Illuminate Request |
230,393 | public function addAction ( array $ action ) { $ actions = $ this -> getAction ( ) ; $ actions [ ] = $ action ; return $ this -> setAction ( $ actions ) ; } | Set an array in the action array . |
230,394 | private function getPayloadAlertKeyValue ( ) { if ( $ this -> getSimpleAlert ( ) ) { return $ this -> getSimpleAlert ( ) ; } $ payloadAlert = array ( ) ; if ( $ this -> getAlertTitle ( ) ) { $ payloadAlert [ 'title' ] = $ this -> getAlertTitle ( ) ; } if ( $ this -> getAlertBody ( ) ) { $ payloadAlert [ 'body' ] = $ th... | Get the value of the payload alert key . |
230,395 | public function finish ( \ Caridea \ Validate \ Registry $ registry ) : \ Caridea \ Validate \ Rule { if ( $ this -> validator instanceof \ Caridea \ Validate \ Validator ) { return $ this ; } else { $ rule = clone $ this ; $ builder = $ registry -> builder ( ) ; switch ( $ this -> operator ) { case "nested_object" : c... | Finishes creating a rule using the parent builder . |
230,396 | protected function compileKey ( Blueprint $ blueprint , Fluent $ command , $ type ) { $ columns = $ this -> columnize ( $ command -> columns ) ; $ table = $ this -> wrapTable ( $ blueprint ) ; $ index = $ this -> wrap ( $ command -> index ) ; return "alter table {$table} add {$type} {$index}($columns)" ; } | Compile an index creation command . |
230,397 | protected function flatMap ( array $ flattened , MonadInterface $ result ) { $ value = $ result -> get ( ) ; if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } return array_merge ( $ flattened , $ value ) ; } | Internal callback that is used in conjunction with php s array_reduce to flatten recursive chain results . |
230,398 | public function build ( array $ params = null ) { if ( null !== $ params ) { $ this -> setParams ( $ params ) ; } $ this -> adapter = $ this -> getDoctrinePaginatorAdapter ( ) ; $ this -> setCurrentPageNumber ( $ this -> getParam ( 'page' , 1 ) ) ; $ this -> setDefaultItemCountPerPage ( $ this -> getParam ( 'limit' , 3... | Build the instance |
230,399 | public function getParam ( $ param , $ default = null ) { if ( array_key_exists ( $ param , $ this -> params ) ) { return $ this -> params [ $ param ] ; } return $ default ; } | Get a specified param |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.