idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
5,900 | protected function getProgramOptions ( InputInterface $ input , OutputInterface $ output ) { $ opts = array ( ) ; foreach ( $ this -> getDefinition ( ) -> getOptions ( ) as $ o ) { $ name = $ o -> getName ( ) ; if ( ! array_key_exists ( $ name , $ this -> programOptions ) ) { continue ; } $ value = $ input -> getOption... | Convert console command options to ssh program options . |
5,901 | public function execute ( InputInterface $ input , OutputInterface $ output ) { if ( ! $ this -> emailSender ) { throw new LogicException ( 'No email sender configured (did you set the API key?)' ) ; } if ( ! $ this -> emailMapper ) { throw new LogicException ( 'No email mapper configured' ) ; } $ output -> writeln ( '... | Execute this console command to send an email |
5,902 | public function scopeEmbed ( $ query , $ embed ) { $ separator = isset ( $ this -> embedSeparator ) ? $ this -> embedSeparator : ',' ; $ attributes = is_string ( $ embed ) ? @ explode ( $ separator , $ embed ) : ( array ) $ embed ; $ embedable = isset ( $ this -> embedable ) ? $ this -> embedable : [ ] ; $ accessors = ... | Includes the required relations in the query builder . |
5,903 | public function applyEmbedableAttributes ( $ embed ) { $ separator = isset ( $ this -> embedSeparator ) ? $ this -> embedSeparator : ',' ; $ attributes = is_string ( $ embed ) ? @ explode ( $ separator , $ embed ) : ( array ) $ embed ; $ embedable = isset ( $ this -> embedable ) ? $ this -> embedable : [ ] ; $ accessor... | Applies the given accessors to the model . |
5,904 | public static function getPattern ( $ string = '' , $ delimiter = '#' , $ options = 'i' , $ strict = false ) { $ replacements = array ( '.' => '\\.' , '*' => '.*' , $ delimiter => '\\' . $ delimiter ) ; return $ delimiter . '^' . ( $ strict ? '' : '.*' ) . strtr ( $ string , $ replacements ) . ( $ strict ? '' : '.*' ) ... | Get a read - to - use regular expression from a string pattern |
5,905 | private function getCommandClassName ( $ command ) { $ names = explode ( '-' , $ command ) ; $ className = '' ; foreach ( $ names as $ name ) { $ className .= ucfirst ( $ name ) ; } return $ className ; } | Retorna o nome da classe do comando . |
5,906 | public function sendHeaderResponse ( ) { if ( $ this -> response != false ) { $ this -> response -> sendHeaders ( ) ; return $ this -> response -> getWpStatusCodeHeader ( ) ; } } | Send proper HTTP response . |
5,907 | protected function setImportance ( $ type ) { switch ( $ type ) { case 'error' : $ this -> importance = MonologLogger :: ERROR ; break ; case 'info' : default : $ this -> importance = MonologLogger :: INFO ; break ; } } | Set logger importance |
5,908 | public function add ( $ method , $ str ) { $ str = $ this -> cleanLine ( $ str ) ; $ method = 'add' . ucfirst ( $ method ) ; $ this -> logger -> $ method ( $ str ) ; } | Add a entry |
5,909 | public function importJournals ( $ ids ) { $ journalsSql = 'SELECT journal_id, path FROM journals WHERE journal_id IN (?)' ; $ journalsStatement = $ this -> dbalConnection -> executeQuery ( $ journalsSql , array ( $ ids ) , array ( Connection :: PARAM_INT_ARRAY ) ) ; $ journals = $ journalsStatement -> fetchAll ( ) ; f... | Imports specified journals |
5,910 | public function getChecksumCrc ( $ arrData ) { if ( ! UCProLib :: isValidXTArray ( $ arrData ) ) { return '' ; } $ nRet = 0 ; $ sString = $ this -> _GetDigestSource ( $ arrData ) ; if ( CLib :: IsExistingString ( $ sString ) ) { $ sData = mb_strtolower ( trim ( $ sString . "-" . $ this -> m_arrCfg [ UCProConst :: CONFI... | build crc checksum |
5,911 | public static function setConfig ( $ POST ) { $ handle = fopen ( dirname ( dirname ( __FILE__ ) ) . '/../config.local.php' , "w+" ) ; $ text = "<?php\n\$config = array(\n'db_host' => '" . $ POST [ 'db_host' ] . "',\n'db_name' => '" . strtolower ( $ POST [ 'db_name' ] ) . "',\n'db_login' => '" . $ POST [ 'db_login' ] . ... | Create the config file containing database credential Need to lowercase database name |
5,912 | public function get ( ) { $ builder = $ this -> createBuilder ( ) ; if ( ! $ this -> prepare ( $ builder ) ) { return $ this -> complete ( [ ] ) ; } return $ this -> complete ( $ builder -> getConnection ( ) -> select ( $ builder -> toSql ( ) , $ builder -> getBindings ( ) , ! $ builder -> useWritePdo , $ this -> fetch... | Execute the query as a select statement and get result as collection . |
5,913 | private function getPrimaryNamespace ( PackageInterface $ package ) { $ primaryNs = null ; foreach ( $ package -> getAutoload ( ) as $ type => $ pathMap ) { if ( $ type !== 'psr-4' ) { continue ; } if ( count ( $ pathMap ) === 1 ) { $ primaryNs = key ( $ pathMap ) ; break ; } $ matches = preg_grep ( '#^(\./)?src/?$#' ,... | Get primary namespace |
5,914 | private function updateConfigFile ( PackageInterface $ package ) { $ defaultConfigFile = $ this -> projectPath . self :: DS . 'App' . self :: DS . 'Resource' . self :: DS . 'config' . self :: DS . 'config.default.php' ; if ( is_writeable ( $ defaultConfigFile ) ) { $ output = include $ defaultConfigFile ; $ bundleConf ... | Update config file |
5,915 | public function setUser ( $ value ) { if ( $ value !== null ) { $ this -> _user = $ value ; } else { $ this -> _user = Zend_Gdata_Photos :: DEFAULT_USER ; } } | Set the user to query for . When set this user s feed will be returned . If not set or null the default user s feed will be returned instead . |
5,916 | public static function UseSmarty ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( class_exists ( "Smarty" ) ) { $ oThis -> oSmarty = new Smarty ( ) ; $ oThis -> oSmarty -> compile_dir = Storage :: Get ( "smarty.dir.compile" ) ; $ oThis -> oSmarty -> config_dir = Storage :: Get ( "smarty.dir.config" ) ; $ oT... | Function to start Smarty Template Engine use |
5,917 | public static function SetNamespace ( $ sNamespace ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( is_string ( $ sNamespace ) ) { $ sNamespace = strtolower ( str_replace ( " " , "_" , $ sNamespace ) ) ; $ oThis -> sNamespace = $ sNamespace ; } } | Function to configure namespace output |
5,918 | public static function SetTemplate ( $ sTemplateFilename , $ sMasterpageFilename = null ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( is_object ( $ oThis -> oSmarty ) ) { if ( ! is_null ( $ sMasterpageFilename ) ) { $ sContent = $ oThis -> oSmarty -> fetch ( $ sTemplateFilename ) ; $ oThis -> oSmarty -> as... | Function to set the masterpage and template |
5,919 | public static function AppendCSS ( $ sFilenameCSS ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( file_exists ( $ sFilenameCSS ) ) $ oThis -> aCSS [ ] = file_get_contents ( $ sFilenameCSS ) ; } | Function to add CSS file to template |
5,920 | public static function AppendJS ( $ sFilenameJS ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( file_exists ( $ sFilenameJS ) ) $ oThis -> aJS [ ] = file_get_contents ( $ sFilenameJS ) ; } | Function to add Javascript file to template |
5,921 | public static function CreateCacheCSS ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( count ( $ oThis -> aCSS ) > 0 ) { $ sCacheFilename = Storage :: Join ( "dir.public.assets" , strtolower ( $ oThis -> sNamespace ) . ".css" ) ; Storage :: Set ( "assets.css" , Storage :: Join ( "route.root" , "public/asset... | Function to create the CSS file cache |
5,922 | private static function MinifyCSS ( $ sStr ) { $ sStr = preg_replace ( '!/\*.*?\*/!s' , '' , $ sStr ) ; $ sStr = preg_replace ( '/\n\s*\n/' , "\n" , $ sStr ) ; $ sStr = preg_replace ( '/[\n\r \t]/' , ' ' , $ sStr ) ; $ sStr = preg_replace ( '/ +/' , ' ' , $ sStr ) ; $ sStr = preg_replace ( '/ ?([,:;{}]) ?/' , '$1' , $ ... | Function to compress CSS file cache |
5,923 | public static function CreateCacheJS ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( count ( $ oThis -> aJS ) > 0 ) { $ sCacheFilename = Storage :: Join ( "dir.public.assets" , strtolower ( $ oThis -> sNamespace ) . ".js" ) ; Storage :: Set ( "assets.js" , Storage :: Join ( "route.root" , "public/assets/" ... | Function to create the Javascript file cache |
5,924 | private static function IncludeTemplate ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ oThis -> ReplaceVars ( ) ; $ oThis -> sBuffer = trim ( $ oThis -> sBuffer ) ; $ Offset = 0 ; while ( preg_match ( '/{include\s*(.*?)}/i' , $ oThis -> sBuffer , $ aMatches , PREG_OFFSET_CAPTURE , $ Offset ) ) { $ sFilename ... | Function to include subtemplates |
5,925 | private static function ReplaceVars ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ aP = array ( ) ; $ iOffset = 0 ; while ( preg_match ( '/(\{\$(.*?)\})/i' , $ oThis -> sBuffer , $ aMatches , PREG_OFFSET_CAPTURE , $ iOffset ) ) { $ mVar = $ aMatches [ 2 ] [ 0 ] ; if ( Storage :: Has ( $ mVar ) ) { $ mTo = St... | Function to handle variables required in the template |
5,926 | private static function RemoveUndefinedVars ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ iOffset = 0 ; while ( preg_match ( '/{\$(.*?)}/i' , $ oThis -> sBuffer , $ aMatches , PREG_OFFSET_CAPTURE , $ iOffset ) ) { $ oThis -> sBuffer = str_replace ( $ aMatches [ 0 ] [ 0 ] , "false" , $ oThis -> sBuffer ) ; $... | Function to remove variables that were not stored |
5,927 | private static function CheckConditions ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ oThis -> sBuffer = str_replace ( "{else}" , "<?php } else { ?>" , $ oThis -> sBuffer ) ; $ oThis -> sBuffer = str_replace ( "{endif}" , "<?php } ?>" , $ oThis -> sBuffer ) ; $ oThis -> sBuffer = str_replace ( array ( '{if ... | Function for treatment of conditionals in the template |
5,928 | public static function ReplaceList ( $ sListName , $ aData ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ oThis -> sBuffer = str_replace ( "{end}" , "<?php } ?>" , $ oThis -> sBuffer ) ; $ Offset = 0 ; $ aC = "abcdefghijklmnopqrstuvxzywABCDEFGHIJKLMNOPQRSTUVXZWY" ; $ sHash = "" ; for ( $ i = 0 ; $ i < 10 ; $ i... | Function to replace the template lists |
5,929 | public static function ExtractList ( $ sListName ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ iStart = strpos ( $ oThis -> sBuffer , "{list:{$sListName}}" ) ; if ( $ iStart > 0 ) $ iEnd = strpos ( $ oThis -> sBuffer , "{end}" , $ iStart ) ; if ( $ iStart > 0 && $ iEnd > 0 ) { $ sNewBuffer = substr ( $ oThis ... | Function to extract the template lists |
5,930 | public static function SendHTTPCode ( $ iCode ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( array_key_exists ( $ iCode , $ oThis -> aHTTPStatus ) ) { @ header ( $ oThis -> aHTTPStatus [ $ iCode ] ) ; @ header ( "Connection: close" ) ; die ( ) ; } } | Function to return HTTP exceptions |
5,931 | public static function Redirect ( $ sUrl ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; @ header ( $ oThis -> aHTTPStatus [ 301 ] ) ; @ header ( "Location: " . $ sUrl ) ; die ( ) ; } | Function to output redirection |
5,932 | public static function PreCompile ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ oThis -> IncludeTemplate ( ) ; $ oThis -> ReplaceVars ( ) ; $ oThis -> RemoveUndefinedVars ( ) ; $ oThis -> CheckConditions ( ) ; } | Function to precompile template |
5,933 | public static function Send ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( is_object ( $ oThis -> oSmarty ) ) { $ oThis -> CreateCacheCSS ( ) ; $ oThis -> CreateCacheJS ( ) ; Storage :: AssignSmarty ( $ oThis -> oSmarty ) ; Events :: Call ( "BeforeSendingOutput" ) ; $ oThis -> oSmarty -> display ( $ oThis... | Function to send output |
5,934 | public static function SanitizeOutput ( $ sBuffer ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ aSearch = array ( '/\>[^\S ]+/s' , '/[^\S ]+\</s' , '/(\s)+/s' ) ; $ aReplace = array ( '>' , '<' , '\\1' ) ; $ oThis -> sBuffer = preg_replace ( $ aSearch , $ aReplace , $ sBuffer ) ; } | Function to minify output |
5,935 | public static function ClearList ( ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; if ( preg_match ( '/{list\:(.*?)}/' , $ oThis -> sBuffer , $ aMatches ) == 1 ) { $ sListName = $ aMatches [ 1 ] ; $ iStart = strpos ( $ oThis -> sBuffer , "{list:{$sListName}}" ) ; if ( $ iStart > 0 ) $ iEnd = strpos ( $ oThis -> s... | Function to remove empty lists inside template |
5,936 | public function getProvider ( $ name ) { foreach ( $ this -> providers as $ provider ) { if ( $ provider -> getName ( ) === $ name ) { return $ provider ; } } return null ; } | Returns the first provider by a given name |
5,937 | protected function returnStatusFromFeature ( FeatureInterface $ feature ) { $ status = $ feature -> getStatus ( ) ; $ this -> logger -> info ( 'Feature {feature} returned as {status} due to {provider} provider' , [ 'feature' => $ feature -> getName ( ) , 'status' => Status :: $ messages [ $ status ] , 'provider' => $ f... | Given a feature resolves a status reports on it and returns it |
5,938 | protected function validateFeatureArray ( $ features , ProviderInterface $ provider ) { if ( ! is_array ( $ features ) ) { $ this -> logger -> error ( 'Feature provider {provider} did not provide an array of features' , [ 'provider' => $ provider -> getName ( ) ] ) ; return [ ] ; } return $ features ; } | Validates that the response from the provider is a set of features |
5,939 | protected function findRepositoryRoot ( \ ZipArchive $ archive ) { $ count = $ archive -> numFiles ; $ rootFile = $ archive -> statIndex ( 0 ) ; $ root = $ rootFile [ 'name' ] ; for ( $ i = 1 ; $ i < $ count ; ++ $ i ) { $ file = $ archive -> statIndex ( $ i ) ; $ root = $ this -> commonStartString ( $ root , $ file [ ... | Find repository root |
5,940 | protected function commonStartString ( $ string1 , $ string2 ) { $ length = min ( strlen ( $ string1 ) , strlen ( $ string2 ) ) ; $ common = '' ; for ( $ i = 0 ; $ i < $ length && $ string1 [ $ i ] === $ string2 [ $ i ] ; ++ $ i ) { $ common .= $ string1 [ $ i ] ; } return $ common ; } | Common start string |
5,941 | public function load ( $ fileName , $ withHeader = true ) { if ( $ this -> files -> exists ( $ fileName ) != true ) { error ( 'File %s not found' , $ fileName ) ; } $ this -> fileName = $ fileName ; $ this -> cols = [ ] ; $ this -> items = [ ] ; $ hnd = fopen ( $ this -> fileName , 'r' ) ; while ( $ data = fgetcsv ( $ ... | Carregar arquivo CSV . |
5,942 | protected function make_row ( $ data ) { $ line = [ ] ; foreach ( $ this -> cols as $ i => $ key ) { $ value = ( array_key_exists ( $ i , $ data ) ? $ data [ $ i ] : '' ) ; $ value = ( $ this -> utf8 ? utf8_decode ( $ value ) : $ value ) ; $ line [ $ key ] = $ value ; } return $ line ; } | Preparar linha CSV . |
5,943 | public function get ( $ path = '/' ) { $ fullPath = realpath ( $ this -> root . $ path ) ; if ( ( $ fullPath === false ) || ( strpos ( $ fullPath , $ this -> root ) !== 0 ) ) { throw new \ RuntimeException ( "File not found $path." ) ; } switch ( true ) { case ( $ path === '/' ) : return $ this ; case is_dir ( $ fullPa... | Get checkout item |
5,944 | public static function getDocumentClassName ( $ shortName , $ gatewayClass ) { $ shortName = ucfirst ( $ shortName ) ; $ shortName = str_replace ( '_' , '\\' , $ shortName ) ; $ class = self :: getGatewayNamespace ( $ gatewayClass ) ; $ class .= '\\Document\\' . $ shortName ; if ( ! class_exists ( $ class ) ) { $ class... | Resolve a short document name to a full namespaced document class . |
5,945 | public static function toFloat ( $ value ) { if ( ! is_string ( $ value ) && ! is_int ( $ value ) && ! is_float ( $ value ) ) { throw new InvalidArgumentException ( 'Data type is not a valid decimal number.' ) ; } if ( is_string ( $ value ) ) { if ( ! preg_match ( '/^[-]?[0-9]+(\.[0-9]*)?$/' , $ value ) ) { throw new I... | Convert an amount into a float . The float datatype can then be converted into the string format that the remote gateway requires . |
5,946 | public function instantiateClass ( string $ className , array $ args ) { $ class = $ this -> getClass ( $ className ) ; $ constructor = $ class -> getConstructor ( ) ; if ( empty ( $ constructor ) ) { $ instance = $ class -> newInstanceWithoutConstructor ( ) ; } else { $ instance = $ class -> newInstanceArgs ( $ args )... | Create instance using constructor if applicable . Does not check if class exists or whether it is instantiable . |
5,947 | public static function specify ( $ label , $ block ) { $ spec = new Context ( $ label , $ block , '' , NULL , self :: $ expector ) ; self :: $ sphecs [ ] = $ spec ; } | The entry point for building a specification . |
5,948 | public function endpoint ( $ method , $ uri , $ name ) { return $ this -> endpoints -> add ( new Endpoint ( $ method , $ uri ) , $ name ) ; } | add a endpoint to the api . |
5,949 | public function execute ( $ name , array $ params = [ ] , array $ headers = [ ] ) { $ executor = new Executor ( $ this ) ; return $ executor -> run ( $ name , $ params , $ headers ) ; } | Execute a call in api endpoint . |
5,950 | public static function isOfCoercibleType ( $ value , string $ type ) : bool { if ( $ type === "mixed" ) { return true ; } $ valueType = gettype ( $ value ) ; return $ valueType === $ type || ( $ valueType === "object" && get_class ( $ value ) === $ type ) || ( self :: isNumericType ( $ type ) && is_numeric ( $ value ) ... | Checks if the provided value can be coerced to the provided type . This method is intended for use with primitive values . |
5,951 | public static function isBooleanValue ( $ value ) : bool { return is_bool ( $ value ) || self :: isBooleanStringValue ( $ value ) || self :: isBooleanNumericValue ( $ value ) ; } | Checks if the provided value is a boolean value or a representation of a boolean value . |
5,952 | public static function coerceType ( $ value , string $ type ) { if ( $ value === null ) { return null ; } if ( self :: isTypedArrayType ( $ type ) && self :: isValidArrayOfType ( $ value , $ type ) ) { $ arrayType = self :: getTypeOfTypedArrayType ( $ type ) ; return array_map ( function ( $ value ) use ( $ arrayType )... | Coerces the provided value to the provided type . If the type does not match either bool float double int or string the same value is returned . |
5,953 | public static function getType ( $ value ) { if ( $ value === null ) { return null ; } $ type = gettype ( $ value ) ; if ( is_array ( $ value ) && ! empty ( $ value ) ) { $ arrayType = null ; foreach ( $ value as $ entry ) { if ( $ arrayType == null ) { $ arrayType = self :: getType ( $ entry ) ; } else { return "mixed... | Returns the type of the provided value |
5,954 | public static function toBooleanValue ( $ value ) { if ( $ value === null || is_bool ( $ value ) ) { return $ value ; } if ( is_string ( $ value ) ) { if ( StringHelper :: equals ( $ value , "true" , true ) ) { return true ; } elseif ( StringHelper :: equals ( $ value , "false" , true ) ) { return false ; } } elseif ( ... | Converts the provided value to a bool . If the value is of the wrong type has the wrong value or is null null is returned . |
5,955 | public function processController ( $ name , AnnotationCollection $ annotations ) { $ this -> controllerName = $ name ; $ this -> baseName = null ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof Annotation \ Base ) { $ this -> baseName = $ annotation -> getName ( ) ; } } } | Set the name of the controller and parse the class annotations . |
5,956 | public function processMethod ( $ name , AnnotationCollection $ annotations , ArrayObject $ config ) { if ( ! preg_match ( '/^(.*)Action$/i' , $ name , $ match ) ) { return ; } $ actionName = $ match [ 1 ] ; $ routeType = null ; $ routeName = null ; $ routeRoute = null ; $ defaults = array ( ) ; $ constraints = array (... | Read the method annotations and construct the config . |
5,957 | protected function & findConfigSection ( $ routeName , ArrayObject $ config ) { $ routeParts = explode ( '/' , $ routeName ) ; reset ( $ routeParts ) ; $ part = current ( $ routeParts ) ; $ settings = & $ config [ $ part ] ; if ( ! next ( $ routeParts ) ) { return $ settings ; } do { $ part = current ( $ routeParts ) ;... | Navigate through the config try to find the given route leaf . |
5,958 | public function readAll ( $ byteString ) { $ saftey = 0 ; $ results = [ ] ; do { $ container = $ this -> readNext ( $ byteString ) ; $ containerString = $ container -> getByteString ( ) ; $ containerStringLength = strlen ( $ containerString ) ; $ byteString = substr ( $ byteString , $ containerStringLength ) ; $ result... | This method breaks a binary string into an array of BinnContainers . |
5,959 | public function renderView ( ) { header ( 'Content-Type: application/json;charset=utf-8' ) ; $ json = json_encode ( $ this -> getViewVariables ( ) ) ; if ( $ json ) { echo $ json ; } else { throw new \ RuntimeException ( $ this -> getEncodeErrors ( ) [ json_last_error ( ) ] ) ; } } | Render as JSON any registered view variables |
5,960 | function nextOuter ( ) { while ( $ this -> inner -> valid ( ) ) { $ v = $ this -> inner -> current ( ) ; if ( is_iterable ( $ v ) ) { $ this -> outer = iterator ( $ v ) ; $ this -> outer -> rewind ( ) ; if ( $ this -> outer -> valid ( ) ) return ; $ this -> inner -> next ( ) ; } else break ; } $ this -> outer = null ; ... | Advance the inner iterator until we get a non - empty outer iterator . |
5,961 | public static function factory ( string $ className = '' ) : LogInterface { static :: init ( ) ; $ className = '\\' . $ className ; $ loggerConfig = \ array_key_exists ( $ className , static :: $ classConfig ) ? static :: $ classConfig [ $ className ] : static :: $ classConfig [ 'Default' ] ; $ loggerClass = '\\MS\\Lig... | Returns logger for given class |
5,962 | public static function passwordHash ( string $ password , string $ algo = PASSWORD_BCRYPT ) : string { return password_hash ( $ password , $ algo ) ; } | Hash a password with password_hash function |
5,963 | public static function getRandomHash ( bool $ secure = false ) : string { return self :: hash ( microtime ( ) . rand ( 10000 , 100000 ) , $ secure ) ; } | Get a random hash string |
5,964 | public function export ( NodeInterface $ node , array $ options = [ ] ) { $ options = array_replace_recursive ( [ 'writer' => 'graphviz' ] , $ options ) ; if ( is_string ( $ options [ 'writer' ] ) ) { switch ( $ options [ 'writer' ] ) { case 'graphviz' : $ options [ 'path' ] = $ options [ 'path' ] ?? $ this -> generate... | Exports a graph to a graphviz image . |
5,965 | public function generateRandomFilePath ( ) { do { $ file = sys_get_temp_dir ( ) . '/graphviz-' . sha1 ( uniqid ( 'graphviz-image-' , true ) . time ( ) . rand ( 0 , 9999 ) ) . '.png' ; } while ( is_file ( $ file ) ) ; return $ file ; } | Returns a random file path to use for a new file . |
5,966 | protected function createNodeInstance ( array $ data , array $ options = [ ] ) : NodeInterface { $ factory = $ this -> getNodeFactory ( ) ; $ node = $ factory ( $ data , $ options ) ; if ( ! is_object ( $ node ) || ! ( $ node instanceof NodeInterface ) ) { throw ValidationException :: create ( 'Node Factory must return... | Creates a Node instance through the node factory . |
5,967 | protected function _connect ( ) { $ this -> _connection = @ mysqli_connect ( $ this -> _server , $ this -> _username , $ this -> _password ) ; if ( ! @ mysqli_select_db ( $ this -> _connection , $ this -> _database ) ) { if ( ! $ this -> _connection ) { throw new ConnectionException ( 'Could not open the requested ... | Connect to the MySQL server . |
5,968 | public static function connectFromString ( $ sql_string ) { list ( $ username , $ sql_string ) = explode ( ':' , trim ( $ sql_string ) , 2 ) ; $ password = substr ( $ sql_string , 0 , strrpos ( $ sql_string , '@' ) ) ; list ( $ server , $ database ) = explode ( '/' , substr ( strrchr ( $ sql_string , '@' ) , 1 ) ) ; re... | Create a MySQL instance from a connection - string . |
5,969 | public function query ( $ query , $ return_set = false , $ buffered = true ) { $ this -> _result = null ; $ query = trim ( $ query ) ; $ this -> _result = @ mysqli_query ( $ this -> _connection , $ query ) ; if ( ! $ this -> _result ) { $ error_no = @ mysqli_errno ( $ this -> _connection ) ; $ error_message = @ mysqli_... | Send a query to the MySQL server . |
5,970 | private function guardWorkloadIsNonEmptyString ( ) { if ( ! is_string ( $ this -> workload ) || '' === trim ( $ this -> workload ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not valid workload value' , $ this -> workload ) ) ; } } | Guards the workload property |
5,971 | public static function sort ( array & $ arr , callable $ comp ) : void { $ aux = $ arr ; static :: partition ( $ aux , $ arr , 0 , count ( $ arr ) - 1 , $ comp ) ; } | Sorts an array with a stable sort |
5,972 | protected static function partition ( array & $ src , array & $ dst , int $ lo , int $ hi , callable $ comp ) : void { if ( $ hi <= $ lo + static :: SORT_CUTOFF ) { static :: insertionSort ( $ dst , $ lo , $ hi , $ comp ) ; return ; } $ mid = ( int ) ( $ lo + ( $ hi - $ lo ) / 2 ) ; static :: partition ( $ dst , $ src ... | Partitions and sorts array |
5,973 | protected static function merge ( array & $ src , array & $ dst , int $ lo , int $ mid , int $ hi , callable $ comp ) : void { $ i = $ lo ; $ j = $ mid + 1 ; for ( $ k = $ lo ; $ k <= $ hi ; $ k ++ ) { if ( $ i > $ mid ) { $ dst [ $ k ] = $ src [ $ j ++ ] ; } elseif ( $ j > $ hi ) { $ dst [ $ k ] = $ src [ $ i ++ ] ; }... | Merges compared arrays |
5,974 | protected static function insertionSort ( array & $ arr , int $ lo , int $ hi , callable $ comp ) : void { for ( $ i = $ lo ; $ i <= $ hi ; $ i ++ ) { for ( $ j = $ i ; $ j > $ lo && static :: lt ( $ arr [ $ j ] , $ arr [ $ j - 1 ] , $ comp ) ; $ j -- ) { static :: exch ( $ arr , $ j , $ j - 1 ) ; } } } | Sorts small compared sub - arrays using insertion sort |
5,975 | protected static function exch ( array & $ arr , int $ i , int $ j ) : void { $ temp = $ arr [ $ i ] ; $ arr [ $ i ] = $ arr [ $ j ] ; $ arr [ $ j ] = $ temp ; } | Exchanges two items in an array |
5,976 | public function attributes ( ) : array { $ languages = TransHelper :: getAllLanguages ( ) ; $ translatedAttributes = [ 'name' , 'slug' ] ; $ placeholder = 'for language ":lang"' ; if ( $ languages -> count ( ) == 1 ) { $ language = $ languages -> first ( ) ; return [ "translations.{$language->iso_code}.name" => '' , "t... | Get the validation message attributes |
5,977 | protected function getWhereClause ( ) { $ where = "WHERE\n" ; $ value = $ this -> user_id_getter -> invoke ( ) ; if ( empty ( $ value ) && ( string ) $ value != "0" ) { $ where .= $ this -> user_id_field . " IS NULL" ; } else switch ( checkempty ( $ this -> settings_fields [ $ this -> user_id_field ] ) ) { case DBWorke... | This is internal auxiliary function for getting where clause for getting and updating the user record . |
5,978 | protected function saveSettingsData ( & $ data ) { $ update_string = "" ; foreach ( $ this -> settings_fields as $ field => $ type ) { if ( $ field == $ this -> user_id_field ) { continue ; } $ value = $ this -> dbworker -> escape ( checkempty ( $ data [ $ field ] ) ) ; if ( empty ( $ value ) && ( string ) $ value != "... | This is internal auxiliary function for storing the settings to the target user table defined by the iniailization . |
5,979 | protected function loadSettingsData ( & $ data ) { $ query = "SELECT\n" ; $ query .= implode ( ", " , array_keys ( $ this -> settings_fields ) ) . "\n" ; $ query .= "FROM " . $ this -> user_table . "\n" ; $ query .= $ this -> getWhereClause ( ) ; if ( ! $ this -> dbworker -> execute_query ( $ query ) ) { throw new \ Ex... | This is internal auxiliary function for loading the settings from the target user table defined by the iniailization . |
5,980 | public function loadSettings ( ) { $ this -> validateParameters ( ) ; if ( ! empty ( $ this -> temp_settings [ "__loaded" ] ) ) { return true ; } if ( ! $ this -> loadSettingsData ( $ this -> settings ) ) { return false ; } $ this -> temp_settings = $ this -> settings ; unset ( $ this -> temp_settings [ "__dirty" ] ) ;... | Loads the settings from the target user table . |
5,981 | public function saveSettings ( ) { $ this -> validateParameters ( ) ; $ old_dirty_state = $ this -> temp_settings [ "__dirty" ] ; unset ( $ this -> temp_settings [ "__dirty" ] ) ; if ( $ this -> saveSettingsData ( $ this -> temp_settings ) ) { $ this -> settings = $ this -> temp_settings ; return true ; } $ this -> tem... | Saves the settings from to the target user table . |
5,982 | private function validateAndTrimHeader ( $ header , $ values ) : array { if ( ! is_array ( $ values ) ) { $ values = [ $ values ] ; } elseif ( empty ( $ values ) ) { throw new \ InvalidArgumentException ( 'Header values must be strings, empty array given.' ) ; } else { $ values = array_values ( $ values ) ; } if ( ! is... | Make sure header has a non - empty string name and a sting value . |
5,983 | private function computeHash ( $ uri ) { if ( ! isset ( $ this -> secret ) ) { $ this -> secret = $ this -> tensideConfig -> getSecret ( ) ; } return urlencode ( base64_encode ( hash_hmac ( 'sha256' , $ uri , $ this -> secret , true ) ) ) ; } | Calculate the hash . |
5,984 | private function buildUrl ( array $ url , array $ params = array ( ) ) { ksort ( $ params ) ; $ url [ 'query' ] = http_build_query ( $ params , '' , '&' ) ; $ scheme = isset ( $ url [ 'scheme' ] ) ? $ url [ 'scheme' ] . '://' : '' ; $ host = isset ( $ url [ 'host' ] ) ? $ url [ 'host' ] : '' ; $ port = isset ( $ url [ ... | Build the url . |
5,985 | public function indexAction ( ) { $ this -> view -> setTemplateBefore ( 'private' ) ; if ( $ this -> request -> isPost ( ) ) { $ profile = Profiles :: findFirstById ( $ this -> request -> getPost ( 'profileId' ) ) ; if ( $ profile ) { if ( $ this -> request -> hasPost ( 'permissions' ) ) { $ profile -> getPermissions (... | View the permissions for a profile level and change them if we have a POST . |
5,986 | protected function tryInvokeActionMethod ( string $ action , array $ parameters , bool $ isCaseSensitive , & $ result , ? bool & $ hasFoundActionMethod = null ) : bool { $ reflectionClass = new \ ReflectionClass ( $ this ) ; $ actionMethod = self :: findActionMethod ( $ reflectionClass , $ action , $ isCaseSensitive ) ... | Try to invoke an action method . |
5,987 | private function invokeActionMethod ( \ ReflectionMethod $ actionMethod , array $ parameters ) { $ this -> actionMethod = $ actionMethod ; $ preActionResult = $ this -> isPreActionEventEnabled ( ) ? $ this -> onPreActionEvent ( ) : null ; if ( $ preActionResult !== null ) { return $ preActionResult ; } $ result = $ act... | Invoke action method . |
5,988 | private static function actionMethodMatchesParameters ( \ ReflectionMethod $ reflectionMethod , array $ parameters ) : bool { $ parametersCount = count ( $ parameters ) ; if ( $ reflectionMethod -> getNumberOfParameters ( ) < $ parametersCount ) { return false ; } $ index = 0 ; foreach ( $ reflectionMethod -> getParame... | Check if an action method matches an array of parameters . |
5,989 | private static function findActionMethod ( \ ReflectionClass $ reflectionClass , string $ action , bool $ isCaseSensitive ) : ? \ ReflectionMethod { $ actionMethod = null ; if ( strlen ( $ action ) > 0 && ctype_digit ( $ action [ 0 ] ) ) { $ action = '_' . $ action ; } try { $ actionMethod = $ reflectionClass -> getMet... | Try to find an action method by action . |
5,990 | protected function & getIntlDatetimeFormatter ( $ langAndLocale = NULL , $ dateType = NULL , $ timeType = NULL , $ timeZone = NULL , $ calendar = NULL ) { $ key = implode ( '_' , [ 'datetime' , serialize ( func_get_args ( ) ) ] ) ; if ( ! isset ( $ this -> intlFormatters [ $ key ] ) ) { $ this -> intlFormatters [ $ key... | Get stored \ IntlDateFormatter instance or create new one . |
5,991 | public function getFacetsByCriteria ( Criteria $ criteria ) { $ query = new Query ( ) ; $ query -> setSize ( 0 ) ; $ filter = $ this -> createFilterFromCriteria ( $ criteria ) ; $ priorityFacet = new Facet \ Terms ( 'priorities' ) ; $ priorityFacet -> setField ( 'priority' ) ; if ( $ filter -> getFilters ( ) ) { $ prio... | Return facets . |
5,992 | private function applyCriteriaToQuery ( Criteria $ criteria , Query $ query , $ prefix = '' ) { if ( ! count ( $ criteria ) ) { return ; } $ query -> setPostFilter ( $ this -> createFilterFromCriteria ( $ criteria ) ) ; } | Apply criteria to query . |
5,993 | public static function parse ( $ intStr ) { $ int = new static ( \ strlen ( $ intStr ) ) ; if ( Number :: between ( $ int , MySQL :: getConstant ( 'TINYINT_MIN' ) , MySQL :: getConstant ( 'TINYINT_MAX' ) ) ) { $ int -> _IntType = static :: TINY_INT ; } else if ( Number :: between ( $ int , MySQL :: getConstant ( 'SMALL... | Determines the most appropriate int type |
5,994 | public function name ( string $ string ) : ValidationObject { if ( ! isset ( $ this -> forms [ $ string ] ) ) { $ this -> forms [ $ string ] = new ValidationObject ( $ string ) ; } return $ this -> forms [ $ string ] ; } | create new validation |
5,995 | public function get ( string $ name ) : string { $ forms = $ this -> forms ; foreach ( $ forms as $ id => $ item ) { $ val = $ item -> get ( ) ; if ( isset ( $ val [ $ name ] ) && $ val [ $ name ] ) { return $ id ; } } return false ; } | get field name of username|password|email |
5,996 | public function is ( string $ field , string $ name ) { return $ this -> forms [ $ field ] -> get ( ) [ $ name ] ; } | get one validation parameter from one field |
5,997 | public function getAll ( ) : array { $ forms = $ this -> forms ; $ a = [ ] ; foreach ( $ forms as $ id => $ item ) { $ a [ $ id ] = $ item -> get ( ) ; } return $ a ; } | get all validation parameters from all fields |
5,998 | public function getDataTables ( $ label = null ) { if ( $ label !== null ) { return isset ( $ this -> extraTables [ $ label ] ) ? $ this -> extraTables [ $ label ] : array ( ) ; } return $ this -> extraTables ; } | Returns all the extra data tables registered with this handler . Optionally accepts a label parameter to only return the data table under that label . |
5,999 | public function code ( ) { $ fieldWrapper = new HTMLBrick ( 'div' , $ this -> field ( ) ) ; $ fieldWrapper -> addClass ( 'col-lg-9' ) ; $ formGroup = new HTMLBrick ( 'div' , $ this -> label ( ) . $ fieldWrapper ) ; $ formGroup -> addClass ( 'form-group' ) ; if ( $ this -> hasError ) { $ formGroup -> addClass ( 'has-err... | Show the div container . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.