idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
18,700 | private function resolveParameter ( \ ReflectionParameter $ param , array $ args ) { $ className = $ param -> getClass ( ) ; if ( $ className !== null ) { return $ this -> make ( $ className -> getName ( ) ) ; } elseif ( isset ( $ args [ $ param -> getName ( ) ] ) ) { return $ args [ $ param -> getName ( ) ] ; } elseif ( $ param -> isOptional ( ) ) { return $ param -> getDefaultValue ( ) ; } else { throw new ClassResolvingException ( 'Cannot resolve Parameter #' . $ param -> getPosition ( ) . " '" . $ param -> getName ( ) . "'" ) ; } } | Resolves a ReflectionParameter . |
18,701 | public function Factory ( $ Alias , $ Args = NULL ) { if ( ! array_key_exists ( $ Alias , $ this -> _Objects ) ) return NULL ; $ Def = & $ this -> _Objects [ $ Alias ] ; $ ClassName = $ Def [ 'ClassName' ] ; if ( ! class_exists ( $ ClassName ) ) { $ Path = $ Def [ 'Path' ] ; if ( substr ( $ Path , 0 , 1 ) == '~' ) { $ Path = PATH_ROOT . substr ( $ Path , 1 ) ; $ Def [ 'Path' ] = $ Path ; } if ( file_exists ( $ Path ) ) require_once ( $ Path ) ; } if ( ! class_exists ( $ ClassName , FALSE ) ) { throw new Exception ( sprintf ( 'Class %s not found while trying to get an object for %s. Check the path %s.' , $ ClassName , $ Alias , $ Def [ 'Path' ] ) ) ; } $ Result = NULL ; $ FactoryType = $ Def [ 'FactoryType' ] ; $ FactorySupplimentData = isset ( $ Def [ $ FactoryType ] ) ? $ Def [ $ FactoryType ] : NULL ; switch ( $ FactoryType ) { case Gdn :: FactoryInstance : $ Result = $ this -> _InstantiateObject ( $ Alias , $ ClassName , $ Args ) ; break ; case Gdn :: FactoryPrototype : $ Prototype = $ FactorySupplimentData ; $ Result = clone $ Prototype ; break ; case Gdn :: FactorySingleton : $ SingletonDef = $ FactorySupplimentData ; if ( is_array ( $ SingletonDef ) ) { $ Singleton = NULL ; $ Args = $ SingletonDef ; } else { $ Singleton = $ SingletonDef ; } if ( is_null ( $ Singleton ) ) { $ Singleton = $ this -> _InstantiateObject ( $ Alias , $ ClassName , $ Args ) ; $ Def [ $ FactoryType ] = $ Singleton ; } $ Result = $ Def [ $ FactoryType ] ; break ; case Gdn :: FactoryRealSingleton : $ RealSingletonDef = $ FactorySupplimentData ; if ( ! is_object ( $ RealSingletonDef ) ) { $ RealSingleton = NULL ; } else { $ RealSingleton = $ RealSingletonDef ; } if ( is_null ( $ RealSingleton ) ) { $ RealSingleton = call_user_func_array ( array ( $ ClassName , $ RealSingletonDef ) , $ Args ) ; $ this -> _SetDependancies ( $ Alias , $ RealSingleton ) ; $ Def [ $ FactoryType ] = $ RealSingleton ; } $ Result = $ Def [ $ FactoryType ] ; break ; default : throw new Exception ( ) ; break ; } return $ Result ; } | Creates an object with mapped to the name . |
18,702 | public function InstallDependency ( $ Alias , $ PropertyName , $ SourceAlias ) { if ( ! array_key_exists ( $ Alias , $ this -> _Dependencies ) ) { $ this -> _Dependencies [ $ Alias ] = array ( $ PropertyName => $ SourceAlias ) ; } else { $ this -> _Dependencies [ $ Alias ] [ $ PropertyName ] = $ SourceAlias ; } } | Install a dependency for the factory . |
18,703 | protected function _InstantiateObject ( $ Alias , $ ClassName , $ Args = NULL ) { if ( is_null ( $ Args ) ) $ Args = array ( ) ; $ Result = NULL ; switch ( count ( $ Args ) ) { case 0 : $ Result = new $ ClassName ; break ; case 1 : $ Result = new $ ClassName ( $ Args [ 0 ] ) ; break ; case 2 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] ) ; break ; case 3 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] ) ; break ; case 4 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] , $ Args [ 3 ] ) ; break ; case 5 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] , $ Args [ 3 ] , $ Args [ 4 ] ) ; break ; case 6 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] , $ Args [ 3 ] , $ Args [ 4 ] , $ Args [ 5 ] ) ; break ; case 7 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] , $ Args [ 3 ] , $ Args [ 4 ] , $ Args [ 5 ] , $ Args [ 6 ] ) ; break ; case 8 : $ Result = new $ ClassName ( $ Args [ 0 ] , $ Args [ 1 ] , $ Args [ 2 ] , $ Args [ 3 ] , $ Args [ 4 ] , $ Args [ 5 ] , $ Args [ 6 ] , $ Args [ 7 ] ) ; break ; default : throw new Exception ( ) ; } $ this -> _SetDependancies ( $ Alias , $ Result ) ; return $ Result ; } | Instantiate a new object . |
18,704 | public function Cleanup ( ) { foreach ( $ this -> _Objects as $ FactoryInstanceName => & $ FactoryInstance ) { if ( ! is_array ( $ FactoryInstance ) ) continue ; $ FactoryType = $ FactoryInstance [ 'FactoryType' ] ; if ( ! array_key_exists ( $ FactoryType , $ FactoryInstance ) ) continue ; $ FactoryObject = & $ FactoryInstance [ $ FactoryType ] ; if ( method_exists ( $ FactoryObject , 'Cleanup' ) ) $ FactoryObject -> Cleanup ( ) ; unset ( $ FactoryInstance ) ; } } | Clean up the factory s objects |
18,705 | public function UninstallDependency ( $ Alias , $ PropertyName = NULL ) { if ( array_key_exists ( $ Alias , $ this -> _Dependencies ) ) { if ( is_null ( $ PropertyName ) ) unset ( $ this -> _Dependencies [ $ Alias ] ) ; elseif ( array_key_exists ( $ PropertyName , $ this -> _Dependencies [ $ Alias ] ) ) unset ( $ this -> _Dependencies [ $ Alias ] [ $ PropertyName ] ) ; } } | Uninstall a dependency definition . |
18,706 | public function getCamelCase ( bool $ upperCamelCase = true , int $ acronymMaxLength = null ) : string { $ phrase = '' ; foreach ( $ this -> words as $ word ) { if ( ! $ upperCamelCase ) { $ phrase .= $ word -> getCapitalCase ( ) ; $ upperCamelCase = true ; continue ; } $ phrase .= $ word -> getCapitalCase ( ) ; } return $ phrase ; } | Returns the phrase as camel case . |
18,707 | public function getSnakeCase ( string $ glue = '-' ) { $ words = [ ] ; foreach ( $ this -> words as $ word ) { $ words [ ] = $ word -> getLowerCase ( ) ; } return implode ( $ glue , $ words ) ; } | Returns the snake case version with the glue provided . |
18,708 | public static function decode ( string $ phrase , string $ concatenationType = self :: CONCATENATION_TYPE_ALL , string $ glue = null ) { if ( $ concatenationType == self :: CONCATENATION_TYPE_CAPITALIZATION || $ concatenationType == self :: CONCATENATION_TYPE_ALL ) { $ phrase = preg_split ( '/(?=[A-Z])/' , $ phrase ) ; } else { $ phrase = [ $ phrase ] ; } if ( $ concatenationType == self :: CONCATENATION_TYPE_GLUE || $ concatenationType == self :: CONCATENATION_TYPE_ALL ) { $ newWords = [ ] ; foreach ( $ phrase as $ i ) { array_push ( $ newWords , ... self :: unglue ( $ i , $ glue ) ) ; } $ phrase = $ newWords ; } $ phrase = array_filter ( $ phrase ) ; foreach ( $ phrase as & $ word ) { $ word = Dictionary :: getInstance ( ) -> getWord ( $ word ) ; } return new self ( ... $ phrase ) ; } | Given a phrase as a string and a few options break it down into individual Word objects and create a Phrase with them . |
18,709 | protected static function unglue ( string $ string , string $ glue = null ) : array { $ glue = ( $ glue === null ) ? '-_ ' : $ glue ; return preg_split ( "/[" . $ glue . "]+/" , $ string ) ; } | Given one or more characters as glue separate a string into an array of strings . |
18,710 | public static function decodeSnakeCase ( string $ phrase , string $ glue = '-' ) { return self :: decode ( $ phrase , self :: CONCATENATION_TYPE_GLUE , $ glue ) ; } | Convenience method to separate snake cased words . |
18,711 | static function get ( $ alias = null ) { if ( $ alias === null ) { return static :: $ config [ static :: $ default ] ; } if ( isset ( static :: $ config [ $ alias ] ) ) { return static :: $ config [ $ alias ] ; } else { return false ; } } | Get Database configurations |
18,712 | public function exchangeArray ( array $ state ) { if ( $ this instanceof IValueObject && $ this -> isExchanged ( ) ) throw new Exception ( "Cannot change ValueObjects. Create new object instead" ) ; if ( $ this instanceof IValidatorAware && ! is_null ( $ this -> getValidator ( ) ) && ! $ this -> getValidator ( ) -> isValid ( $ state ) ) { $ stateRep = array ( ) ; foreach ( $ state as $ key => $ val ) $ stateRep [ ] = $ key . ' => ' . ( is_object ( $ val ) ? '[Object]' : ( is_resource ( $ val ) ? '[Resource]' : var_export ( $ val , true ) ) ) ; throw new InvalidStateException ( "ExchangeArray called with an invalid state: " . var_export ( $ this -> getValidator ( ) -> getMessages ( ) , true ) . "\n\n(" . implode ( ',' , $ stateRep ) . ')' ) ; } $ toSet = $ this -> getStateVarsWithAll ( ) ; foreach ( $ this -> getStateVO ( ) as $ voIndex ) if ( isset ( $ state [ $ voIndex ] ) ) { $ vo = $ state [ $ voIndex ] ; if ( $ vo instanceof IExchangeState ) $ state = array_merge ( $ state , $ vo -> getArrayCopy ( ) ) ; } foreach ( $ toSet as $ var ) { if ( isset ( $ state [ $ var ] ) ) { $ value = $ state [ $ var ] ; if ( $ this instanceof IValueObject && $ value instanceof IFreezable ) $ value -> freeze ( ) ; $ this -> { self :: _privatizeField ( $ var ) } = $ value ; } else $ this -> { self :: _privatizeField ( $ var ) } = null ; } if ( $ this instanceof IValueObject ) $ this -> markExchanged ( ) ; } | Implements a state into an entity |
18,713 | public function getToken ( ) : string { if ( ( $ this -> token === null ) || ( $ this -> token -> isExpired ( ) ) ) { $ jwtBuilder = new Builder ( ) ; $ jwtBuilder -> set ( 'iss' , $ this -> credentialPublicKey ) ; $ jwtBuilder -> set ( 'sub' , $ this -> userName ) ; $ this -> token = $ jwtBuilder -> sign ( new Sha256 ( ) , $ this -> credentialPrivateKey ) -> getToken ( ) ; } return ( string ) $ this -> token ; } | Generates the User Token and returns it . |
18,714 | public static function camelize ( $ string , $ separator = '_' ) : string { if ( is_array ( $ separator ) ) { $ separator = "(\\" . implode ( "|\\" , $ separator ) . ")" ; } else { $ separator = '\\' . $ separator ; } return preg_replace_callback ( "/{$separator}[a-zA-Z]/" , function ( $ matches ) { return strtoupper ( $ matches [ 0 ] [ 1 ] ) ; } , strtolower ( $ string ) ) ; } | Converts text separated by a specified separator to camel case . This function converts the entire text into lower case before performing the camel case conversion . Due to this the first character would be lowercased . |
18,715 | public static function deCamelize ( $ string , $ separator = '_' ) : string { return preg_replace_callback ( "/[A-Z][a-z]/" , function ( $ matches ) use ( $ separator ) { return $ separator . strtolower ( $ matches [ 0 ] ) ; } , lcfirst ( $ string ) ) ; } | Converts camel case text into regular text separated with an arbitrary separator . By default the seperator is an underscore . A space can also be used as the seperator in cases where the conversion is to an English sentence . |
18,716 | private static function runInflection ( $ text , $ rules ) { if ( in_array ( $ text , self :: $ noPlurals ) ) { return $ text ; } foreach ( $ rules as $ rule ) { if ( preg_match ( $ rule [ 0 ] , $ text , $ matches ) ) { return substr ( $ text , 0 , strlen ( $ text ) - strlen ( $ matches [ 'remove' ] ?? '' ) ) . $ rule [ 1 ] ; } } } | Run through the rules and generate a text transformation . |
18,717 | public function setTranslator ( \ Symfony \ Component \ Translation \ Translator $ translator ) { $ this -> translator = $ translator ; return $ this -> translator ; } | Set translator instance |
18,718 | public function trans ( $ id , $ params = [ ] , $ domain = null , $ locale = null ) { return $ this -> getTranslator ( ) -> trans ( $ id , $ params , $ domain , $ locale ) ; } | Translate the id using the translator |
18,719 | public function createView ( $ object ) { if ( ! is_object ( $ object ) ) { return null ; } foreach ( $ this -> registry as $ className => $ viewFactory ) { if ( $ object instanceof $ className ) { return $ viewFactory -> createView ( $ object ) ; } } } | Create a view for the object looking for a suitable factory |
18,720 | public function getAllGrupsWithMisses ( $ deflocale , $ includingmissedindef = true ) { $ result = array ( ) ; $ translate = $ this -> getTranslateObject ( ) ; $ translate -> setLocale ( $ deflocale ) ; $ defgroups = $ translate -> getAllGroups ( ) ; $ usedlanguages = $ this -> getUsedLanguages ( ) ; foreach ( $ usedlanguages as $ lang => $ langdata ) { foreach ( $ defgroups as $ group ) { $ difference = $ this -> getDifference ( $ group , $ lang , $ deflocale ) ; if ( $ difference [ 'missedcount' ] > 0 ) { if ( ! is_array ( $ result [ $ lang ] ) ) { $ result [ $ lang ] = array ( ) ; } $ result [ $ lang ] [ $ group ] = $ difference [ 'missedcount' ] ; } } } return $ result ; } | Returns all groups - locale associations where are some data missed comparing to def locale |
18,721 | public function getDifference ( $ group , $ locale , $ deflocale ) { $ translate = $ this -> getTranslateObject ( ) ; $ translate -> setLocale ( $ deflocale ) ; $ allkeys = $ translate -> getAllKeysForGroup ( $ group ) ; $ translate -> setLocale ( $ locale ) ; $ result [ 'groupmissed' ] = false ; try { $ keys = $ translate -> getAllKeysForGroup ( $ group ) ; } catch ( \ Exception $ e ) { $ result [ 'groupmissed' ] = true ; $ keys = array ( ) ; } $ result [ 'missed' ] = array_values ( array_diff ( $ allkeys , $ keys ) ) ; $ result [ 'extra' ] = array_values ( array_diff ( $ keys , $ allkeys ) ) ; $ result [ 'missedcount' ] = count ( $ result [ 'missed' ] ) ; $ result [ 'extracount' ] = count ( $ result [ 'extra' ] ) ; $ result [ 'total' ] = $ result [ 'missedcount' ] + $ result [ 'extracount' ] ; return $ result ; } | Returns information about difference between same group file in different locales an be used to find what is missed in secondary languages files |
18,722 | public function getMissedKeysTemplate ( $ group , $ locale , $ deflocale , $ mode = 'empty' , $ returntype = 'text' , $ textlinesplitter = "\n" ) { $ translate = $ this -> getTranslateObject ( true ) ; $ translate -> setLocale ( $ deflocale ) ; $ difference = $ this -> getDifference ( $ group , $ locale , $ deflocale ) ; $ fixtextlines = array ( ) ; foreach ( $ difference [ 'missed' ] as $ key ) { $ line = $ key . ' = ' ; if ( $ mode == 'empty' ) { $ line .= '#' ; } $ defvalue = $ translate -> getText ( $ key , $ group ) ; $ line .= $ defvalue ; if ( $ returntype == 'hash' ) { $ fixtextlines [ $ key ] = $ defvalue ; } else { $ fixtextlines [ ] = $ line ; } } if ( $ returntype == 'lines' || $ returntype == 'hash' ) { return $ fixtextline ; } return implode ( $ textlinesplitter , $ fixtextlines ) ; } | Returns text of array of lines to add toa secondary locale group to correct it |
18,723 | public function fixMissedKeysFromTemplate ( $ group , $ locale , $ deflocale , $ mode = 'empty' , $ textlinesplitter = "\n" ) { $ text = $ this -> getMissedKeysTemplate ( $ group , $ locale , $ deflocale , $ mode , 'text' , $ textlinesplitter ) ; $ translate = $ this -> getTranslateObject ( ) ; $ groupfile = $ translate -> getGroupFile ( $ group , $ locale ) ; $ groupfilecontents = '' ; if ( file_exists ( $ groupfile ) ) { $ groupfilecontents = @ file_get_contents ( $ groupfile ) ; } $ groupfilecontents .= $ textlinesplitter . $ text ; file_put_contents ( $ groupfile , $ groupfilecontents ) ; return true ; } | Fixes a group by adding all missed keys with empty values or def locale values |
18,724 | public function getEmptyKeysWithDefValues ( $ group , $ locale , $ deflocale , $ skipfiles = true ) { $ translate = $ this -> getTranslateObject ( true ) ; $ translate -> setLocale ( $ deflocale ) ; $ allkeys = $ translate -> getAllKeysForGroup ( $ group ) ; $ alltranslates = $ translate -> getDataForGroup ( $ group ) ; $ translate -> setLocale ( $ locale ) ; try { $ keys = $ translate -> getAllKeysForGroup ( $ group ) ; $ translates = $ translate -> getDataForGroup ( $ group ) ; } catch ( \ Exception $ e ) { $ keys = array ( ) ; $ translates = array ( ) ; } $ missed = array_values ( array_diff ( $ allkeys , $ keys ) ) ; $ result = array ( ) ; foreach ( $ translates as $ key => $ value ) { if ( $ value == '' ) { $ missed [ ] = $ key ; } } foreach ( $ missed as $ key ) { $ result [ $ key ] = $ alltranslates [ $ key ] ; if ( $ result [ $ key ] == '' ) { $ result [ $ key ] = '*' ; } elseif ( strpos ( $ result [ $ key ] , 'file:' ) === 0 && $ skipfiles ) { unset ( $ result [ $ key ] ) ; } } return $ result ; } | Returns all empty keys from a group and associated values from def locale group |
18,725 | public function fixMissedKeysFromList ( $ lines , $ group , $ locale , $ deflocale , $ skipfiles = true , $ textlinesplitter = "\n" ) { $ list = $ this -> getEmptyKeysWithDefValues ( $ group , $ locale , $ deflocale , $ skipfiles ) ; if ( count ( $ list ) != count ( $ lines ) ) { throw new \ Exception ( sprintf ( 'Wrong count of input lines. %d vs %d' , count ( $ list ) , count ( $ lines ) ) ) ; } $ translate = $ this -> getTranslateObject ( true ) ; $ translate -> setLocale ( $ locale ) ; try { $ translates = $ translate -> getDataForGroup ( $ group ) ; } catch ( \ Exception $ e ) { $ translates = array ( ) ; } foreach ( $ list as $ key => $ value ) { $ value = array_shift ( $ lines ) ; $ translates [ $ key ] = $ value ; } $ groupfile = $ translate -> getGroupFile ( $ group , $ locale ) ; array_walk ( $ translates , function ( & $ value , $ key ) { $ value = "$key = $value" ; } ) ; $ groupfilecontents .= implode ( $ textlinesplitter , $ translates ) . $ textlinesplitter ; file_put_contents ( $ groupfile , $ groupfilecontents ) ; return true ; } | Receives a group of values as a list and assigns to missed keys in a group of locale . It can be used to quick translate of values as text file with a value per line . |
18,726 | public function setNameAttribute ( $ value ) { $ this -> attributes [ 'name' ] = json_encode ( ! is_array ( $ value ) ? [ app ( ) -> getLocale ( ) => $ value ] : $ value ) ; } | Set the translatable name attribute . |
18,727 | public function setDescriptionAttribute ( $ value ) { $ this -> attributes [ 'description' ] = ! empty ( $ value ) ? json_encode ( ! is_array ( $ value ) ? [ app ( ) -> getLocale ( ) => $ value ] : $ value ) : null ; } | Set the translatable description attribute . |
18,728 | public function scopeWithGroup ( Builder $ query , string $ group = null ) : Builder { return $ group ? $ query -> where ( 'group' , $ group ) : $ query ; } | Scope tags by given group . |
18,729 | public static function findManyByNameOrCreate ( array $ tags , string $ group = null , string $ locale = null ) : Collection { return collect ( $ tags ) -> map ( function ( $ tag ) use ( $ group , $ locale ) { return static :: findByNameOrCreate ( $ tag , $ group , $ locale ) ; } ) ; } | Find many tags by name or create if not exists . |
18,730 | public static function findByNameOrCreate ( string $ name , string $ locale = null , string $ group = null ) : Tag { $ locale = $ locale ?? app ( ) -> getLocale ( ) ; return static :: findByName ( $ name , $ locale ) ? : static :: createByName ( $ name , $ locale , $ group ) ; } | Find tag by attribute or create if not exists . |
18,731 | public function compile ( ) { $ loader = $ this -> loaderFactory -> newInstance ( ) ; $ cache = $ this -> cacheFactory -> produce ( ) ; if ( true === $ cache -> expired ( ) ) { $ config = $ this -> loadConfig ( $ loader ) ; $ cache -> write ( $ config ) ; } else { $ config = $ cache -> get ( ) ; } return $ config ; } | Builds the configuration tree out of all of the App configuration definitions . |
18,732 | public function printLine ( $ line ) { if ( ! $ this -> handle ) { throw new \ RuntimeException ( 'can not write to file: invalid file handle' ) ; } fwrite ( $ this -> handle , $ line . "\n" ) ; ++ $ this -> lineNumber ; } | Write to the file . |
18,733 | public function setTemporaryPath ( $ temporaryPath ) { $ this -> temporaryPath = $ temporaryPath ; if ( ! $ this -> didMove ) { $ this -> currentPath = $ temporaryPath ; $ this -> fileSize = 0 ; if ( file_exists ( $ this -> currentPath ) ) { $ this -> fileSize = filesize ( $ temporaryPath ) ; } } return $ this ; } | Sets the path to local temporary file that was created to hold this file upload . |
18,734 | public function getErrorMessage ( ) { switch ( $ this -> error ) { case UPLOAD_ERR_OK : return 'File uploaded successfully.' ; case UPLOAD_ERR_INI_SIZE : case UPLOAD_ERR_FORM_SIZE : return 'The uploaded file exceeds the maximum file size.' ; case UPLOAD_ERR_NO_FILE : return 'No file was uploaded.' ; case UPLOAD_ERR_PARTIAL : return 'The file was only partially uploaded.' ; case UPLOAD_ERR_NO_TMP_DIR : case UPLOAD_ERR_CANT_WRITE : return 'Could not create temporary file.' ; case UPLOAD_ERR_EXTENSION : return 'The upload was blocked.' ; } return 'An unknown error occured.' ; } | Gets a description of the upload error that has occurred . |
18,735 | public function saveTo ( $ targetPath ) { if ( $ this -> hasError ( ) ) { return false ; } if ( $ this -> getFileSize ( ) <= 0 ) { return false ; } if ( ! $ this -> didMove ) { $ moveOk = move_uploaded_file ( $ this -> getTemporaryPath ( ) , $ targetPath ) ; } else { $ moveOk = copy ( $ this -> getCurrentPath ( ) , $ targetPath ) ; } if ( $ moveOk ) { $ this -> didMove = true ; $ this -> currentPath = $ targetPath ; } return $ moveOk ; } | Moves the temporary file to a given location or copies the previously moved file to a new location . If the destination file already exists it will be overwritten . The temporary file will be deleted . |
18,736 | public static function table ( $ table , $ connection = null ) { return self :: getInstance ( ) -> getConnection ( $ connection ) -> table ( $ table ) ; } | Get a fluent query builder instance . |
18,737 | public function build ( ) { $ issue = $ this -> root ; $ this -> issues [ $ issue -> getKey ( ) ] = $ issue ; $ unreceivedIssues = array_diff_key ( $ this -> issues , $ this -> populatedIssueKeys ) ; while ( count ( $ unreceivedIssues ) > 0 && $ this -> depth < $ this -> maxDepth ) { $ unpopulatedIssueKeys = [ ] ; foreach ( $ unreceivedIssues as $ issue ) { $ this -> populatedIssueKeys [ $ issue -> getKey ( ) ] = 1 ; foreach ( $ issue -> getLinks ( ) as $ issueLink ) { $ unpopulatedIssueKey = IssueLinkHelper :: getLinkedIssueKey ( $ issueLink ) ; if ( $ unpopulatedIssueKey ) { $ unpopulatedIssueKeys [ $ unpopulatedIssueKey ] = $ unpopulatedIssueKey ; } } } $ notProcessedIssueKeys = [ ] ; foreach ( $ unpopulatedIssueKeys as $ issueKey ) { if ( ! array_key_exists ( $ issueKey , $ this -> issues ) ) { $ notProcessedIssueKeys [ ] = $ issueKey ; } } if ( $ notProcessedIssueKeys ) { $ issues = $ this -> getIssuesFromRepositoryByKeys ( $ notProcessedIssueKeys ) ; foreach ( $ issues as $ issue ) { if ( ! array_key_exists ( $ issue -> getKey ( ) , $ this -> issues ) ) { $ this -> issues [ $ issue -> getKey ( ) ] = $ issue ; } } } $ unreceivedIssues = array_diff_key ( $ this -> issues , $ this -> populatedIssueKeys ) ; $ this -> depth ++ ; } } | Builds issue tree |
18,738 | private function getIssuesFromRepositoryByKeys ( array $ keys ) { $ issues = [ ] ; if ( $ keys ) { $ query = $ this -> issueQuery ; $ query [ 'jql' ] = 'key IN (' . implode ( ',' , $ keys ) . ')' ; $ issues = $ this -> dispatcher -> getIssues ( $ query ) ; } return $ issues ; } | Returns issues by keys from repository |
18,739 | public function getIssueByKey ( $ key ) { if ( array_key_exists ( $ key , $ this -> issues ) && isset ( $ this -> issues [ $ key ] ) ) { return $ this -> issues [ $ key ] ; } return null ; } | Returns issue by keys from memory |
18,740 | function gastos_pagos ( ) { $ gastosDeuda = $ this -> Gasto -> enDeuda ( ) ; $ gastosSeleccionados = $ this -> data [ 'Gasto' ] [ 'Gasto' ] ; foreach ( $ gastosSeleccionados as $ gs ) { if ( in_array ( $ gs , $ gastosDeuda ) ) { return false ; } } return true ; } | Verifica que el egreso no se realizara sobre un gasto que ya esta marcado como pagado |
18,741 | public function SetToggle ( ) { $ Session = Gdn :: Session ( ) ; if ( ! $ Session -> IsValid ( ) ) return ; $ ShowAllCategories = GetIncomingValue ( 'ShowAllCategories' , '' ) ; if ( $ ShowAllCategories != '' ) { $ ShowAllCategories = $ ShowAllCategories == 'true' ? TRUE : FALSE ; $ ShowAllCategoriesPref = $ Session -> GetPreference ( 'ShowAllCategories' ) ; if ( $ ShowAllCategories != $ ShowAllCategoriesPref ) $ Session -> SetPreference ( 'ShowAllCategories' , $ ShowAllCategories ) ; Redirect ( '/' . ltrim ( Gdn :: Request ( ) -> Path ( ) , '/' ) ) ; } } | Set the preference in the user s session . |
18,742 | public function attachTrigger ( TriggerInterface $ trigger , $ eventNameOrClass , $ priority = 1 ) { $ event = ltrim ( ( string ) $ eventNameOrClass , '\\' ) ; $ this -> events [ $ event ] [ ( int ) $ priority . '.0' ] [ ] = $ trigger ; return $ this ; } | Attachs an trigger to the specified event . |
18,743 | public function attach ( $ eventNameOrClass , $ listenerName , $ listenerMethod , $ priority = 1 ) { $ trigger = new Trigger ( $ listenerName , $ listenerMethod ) ; $ this -> attachTrigger ( $ trigger , $ eventNameOrClass , $ priority ) ; return $ this ; } | Attachs an listener to the specified event . |
18,744 | public function detachTrigger ( TriggerInterface $ trigger , $ eventNameOrClass ) { $ event = ( string ) $ eventNameOrClass ; if ( isset ( $ this -> events [ $ event ] ) ) { foreach ( $ this -> events [ $ event ] as $ priority => $ triggers ) { if ( false !== ( $ key = array_search ( $ trigger , $ triggers , false ) ) ) { unset ( $ this -> events [ $ event ] [ $ priority ] [ $ key ] ) ; } } } return $ this ; } | Detaches trigger from the specified event . |
18,745 | public function clearTriggers ( $ eventNameOrClass ) { if ( isset ( $ this -> events [ $ eventNameOrClass ] ) ) { unset ( $ this -> events [ $ eventNameOrClass ] ) ; } return $ this ; } | Clears all triggers for a given event . |
18,746 | public function merge ( EventsInterface $ source = null ) { if ( null === $ source ) { return $ this -> events ; } $ this -> events = array_merge ( $ this -> events , $ source -> merge ( ) ) ; } | Merges with other events . |
18,747 | protected function pullTriggers ( EventInterface $ event ) { $ event -> stopPropagation ( false ) ; foreach ( $ this -> getTriggers ( $ event ) as $ trigger ) { $ trigger ( $ event ) ; if ( $ event -> propagationIsStopped ( ) ) { break ; } } return $ event ; } | Pull the triggers . |
18,748 | protected function getTriggers ( EventInterface $ event ) { $ eventName = $ event -> getName ( ) ; $ eventClass = get_class ( $ event ) ; $ search = [ ] ; if ( isset ( $ this -> events [ $ eventName ] ) ) { $ search [ ] = $ this -> events [ $ eventName ] ; } if ( isset ( $ this -> events [ $ eventClass ] ) ) { $ search [ ] = $ this -> events [ $ eventClass ] ; } $ parent = $ event ; while ( $ parent = get_parent_class ( $ parent ) ) { if ( isset ( $ this -> events [ $ parent ] ) ) { $ search [ ] = $ this -> events [ $ parent ] ; } } if ( empty ( $ search ) ) { return $ search ; } $ triggers = call_user_func_array ( 'array_merge_recursive' , $ search ) ; krsort ( $ triggers ) ; return call_user_func_array ( 'array_merge' , $ triggers ) ; } | Gets the triggers for the currently event . |
18,749 | public function renderTable ( ) { $ header = $ this -> tableHeaders ( ) ; $ content = H :: table ( $ header , $ this -> getTableAttributes ( ) ) ; return $ content ; } | Draws the entire Table |
18,750 | protected function tableHeaders ( ) : string { $ arrCells = [ ] ; foreach ( $ this -> getHeaderColumns ( ) as $ key => $ val ) { $ arrCells [ ] = $ this -> renderHeaderColumn ( $ key , $ val ) ; } $ arrCells [ ] = "" ; $ content = H :: renderTableHeaderRow ( $ arrCells ) ; $ full = H :: thead ( $ content ) . H :: tbody ( '' ) ; return $ full ; } | Render the Header of the overview Table |
18,751 | protected function renderHeaderColumn ( string $ label , string $ attributeName , string $ dataType = "text" ) : string { $ this -> getTableAttributes ( ) ; $ inputAttr = [ "data-parent" => $ this -> tableAttributes [ 'id' ] , "data-attribute" => $ attributeName , "data-sort" => "ASC" , "data-type" => $ dataType , "class" => "infiniteScrollTableHeaderLink" , ] ; $ inputField = "" ; if ( $ dataType !== null ) { $ fieldAttr = [ "size" => strlen ( $ label ) , ] ; $ inputField = H :: input ( $ attributeName , $ dataType , null , $ fieldAttr ) ; } return H :: span ( $ label , $ inputAttr ) . $ inputField ; } | Render a single Header Column |
18,752 | public function jsonRows ( ) { $ arrWhat = array_values ( $ this -> getHeaderColumns ( ) ) ; $ arrWhere = [ ] ; $ arrOrder = [ '`id` DESC' ] ; $ start = 0 ; $ pageSize = 15 ; if ( isset ( $ _POST [ 'page' ] ) && isset ( $ _POST [ 'pageSize' ] ) ) { $ page = ( int ) $ _POST [ 'page' ] ; $ pageSize = ( int ) $ _POST [ 'pageSize' ] ; $ start = $ page * $ pageSize ; } if ( isset ( $ _POST [ 'sort' ] ) && isset ( $ _POST [ 'sortDir' ] ) ) { $ sort = ( string ) $ _POST [ 'sort' ] ; $ sortDir = ( string ) $ _POST [ 'sortDir' ] ; if ( ! in_array ( $ sortDir , [ 'ASC' , 'DESC' ] ) ) { throw new Exception ( 'Someone is doing something evil here :(' ) ; } if ( ! in_array ( $ sort , $ this -> getAllowedPostColumns ( ) ) ) { throw new Exception ( 'Someone is doing something evil here :(' ) ; } $ arrOrder = [ '`' . $ sort . '` ' . $ sortDir ] ; } foreach ( $ arrWhat as $ filter ) { if ( in_array ( $ filter , $ arrWhat ) && isset ( $ _POST [ 'filter_' . $ filter ] ) ) { $ arrWhere [ $ filter ] = [ "operator" => "like" , "value" => '%' . $ _POST [ 'filter_' . $ filter ] . '%' ] ; } } $ arrLimit = [ $ start , $ pageSize ] ; $ rows = $ this -> loadByPrepStmt ( $ arrWhat , $ arrWhere , $ arrOrder , $ arrLimit ) ; if ( count ( $ rows ) < 1 ) { return "[]" ; } foreach ( $ rows as $ key => $ columns ) { foreach ( $ columns as $ cKey => $ column ) { if ( $ cKey == "createDate" ) { $ rows [ $ key ] [ $ cKey ] = strftime ( "%d.%m.%Y %H:%M:%S" , strtotime ( $ column ) ) ; } } $ rows [ $ key ] [ 'actions' ] = $ this -> renderActionLinks ( ) ; } $ json = json_encode ( $ rows , JSON_UNESCAPED_UNICODE ) ; return $ json ; } | Fetches Data for Table Rows and returns as json uses POST vars page pageSize sort sortDir |
18,753 | protected function getAllowedPostColumns ( ) : array { $ arrColumns = $ this -> getTableColumns ( ) ; $ arrColumnNames = [ ] ; foreach ( $ arrColumns as $ column ) { $ arrColumnNames [ ] = $ column [ 'Field' ] ; } return $ arrColumnNames ; } | Gets all columns of the db table use them for security checks |
18,754 | public function oauthClientClass ( $ instance = false ) { if ( ! isset ( $ this -> oauth_client_class ) ) { throw new \ InvalidArgumentException ( static :: class . ' does not implement an OAuth Client class definition.' ) ; } return $ instance ? new $ this -> oauth_client_class : $ this -> oauth_client_class ; } | Get the applications OAuth client class |
18,755 | public function getToken ( $ username ) { return isset ( $ this -> access_tokens [ $ username ] ) ? $ this -> access_tokens [ $ username ] : null ; } | Retrieve an access token |
18,756 | public function applyScopesToUser ( $ user , array $ scopes ) { if ( ! is_a ( $ user , Model :: class ) ) { $ this -> fail ( 'User is not a model.' ) ; } $ scopes = array_map ( function ( $ scope ) { return [ 'oauth_scope_id' => $ scope ] ; } , $ scopes ) ; $ user -> scopes ( ) -> attach ( $ scopes ) ; return $ user -> fresh ( [ 'scopes' ] ) ; } | Attach scopes to a user |
18,757 | public function createClientWithScopes ( $ id , $ secret , array $ scopes ) { $ client = $ this -> oauthClientClass ( true ) ; $ client -> id = $ id ; $ client -> secret = $ secret ; $ client -> name = $ id ; $ client -> save ( ) ; $ apply_scopes = [ ] ; foreach ( $ scopes as $ scope ) { $ apply_scopes [ ] = [ 'client_id' => $ id , 'scope_id' => $ scope , ] ; } DB :: table ( 'oauth_client_scopes' ) -> insert ( $ apply_scopes ) ; return $ client ; } | Create a client and give it some scopes |
18,758 | private function parseExpression ( string $ variable = '' , array $ expression = [ ] , string $ logicalOp = ' AND ' ) : string { $ ret = [ ] ; foreach ( $ expression as $ operator => $ value ) { if ( \ in_array ( $ operator , $ this -> operatorsFrom ) ) { $ operator = \ str_replace ( $ this -> operatorsFrom , $ this -> operatorsTo , $ operator ) ; $ ret [ ] = \ sprintf ( '%s%s%s' , $ variable , $ operator , $ this -> escapeClass -> escape ( $ value ) ) ; } elseif ( $ operator == '$in' && \ is_array ( $ value ) ) { $ value = \ array_map ( [ $ this -> escapeClass , 'escape' ] , $ value ) ; $ ret [ ] = \ sprintf ( '%s IN (%s)' , $ variable , \ implode ( ',' , $ value ) ) ; } elseif ( $ operator == '$in' && \ is_string ( $ value ) ) { $ value = $ this -> escapeClass -> escape ( $ value ) ; $ ret [ ] = \ sprintf ( '%s IN (%s)' , $ variable , $ value ) ; } elseif ( $ operator == '$nin' && \ is_array ( $ value ) ) { $ value = \ array_map ( [ $ this -> escapeClass , 'escape' ] , $ value ) ; $ ret [ ] = \ sprintf ( '%s NOT IN (%s)' , $ variable , \ implode ( ',' , $ value ) ) ; } elseif ( $ operator == '$nin' && \ is_string ( $ value ) ) { $ value = $ this -> escapeClass -> escape ( $ value ) ; $ ret [ ] = \ sprintf ( '%s NOT IN (%s)' , $ variable , $ value ) ; } elseif ( $ operator == '$like' ) { $ ret [ ] = \ sprintf ( '%s LIKE %s' , $ variable , $ this -> escapeClass -> escape ( $ value ) ) ; } } return \ implode ( $ logicalOp , $ ret ) ; } | Parses logical expression |
18,759 | public static function create ( $ client , $ jobName , $ payload = null ) { $ longLog = new self ( $ client , $ jobName , $ payload ) ; return $ longLog ; } | Create new LongLog object with client variable |
18,760 | public function deleteByProductAbstractId ( int $ idProductAbstract ) : void { $ this -> getFactory ( ) -> getBrandProductQuery ( ) -> filterByFkProductAbstract_In ( [ $ idProductAbstract ] ) -> delete ( ) ; } | Delete brand relation by product abstract id |
18,761 | public function addBrandProductRelations ( int $ idProductAbstract , array $ brandIds ) : void { if ( count ( $ brandIds ) === 0 ) { return ; } foreach ( $ brandIds as $ brandId ) { $ entity = new FosBrandProduct ( ) ; $ entity -> setFkProductAbstract ( $ idProductAbstract ) -> setFkBrand ( $ brandId ) -> save ( ) ; } } | Add brand product relation |
18,762 | public function deleteBrandProductRelations ( int $ idProductAbstract , array $ brandIds ) : void { if ( count ( $ brandIds ) === 0 ) { return ; } $ this -> getFactory ( ) -> getBrandProductQuery ( ) -> filterByFkProductAbstract ( $ idProductAbstract ) -> filterByFkBrand_In ( $ brandIds ) -> delete ( ) ; } | Delete brand product relation |
18,763 | public function getFileBody ( ) { if ( ! isset ( $ this -> _fileBody ) ) { if ( is_file ( $ this -> _srcFilePath ) ) { $ this -> _fileBody = file_get_contents ( $ this -> _srcFilePath ) ; } else { $ this -> errmsg = Yii :: t ( $ this -> tc , "Source file '{file}' not found" , [ 'file' => $ this -> _srcFilePath ] ) ; return false ; } } return $ this -> _fileBody ; } | Get file body |
18,764 | public function synchronize ( ) { if ( empty ( $ this -> _fileSubpath ) ) { $ file = empty ( $ this -> _destFilePath ) ? $ this -> fileUrl : $ this -> _destFilePath ; $ this -> errmsg = __METHOD__ . "({$this->fileUrl}): " . Yii :: t ( $ this -> tc , "File '{file}' is not from upload mirror area" , [ 'file' => $ file ] ) ; return false ; } $ ext = $ this -> isAllowedExtension ( ) ; if ( $ ext !== true ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "File has not allowed type '{ext}'" , [ 'ext' => $ ext ] ) ; return false ; } if ( ! is_file ( $ this -> _srcFilePath ) ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "Source file '{file}' not found" , [ 'file' => $ this -> _srcFilePath ] ) ; return false ; } $ needUpdate = $ this -> needUpdate ( $ this -> _srcFilePath , $ this -> _destFilePath ) ; if ( is_file ( $ this -> _destFilePath ) ) { if ( $ needUpdate && ! @ unlink ( $ this -> _destFilePath ) ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "Can't delete file '{file}'" , [ 'file' => $ this -> _destFilePath ] ) ; return false ; } } $ result = $ this -> copyFile ( $ this -> _srcFilePath , $ this -> _destFilePath ) ; if ( $ result === false ) { $ this -> errmsg = $ this -> errmsg ? : Yii :: t ( $ this -> tc , "Can't copy file" ) ; return false ; } $ this -> _fileBody = file_get_contents ( $ this -> _destFilePath ) ; return true ; } | Synchronize file from uploads area to web root files area . |
18,765 | protected function bindClientEvents ( PoolClientInterface $ client ) { $ clientId = $ client -> getClientId ( ) ; $ this -> _clientsStates [ $ clientId ] = PoolClientInterface :: CLIENT_POOL_STATE_READY ; $ this -> _clientsQueueCounters [ $ clientId ] = 0 ; $ client -> once ( PoolClientInterface :: CLIENT_POOL_EVENT_CLOSE , function ( ) use ( $ client , $ clientId ) { unset ( $ this -> _clients [ $ clientId ] ) ; unset ( $ this -> _clientsStates [ $ clientId ] ) ; unset ( $ this -> _clientsQueueCounters [ $ clientId ] ) ; $ client -> removeAllListeners ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_STATE ) ; $ client -> removeAllListeners ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_QUEUE ) ; } ) ; $ client -> on ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_STATE , function ( $ state ) use ( $ client , $ clientId ) { $ this -> _clientsStates [ $ clientId ] = $ state ; } ) ; $ client -> on ( PoolClientInterface :: CLIENT_POOL_EVENT_CHANGE_QUEUE , function ( $ queueCount ) use ( $ client , $ clientId ) { $ this -> _clientsQueueCounters [ $ clientId ] = $ queueCount ; } ) ; } | Bind event handlers to client instance |
18,766 | protected function createCleanupTimer ( ) { if ( ! isset ( $ this -> clientTtl ) ) { return ; } $ this -> _clientsCleanupTimer = $ this -> loop -> addPeriodicTimer ( 3 , function ( $ timer ) { $ expireTime = time ( ) - $ this -> clientTtl ; foreach ( $ this -> _clients as $ client ) { if ( $ client -> createdAt < $ expireTime ) { $ client -> clientClose ( ) ; } } } ) ; } | Create cleanup timer if Client TTL is configured |
18,767 | protected function voteForReadAction ( $ folder , TokenInterface $ token ) { return $ this -> isSubjectInPerimeter ( $ this -> getPath ( $ folder ) , $ token -> getUser ( ) , MediaFolderInterface :: ENTITY_TYPE ) ; } | Vote for Read action A user can read a folder if it is in his perimeter |
18,768 | public static function getResource ( StreamInterface $ stream ) { self :: register ( ) ; if ( $ stream -> isReadable ( ) ) { $ mode = $ stream -> isWritable ( ) ? 'r+' : 'r' ; } elseif ( $ stream -> isWritable ( ) ) { $ mode = 'w' ; } else { throw new \ InvalidArgumentException ( 'The stream must be readable, ' . 'writable, or both.' ) ; } return fopen ( 'phmessage://stream' , $ mode , null , stream_context_create ( [ 'phmessage' => [ 'stream' => $ stream ] , ] ) ) ; } | Returns a resource representing the stream . |
18,769 | public function command ( $ command ) { if ( ! in_array ( $ command , [ 'start' , 'stop' , 'restart' , 'reload' , 'force-reload' , 'status' ] ) ) { throw new \ InvalidArgumentException ( $ command ) ; } $ command = 'sudo /etc/init.d/tor ' . $ command ; $ command = new Command ( $ command ) ; $ command -> execute ( ) ; return $ command ; } | Execute tor command |
18,770 | public function curl ( $ url ) { $ ip = '127.0.0.1' ; $ port = '9051' ; $ auth = 'PASSWORD' ; $ command = 'signal NEWNYM' ; $ fp = fsockopen ( $ ip , $ port , $ error_number , $ err_string , 2 ) ; if ( ! $ fp ) { echo "ERROR: $error_number : $err_string" ; return false ; } else { fwrite ( $ fp , "AUTHENTICATE \"" . $ auth . "\"\n" ) ; fread ( $ fp , 512 ) ; fwrite ( $ fp , $ command . "\n" ) ; fread ( $ fp , 512 ) ; } fclose ( $ fp ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_PROXY , '127.0.0.1:9050' ) ; curl_setopt ( $ ch , CURLOPT_PROXYTYPE , CURLPROXY_SOCKS5 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_VERBOSE , 0 ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , $ this -> getUserAgent ( ) ) ; curl_setopt ( $ ch , CURLOPT_ENCODING , 'gzip' ) ; $ response = curl_exec ( $ ch ) ; return [ $ response , $ ch ] ; } | Tor curl wrapper |
18,771 | public function getUserAgent ( $ random = false ) { if ( $ random === false ) { return 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0' ; } $ headers = [ 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0' , 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' , 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36' , 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36' , 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0' , 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36' , 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0' , ] ; $ randomKey = array_rand ( $ headers ) ; return $ headers [ $ randomKey ] ; } | Get a user agent |
18,772 | public function getAsBool ( $ key , $ default = 0 ) { $ value = $ this -> get ( $ key , $ default ) ; if ( $ value === 'false' ) return false ; return ( bool ) $ value ; } | get as bool |
18,773 | public function getMiddleName ( ) : ? string { if ( ! $ this -> hasMiddleName ( ) ) { $ this -> setMiddleName ( $ this -> getDefaultMiddleName ( ) ) ; } return $ this -> middleName ; } | Get middle name |
18,774 | public function getFlashMessage ( ) { if ( Session :: get ( 'FMess' ) === true ) { $ response = array ( 'type' => Session :: get ( 'FMessType' ) , 'message' => Session :: get ( 'FMessMsg' ) ) ; Session :: destroy ( 'FMess' ) ; Session :: destroy ( 'FMessType' ) ; Session :: destroy ( 'FMessMsg' ) ; return $ response ; } return false ; } | Create info flash message |
18,775 | public static function __ ( string $ code ) : string { $ t = self :: getInstance ( ) ; if ( ! isset ( $ t -> translations [ $ code ] ) ) { return $ code ; } return $ t -> translations [ $ code ] ; } | Get the current Translation |
18,776 | public function build ( ) { $ this -> site = new Site ( $ this -> config [ 'config' ] [ 'url' ] , $ this -> config [ 'config' ] [ 'title' ] , $ this -> config [ 'config' ] [ 'tagline' ] , $ this -> getPosts ( ) , $ this -> getPages ( ) , $ this -> getCategories ( ) , $ this -> getAssets ( ) , $ this -> getPaginations ( ) , $ this -> getAuthors ( ) ) ; } | Main method to site |
18,777 | protected function getFormat ( BBcodeElementNodeInterface $ el ) { $ options = $ el -> getAttribute ( ) ; $ options = json_decode ( $ options [ 'media' ] , true ) ; return is_array ( $ options ) && array_key_exists ( 'format' , $ options ) ? $ options [ 'format' ] : MediaInterface :: MEDIA_ORIGINAL ; } | Get requested media format |
18,778 | protected function getStyle ( BBcodeElementNodeInterface $ el ) { $ options = $ el -> getAttribute ( ) ; $ options = json_decode ( $ options [ 'media' ] , true ) ; return is_array ( $ options ) && array_key_exists ( 'style' , $ options ) ? $ options [ 'style' ] : '' ; } | Get requested media style |
18,779 | private function _prepareWhere ( ) { $ sQuery = '' ; if ( is_array ( $ this -> _mWhere ) && count ( $ this -> _mWhere ) > 0 ) { $ sQuery .= ' WHERE ' ; foreach ( $ this -> _mWhere as $ sKey => $ sValue ) { $ sQuery .= "" . $ sKey . " = '" . str_replace ( "'" , "\'" , $ sValue ) . "' && " ; } $ sQuery = substr ( $ sQuery , 0 , - 3 ) ; } else if ( $ this -> _mWhere instanceof Where ) { $ sQuery .= ' WHERE 1 ' . $ this -> _mWhere -> get ( ) ; } $ sQuery = str_replace ( '1 &&' , '' , $ sQuery ) ; return $ sQuery ; } | prepare the where |
18,780 | private function _prepareHaving ( ) { $ sQuery = '' ; if ( is_array ( $ this -> _aHaving ) && count ( $ this -> _aHaving ) > 0 ) { $ sQuery .= ' HAVING ' ; foreach ( $ this -> _aHaving as $ sKey => $ sValue ) { $ sQuery .= "" . $ sKey . " = '" . str_replace ( "'" , "\'" , $ sValue ) . "' && " ; } $ sQuery = substr ( $ sQuery , 0 , - 3 ) ; } else if ( $ this -> _aHaving instanceof Where ) { $ sQuery .= ' HAVING 1 ' . $ this -> _aHaving -> get ( ) ; } return $ sQuery ; } | prepare the having |
18,781 | private function _prepareJoin ( ) { $ sQuery = '' ; if ( is_array ( $ this -> _aJoin ) && count ( $ this -> _aJoin ) > 0 ) { foreach ( $ this -> _aJoin as $ sKey => $ aValue ) { if ( isset ( $ aValue [ 'type' ] ) && $ aValue [ 'type' ] == 'left' ) { $ sQuery .= " LEFT JOIN `" . $ aValue [ 'table' ] . "` " ; } else { $ sQuery .= " INNER JOIN `" . $ aValue [ 'table' ] . "` " ; } if ( isset ( $ aValue [ 'as' ] ) && $ aValue [ 'as' ] ) { $ sQuery .= " AS " . $ aValue [ 'as' ] . " " ; } else { $ sQuery .= " AS t" . $ this -> _iAlias . " " ; $ this -> _iAlias ++ ; } $ sQuery .= " ON " . $ aValue [ 'left_field' ] . " = " . $ aValue [ 'right_field' ] . " " ; } } return $ sQuery ; } | prepare the join |
18,782 | private function _prepareOrderBy ( ) { $ sQuery = '' ; if ( is_array ( $ this -> _aOrderBy ) && count ( $ this -> _aOrderBy ) > 0 ) { $ sQuery .= ' ORDER BY ' . implode ( ',' , $ this -> _aOrderBy ) . ' ' ; } return $ sQuery ; } | prepare the order by |
18,783 | private function _prepareGroupBy ( ) { $ sQuery = '' ; if ( is_array ( $ this -> _aGroupBy ) && count ( $ this -> _aGroupBy ) > 0 ) { $ sQuery .= ' GROUP BY ' . implode ( ',' , $ this -> _aGroupBy ) . ' ' ; } return $ sQuery ; } | prepare the group by |
18,784 | private function _prepareLimit ( ) { $ sQuery = '' ; $ limit = ( int ) $ this -> _iLimit ; $ iOffset = $ this -> _iOffset ; if ( $ limit != 0 || $ iOffset > 0 ) { $ sQuery .= ' LIMIT ' ; } if ( $ iOffset > 0 ) { $ sQuery .= $ iOffset . ', ' . $ limit ; } else if ( $ limit != 0 ) { $ sQuery .= $ limit . ' ' ; } return $ sQuery ; } | prepare the limit |
18,785 | public function flush ( ) { $ this -> where = null ; $ this -> _aSelect = array ( ) ; $ this -> _sFrom = '' ; $ this -> _sFromAs = '' ; $ this -> _aJoin = array ( ) ; $ this -> _sUpdate = '' ; $ this -> _mWhere = array ( ) ; $ this -> _aSet = array ( ) ; $ this -> _sInsertInto = '' ; $ this -> _aValues = array ( ) ; $ this -> _sDelete = '' ; $ this -> _aOrderBy = array ( ) ; $ this -> _aGroupBy = array ( ) ; $ this -> _iLimit = null ; return $ this ; } | flush the ORM |
18,786 | public function addDependencies ( array $ dependenciesToAdd ) { $ this -> setCollectedDependencies ( array_merge ( array_unique ( array_merge ( $ this -> getCollectedDependencies ( ) , $ dependenciesToAdd ) ) ) ) ; return $ this ; } | Adds the given dependencies to the collectedDependencies without duplicating values and while maintining serial numerical index |
18,787 | static function find ( $ file , $ prefix_cdn_config = "cdn" ) { if ( ! $ real_path = \ Fw \ Find :: in ( "assets" , $ file ) ) throw new \ Exception ( "$file not found" ) ; $ so = strlen ( \ Fw \ Config :: get ( "docroot" ) ) - 1 ; return \ Fw \ Config :: get ( $ prefix_cdn_config ) . substr ( $ real_path , $ so ) ; } | Searches for asset based on the asset resources defined in \ Fw \ Find |
18,788 | public function getContent ( ) { if ( empty ( $ this -> content ) ) { $ requestBody = file_get_contents ( 'php://input' ) ; if ( strlen ( $ requestBody ) > 0 ) { $ this -> content = $ requestBody ; } } return $ this -> content ; } | Get raw request body |
18,789 | public function getServer ( $ name = null , $ default = null ) { if ( $ this -> serverParams === null ) { $ this -> serverParams = new Parameters ( ) ; } if ( $ name === null ) { return $ this -> serverParams ; } return $ this -> serverParams -> get ( $ name , $ default ) ; } | Return the parameter container responsible for server parameters or a single parameter value . |
18,790 | public function getEnv ( $ name = null , $ default = null ) { if ( $ this -> envParams === null ) { $ this -> envParams = new Parameters ( ) ; } if ( $ name === null ) { return $ this -> envParams ; } return $ this -> envParams -> get ( $ name , $ default ) ; } | Return the parameter container responsible for env parameters or a single parameter value . |
18,791 | protected function detectBasePath ( ) { $ filename = basename ( $ this -> getServer ( ) -> get ( 'SCRIPT_FILENAME' , '' ) ) ; $ baseUrl = $ this -> getBaseUrl ( ) ; if ( $ baseUrl === '' ) { return '' ; } if ( basename ( $ baseUrl ) === $ filename ) { return str_replace ( '\\' , '/' , dirname ( $ baseUrl ) ) ; } return $ baseUrl ; } | Autodetect the base path of the request |
18,792 | public function select ( $ table , $ fields = [ ] , WhereStatementInterface $ where = null , $ fetchStyle = PDO :: FETCH_ASSOC , $ fetchFlat = false , $ defaultValue = [ ] ) { return new Select ( $ table , $ fields , $ where , $ fetchStyle , $ fetchFlat , $ defaultValue ) ; } | retrieves data from a PDO connected resource |
18,793 | public function update ( $ table , array $ data , WhereStatementInterface $ where = null ) { return new Update ( $ table , $ data , $ where ) ; } | changes values of existing data in a PDO connected resource |
18,794 | public function registerTaxonomies ( ) { if ( ! function_exists ( 'register_taxonomy' ) ) { return ; } $ this -> taxonomies -> rewind ( ) ; while ( $ this -> taxonomies -> valid ( ) ) { $ taxonomy = $ this -> taxonomies -> current ( ) ; register_taxonomy ( $ taxonomy -> getName ( ) , $ taxonomy -> getSupportedPostTypes ( ) , $ taxonomy -> getArgs ( ) ) ; $ this -> taxonomies -> next ( ) ; } } | Registers all the taxonomies added |
18,795 | public function allowBban ( $ allow = null ) { if ( null !== $ allow ) { $ this -> allowBban = ( bool ) $ allow ; return $ this ; } return $ this -> allowBban ; } | Allow Bban . |
18,796 | public static function bootTenantable ( ) { static :: addGlobalScope ( 'tenant' , function ( Builder $ builder ) { if ( $ tenant = config ( 'rinvex.tenantable.tenant' ) ) { $ builder -> whereHas ( 'tenants' , function ( Builder $ builder ) use ( $ tenant ) { $ key = $ tenant instanceof Model ? $ tenant -> getKeyName ( ) : ( is_int ( $ tenant ) ? 'id' : 'slug' ) ; $ value = $ tenant instanceof Model ? $ tenant -> $ key : $ tenant ; $ builder -> where ( $ key , $ value ) ; } ) ; } } ) ; static :: created ( function ( Model $ tenantableModel ) { if ( $ tenantableModel -> queuedTenants ) { $ tenantableModel -> attachTenants ( $ tenantableModel -> queuedTenants ) ; $ tenantableModel -> queuedTenants = [ ] ; } } ) ; static :: deleted ( function ( Model $ tenantableModel ) { $ tenantableModel -> tenants ( ) -> detach ( ) ; } ) ; } | Boot the tenantable trait for a model . |
18,797 | public function tenantsWithGroup ( string $ group = null ) : Collection { return $ this -> tenants -> filter ( function ( Tenant $ tenant ) use ( $ group ) { return $ tenant -> group === $ group ; } ) ; } | Filter tenants with group . |
18,798 | protected static function getRandomData ( $ length , $ packSize , $ packFormat , $ callback = null ) { $ data = '' ; while ( strlen ( $ data ) < $ length ) { $ randomBytes = self :: getRandomBytes ( $ packSize ) ; $ value = unpack ( $ packFormat , $ randomBytes ) [ 1 ] ; if ( is_callable ( $ callback ) ) { $ value = call_user_func ( $ callback , $ value ) ; } $ data .= $ value ; } return substr ( $ data , 0 , $ length ) ; } | Generate random data based on the provided parameters |
18,799 | public static function raw ( $ length ) { $ data = '' ; while ( strlen ( $ data ) < $ length ) { $ data .= self :: getRandomBytes ( $ length ) ; } return substr ( $ data , 0 , $ length ) ; } | Gerate a string of raw random bytes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.