idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
42,000 | protected function & internalGetModular ( string $ name ) : ModularAbstract { $ modularName = $ this -> sanitizeModularName ( $ name ) ; if ( ! $ modularName ) { throw new InvalidArgumentException ( "Please insert not an empty arguments" , E_USER_ERROR ) ; } if ( ! $ this -> exist ( $ modularName ) ) { throw new InvalidModularException ( sprintf ( '%1$s %2$s has not found' , $ this -> modularParser -> getName ( ) , $ name ) ) ; } if ( is_array ( $ this -> validModular [ $ modularName ] ) ) { $ className = empty ( $ this -> validModular [ $ modularName ] [ static :: CLASS_NAME_KEY ] ) ? null : ( string ) $ this -> validModular [ $ modularName ] [ static :: CLASS_NAME_KEY ] ; if ( ! $ className || ! class_exists ( $ this -> validModular [ $ modularName ] [ static :: CLASS_NAME_KEY ] ) ) { throw new InvalidModularException ( sprintf ( '%1$s %2$s has not found' , $ this -> modularParser -> getName ( ) , $ name ) ) ; } $ modular = new $ className ( $ this -> modularParser -> getContainer ( ) , $ modularName ) ; $ this -> validModular [ $ modularName ] = $ modular ; } if ( ! $ this -> validModular [ $ modularName ] instanceof ModularAbstract ) { unset ( $ this -> validModular [ $ modularName ] ) ; $ e = new InvalidModularException ( sprintf ( '%1$s %2$s Is not valid.' , $ this -> modularParser -> getName ( ) , $ name ) ) ; $ this -> invalidModular [ $ modularName ] = $ e ; throw $ e ; } return $ this -> validModular [ $ modularName ] ; } | Get Modular Given By Name |
42,001 | public function getAllModularInfo ( ) { $ modularInfo = new Collection ( ) ; foreach ( $ this -> getAllValidModular ( ) as $ modularName => $ modular ) { $ modularInfo [ $ modularName ] = $ this -> getModularInformation ( $ modularName ) ; } return $ modularInfo ; } | Get All ModularAbstract Info |
42,002 | public function hasLoaded ( string $ name ) { $ modularName = $ this -> sanitizeModularName ( $ name ) ; return $ modularName && ! empty ( $ this -> loadedModular [ $ modularName ] ) ; } | Check If Modular Has Loaded |
42,003 | public function get ( string $ name = null ) : \ TheCMSThread \ Classes \ Plugin { if ( empty ( $ name ) === false && empty ( $ this -> plugins [ $ name ] ) === false ) { return $ this -> plugins [ $ name ] ; } else { throw new \ InvalidArgumentException ( "Plugin not found" ) ; } } | Returns a plugin object |
42,004 | public function runAll ( ) : string { $ result = '' ; foreach ( $ this -> getAll ( ) as $ plugin ) { $ result .= ( string ) $ plugin -> run ( ) ; } return $ result ; } | Runs the list of all active plugin objects |
42,005 | public function run ( string $ name = null ) : string { return ( string ) $ this -> get ( $ name ) -> run ( ) ; } | Runs a plugin object |
42,006 | public function stylesAll ( ) : array { $ styles = [ ] ; foreach ( $ this -> getAll ( ) as $ name => $ plugin ) { $ styles [ $ name ] = $ plugin -> styles ( ) ; } return $ styles ; } | Returns the list of all active plugin stylesheets |
42,007 | public function scriptsAll ( ) : array { $ scripts = [ ] ; foreach ( $ this -> getAll ( ) as $ name => $ plugin ) { $ scripts [ $ name ] = $ plugin -> scripts ( ) ; } return $ scripts ; } | Returns the list of all active plugin scripts |
42,008 | protected function renderHelper ( $ name , $ value , ElementInterface $ element ) { $ helper = $ this -> getView ( ) -> plugin ( $ name ) ; if ( $ helper instanceof HtmlContainer && $ helper -> getTagName ( ) ) { $ this -> shouldWrap = false ; return $ helper ( $ value , $ element -> getAttributes ( ) ) ; } $ this -> shouldWrap = true ; return $ helper ( $ value ) ; } | Render value by helper name |
42,009 | protected function renderInstance ( ElementInterface $ element ) { $ value = $ this -> getElementValue ( $ element ) ; foreach ( $ this -> classMap as $ class => $ pluginName ) { if ( $ value instanceof $ class ) { return $ this -> renderHelper ( $ pluginName , $ value , $ element ) ; } } return ; } | Render element by instance map |
42,010 | protected static function _prepare ( ) { if ( empty ( static :: $ _module ) ) { $ module = Module :: getModuleByClassname ( Module :: className ( ) ) ; if ( ! empty ( $ module ) ) { static :: $ _sysControllerUid = "/sys/main" ; static :: $ _routeActionView = "/{$module->uniqueId}/main/view" ; static :: $ _routeActionShow = "/{$module->uniqueId}/main/show" ; static :: $ _model = $ module :: model ( self :: MODEL_ALIAS ) ; } } } | Init usable vars |
42,011 | protected static function checkRoutesLink ( $ node ) { $ nodeLink = static :: $ _model -> getNodePath ( $ node ) ; $ result = false ; foreach ( Yii :: $ app -> urlManager -> rules as $ nextRule ) { if ( RoutesBuilder :: properRule ( $ nextRule , $ nodeLink ) ) { $ result = true ; break ; } } if ( $ result ) { $ result = '/' . $ nodeLink ; $ lh = static :: langHelperClass ( ) ; if ( $ lh :: countActiveLanguages ( ) > 1 ) { $ lang = $ lh :: getLangCode2 ( static :: language ( ) ) ; $ result = '/' . $ lang . '/' . $ nodeLink ; } } return $ result ; } | For node without text check if exists such route for any another module . If such route exists will return link for menu . |
42,012 | protected static function createContentLink ( $ node ) { static :: _prepare ( ) ; $ url = false ; if ( empty ( $ node -> text ) && ! empty ( $ node -> route ) ) { $ url = static :: routeToLink ( $ node -> route ) ; } if ( $ url === false ) { $ url = Url :: toRoute ( [ static :: $ _routeActionView , 'id' => $ node -> id ] ) ; $ parts = parse_url ( $ url ) ; if ( ! empty ( $ parts [ 'path' ] ) ) { $ url = $ parts [ 'path' ] ; if ( strstr ( $ url , static :: $ _routeActionView ) ) { $ url = false ; } } } if ( $ url === false && empty ( $ node -> route ) && ! empty ( $ node -> text ) ) { $ url = Url :: toRoute ( [ static :: $ _routeActionShow , 'id' => $ node -> id , 'slug' => $ node -> slug ] ) ; } return $ url ; } | Create link for node . |
42,013 | public static function routeToLink ( $ strRoute , $ ctrlLinkPrefix = null ) { if ( empty ( $ ctrlLinkPrefix ) ) { static :: _prepare ( ) ; $ ctrlLinkPrefix = Url :: toRoute ( [ static :: $ _sysControllerUid ] ) ; } $ strRoute = trim ( $ strRoute ) ; $ url = $ route = false ; if ( substr ( $ strRoute , 0 , 1 ) == '=' ) { $ url = trim ( substr ( $ strRoute , 1 ) ) ; } else { if ( substr ( $ strRoute , 0 , 1 ) == '[' ) { $ route = static :: convertRouteStrToArray ( $ strRoute ) ; } elseif ( substr ( $ strRoute , 0 , 1 ) == '/' ) { $ route = $ strRoute ; } if ( ! $ route ) { $ url = false ; } else { try { $ url = Url :: toRoute ( $ route ) ; $ parts = parse_url ( $ url ) ; if ( 0 === strpos ( $ parts [ 'path' ] , $ ctrlLinkPrefix ) ) { static :: $ errorRouteConvert = "Illegal link resolved" ; $ url = false ; } } catch ( InvalidParamException $ ex ) { static :: $ errorRouteConvert = $ ex -> getMessage ( ) ; $ url = false ; } } } return $ url ; } | Convert route to link . |
42,014 | protected static function convertRouteStrToArray ( $ strRoute ) { $ str = trim ( $ strRoute ) ; if ( substr ( $ str , 0 , 1 ) == '[' && substr ( $ str , - 1 , 1 ) == ']' ) { $ str = trim ( $ str , "[]" ) ; } else { static :: $ errorRouteConvert = "Array syntax: not found '[' or ']'" ; return false ; } $ array = [ ] ; $ i = 0 ; $ parts = explode ( ',' , $ str ) ; foreach ( $ parts as $ next ) { $ element = explode ( "=>" , $ next ) ; if ( is_array ( $ element ) && count ( $ element ) == 1 ) { $ val = trim ( $ element [ 0 ] ) ; if ( ( substr ( $ val , 0 , 1 ) == '"' && substr ( $ val , - 1 , 1 ) == '"' ) || ( substr ( $ val , 0 , 1 ) == "'" && substr ( $ val , - 1 , 1 ) == "'" ) ) { $ array [ $ i ++ ] = trim ( $ val , "\"'" ) ; } else { static :: $ errorRouteConvert = "Array element syntax: '$val'" ; return false ; } } elseif ( is_array ( $ element ) && count ( $ element ) == 2 ) { $ key = trim ( $ element [ 0 ] ) ; $ val = trim ( $ element [ 1 ] ) ; if ( ( ( substr ( $ key , 0 , 1 ) == '"' && substr ( $ key , - 1 , 1 ) == '"' ) || ( substr ( $ key , 0 , 1 ) == "'" && substr ( $ key , - 1 , 1 ) == "'" ) ) && ( ( substr ( $ val , 0 , 1 ) == '"' && substr ( $ val , - 1 , 1 ) == '"' ) || ( substr ( $ val , 0 , 1 ) == "'" && substr ( $ val , - 1 , 1 ) == "'" ) || is_numeric ( $ val ) ) ) { $ array [ trim ( $ key , "\"'" ) ] = trim ( $ val , "\"'" ) ; } else { static :: $ errorRouteConvert = "Array element syntax: '$key => $val'" ; return false ; } } else { static :: $ errorRouteConvert = "Array element syntax" ; return false ; } } return $ array ; } | Convert string array definition to array . |
42,015 | public static function uniq ( $ collection = null , $ is_sorted = null , $ iterator = null ) { $ return = array ( ) ; if ( count ( $ collection ) === 0 ) { return $ return ; } $ calculated = array ( ) ; foreach ( $ collection as $ item ) { $ val = ( ! is_null ( $ iterator ) ) ? $ iterator ( $ item ) : $ item ; if ( is_bool ( array_search ( $ val , $ calculated , true ) ) ) { $ calculated [ ] = $ val ; $ return [ ] = $ item ; } } return $ return ; } | Return an array of the unique values |
42,016 | public static function first ( $ collection = null , $ n = null ) { if ( $ n === 0 ) { return array ( ) ; } if ( is_null ( $ n ) ) { return current ( array_splice ( $ collection , 0 , 1 , true ) ) ; } return array_splice ( $ collection , 0 , $ n , true ) ; } | Get the first element of an array . Passing n returns the first n elements . |
42,017 | public static function rest ( $ collection = null , $ index = null ) { if ( is_null ( $ index ) ) { $ index = 1 ; } return array_splice ( $ collection , $ index ) ; } | Get the rest of the array elements . Passing n returns from that index onward . |
42,018 | public function filter ( $ collection = null , $ iterator = null ) { $ return = array ( ) ; foreach ( $ collection as $ val ) { if ( call_user_func ( $ iterator , $ val ) ) { $ return [ ] = $ val ; } } return $ return ; } | Return an array of values that pass the truth iterator test |
42,019 | public static function getRelativePath ( $ frompath , $ topath = "" ) { if ( empty ( $ topath ) ) { $ topath = $ frompath ; $ frompath = getcwd ( ) ; } if ( $ frompath == "." ) $ frompath = getcwd ( ) ; if ( $ topath == "." ) $ topath = getcwd ( ) ; if ( $ frompath [ 0 ] != DIRECTORY_SEPARATOR ) $ frompath = getcwd ( ) . DIRECTORY_SEPARATOR . $ frompath ; if ( $ topath [ 0 ] != DIRECTORY_SEPARATOR ) $ topath = getcwd ( ) . DIRECTORY_SEPARATOR . $ topath ; $ from = explode ( DIRECTORY_SEPARATOR , $ frompath ) ; $ to = explode ( DIRECTORY_SEPARATOR , $ topath ) ; $ relpath = '' ; $ i = 0 ; while ( isset ( $ from [ $ i ] ) && isset ( $ to [ $ i ] ) ) { if ( $ from [ $ i ] != $ to [ $ i ] ) break ; $ i ++ ; } $ j = count ( $ from ) - 1 ; while ( $ i <= $ j ) { if ( ! empty ( $ from [ $ j ] ) ) $ relpath .= '..' . DIRECTORY_SEPARATOR ; $ j -- ; } while ( isset ( $ to [ $ i ] ) ) { if ( ! empty ( $ to [ $ i ] ) ) $ relpath .= $ to [ $ i ] . DIRECTORY_SEPARATOR ; $ i ++ ; } return substr ( $ relpath , 0 , - 1 ) ? : "." ; } | Get the relative path between 2 folders . |
42,020 | public static function readPartialFile ( $ file , $ from = 0 , $ to = 0 , $ filesize = FALSE , $ force = FALSE , $ context = NULL ) { if ( ! $ force ) { if ( ! @ file_exists ( $ file ) ) { return 404 ; } if ( ! @ is_readable ( $ file ) ) { return 403 ; } } if ( ! ( $ file instanceof SplFileObject ) ) { $ file = new SplFileObject ( $ file ) ; } $ filesize = $ file -> getSize ( ) ; if ( is_array ( $ from ) ) { throw new Exception ( "Not implemented yet." ) ; } if ( $ from < 0 ) { $ from = $ filesize + $ from ; } if ( $ to <= 0 ) { $ to = $ filesize + $ to - 1 ; } if ( $ from < 0 || $ to >= $ filesize || $ from > $ to ) { throw new Exception ( "Invalid Range. (filesize: $filesize, from: $from, to: $to)" ) ; } $ file -> fseek ( $ from ) ; $ length = $ to - $ from + 1 ; while ( $ length ) { $ read = ( $ length > 8192 ) ? 8192 : $ length ; $ length -= $ read ; $ content = $ file -> fread ( $ read ) ; if ( $ content === FALSE ) { return FALSE ; } else { print ( $ content ) ; } } return $ length ; } | Like PHPs readfile but the range of the output can be specified |
42,021 | public static function flattenArray ( $ array , $ delimiter = '.' , $ prefix = '' ) { if ( ! is_array ( $ array ) ) { return $ array ; } $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ result = array_merge ( $ result , self :: flattenArray ( $ value , $ delimiter , $ prefix . $ key . $ delimiter ) ) ; } else { $ result [ $ prefix . $ key ] = $ value ; } } return $ result ; } | Flattens an array preserving keys delimited by a delimiter |
42,022 | public static function unflattenArray ( $ array , $ delimiter = '.' ) { if ( ! is_array ( $ array ) ) { return $ array ; } $ add = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( strpos ( $ key , $ delimiter ) === FALSE ) { continue ; } $ add [ ] = [ explode ( $ delimiter , $ key ) , $ value ] ; unset ( $ array [ $ key ] ) ; } foreach ( $ add as $ pair ) { $ current = & $ array ; while ( ! is_null ( $ key = array_shift ( $ pair [ 0 ] ) ) ) { if ( ! is_array ( $ current ) ) { $ current = array ( ) ; } if ( ! array_key_exists ( $ key , $ current ) ) { $ current [ $ key ] = array ( ) ; } $ current = & $ current [ $ key ] ; } $ current = $ pair [ 1 ] ; } return $ array ; } | Unflattens an array by a delimiter . |
42,023 | public static function redirect ( $ target , $ status_code = 302 , $ loops = NULL ) { if ( ! $ loops ) { $ loops = Loops :: getCurrentLoops ( ) ; } $ config = $ loops -> getService ( "config" ) ; $ request = $ loops -> getService ( "request" ) ; $ response = $ loops -> getService ( "response" ) ; $ core = $ loops -> getService ( "web_core" ) ; if ( $ target instanceof ElementInterface ) { $ target = $ core -> base_url . $ target -> getPagePath ( ) ; } if ( ! is_string ( $ target ) ) { throw new Exception ( "Target must be string or implement 'Loops\ElementInterface'." ) ; } $ response -> addHeader ( "Location: " . $ target . $ request -> getQuery ( ) ) ; return $ status_code ; } | Sets up redirect headers in the response |
42,024 | public static function recursiveUnlink ( $ dir ) { $ result = TRUE ; if ( is_dir ( $ dir ) ) { foreach ( scandir ( $ dir ) as $ sub ) { if ( in_array ( $ sub , [ '.' , '..' ] ) ) continue ; $ result &= self :: recursiveUnlink ( "$dir/$sub" ) ; } $ result &= rmdir ( $ dir ) ; } elseif ( is_file ( $ dir ) ) { $ result &= unlink ( $ dir ) ; } else { $ result = FALSE ; } return ( bool ) $ result ; } | Recursively unlinks a directory |
42,025 | public static function recursiveMkdir ( $ pathname , $ mode = 0777 , $ recursive = TRUE , $ context = NULL ) { if ( is_dir ( $ pathname ) ) { return TRUE ; } if ( $ context ) { return mkdir ( $ pathname , $ mode , $ recursive , $ context ) ; } else { return mkdir ( $ pathname , $ mode , $ recursive ) ; } } | Recursively created a directory |
42,026 | public static function reflectionInstance ( $ classname , $ arguments = [ ] , $ set_remaining = FALSE , $ set_include = FALSE , $ set_exclude = FALSE ) { $ reflection = new ReflectionClass ( $ classname ) ; if ( ! $ constructor = $ reflection -> getConstructor ( ) ) { return new $ classname ; } $ args = self :: getReflectionArgs ( $ constructor , $ arguments , $ missing ) ; if ( $ missing ) { $ parts = [ ] ; foreach ( $ missing as $ key => $ name ) { $ parts [ ] = "'$name' (or '$key')" ; } $ missing = implode ( ", " , $ parts ) ; throw new Exception ( "Can not create object of type '$classname'. Argument $missing needs to be set." ) ; } $ instance = $ reflection -> newInstanceArgs ( $ args ) ; if ( $ set_remaining ) { foreach ( $ arguments as $ key => $ value ) { if ( is_array ( $ set_include ) && ! in_array ( $ key , $ set_include ) ) { continue ; } if ( is_array ( $ set_exclude ) && in_array ( $ key , $ set_exclude ) ) { continue ; } $ instance -> $ key = $ value ; } } return $ instance ; } | Invokes constructors by assembling arguments from an array with the help of the reflection API . |
42,027 | public static function reflectionFunction ( $ function , $ arguments = [ ] ) { $ method = is_array ( $ function ) ; if ( $ method ) { $ reflection = new ReflectionMethod ( $ function [ 0 ] , $ function [ 1 ] ) ; } else { $ reflection = new ReflectionFunction ( $ function ) ; } $ args = self :: getReflectionArgs ( $ reflection , $ arguments , $ missing ) ; if ( $ missing ) { $ name = $ reflection -> getName ( ) ; $ parts = [ ] ; foreach ( $ missing as $ key => $ name ) { $ parts [ ] = "'$name' (or '$key')" ; } $ missing = implode ( ", " , $ parts ) ; throw new Exception ( "Can not call function '$name'. Argument(s) $missing need to be set." ) ; } return $ method ? $ reflection -> invokeArgs ( $ function [ 0 ] , $ args ) : $ reflection -> invokeArgs ( $ args ) ; } | Invokes functions by assembling arguments from an array with the help of the reflection API . |
42,028 | public static function lastChange ( $ dirs , Cache $ cache = NULL , & $ cache_key = "" ) { $ files = call_user_func_array ( "array_merge" , array_map ( function ( $ dir ) { if ( ! is_dir ( $ dir ) ) return [ ] ; return iterator_to_array ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dir ) ) ) ; } , ( array ) $ dirs ) ) ; if ( ! $ files ) { return NULL ; } $ files = array_filter ( $ files , function ( $ file ) { return ! is_link ( $ file ) ; } ) ; usort ( $ files , function ( $ a , $ b ) { return $ b -> getMTime ( ) - $ a -> getMTime ( ) ; } ) ; if ( ! $ cache ) { return $ files [ 0 ] ; } $ lastchange = $ files [ 0 ] -> getMTime ( ) ; $ cache_key = "Loops-Misc-filesChanged-" . implode ( "-" , $ dirs ) ; if ( $ cache -> contains ( $ cache_key ) ) { $ mtime = $ cache -> fetch ( $ cache_key ) ; } else { $ mtime = FALSE ; } $ cache -> save ( $ cache_key , $ lastchange ) ; if ( $ mtime != $ lastchange ) { return $ files [ 0 ] ; } return NULL ; } | Finds the lastest change in a directory since the last call if there were any . |
42,029 | public static function fullPath ( $ path , $ cwd = NULL , $ allow_parent = FALSE ) { if ( substr ( $ path , 0 , 1 ) == DIRECTORY_SEPARATOR ) { return $ path ; } if ( substr ( $ path , 1 , 2 ) == ":\\" ) { return $ path ; } if ( ! $ allow_parent ) { $ parts = explode ( DIRECTORY_SEPARATOR , $ path ) ; if ( array_search ( ".." , $ parts ) !== FALSE ) { throw new Exception ( "Parent directory in path '$path' detected. This is currently not allowed." ) ; } } $ path = rtrim ( $ cwd ? : getcwd ( ) , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . $ path ; if ( substr ( $ path , 1 , 2 ) == ":\\" ) { $ prefix = substr ( $ path , 0 , 3 ) ; $ path = substr ( $ path , 3 ) ; } else { $ prefix = "" ; } $ parts = explode ( DIRECTORY_SEPARATOR , $ path ) ; $ result = [ ] ; while ( $ parts ) { $ part = array_shift ( $ parts ) ; if ( $ part == ".." ) { if ( count ( $ result ) <= 1 ) { throw new Exception ( "'$path' can not exist." ) ; } array_pop ( $ result ) ; } else { array_push ( $ result , $ part ) ; } } return $ prefix . implode ( DIRECTORY_SEPARATOR , $ result ) ; } | Gets the full path from relative paths |
42,030 | public function init ( ) { self :: $ app = $ this ; spl_autoload_register ( array ( $ this [ 'loader' ] , 'load' ) ) ; $ this -> registerProviders ( ) ; $ this -> registerAliases ( ) ; } | Register the auto - loader |
42,031 | public function registerProviders ( ) { $ providers = $ this [ 'config' ] -> get ( 'app.providers' ) ; foreach ( $ providers as $ provider ) { $ this -> providers [ $ provider ] = new $ provider ( $ this ) ; $ this -> providers [ $ provider ] -> register ( ) ; } } | Register all the providers |
42,032 | private function initDefaultClasses ( ) { $ this [ 'loader' ] = $ this -> share ( function ( $ app ) { return new ClassLoader ( ) ; } ) ; $ this [ 'config' ] = $ this -> share ( function ( $ app ) { $ config = new Config ( ) ; $ config -> addHint ( $ app [ 'path.root' ] . '/resources/config/' ) ; return $ config ; } ) ; $ this -> instance ( 'app' , $ this ) ; } | Init default classes used by the application |
42,033 | protected function isDynamicAttribute ( AnnotationBag $ propertyAnnotations ) { return $ propertyAnnotations -> has ( 'Query' ) || $ propertyAnnotations -> has ( 'Statement' ) || $ propertyAnnotations -> has ( 'Procedure' ) || $ propertyAnnotations -> has ( 'Eval' ) ; } | Determines if a given property is a dyamic attribute |
42,034 | protected function parseDynamicAttribute ( $ propertyName , \ ReflectionProperty $ reflectionProperty , AnnotationBag $ propertyAnnotations ) { if ( $ propertyAnnotations -> has ( 'Query' ) ) $ attribute = new Query ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; elseif ( $ propertyAnnotations -> has ( 'Statement' ) ) $ attribute = new Statement ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; elseif ( $ propertyAnnotations -> has ( 'Procedure' ) ) $ attribute = new Procedure ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; elseif ( $ propertyAnnotations -> has ( 'Eval' ) ) $ attribute = new Macro ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; if ( $ attribute -> isCacheable ( ) ) $ this -> attributes [ $ propertyName ] = $ attribute ; else $ this -> dynamicAttributes [ $ propertyName ] = $ attribute ; } | Parses a dynamic attribute |
42,035 | protected function isAssociation ( AnnotationBag $ propertyAnnotations ) { return $ propertyAnnotations -> has ( 'OneToOne' ) || $ propertyAnnotations -> has ( 'OneToMany' ) || $ propertyAnnotations -> has ( 'ManyToOne' ) || $ propertyAnnotations -> has ( 'ManyToMany' ) ; } | Determines if a given property is an association |
42,036 | protected function parseAssociation ( $ propertyName , \ ReflectionProperty $ reflectionProperty , AnnotationBag $ propertyAnnotations ) { if ( $ propertyAnnotations -> has ( 'OneToOne' ) ) { $ association = new OneToOne ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; if ( $ association -> isForeignKey ( ) ) { $ attribute = $ association -> getAttribute ( ) -> getArgument ( ) ; $ this -> foreignKeys [ $ attribute ] = $ propertyName ; } elseif ( $ association -> isCascade ( ) ) $ this -> references [ ] = $ propertyName ; } elseif ( $ propertyAnnotations -> has ( 'OneToMany' ) ) { $ association = new OneToMany ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; if ( $ association -> isCascade ( ) ) $ this -> references [ ] = $ propertyName ; } elseif ( $ propertyAnnotations -> has ( 'ManyToOne' ) ) { $ association = new ManyToOne ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; $ attribute = $ association -> getAttribute ( ) -> getArgument ( ) ; $ this -> foreignKeys [ $ attribute ] = $ propertyName ; } elseif ( $ propertyAnnotations -> has ( 'ManyToMany' ) ) { $ association = new ManyToMany ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; if ( $ association -> isCascade ( ) ) $ this -> references [ ] = $ propertyName ; } $ this -> associations [ $ propertyName ] = $ association ; } | Parses an entity association |
42,037 | protected function parseProperties ( ) { if ( $ this -> isEntity ( ) ) { $ this -> propertyMap = [ ] ; $ this -> foreignkeys = $ this -> references = [ ] ; $ this -> readOnlyProperties = [ ] ; $ this -> duplicateChecks = [ ] ; } $ properties = $ this -> reflectionClass -> getProperties ( ) ; foreach ( $ properties as $ reflectionProperty ) { $ propertyName = $ reflectionProperty -> getName ( ) ; $ propertyAnnotations = Omocha :: getAnnotations ( $ reflectionProperty ) ; if ( ( $ this -> isEntity ( ) || $ this -> isResultMap ( ) ) && $ this -> isDynamicAttribute ( $ propertyAnnotations ) ) $ this -> parseDynamicAttribute ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; elseif ( $ this -> isEntity ( ) && $ this -> isAssociation ( $ propertyAnnotations ) ) $ this -> parseAssociation ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; else { $ property = new ClassProperty ( $ propertyName , $ reflectionProperty , $ propertyAnnotations ) ; if ( $ this -> isEntity ( ) ) { if ( $ property -> isPrimaryKey ( ) ) $ this -> primaryKey = $ propertyName ; elseif ( $ property -> checksForDuplicates ( ) ) $ this -> duplicateChecks [ ] = $ propertyName ; $ this -> propertyMap [ $ propertyName ] = $ property -> getColumn ( ) ; if ( $ property -> isReadOnly ( ) ) $ this -> readOnlyProperties [ ] = $ propertyName ; } $ this -> properties [ $ propertyName ] = $ property ; } } } | Parses the properties of the current class |
42,038 | public function isSafe ( ) { if ( $ this -> classAnnotations -> has ( 'Safe' ) ) return ( bool ) $ this -> classAnnotations -> get ( 'Safe' ) -> getValue ( ) ; return false ; } | DEtermines if a type handler provides safe values |
42,039 | function import ( $ data ) { if ( $ data === null ) return $ this ; if ( ! ( is_array ( $ data ) || $ data instanceof \ Traversable || $ data instanceof \ stdClass ) ) throw new \ InvalidArgumentException ( sprintf ( 'Data must be instance of \Traversable, \stdClass or array. given: (%s)' , \ Poirot \ Std \ flatten ( $ data ) ) ) ; if ( $ data instanceof \ stdClass ) $ data = \ Poirot \ Std \ toArrayObject ( $ data ) ; foreach ( $ data as $ k => $ v ) $ this -> set ( $ k , $ v ) ; return $ this ; } | Import Data Into Current Realm |
42,040 | public function parseFile ( string $ path ) : bool { static :: $ iteration ++ ; if ( static :: $ iteration > 10 ) exit ( ) ; if ( in_array ( $ path , $ this -> parsed_files ) ) { return true ; } $ this -> parsed_files [ ] = $ path ; if ( is_readable ( $ path ) ) { $ array = include ( $ path ) ; } else { if ( isset ( Core :: i ( ) -> log ) ) { Core :: i ( ) -> log -> debug ( 'Config path ' . $ path . ' could not be read.' ) ; } return false ; } if ( ! is_array ( $ array ) ) { if ( isset ( Core :: i ( ) -> log ) ) { Core :: i ( ) -> log -> debug ( 'Config file ' . $ path . ' is not an array.' ) ; } return false ; } $ this -> parseArray ( $ array ) ; return true ; } | Process a single file s configuration settings . |
42,041 | private function init ( ) { $ current_dir = realpath ( '.' ) ; $ output = "" ; $ result = array ( 'status' => true , 'message' => '' ) ; $ server_list = $ this -> options -> preview_server ; array_push ( $ server_list , json_decode ( json_encode ( array ( 'name' => 'master' , 'path' => $ this -> options -> git -> repository , ) ) ) ) ; set_time_limit ( 0 ) ; foreach ( $ server_list as $ preview_server ) { chdir ( $ current_dir ) ; try { if ( strlen ( $ preview_server -> path ) ) { if ( ! file_exists ( $ preview_server -> path ) ) { if ( ! mkdir ( $ preview_server -> path , 0777 ) ) { throw new \ Exception ( 'Creation of preview server directory failed.' ) ; } } if ( ! file_exists ( $ preview_server -> path . "/.git" ) ) { if ( chdir ( $ preview_server -> path ) ) { exec ( 'git init' , $ output ) ; $ url = $ this -> options -> git -> protocol . "://" ; if ( strlen ( @ $ this -> options -> git -> username ) ) { $ url .= urlencode ( $ this -> options -> git -> username ) . ":" . urlencode ( $ this -> options -> git -> password ) . "@" ; } $ url .= $ this -> options -> git -> url ; exec ( 'git remote add origin ' . escapeshellarg ( $ url ) , $ output ) ; exec ( 'git fetch origin' , $ output ) ; exec ( 'git pull origin master' , $ output ) ; chdir ( $ current_dir ) ; } else { throw new \ Exception ( 'Preview server directory not found.' ) ; } } } } catch ( \ Exception $ e ) { set_time_limit ( 30 ) ; $ result [ 'status' ] = false ; $ result [ 'message' ] = $ e -> getMessage ( ) ; chdir ( $ current_dir ) ; return $ result ; } } set_time_limit ( 30 ) ; $ result [ 'status' ] = true ; return $ result ; } | initialize GIT Repository |
42,042 | private function generateRepository ( $ className ) { $ table = EntityReflexion :: getTable ( $ className ) ; if ( $ table === NULL ) { throw new RepositoryException ( "Entity \"" . $ className . " has no annotation \"table\"" ) ; } else { $ genClassName = $ this -> generateRepositoryName ( $ className ) ; if ( ! class_exists ( $ genClassName ) ) { $ class = $ this -> cache -> load ( $ genClassName ) ; if ( $ class ) { $ repository = $ class ; } else { $ repository = new ClassType ( $ genClassName ) ; $ repository -> addExtend ( '\slimORM\BaseRepository' ) ; $ repository -> setFinal ( TRUE ) ; $ repository -> addComment ( $ genClassName ) ; $ repository -> addComment ( "@generated" ) ; $ repository -> addProperty ( "connection" ) -> setVisibility ( "protected" ) -> addComment ( '@var \Nette\Database\Context' ) ; $ repository -> addProperty ( "entityManager" ) -> setVisibility ( "protected" ) -> addComment ( '@var \slimORM\EntityManager' ) ; $ parameter = new Parameter ( "connection" ) ; $ parameter -> setTypeHint ( '\Nette\Database\Context' ) ; $ parameter2 = new Parameter ( "entityManager" ) ; $ parameter2 -> setTypeHint ( '\slimORM\EntityManager' ) ; $ entity = EntityManager :: PREFIX . str_replace ( "\\" , "" , $ className ) . "Entity" ; $ repository -> addMethod ( "__construct" ) -> addComment ( $ genClassName . " constructor" ) -> addComment ( '@param \Nette\Database\Context $connection' ) -> addComment ( '@param \slimORM\EntityManager $entityManager' ) -> setParameters ( array ( $ parameter , $ parameter2 ) ) -> setBody ( "\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");" ) ; $ parameter = new Parameter ( "key" ) ; $ repository -> addMethod ( "get" ) -> addComment ( "Find item by primary key" ) -> addComment ( "@param int \$key" ) -> addComment ( "@return $entity|null" ) -> setParameters ( array ( $ parameter ) ) -> setBody ( "return parent::get(\$key);" ) ; $ this -> cache -> save ( $ genClassName , $ repository , array ( Cache :: FILES => EntityReflexion :: getFile ( $ className ) , ) ) ; } $ res = eval ( '?><?php ' . $ repository ) ; if ( $ res === FALSE && ( $ error = error_get_last ( ) ) && $ error [ 'type' ] === E_PARSE ) { throw new \ ErrorException ( $ error [ 'message' ] , 0 , $ error [ 'type' ] , $ error [ 'file' ] , $ error [ 'line' ] ) ; } $ this -> repositories [ $ genClassName ] = new $ genClassName ( $ this -> connection , $ this ) ; } else if ( ! isset ( $ this -> repositories [ $ genClassName ] ) ) { $ this -> repositories [ $ genClassName ] = new $ genClassName ( $ this -> connection , $ this ) ; } } } | Generate repository class |
42,043 | private function generateEntity ( $ className ) { $ genClassName = EntityManager :: PREFIX . str_replace ( "\\" , "" , $ className ) . "Entity" ; $ table = EntityReflexion :: getTable ( $ className ) ; if ( $ table === NULL ) { throw new RepositoryException ( "Entity \"" . $ className . " has no annotation \"table\"" ) ; } else { if ( in_array ( $ genClassName , $ this -> entities ) || class_exists ( $ genClassName ) ) { return ; } else { $ this -> entities [ $ genClassName ] = $ genClassName ; $ class = $ this -> cache -> load ( $ genClassName ) ; if ( $ class ) { $ repository = $ class ; $ references = $ this -> getReferences ( $ className ) ; $ this -> generateReferences ( $ references ) ; } else { $ repository = new ClassType ( $ genClassName ) ; $ repository -> addExtend ( $ className ) ; $ repository -> setFinal ( TRUE ) ; $ repository -> addComment ( $ genClassName ) ; $ repository -> addComment ( "@table " . $ table ) ; $ columns = $ this -> getColumns ( $ className ) ; $ this -> generateGetters ( $ columns , $ repository ) ; $ references = $ this -> getReferences ( $ className ) ; $ this -> generateReferences ( $ references , $ repository ) ; $ this -> generateAddMethods ( $ references , $ repository ) ; $ this -> generateOverrides ( $ repository ) ; $ this -> cache -> save ( $ genClassName , $ repository , array ( Cache :: FILES => EntityReflexion :: getFile ( $ className ) , ) ) ; } if ( ! class_exists ( $ genClassName ) ) { $ res = eval ( '?><?php ' . $ repository ) ; if ( $ res === FALSE && ( $ error = error_get_last ( ) ) && $ error [ 'type' ] === E_PARSE ) { throw new \ ErrorException ( $ error [ 'message' ] , 0 , $ error [ 'type' ] , $ error [ 'file' ] , $ error [ 'line' ] ) ; } } } } } | Generate entity class |
42,044 | public function transform ( ) { if ( ! $ this -> transformer ) { return [ ] ; } $ presentation = $ this -> transformer -> transform ( $ this -> resource ) ; return $ this -> transformToArray ( $ presentation ) ; } | Present the item using a transformer . |
42,045 | protected function transformToArray ( array $ presentation ) { $ array = [ ] ; foreach ( $ presentation as $ key => $ item ) { if ( is_array ( $ item ) ) { $ array [ $ key ] = $ this -> transformToArray ( $ item ) ; } else if ( $ item instanceof Hidden ) { continue ; } else if ( $ item instanceof Presentation ) { $ array [ $ key ] = $ item -> show ( ) ; } else { $ array [ $ key ] = $ item ; } } return $ array ; } | Transform a presentation to an array . |
42,046 | private function addMainFieldset ( FormInterface $ form ) { $ mainData = $ form -> addChild ( $ this -> getElement ( 'nested_fieldset' , [ 'name' => 'main_data' , 'label' => 'common.fieldset.general' , ] ) ) ; $ languageData = $ mainData -> addChild ( $ this -> getElement ( 'language_fieldset' , [ 'name' => 'translations' , 'label' => 'common.fieldset.translations' , 'transformer' => $ this -> getRepositoryTransformer ( 'translation' , $ this -> get ( 'page.repository' ) ) , ] ) ) ; $ name = $ languageData -> addChild ( $ this -> getElement ( 'text_field' , [ 'name' => 'name' , 'label' => 'common.label.name' , 'rules' => [ $ this -> getRule ( 'required' ) , ] , ] ) ) ; $ languageData -> addChild ( $ this -> getElement ( 'slug_field' , [ 'name' => 'slug' , 'label' => 'common.label.slug' , 'name_field' => $ name , 'generate_route' => 'route.generate' , 'translatable_id' => $ this -> getRequestHelper ( ) -> getAttributesBagParam ( 'id' ) , 'rules' => [ $ this -> getRule ( 'required' ) , ] , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'checkbox' , [ 'name' => 'publish' , 'label' => 'common.label.publish' , 'comment' => 'page.comment.publish' , 'default' => 1 , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'text_field' , [ 'name' => 'hierarchy' , 'label' => 'common.label.hierarchy' , 'rules' => [ $ this -> getRule ( 'required' ) , ] , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'text_field' , [ 'name' => 'section' , 'label' => 'page.label.section' , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'tree' , [ 'name' => 'parent' , 'label' => 'page.label.parent' , 'choosable' => true , 'selectable' => false , 'sortable' => false , 'clickable' => false , 'items' => $ this -> get ( 'page.dataset.admin' ) -> getResult ( 'flat_tree' ) , 'restrict' => $ this -> getRequestHelper ( ) -> getAttributesBagParam ( 'id' ) , 'transformer' => $ this -> getRepositoryTransformer ( 'entity' , $ this -> get ( 'page.repository' ) ) , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'tip' , [ 'tip' => $ this -> trans ( 'page.tip.client_groups' ) , ] ) ) ; $ mainData -> addChild ( $ this -> getElement ( 'multi_select' , [ 'name' => 'clientGroups' , 'label' => 'page.label.client_groups' , 'options' => $ this -> get ( 'client_group.dataset.admin' ) -> getResult ( 'select' ) , 'transformer' => $ this -> getRepositoryTransformer ( 'collection' , $ this -> get ( 'client_group.repository' ) ) , ] ) ) ; } | Adds main settings fieldset to form |
42,047 | public function mapMaker ( ? string $ maker ) : ? string { if ( null === $ maker ) { return null ; } switch ( mb_strtolower ( trim ( $ maker ) ) ) { case '' : case 'unknown' : case 'other' : case 'bot' : case 'various' : $ maker = null ; break ; case 'microsoft' : case 'microsoft corporation.' : $ maker = 'Microsoft Corporation' ; break ; case 'apple' : case 'apple inc.' : case 'apple computer, inc.' : $ maker = 'Apple Inc' ; break ; case 'google' : case 'google inc.' : case 'google, inc.' : $ maker = 'Google Inc' ; break ; case 'lunascape & co., ltd.' : $ maker = 'Lunascape Corporation' ; break ; case 'opera software asa.' : $ maker = 'Opera Software ASA' ; break ; case 'sun microsystems, inc.' : $ maker = 'Oracle' ; break ; case 'postbox, inc.' : $ maker = 'Postbox Inc' ; break ; case 'comodo group, inc.' : $ maker = 'Comodo Group Inc' ; break ; case 'canonical ltd.' : $ maker = 'Canonical Ltd' ; break ; case 'gentoo foundation, inc.' : $ maker = 'Gentoo Foundation Inc' ; break ; case 'omni development, inc.' : $ maker = 'Omni Development Inc' ; break ; case 'slackware linux, inc.' : $ maker = 'Slackware Linux Inc' ; break ; case 'red hat, inc.' : $ maker = 'Red Hat Inc' ; break ; case 'rim' : $ maker = 'Research In Motion Limited' ; break ; case 'mozilla' : $ maker = 'Mozilla Foundation' ; break ; case 'majestic-12' : $ maker = 'Majestic-12 Ltd' ; break ; case 'zum internet' : $ maker = 'ZUMinternet Corp' ; break ; case 'mojeek ltd.' : $ maker = 'Linkdex Limited' ; break ; default : break ; } return $ maker ; } | maps the maker of the browser os engine or device |
42,048 | public static function docPart ( $ htmlPart , $ encoding = 'utf-8' , $ docType = NULL ) { if ( ! is_string ( $ htmlPart ) ) $ htmlPart = self :: export ( $ htmlPart ) ; if ( mb_strpos ( trim ( $ htmlPart ) , '<!DOCTYPE' ) === 0 ) { $ document = $ htmlPart ; } else { $ docType = $ docType ? : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ; $ document = $ docType . "\n" ; if ( mb_strpos ( trim ( $ htmlPart ) , '<html' ) === 0 ) { $ document .= $ htmlPart ; } else { $ document .= '<html><head><meta http-equiv="Content-Type" content="text/html; charset=' . $ encoding . '"/></head><body>' . $ htmlPart . '</body></html>' ; } } return self :: doc ( $ document ) ; } | Takes any HTML snippet and makes a correct DOMDocument out of it |
42,049 | public function waitFor ( callable $ lambda , $ attempts = 10 , $ waitInterval = 1 ) { for ( $ i = 0 ; $ i < $ attempts ; $ i ++ ) { try { if ( $ lambda ( $ this ) === true ) { return ; } } catch ( \ Exception $ e ) { } $ this -> wait ( $ waitInterval ) ; } throw new \ Exception ( "Step did not succeed after {$attempts} attempts." ) ; } | Attempt the given function a configurable number of times waiting X seconds between each attempt . If the step does not succeed in any of the attempts success being defined as the lambda returning true then throw an exception . |
42,050 | public function setRowCount ( $ rowCount ) { if ( $ rowCount instanceof \ Doctrine_Query ) { $ sql = $ rowCount -> getSql ( ) ; if ( false === strpos ( $ sql , self :: ROW_COUNT_COLUMN ) ) { throw new \ Zend_Paginator_Exception ( 'Row count column not found' ) ; } $ result = $ rowCount -> fetchOne ( ) -> toArray ( ) ; $ this -> _rowCount = count ( $ result ) > 0 ? $ result [ self :: ROW_COUNT_COLUMN ] : 0 ; } else if ( is_integer ( $ rowCount ) ) { $ this -> _rowCount = $ rowCount ; } else { throw new \ Zend_Paginator_Exception ( 'Invalid row count' ) ; } return $ this ; } | Sets the total row count either directly or through a supplied query |
42,051 | public function generate ( ... $ database ) { $ databases = $ this -> getDatabaseList ( $ database ) ; foreach ( $ databases as $ connection => $ database ) { $ this -> setDatabaseConfiguration ( $ connection , $ database , $ configs ) ; $ this -> createVisionDirectoryByDatabaseName ( $ database ) ; $ this -> createVisionModelFile ( $ database , $ configs ) ; } } | Generate Grand Vision |
42,052 | protected function setDatabaseConfiguration ( $ connection , & $ database , & $ configs ) { $ configs = [ ] ; if ( is_array ( $ database ) ) { $ configs = $ database ; $ database = $ connection ; } $ configs [ 'database' ] = $ database ? : $ this -> defaultDatabaseName ; } | Protected set database configuration |
42,053 | protected function createVisionModelFile ( $ database , $ configs ) { $ tables = $ this -> getTableList ( $ database ) ; $ database = ucfirst ( $ database ) ; foreach ( $ tables as $ table ) { ( new File ) -> object ( 'model' , $ this -> getDatabaseVisionClassName ( $ database , $ table ) , [ 'path' => $ this -> getDatabaseVisionDirectory ( $ database ) , 'namespace' => $ this -> getDatabaseVisionNamespace ( $ database ) , 'use' => [ 'GrandModel' ] , 'extends' => 'GrandModel' , 'constants' => [ 'table' => "'" . ucfirst ( $ table ) . "'" , 'connection' => $ this -> stringArray ( $ configs ) ] ] ) ; } } | Protected create vision model file |
42,054 | protected function getDatabaseList ( $ database ) { $ databases = $ database ; if ( is_array ( ( $ database [ 0 ] ?? NULL ) ) ) { $ databases = $ database [ 0 ] ; } if ( empty ( $ database ) ) { $ databases = $ this -> tool -> listDatabases ( ) ; } return $ databases ; } | Protected get database list |
42,055 | protected function deleteVisionFile ( $ database , $ tables ) { foreach ( $ tables as $ table ) { unlink ( $ this -> getVisionFilePath ( $ database , $ table ) ) ; } } | Protected delete vision file |
42,056 | protected function getDatabaseVisionClassName ( $ database , $ table ) { return INTERNAL_ACCESS . ( strtolower ( $ database ) === strtolower ( $ this -> defaultDatabaseName ) ? NULL : ucfirst ( $ database ) ) . ucfirst ( $ table ) . 'Vision' ; } | Protected get database vision class name |
42,057 | protected function getVisionFilePath ( $ database , $ table ) { return $ this -> getVisionDirectory ( ) . Base :: suffix ( ucfirst ( $ database ) ) . $ this -> getDatabaseVisionClassName ( $ database , $ table ) . '.php' ; } | Protected get vision file path |
42,058 | protected function stringArray ( Array $ data ) { $ str = EOL . HT . '[' . EOL ; foreach ( $ data as $ key => $ val ) { $ str .= HT . HT . "'" . $ key . "' => '" . $ val . "'," . EOL ; } $ str = Base :: removeSuffix ( $ str , ',' . EOL ) ; $ str .= EOL . HT . ']' ; return $ str ; } | Protected String Array |
42,059 | private function uncan ( $ payload ) { $ decoded = null ; if ( empty ( $ payload ) || ! is_string ( $ payload ) ) throw new RpcException ( "Invalid Request" , - 32600 ) ; if ( substr ( $ payload , 0 , 27 ) == 'comodojo_encrypted_request-' ) { if ( empty ( $ this -> encrypt ) ) throw new RpcException ( "Transport error" , - 32300 ) ; $ this -> request_is_encrypted = true ; $ aes = new AES ( ) ; $ aes -> setKey ( $ this -> encrypt ) ; $ payload = $ aes -> decrypt ( base64_decode ( substr ( $ payload , 27 ) ) ) ; if ( $ payload == false ) throw new RpcException ( "Transport error" , - 32300 ) ; } if ( $ this -> protocol == 'xml' ) { $ decoder = new XmlrpcDecoder ( ) ; try { $ decoded = $ decoder -> decodeCall ( $ payload ) ; } catch ( XmlrpcException $ xe ) { throw new RpcException ( "Parse error" , - 32700 ) ; } } else if ( $ this -> protocol == 'json' ) { if ( strtolower ( $ this -> encoding ) != 'utf-8' ) { $ payload = mb_convert_encoding ( $ payload , "UTF-8" , strtoupper ( $ this -> encoding ) ) ; } $ decoded = json_decode ( $ payload , false ) ; if ( is_null ( $ decoded ) ) throw new RpcException ( "Parse error" , - 32700 ) ; } else { throw new RpcException ( "Transport error" , - 32300 ) ; } return $ decoded ; } | Uncan the provided payload |
42,060 | private function can ( $ response , $ error ) { $ encoded = null ; if ( $ this -> protocol == 'xml' ) { $ encoder = new XmlrpcEncoder ( ) ; $ encoder -> setEncoding ( $ this -> encoding ) ; try { $ encoded = $ error ? $ encoder -> encodeError ( $ response -> getCode ( ) , $ response -> getMessage ( ) ) : $ encoder -> encodeResponse ( $ response ) ; } catch ( XmlrpcException $ xe ) { $ this -> logger -> error ( $ xe -> getMessage ( ) ) ; $ encoded = $ encoder -> encodeError ( - 32500 , "Application error" ) ; } } else { if ( strtolower ( $ this -> encoding ) != 'utf-8' && ! is_null ( $ response ) ) { array_walk_recursive ( $ response , function ( & $ entry ) { if ( is_string ( $ entry ) ) { $ entry = mb_convert_encoding ( $ entry , strtoupper ( $ this -> encoding ) , "UTF-8" ) ; } } ) ; } $ encoded = is_null ( $ response ) ? null : json_encode ( $ response ) ; } $ this -> logger -> debug ( "Plain response: $encoded" ) ; if ( $ this -> request_is_encrypted ) { $ aes = new AES ( ) ; $ aes -> setKey ( $ this -> encrypt ) ; $ encoded = 'comodojo_encrypted_response-' . base64_encode ( $ aes -> encrypt ( $ encoded ) ) ; $ this -> logger -> debug ( "Encrypted response: $encoded" ) ; } return $ encoded ; } | Can the RPC response |
42,061 | private static function setIntrospectionMethods ( $ methods ) { $ methods -> add ( RpcMethod :: create ( "system.getCapabilities" , '\Comodojo\RpcServer\Reserved\GetCapabilities::execute' ) -> setDescription ( "This method lists all the capabilites that the RPC server has: the (more or less standard) extensions to the RPC spec that it adheres to" ) -> setReturnType ( 'struct' ) ) ; $ methods -> add ( RpcMethod :: create ( "system.listMethods" , '\Comodojo\RpcServer\Introspection\ListMethods::execute' ) -> setDescription ( "This method lists all the methods that the RPC server knows how to dispatch" ) -> setReturnType ( 'array' ) ) ; $ methods -> add ( RpcMethod :: create ( "system.methodHelp" , '\Comodojo\RpcServer\Introspection\MethodHelp::execute' ) -> setDescription ( "Returns help text if defined for the method passed, otherwise returns an empty string" ) -> setReturnType ( 'string' ) -> addParameter ( 'string' , 'method' ) ) ; $ methods -> add ( RpcMethod :: create ( "system.methodSignature" , '\Comodojo\RpcServer\Introspection\MethodSignature::execute' ) -> setDescription ( "Returns an array of known signatures (an array of arrays) for the method name passed." . "If no signatures are known, returns a none-array (test for type != array to detect missing signature)" ) -> setReturnType ( 'array' ) -> addParameter ( 'string' , 'method' ) ) ; $ methods -> add ( RpcMethod :: create ( "system.multicall" , '\Comodojo\RpcServer\Reserved\Multicall::execute' ) -> setDescription ( "Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader\$1208 for details" ) -> setReturnType ( 'array' ) -> addParameter ( 'array' , 'requests' ) ) ; } | Inject introspection and reserved RPC methods |
42,062 | private static function setCapabilities ( $ capabilities ) { $ supported_capabilities = array ( 'xmlrpc' => array ( 'http://www.xmlrpc.com/spec' , 1 ) , 'system.multicall' => array ( 'http://www.xmlrpc.com/discuss/msgReader$1208' , 1 ) , 'introspection' => array ( 'http://phpxmlrpc.sourceforge.net/doc-2/ch10.html' , 2 ) , 'nil' => array ( 'http://www.ontosys.com/xml-rpc/extensions.php' , 1 ) , 'faults_interop' => array ( 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php' , 20010516 ) , 'json-rpc' => array ( 'http://www.jsonrpc.org/specification' , 2 ) ) ; foreach ( $ supported_capabilities as $ capability => $ values ) { $ capabilities -> add ( $ capability , $ values [ 0 ] , $ values [ 1 ] ) ; } } | Inject supported capabilities |
42,063 | private static function setErrors ( $ errors ) { $ std_rpc_errors = array ( - 32700 => "Parse error" , - 32701 => "Parse error - Unsupported encoding" , - 32702 => "Parse error - Invalid character for encoding" , - 32600 => "Invalid Request" , - 32601 => "Method not found" , - 32602 => "Invalid params" , - 32603 => "Internal error" , - 32500 => "Application error" , - 32400 => "System error" , - 32300 => "Transport error" , - 31000 => "Multicall is available only in XMLRPC" , - 31001 => "Recursive system.multicall forbidden" ) ; foreach ( $ std_rpc_errors as $ code => $ message ) { $ errors -> add ( $ code , $ message ) ; } } | Inject standard and RPC errors |
42,064 | public function findUserIdsWithOnlyOneGroup ( ) { $ query = $ this -> find ( ) ; return $ query -> select ( [ 'user_id' , 'group_count' => $ query -> func ( ) -> count ( '*' ) ] ) -> group ( 'user_id' ) -> having ( [ 'group_count = 1' ] ) -> extract ( 'user_id' ) -> toArray ( ) ; } | Find all user ids of users assigned to only one group . |
42,065 | public static function contains ( $ string = false , $ substring = false ) { if ( $ substring && $ substring && strpos ( $ string , $ substring ) !== false ) { return true ; } return false ; } | Check if the given string contains a specific substring . |
42,066 | public static function count ( $ string = false , $ selector = false ) { if ( $ string ) { switch ( $ selector ) { case 'words' : return str_word_count ( $ string ) ; default : if ( self :: substring ( $ selector , 0 , 1 ) === ':' ) { return substr_count ( $ string , self :: substring ( $ selector , 1 ) ) ; } return self :: length ( $ string ) ; } } return false ; } | Get string length number of words or the occurences of specific word . |
42,067 | public static function lowercase ( $ string = false , $ selector = false ) { if ( $ string ) { switch ( $ selector ) { case 'first' : return lcfirst ( $ string ) ; case 'words' : return lcwords ( $ string ) ; default : return strtolower ( $ string ) ; } } return false ; } | Get string in lowercase . |
42,068 | public static function replace ( $ string = false , $ find = false , $ replaceWith = '' ) { if ( $ string && $ find ) { return str_replace ( $ find , $ replaceWith , $ string ) ; } return false ; } | Get string with specific substring replaced . |
42,069 | public static function substring ( $ string = false , $ firstIndex = 0 , $ maxStringLength = false ) { if ( $ string ) { if ( ! $ maxStringLength ) { $ maxStringLength = ( self :: length ( $ string ) - $ firstIndex ) ; } return substr ( $ string , $ firstIndex , $ maxStringLength ) ; } return false ; } | Get substring . |
42,070 | public static function uppercase ( $ string = false , $ selector = false ) { if ( $ string ) { switch ( $ selector ) { case 'first' : return ucfirst ( $ string ) ; case 'words' : return ucwords ( $ string ) ; default : return strtoupper ( $ string ) ; } } return false ; } | Get string in uppercase . |
42,071 | private function validateUploadedFiles ( array $ uploadedFiles ) { foreach ( $ uploadedFiles as $ file ) { if ( is_array ( $ file ) ) { $ this -> validateUploadedFiles ( $ file ) ; } elseif ( ! $ file instanceof UploadedFileInterface ) { throw new InvalidArgumentException ( 'Invalid entry in uploaded files structure' ) ; } } } | Validate the structure in an uploaded files array . |
42,072 | public static function Create ( Locale $ fallbackLocale , bool $ useUrlPath = true , array $ acceptedRequestParams = [ 'locale' , 'language' , 'lang' ] ) : Locale { if ( $ useUrlPath && static :: TryParseUrlPath ( $ refLocale ) ) { return $ refLocale ; } if ( Locale :: TryParseBrowserInfo ( $ refLocale ) ) { return $ refLocale ; } if ( Locale :: TryParseSystem ( $ refLocale ) ) { return $ refLocale ; } if ( \ count ( $ acceptedRequestParams ) > 0 ) { if ( Locale :: TryParseArray ( $ refLocale , $ _POST , $ acceptedRequestParams ) ) { return $ refLocale ; } if ( Locale :: TryParseArray ( $ refLocale , $ _GET , $ acceptedRequestParams ) ) { return $ refLocale ; } if ( isset ( $ _SESSION ) && Locale :: TryParseArray ( $ refLocale , $ _SESSION , $ acceptedRequestParams ) ) { return $ refLocale ; } } return $ fallbackLocale ; } | Creates a locale with all available methods . If no method can create a Locale the defined fallback locale is used . |
42,073 | private function cleanup ( ) { foreach ( $ this -> threads as $ i => $ szal ) if ( ! $ szal -> isAlive ( ) ) { $ this -> results [ ] = $ this -> threads [ $ i ] -> result ; unset ( $ this -> threads [ $ i ] ) ; } return count ( $ this -> threads ) ; } | Removes closed threads from queue |
42,074 | public function tick ( ) { $ this -> cleanup ( ) ; if ( ( count ( $ this -> threads ) < $ this -> queueSize ) && count ( $ this -> jobs ) ) { $ this -> threads [ ] = $ szal = new Thread ( $ this -> callable , $ this -> message_length ) ; $ szal -> start ( array_shift ( $ this -> jobs ) ) ; } usleep ( ThreadQueue :: TICK_DELAY ) ; return $ this -> queueSize ( ) ; } | Starts new threads if needed |
42,075 | protected function _transform ( ) { $ index = 1 ; foreach ( $ this -> _values as $ value ) { $ paramName = "{$this->_name}_{$index}" ; $ this -> _params [ $ paramName ] = new Param ( $ this -> _type , $ value ) ; $ index ++ ; } } | Transforms values to new params |
42,076 | public function getCurrentUiLang ( $ isTwoLetter = false ) { $ uiLcid3 = Configure :: read ( 'Config.language' ) ; if ( empty ( $ uiLcid3 ) ) { $ uiLcid3 = 'eng' ; } $ uiLcid3 = mb_strtolower ( $ uiLcid3 ) ; if ( ! $ isTwoLetter ) { return $ uiLcid3 ; } return $ this -> convertLangCode ( $ uiLcid3 , 'iso639-1' ) ; } | Get current UI language in format ISO 639 - 1 or ISO 693 - 2 |
42,077 | public function convertLangCode ( $ langCode = null , $ output = null ) { $ result = '' ; if ( empty ( $ langCode ) || empty ( $ output ) ) { return $ result ; } $ cachePath = 'lang_code_info_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ langCode = mb_strtolower ( $ langCode ) ; $ this -> options -> setOutput ( $ output ) ; $ result = ( string ) $ this -> converter -> filter ( $ langCode ) ; Cache :: write ( $ cachePath , $ result , CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE ) ; return $ result ; } | Convert language from format ISO 693 - 2 to ISO 639 - 1 |
42,078 | public function getLangForNumberText ( $ langCode = null ) { $ cachePath = 'lang_code_number_name_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } if ( ! empty ( $ langCode ) ) { $ langUI = $ this -> convertLangCode ( $ langCode , 'iso639-1' ) ; } else { $ langUI = $ this -> getCurrentUiLang ( true ) ; } $ result = 'en_US' ; $ locales = [ 'af' => 'af_ZA' , 'ca' => 'ca_ES' , 'cs' => 'cs_CZ' , 'da' => 'da_DK' , 'de' => 'de_DE' , 'el' => 'el_EL' , 'en' => 'en_US' , 'es' => 'es_ES' , 'fi' => 'fi_FI' , 'fr' => 'fr_FR' , 'he' => 'he_IL' , 'hu' => 'hu_HU' , 'id' => 'id_ID' , 'it' => 'it_IT' , 'ja' => 'ja_JP' , 'ko' => 'ko_KR' , 'lb' => 'lb_LU' , 'lt' => 'lt_LT' , 'lv' => 'lv_LV' , 'nl' => 'nl_NL' , 'pl' => 'pl_PL' , 'pt' => 'pt_PT' , 'ro' => 'ro_RO' , 'ru' => 'ru_RU' , 'sh' => 'sh_RS' , 'sl' => 'sl_SI' , 'sr' => 'sr_RS' , 'sv' => 'sv_SE' , 'th' => 'th_TH' , 'tr' => 'tr_TR' , 'vi' => 'vi_VN' , 'zh' => 'zh_ZH' , ] ; if ( isset ( $ locales [ $ langUI ] ) ) { $ result = $ locales [ $ langUI ] ; } Cache :: write ( $ cachePath , $ result , CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE ) ; return $ result ; } | Return current UI language name for library Tools . NumberTextLib in format RFC5646 . |
42,079 | public static function toScalarTable ( $ list ) { return iter \ iterable ( $ list ) -> map ( function ( $ record ) { return self :: toScalarValues ( $ record ) ; } ) ; } | Helper to convert a n - dimensional array with n > 2 to all scalar values |
42,080 | public function forward ( ) { $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'forward' , WebDriver_Command :: METHOD_POST ) ) ; return $ this ; } | Navigate forwards in the browser history if possible . |
42,081 | public function back ( ) { $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'back' , WebDriver_Command :: METHOD_POST ) ) ; return $ this ; } | Navigate backwards in the browser history if possible . |
42,082 | public function refresh ( ) { $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'refresh' , WebDriver_Command :: METHOD_POST ) ) ; return $ this ; } | Refresh the current page . |
42,083 | public function execute ( $ js , $ args = [ ] ) { $ params = [ 'script' => $ js , 'args' => $ args ] ; $ result = $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'execute' , WebDriver_Command :: METHOD_POST , $ params ) ) ; return isset ( $ result [ 'value' ] ) ? $ result [ 'value' ] : false ; } | Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame |
42,084 | public function screenshotAsImage ( $ asBase64 = false ) { $ image = $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'screenshot' , WebDriver_Command :: METHOD_GET ) ) ; $ image = $ image [ 'value' ] ; if ( ! $ asBase64 ) { $ image = base64_decode ( $ image ) ; } return $ image ; } | Returns screenshot of current page as binary string . |
42,085 | public function findAll ( $ locator , $ parent = null ) { $ commandUri = empty ( $ parent ) ? "elements" : "element/{$parent->getElementId()}/elements" ; $ command = $ this -> getDriver ( ) -> factoryCommand ( $ commandUri , WebDriver_Command :: METHOD_POST , WebDriver_Util :: parseLocator ( $ locator ) ) ; try { $ elementList = $ this -> getDriver ( ) -> curl ( $ command ) ; } catch ( WebDriver_Exception $ e ) { $ parentText = empty ( $ parent ) ? '' : " (parent: {$parent->getLocator()})" ; throw new WebDriver_Exception ( "Elements not found: {$locator}{$parentText} with error: {$e->getMessage()}" ) ; } $ result = [ ] ; foreach ( $ elementList [ 'value' ] as $ value ) { $ elementClass = $ this -> elementClass ; $ result [ ] = new $ elementClass ( $ this , $ locator , $ parent , $ value [ 'ELEMENT' ] ) ; } return $ result ; } | Search for multiple elements on the page |
42,086 | public function keys ( $ charList ) { $ this -> getDriver ( ) -> curl ( $ this -> getDriver ( ) -> factoryCommand ( 'keys' , WebDriver_Command :: METHOD_POST , [ 'value' => WebDriver_Util :: prepareKeyStrokes ( $ charList ) ] ) ) ; return $ this ; } | Sends keystroke sequence . Active modifiers are not cancelled after call which lets to use them with mouse events . |
42,087 | public function source ( ) { $ command = $ this -> getDriver ( ) -> factoryCommand ( 'source' , WebDriver_Command :: METHOD_GET ) ; $ result = $ this -> getDriver ( ) -> curl ( $ command ) ; return $ result [ 'value' ] ; } | Get the current page source . |
42,088 | public function cache ( ) { if ( null === $ this -> cache ) { $ this -> cache = new WebDriver_Cache ( $ this ) ; } return $ this -> cache ; } | Get current context . |
42,089 | public static function mergeDeepArray ( array $ arrays , $ preserve_integer_keys = false ) { $ result = [ ] ; foreach ( $ arrays as $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_integer ( $ key ) && ! $ preserve_integer_keys ) { $ result [ ] = $ value ; } elseif ( isset ( $ result [ $ key ] ) && is_array ( $ result [ $ key ] ) && is_array ( $ value ) ) { $ result [ $ key ] = self :: mergeDeepArray ( array ( $ result [ $ key ] , $ value ) , $ preserve_integer_keys ) ; } else { $ result [ $ key ] = $ value ; } } } return $ result ; } | Merges multiple arrays recursively and returns the merged array . |
42,090 | protected function parseArguments ( AnnotationBag $ propertyAnnotations ) { $ this -> args = [ ] ; $ parameters = $ propertyAnnotations -> find ( 'Param' ) ; foreach ( $ parameters as $ param ) { if ( $ param -> hasArgument ( ) ) { $ arg = $ param -> getArgument ( ) ; if ( strtolower ( $ arg ) == 'self' ) $ this -> useDefaultArgument = true ; else $ this -> args [ ] = Attr :: __callstatic ( $ arg ) ; } else $ this -> args [ ] = $ param -> getValue ( ) ; } if ( empty ( $ this -> args ) ) $ this -> useDefaultArgument = true ; } | Parses attribute argument list |
42,091 | protected function parseConfig ( AnnotationBag $ propertyAnnotations ) { $ this -> config = [ ] ; if ( isset ( $ this -> type ) ) $ this -> config [ 'map.type' ] = $ this -> type ; if ( $ propertyAnnotations -> has ( 'ResultMap' ) ) $ this -> config [ 'map.result' ] = $ propertyAnnotations -> get ( 'ResultMap' ) -> getValue ( ) ; if ( $ propertyAnnotations -> has ( 'Cache' ) ) { $ this -> config [ 'cache.ttl' ] = intval ( $ propertyAnnotations -> get ( 'Cache' ) -> getArgument ( ) ) ; $ this -> config [ 'cache.key' ] = $ propertyAnnotations -> get ( 'Cache' ) -> getValue ( ) ; } $ options = $ propertyAnnotations -> find ( 'Option' , Filter :: HAS_ARGUMENT ) ; foreach ( $ options as $ option ) $ this -> config [ $ option -> getArgument ( ) ] = $ option -> getValue ( ) ; if ( $ propertyAnnotations -> has ( 'Cacheable' ) ) { $ this -> cacheable = ! empty ( $ this -> type ) && ! preg_match ( '/^[arr|array|obj|object]:/' , $ this -> type ) ; } if ( $ propertyAnnotations -> has ( 'If' ) ) { $ this -> program = new DynamicSQLProgram ( $ propertyAnnotations -> get ( 'If' ) -> getValue ( ) ) ; $ this -> condition = function ( $ row , $ config ) { return ( bool ) $ this -> program -> execute ( $ this -> buildEnvironment ( $ config ) , $ row ) ; } ; } elseif ( $ propertyAnnotations -> has ( 'IfNot' ) ) { $ this -> program = new DynamicSQLProgram ( $ propertyAnnotations -> get ( 'IfNot' ) -> getValue ( ) ) ; $ this -> condition = function ( $ row , $ config ) { return ! ( bool ) $ this -> program -> execute ( $ this -> buildEnvironment ( $ config ) , $ row ) ; } ; } elseif ( $ propertyAnnotations -> has ( 'IfNotNull' ) ) { $ attribute = $ propertyAnnotations -> get ( 'IfNotNull' ) -> getArgument ( ) ; $ this -> condition = function ( $ row , $ _ ) use ( $ attribute ) { $ argument = ArgumentWrapper :: wrap ( $ row ) ; return ! ( $ argument -> offsetExists ( $ attribute ) && $ argument -> offsetGet ( $ attribute ) === null ) ; } ; } } | Parses attribute configuration |
42,092 | protected function evaluateCondition ( $ row , $ config ) { if ( isset ( $ this -> condition ) ) return call_user_func ( $ this -> condition , $ row , $ config ) ; return true ; } | Evaluates attribute condition |
42,093 | public function getSubscription ( ) { if ( $ this -> getGateway ( ) instanceof GatewayInterface ) { return $ this -> getGateway ( ) -> getSubscriptionByReference ( $ this -> getSubscriptionReference ( ) ) ; } throw new RuntimeException ( 'Gateway is not set' ) ; } | Return subscription by subscription reference . |
42,094 | public function file ( SplFileInfo $ file ) { return substr ( $ this -> base ( hash_file ( 'sha256' , $ file -> getRealPath ( ) , true ) ) , 0 , 32 ) ; } | Make hash from uploaded file . |
42,095 | private function parse ( ) { if ( $ this -> parsed ) { return ; } switch ( $ this -> query -> mode ) { case Query :: MODE_SELECT : $ this -> parseSelectQuery ( ) ; break ; case Query :: MODE_INSERT : $ this -> parseInsertQuery ( ) ; break ; case Query :: MODE_UPDATE : $ this -> parseUpdateQuery ( ) ; break ; case Query :: MODE_DELETE : $ this -> parseDeleteQuery ( ) ; break ; case Query :: MODE_TRUNCATE : $ this -> parseTruncateQuery ( ) ; break ; case Query :: MODE_ADVANCED : throw new QueryBuilderParseException ( "Query mode not yet implemented!" ) ; break ; case Query :: MODE_NONE : throw new QueryBuilderParseException ( "Query has no mode yet!" ) ; break ; default : throw new QueryBuilderParseException ( "Query mode is invalid!" ) ; break ; } $ this -> parsed = true ; } | Parse the Query object . |
42,096 | private function parseSelectQuery ( ) { $ selectSql = Column :: generateQueryString ( $ this -> query -> select ) ; $ fromSql = Table :: generateQueryString ( $ this -> query -> table ) ; $ whereSql = null ; $ whereBind = array ( ) ; $ sql = [ 'select' => $ selectSql , 'from' => $ fromSql , 'where' => $ whereSql ] ; $ this -> bind = array_merge ( $ this -> bind , $ whereBind ) ; $ this -> sql = $ this -> combineSelectQuery ( $ sql ) ; } | Select Mode Parser . |
42,097 | private function combineSelectQuery ( $ sqlParts ) { $ output = "SELECT " . $ sqlParts [ 'select' ] . " FROM " . $ sqlParts [ 'from' ] ; if ( $ sqlParts [ 'where' ] !== null ) { $ output .= " WHERE " . $ sqlParts [ 'where' ] ; } return $ output ; } | Combine select query . |
42,098 | static public function computeDiff ( Index $ fromIndex , Index $ toIndex , $ caseInsensitive = false ) { $ fromIndexColumns = $ fromIndex -> getColumns ( ) ; for ( $ i = 0 ; $ i < count ( $ fromIndexColumns ) ; $ i ++ ) { $ indexColumn = $ fromIndexColumns [ $ i ] ; if ( ! $ toIndex -> hasColumnAtPosition ( $ i , $ indexColumn , null , $ caseInsensitive ) ) { return true ; } } $ toIndexColumns = $ toIndex -> getColumns ( ) ; for ( $ i = 0 ; $ i < count ( $ toIndexColumns ) ; $ i ++ ) { $ indexColumn = $ toIndexColumns [ $ i ] ; if ( ! $ fromIndex -> hasColumnAtPosition ( $ i , $ indexColumn , null , $ caseInsensitive ) ) { return true ; } } if ( $ fromIndex -> isUnique ( ) != $ toIndex -> isUnique ( ) ) { return true ; } return false ; } | Compute the difference between two index objects |
42,099 | public function get ( $ key ) { $ used_key = $ this -> getUsedKey ( $ key ) ; $ res = $ this -> redis -> get ( $ used_key ) ; if ( $ res === null ) return false ; $ res = $ this -> unesc ( $ res ) ; if ( is_array ( $ key ) ) { return array_combine ( $ key , $ res ) ; } else { return $ res ; } } | read a specific data in the cache . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.