idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
23,900 | public function addAdditionalScript ( $ additionalScript ) : void { if ( ! $ additionalScript instanceof HtmlElementInterface ) { $ additionalScript = new HtmlString ( $ additionalScript ) ; } $ this -> webLibraries [ ] = new InlineWebLibrary ( null , null , $ additionalScript ) ; } | Adds an additional script at the end of the < ; head> ; tag . The provided script can either be a string or an object implementing HtmlElementInterface . |
23,901 | public function humaniceTrace ( array $ trace ) { $ html_helper = $ this -> html ; $ list = [ ] ; foreach ( $ trace as $ id_trace => $ e ) { $ class = explode ( '\\' , key_exists ( 'class' , $ e ) ? $ e [ 'class' ] : '' ) ; $ type = key_exists ( 'type' , $ e ) ? $ e [ 'type' ] : '' ; $ function = key_exists ( 'function' , $ e ) ? $ e [ 'function' ] : '' ; $ args = key_exists ( 'args' , $ e ) ? $ e [ 'args' ] : [ ] ; $ file = key_exists ( 'file' , $ e ) ? $ e [ 'file' ] : [ ] ; $ line = key_exists ( 'line' , $ e ) ? $ e [ 'line' ] : [ ] ; $ item = $ class ? '<span style="color:blue" title="' . implode ( '\\' , $ class ) . '">' . end ( $ class ) . '</span>' : '' ; $ item .= $ type ? '<span style="color:teal">' . $ type . '</span>' : '' ; $ item .= $ function ? '<span style="color:red">' . $ function . '</span>' : '' ; $ item .= $ args ? '(' . $ html_helper -> link ( count ( $ args ) . ' arg' , [ ] , [ 'onclick' => 'var a=document.getElementById(\'args_' . $ id_trace . '\');' . ' if (a.style.display==\'block\') { a.style.display=\'none\' } else { a.style.display=\'block\' };' . 'return false;' ] ) . ')' : '()' ; $ item .= $ file ? ' - <span style="color:lightgray" onmouseover="this.style.color=\'gray\'" ' . 'onmouseout="this.style.color=\'lightgray\'" >' . $ file . '</span>' : '' ; $ item .= $ line ? ' <span style="color:salmon">' . $ line . '</span>' : '' ; $ item .= $ args ? '<div style="display:none" id="args_' . $ id_trace . '">' . @ d ( $ args ) . '</div>' : '' ; $ list [ ] = $ item ; } return $ html_helper -> nestedList ( $ list , [ 'style' => 'font-family: arial; line-height:30px;' , 'reversed' => 'reversed' ] , [ ] , 'ordered' ) ; } | Obtiene el trace de legible de una excepcion |
23,902 | public function listArray ( ) : Array { if ( ! is_file ( $ this -> crontabCommands ) ) { return [ ] ; } return Arrays \ RemoveElement :: element ( explode ( EOL , file_get_contents ( $ this -> crontabCommands ) ) , '' ) ; } | Gets crontab list array |
23,903 | public function list ( ) : String { $ list = '' ; if ( is_file ( $ this -> crontabCommands ) ) { $ jobs = $ this -> listArray ( ) ; $ list = '<pre>' ; $ list .= '[ID] CRON JOB<br><br>' ; foreach ( $ jobs as $ key => $ job ) { $ list .= '[' . $ key . ']: ' . $ job . '<br>' ; } $ list .= '</pre>' ; } return $ list ; } | Gets crontab list |
23,904 | public function remove ( $ key = NULL ) { $ this -> executeRemoveCommand ( ) ; if ( $ key === NULL ) { unlink ( $ this -> crontabCommands ) ; } else { $ this -> removeJobFromExecFile ( $ key ) ; $ this -> executeCommand ( ) ; } } | Remove cron job |
23,905 | protected function createCrontabDirectoryIfNotExists ( ) { if ( ! is_dir ( $ crontabDirectory = pathinfo ( $ this -> crontabCommands , PATHINFO_DIRNAME ) ) ) { Filesystem :: createFolder ( $ crontabDirectory ) ; } } | Protected create crontab directory if not exists |
23,906 | protected function createExecFileIfNotExists ( ) { if ( ! is_file ( $ this -> crontabCommands ) ) { Filesystem \ Forge :: create ( $ this -> crontabCommands ) ; $ this -> processor -> exec ( 'chmod 0777 ' . $ this -> crontabCommands ) ; } } | Protected create exec file if not exists |
23,907 | protected function addJobToExecFile ( $ cmd ) { $ content = file_get_contents ( $ this -> crontabCommands ) ; if ( ! stristr ( $ content , $ cmd ) ) { $ content = $ content . $ this -> getValidCommand ( ) . $ cmd . EOL ; file_put_contents ( $ this -> crontabCommands , $ content ) ; } } | Protected add job to exec file |
23,908 | protected function removeJobFromExecFile ( $ cmd ) { $ jobs = $ this -> listArray ( ) ; unset ( $ jobs [ $ cmd ] ) ; file_put_contents ( $ this -> crontabCommands , implode ( EOL , $ jobs ) . EOL ) ; } | Protected remove job from exec file |
23,909 | protected function getDatetimeFormat ( ) { if ( $ this -> interval !== '* * * * *' ) { $ interval = $ this -> interval . ' ' ; } else { $ interval = ( $ this -> minute ?? '*' ) . ' ' . ( $ this -> hour ?? '*' ) . ' ' . ( $ this -> dayNumber ?? '*' ) . ' ' . ( $ this -> month ?? '*' ) . ' ' . ( $ this -> day ?? '*' ) . ' ' ; } $ this -> defaultIntervalVariables ( ) ; return $ interval ; } | Protected datet time format |
23,910 | protected function defaultCommandVariables ( ) { $ this -> type = NULL ; $ this -> path = NULL ; $ this -> command = NULL ; $ this -> debug = false ; } | Protected defaul command variables |
23,911 | protected function defaultIntervalVariables ( ) { $ this -> interval = '* * * * *' ; $ this -> minute = '*' ; $ this -> hour = '*' ; $ this -> dayNumber = '*' ; $ this -> month = '*' ; $ this -> day = '*' ; } | Protected default interval variables |
23,912 | public function setCommand ( $ command , $ base = null ) { $ base = ( $ base === null ) ? BASE : $ base ; parent :: setCommand ( $ this -> resolveBase ( $ base ) . 'anonym ' . $ command ) ; return $ this ; } | register the command |
23,913 | public function process ( $ text , $ args = null ) { $ text = $ this -> processDocuments ( $ text , $ args ) ; $ text = $ this -> processGalleries ( $ text , $ args ) ; return $ text ; } | Processes the given text |
23,914 | protected function makeDocuments ( array $ matches , array $ ids , $ documents , $ text ) { foreach ( $ ids as $ key => $ id ) { $ document = $ documents -> find ( $ id ) ; $ parsedDocument = '' ; if ( ! is_null ( $ document ) ) { $ parsedDocument = $ document -> present ( ) -> preview ; } $ text = str_replace ( $ matches [ $ key ] , $ parsedDocument , $ text ) ; } return $ text ; } | Replaces the document tags with presenter renders |
23,915 | protected function getGalleryMatches ( $ text ) { preg_match_all ( '~\[gallery.+ids="(\d+(?:,\d+)*)"\]~' , $ text , $ matches ) ; list ( $ matches , $ gallery ) = $ matches ; foreach ( $ gallery as $ key => $ ids ) { $ gallery [ $ key ] = explode ( ',' , $ ids ) ; } return [ $ matches , $ gallery ] ; } | Finds all media in given string |
23,916 | protected function makeGalleries ( array $ matches , array $ idSets , $ text ) { foreach ( $ idSets as $ key => $ ids ) { $ slides = get_nuclear_gallery ( $ ids ) ; $ gallery = ( count ( $ slides ) ) ? $ this -> makeGalleryHTML ( $ slides ) : '' ; $ text = str_replace ( $ matches [ $ key ] , $ gallery , $ text ) ; } return $ text ; } | Replaces the document tags with gallery render |
23,917 | protected function makeGalleryHTML ( Collection $ slides ) { if ( ! count ( $ slides ) ) { return '' ; } $ html = '' ; foreach ( $ slides as $ slide ) { $ html .= $ this -> makeSlideHTML ( $ slide ) ; } return $ this -> wrapSlidesHTML ( $ html ) ; } | Makes gallery HTML |
23,918 | protected function makeSlideHTML ( Image $ image ) { $ translation = $ image -> translate ( ) ; $ caption = ( $ translation ) ? $ translation -> caption : '' ; $ description = ( $ translation ) ? $ translation -> description : '' ; return '<li class="gallery__item"> <figure data-original="' . $ image -> getPublicURL ( ) . '">' . $ image -> present ( ) -> thumbnail . '<figcaption class="gallery-thumbnail__caption">' . $ caption . '</figcaption> <p class="gallery-thumbnail__description">' . $ description . '</p> </figure> </li>' ; } | Makes slide HTML |
23,919 | public function parseString ( $ string ) { $ tokens = new Stack ( $ this -> tokenizer -> tokenize ( $ string ) ) ; if ( $ tokens [ 0 ] -> type === Tokenizer :: T_EOF ) { return new CTX \ AccountInfoList ( ) ; } $ ctx = new CTX ( ) ; $ this -> reduceStruct ( $ tokens , $ ctx ) ; return $ ctx -> accountInfoList [ 0 ] ; } | Parse the given string |
23,920 | private function read ( array $ types , Stack $ tokens ) { $ token = $ tokens -> shift ( ) ; if ( ! in_array ( $ token -> type , $ types , true ) ) { $ names = array ( ) ; foreach ( $ types as $ type ) { $ names [ ] = $ this -> tokenizer -> getTokenName ( $ type ) ; } throw new \ RuntimeException ( "Expected one of: " . implode ( ', ' , $ names ) . ", found " . $ this -> tokenizer -> getTokenName ( $ token -> type ) . ". in line {$token->line} at position {$token->position}." ) ; } return $ token ; } | Read expected from token array |
23,921 | protected function reduceArrayValue ( Stack $ tokens , Struct $ parent ) { $ token = $ this -> read ( array ( Tokenizer :: T_ARRAY_VALUE ) , $ tokens ) ; $ name = $ token -> match [ 'name' ] ; $ parent -> $ name = array_map ( function ( $ value ) use ( $ token ) { return $ this -> getValue ( $ token , $ value ) ; } , preg_split ( '(",\\s*")' , $ token -> match [ 'value' ] ) ) ; } | Reduce array value |
23,922 | protected function getValue ( Token $ token , $ value = null ) { $ value = $ value ? : $ token -> match [ 'value' ] ; $ type = $ token -> match [ 'type' ] ; switch ( true ) { case $ type === 'int' : return ( int ) $ value ; case $ type === 'char' && preg_match ( '(^(?P<value>-?\\d+)%2F100$)' , $ value , $ match ) : return $ match [ 'value' ] / 100 ; case $ type === 'char' : return ( string ) urldecode ( $ value ) ; default : throw new \ RuntimeException ( "Unknown value type $type in line {$token->line} at position {$token->position}." ) ; } } | Convert token value type |
23,923 | private function validateLetter ( ) : bool { if ( $ this -> options [ 'require-letter' ] === true ) { if ( ! \ preg_match ( '/[a-z]/iu' , ( string ) $ this -> value ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_CONTAIN_LETTER ) ; return false ; } } return true ; } | Validates that password contains a letter |
23,924 | private function validateLowercaseLetter ( ) : bool { if ( $ this -> options [ 'require-lowercase-letter' ] === true ) { if ( ! \ preg_match ( '/[a-z]/u' , ( string ) $ this -> value ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_CONTAIN_LOWERCASE_LETTER ) ; return false ; } } return true ; } | Validates that password contains a lowercase letter |
23,925 | private function validateUppercaseLetter ( ) : bool { if ( $ this -> options [ 'require-uppercase-letter' ] === true ) { if ( ! \ preg_match ( '/[A-Z]/u' , ( string ) $ this -> value ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_CONTAIN_UPPERCASE_LETTER ) ; return false ; } } return true ; } | Validates that password contains an uppercase letter |
23,926 | private function validateNumber ( ) : bool { if ( $ this -> options [ 'require-number' ] === true ) { if ( ! \ preg_match ( '/[0-9]/' , ( string ) $ this -> value ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_CONTAIN_NUMBER ) ; return false ; } } return true ; } | Validates that password contains a number |
23,927 | private function validateSpecialCharacter ( ) : bool { if ( $ this -> options [ 'require-special-character' ] === true ) { if ( ! \ preg_match ( '/' . $ this -> options [ 'special-character-pattern' ] . '/' , ( string ) $ this -> value ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_CONTAIN_SPECIAL_CHARACTER ) ; return false ; } } return true ; } | Validates that password contains a special character |
23,928 | private function validateDifferentPreviousOne ( ) : bool { if ( $ this -> options [ 'require-different-than-previous-one' ] === true ) { if ( isset ( $ this -> options [ 'stored-passwords' ] [ 0 ] ) ) { $ passwordHash = ( string ) $ this -> value ; if ( PasswordEnctyption :: compare ( $ passwordHash , $ this -> options [ 'stored-passwords' ] [ 0 ] ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_BE_DIFFERENT_THAN_PREVIOUS_ONE ) ; return false ; } } } return true ; } | Validates that password is different than previous one |
23,929 | private function validateDifferentPreviousAll ( ) : bool { if ( $ this -> options [ 'require-different-than-previous-all' ] === true ) { $ passwordHash = ( string ) $ this -> value ; foreach ( $ this -> options [ 'stored-passwords' ] as $ storedPassword ) { if ( PasswordEnctyption :: compare ( $ passwordHash , $ storedPassword ) ) { $ this -> setError ( self :: VALIDATOR_ERROR_PASSWORD_MUST_BE_DIFFERENT_THAN_PREVIOUS_ALL ) ; return false ; } } } return true ; } | Validates that password is different than all previous passwords |
23,930 | public static function getLastElement ( array & $ inputArray , $ removeElement = false ) { if ( count ( $ inputArray ) > 0 ) { if ( ! $ removeElement ) { $ element = end ( $ inputArray ) ; } else { $ element = array_pop ( $ inputArray ) ; } } else { throw new \ Exception ( 'inputArray has no elements' ) ; } return $ element ; } | Fetches the last element of an array |
23,931 | public static function getLastIndex ( array & $ inputArray , $ removeElement = false ) { $ arrayIndexes = array_keys ( $ inputArray ) ; return self :: getLastElement ( $ arrayIndexes , $ removeElement ) ; } | Returns the last index in the provided array |
23,932 | public static function removeIndexes ( array $ inputArray , array $ indexes , $ reIndex = false ) { if ( $ reIndex ) { $ outputArray = array ( ) ; foreach ( $ inputArray as $ index => $ value ) { if ( ! in_array ( $ index , $ indexes ) ) { $ outputArray [ ] = $ value ; } } } else { foreach ( $ indexes as $ index ) { if ( isset ( $ inputArray [ $ index ] ) ) { unset ( $ inputArray [ $ index ] ) ; } } $ outputArray = $ inputArray ; } return $ outputArray ; } | Removes the specified indexes from the input array before returning it . |
23,933 | public static function mysqliWrapValues ( $ inputArray ) { foreach ( $ inputArray as & $ value ) { if ( $ value !== null ) { $ value = "'" . $ value . "'" ; } else { $ value = "NULL" ; } } return $ inputArray ; } | Wrap all of values in an array for insertion into a database . This is a specific variation of the wrap_elements method that will correctly convert null values into a NULL string without quotes so that nulls get inserted into the database correctly . |
23,934 | public static function fastDiff ( $ array1 , $ array2 ) { $ missingValues = array ( ) ; $ flippedArray2 = array_flip ( $ array2 ) ; foreach ( $ array1 as $ value ) { if ( ! isset ( $ flippedArray2 [ $ value ] ) ) { $ missingValues [ ] = $ value ; } } return $ missingValues ; } | Faster version of array_diff that relies on not needing to keep indexes of the missing values Compares values but returns the indexes |
23,935 | public static function fastIntersect ( $ array1 , $ array2 ) { $ sharedValues = array ( ) ; $ flippedArray2 = array_flip ( $ array2 ) ; foreach ( $ array1 as $ value ) { if ( isset ( $ flippedArray2 [ $ value ] ) ) { $ sharedValues [ ] = $ value ; } } return $ sharedValues ; } | Returns all the values that are in array1 and array2 . Relies on the values being integers or strings Will only return a value once even if it appears multiple times in the array . Does not maintain indexes . |
23,936 | public static function indexDiff ( array $ array1 , array $ array2 ) { $ indexes = array ( ) ; $ flippedArray2 = array_flip ( $ array2 ) ; foreach ( $ array1 as $ index => $ value ) { if ( ! isset ( $ flippedArray2 [ $ value ] ) ) { $ indexes [ ] = $ index ; } } return $ indexes ; } | Same as array_diff except that this returns the indexes of the values that are in array1 but not array2 . WARNING - this is NOT comparing the indexes themselves . |
23,937 | public static function stripEmptyElements ( $ inputArray ) { $ outputArray = array_filter ( $ inputArray ) ; if ( ! self :: isAssoc ( $ inputArray ) ) { $ outputArray = array_values ( $ outputArray ) ; } return $ outputArray ; } | Remove empty elements from the provided array . If the input array is not assosciative then it will be re - indexed . 0 1 2 3 etc |
23,938 | public static function array_combine_list ( array $ keys , array $ rows ) { $ output = array ( ) ; foreach ( $ rows as $ row ) { if ( count ( $ row ) !== count ( $ keys ) ) { $ msg = "array_combine_list: Number of values in one of the rows is " . "not equal to the number of keys." ; throw new \ Exception ( $ msg ) ; } $ output [ ] = array_combine ( $ keys , $ row ) ; } return $ output ; } | Wrapper around array_combine that works on a list of arrays for the values instead of being given a single array for the values . The result is a list of arrays who s keys are provided by the keys parameter and the values are the corresponding values in the rows arrays . |
23,939 | public function QueryOld ( $ fmt , $ parm = null ) { if ( is_object ( $ fmt ) && ( is_object ( $ parm ) || is_array ( $ parm ) ) ) { $ qarg = [ ] ; $ parm = ( object ) $ parm ; foreach ( $ fmt -> GetNamedArgs ( ) as $ arg ) { if ( property_exists ( $ parm , $ arg ) ) $ qarg [ ":{$arg}" ] = $ parm -> { $ arg } ; else if ( property_exists ( $ parm , ":{$arg}" ) ) $ qarg [ "{$arg}" ] = $ parm -> { ":{$arg}" } ; } $ parm = $ qarg ; } else { if ( ! is_array ( $ parm ) ) $ parm = array_slice ( func_get_args ( ) , 1 ) ; } $ qtime = microtime ( true ) ; if ( ! ( $ statement = $ this -> Driver -> prepare ( $ fmt ) ) ) throw new \ Exception ( 'SQL statement was unable to be prepared.' ) ; $ result = new Nether \ Database \ Result ( $ this -> Driver , $ statement , $ parm ) ; static :: $ QueryTime = microtime ( true ) - $ qtime ; static :: $ QueryCount ++ ; return $ result ; } | by better things . |
23,940 | public function filter ( EventInterface $ event ) { $ output = null ; foreach ( $ this -> filters as $ filter ) { $ result = $ filter -> filter ( $ event ) ; if ( $ result === false ) { return false ; } if ( $ result === true ) { $ output = true ; } } return $ output ; } | Filters events that pass all contained filters . |
23,941 | public function newMigration ( ) { $ fileName = ( isset ( $ this -> arguments [ 1 ] ) ) ? $ this -> arguments [ 1 ] : null ; $ this -> migrateManager -> newMigration ( $ fileName ) ; } | Generate new migration file |
23,942 | private function getVersion ( ) { $ select = new QueryBuilder ( ) ; $ versionRow = $ select -> query ( "SELECT value FROM {$this->table} WHERE param = 'migration_version'" ) -> fetchRow ( ) ; if ( ! isset ( $ versionRow [ 'value' ] ) ) die ( "Error: Please init the Crater Migration" ) ; return $ versionRow [ 'value' ] ; } | Get current version of database |
23,943 | private function getMigrationsFiles ( ) { $ migrationPath = $ this -> migrateManager -> storagePath ; $ files = array ( ) ; if ( $ handle = opendir ( $ migrationPath ) ) { while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( $ entry != "." && $ entry != ".." && is_file ( $ migrationPath . '/' . $ entry ) ) { $ segments = explode ( '_' , $ entry ) ; $ files [ $ segments [ 0 ] ] = $ entry ; } } closedir ( $ handle ) ; return $ files ; } die ( Utils :: colorize ( "Error to open migrations storage" , "FAILURE" ) ) ; } | Get all migration files |
23,944 | public function apply ( ) { $ files = $ this -> getMigrationsFiles ( ) ; $ lastMigration = null ; asort ( $ files ) ; foreach ( $ files as $ key => $ value ) { if ( $ key <= $ this -> getVersion ( ) ) continue ; include $ this -> migrateManager -> storagePath . '/' . $ value ; $ className = "Migration_$key" ; $ class = new $ className ( ) ; $ class -> up ( ) ; $ lastMigration = $ key ; unset ( $ class ) ; } if ( ! is_null ( $ lastMigration ) ) { $ this -> setVersion ( $ lastMigration ) ; echo Utils :: colorize ( "Done!" , "SUCCESS" ) ; } else { echo Utils :: colorize ( "The latest version is already installed." , "NOTE" ) ; } } | Install all the migration files |
23,945 | public function rollback ( $ version ) { $ files = $ this -> getMigrationsFiles ( ) ; $ lastMigration = null ; arsort ( $ files ) ; foreach ( $ files as $ key => $ value ) { if ( $ key < $ version ) continue ; include $ this -> migrateManager -> storagePath . '/' . $ value ; $ className = "Migration_$key" ; $ class = new $ className ( ) ; $ class -> down ( ) ; $ lastMigration = $ key ; unset ( $ class ) ; } if ( ! is_null ( $ lastMigration ) ) { $ this -> setVersion ( $ lastMigration - 1 ) ; echo Utils :: colorize ( "Done!" , "SUCCESS" ) ; } else { echo Utils :: colorize ( "The latest version is already installed." , "NOTE" ) ; } } | Return to a specific version |
23,946 | public function add ( EntityInterface $ group ) { if ( ! is_a ( $ group , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ group ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ group -> getName ( ) ) ) { throw new Exception ( 'Cannot add the group. The name of the group is already in use.' ) ; } $ uuid = $ this -> accessControlManager -> addAccessEntity ( $ group ) ; if ( $ uuid === false ) { throw new Exception ( 'Cannot add the group. Internal software error.' ) ; } return $ group ; } | Adds the given group to the access entities |
23,947 | public function update ( EntityInterface $ group ) { if ( ! is_a ( $ group , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ group ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ group -> getUuid ( ) ) ) { throw new Exception ( 'Cannot update the group. The group does not exist.' ) ; } return $ this -> accessControlManager -> updateAccessEntity ( $ group ) ; } | Updates the given Group |
23,948 | public function delete ( EntityInterface $ group ) { if ( ! is_a ( $ group , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ group ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ group -> getUuid ( ) ) ) { throw new Exception ( 'Cannot update the group. Group does not exist.' ) ; } return $ this -> accessControlManager -> deleteAccessEntity ( $ group ) ; } | Deletes the group with the given uuid |
23,949 | public function hasGroupForName ( $ name ) { if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ name ) ) { return true ; } return false ; } | Returns true if the given name of the group exists as access entity |
23,950 | public function getGroupForUuid ( $ uuid ) { if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ uuid ) ) { return false ; } $ accessEntity = $ this -> accessControlManager -> getAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ uuid ) ; if ( $ accessEntity === false ) { return false ; } return $ accessEntity ; } | Returns the group object for the given uuid |
23,951 | public function getGroupForName ( $ name ) { if ( ! $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ name ) ) { return false ; } $ accessEntity = $ this -> accessControlManager -> getAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ name ) ; if ( $ accessEntity === false ) { return false ; } return $ accessEntity ; } | Returns the Group object for the given name |
23,952 | public function setRole ( UserInterface $ user , array $ selectedRole ) { $ choices = $ this -> rolesManager -> getChoices ( ) ; if ( ! isset ( $ choices [ $ selectedRole [ 'roles' ] ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Impossible to set role %s' , $ selectedRole [ 'roles' ] ) ) ; } $ user -> setRoles ( [ $ choices [ $ selectedRole [ 'roles' ] ] ] ) ; $ this -> entityManager -> flush ( ) ; } | Sets a user role . |
23,953 | public function scopeActiveOn ( $ query , $ period ) { return $ query -> whereHas ( 'periods' , function ( $ query ) use ( $ period ) { $ query -> where ( 'academic_periods_id' , $ period ) ; } ) ; } | Only studies active for given period . |
23,954 | public function register ( ) { $ displayer = new BasicDisplayer ; $ handler = new Handler ( $ displayer ) ; $ this -> container -> bind ( 'error' , $ handler ) ; } | Register the error handler into the container . |
23,955 | final private function uniqueId ( $ function ) { if ( is_string ( $ function ) ) { return $ function ; } if ( is_object ( $ function ) ) { $ function = [ $ function , '' ] ; } elseif ( ! is_array ( $ function ) ) { $ function = [ $ function ] ; } $ function = array_values ( $ function ) ; if ( is_object ( $ function [ 0 ] ) ) { return \ spl_object_hash ( $ function [ 0 ] ) . $ function [ 1 ] ; } elseif ( count ( $ function ) > 1 || is_string ( $ function [ 0 ] ) ) { return $ function [ 0 ] . '::' . $ function [ 1 ] ; } return null ; } | Create Unique ID if function is not string |
23,956 | public function exists ( $ hookName , $ functionToCheck = false ) { $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; if ( ! $ hookName || ! isset ( $ this -> filters [ $ hookName ] ) ) { return false ; } $ has = empty ( $ this -> filters [ $ hookName ] ) ; if ( $ has ) { $ exists = false ; foreach ( $ this -> filters [ $ hookName ] as $ callbacks ) { if ( ! empty ( $ callbacks ) ) { $ exists = true ; break ; } } if ( ! $ exists ) { $ has = false ; } } if ( $ functionToCheck === false || $ has === false ) { return $ has ; } if ( ! $ id = $ this -> uniqueId ( $ functionToCheck ) ) { return false ; } foreach ( $ this -> filters [ $ hookName ] as $ priority ) { if ( isset ( $ priority [ $ id ] ) ) { return $ priority ; } } return false ; } | Check if hook name exists |
23,957 | public function call ( $ hookName , $ arg = '' ) : bool { $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; if ( ! $ hookName ) { return false ; } if ( ! isset ( $ this -> actions [ $ hookName ] ) ) { $ this -> actions [ $ hookName ] = 1 ; } else { $ this -> actions [ $ hookName ] ++ ; } if ( ! isset ( $ this -> filters [ $ hookName ] ) ) { return false ; } $ this -> current [ ] = $ hookName ; $ args = [ ] ; if ( is_array ( $ arg ) && 1 == count ( $ arg ) && isset ( $ arg [ 0 ] ) && is_object ( $ arg [ 0 ] ) ) { $ args [ ] = & $ arg [ 0 ] ; } else { $ args [ ] = $ arg ; } for ( $ a = 2 , $ num = func_num_args ( ) ; $ a < $ num ; $ a ++ ) { $ args [ ] = func_get_arg ( $ a ) ; } if ( ! isset ( $ this -> merged [ $ hookName ] ) ) { ksort ( $ this -> filters [ $ hookName ] ) ; $ this -> merged [ $ hookName ] = true ; } reset ( $ this -> filters [ $ hookName ] ) ; do { foreach ( current ( $ this -> filters [ $ hookName ] ) as $ collection ) { if ( ! is_null ( $ collection [ self :: KEY_FUNCTION ] ) ) { call_user_func_array ( $ collection [ self :: KEY_FUNCTION ] , array_slice ( $ args , 0 , ( int ) $ collection [ self :: KEY_ACCEPTED_ARGS ] ) ) ; } } } while ( next ( $ this -> filters [ $ hookName ] ) !== false ) ; array_pop ( $ this -> current ) ; return true ; } | Call hook from existing declared hook record |
23,958 | public function replace ( $ hookName , $ functionToReplace , $ callable , $ priority = 10 , $ acceptedArguments = 1 , $ create = true ) : bool { $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; if ( ! $ hookName ) { throw new InvalidArgumentException ( "Invalid Hook Name Specified" , E_USER_ERROR ) ; } if ( ! is_callable ( $ callable ) ) { throw new RuntimeException ( "Invalid Hook Callable Specified" , E_USER_ERROR ) ; } if ( ( $ has = $ this -> exists ( $ hookName , $ functionToReplace ) ) || $ create ) { $ has && $ this -> remove ( $ hookName , $ functionToReplace ) ; return $ this -> add ( $ hookName , $ callable , $ priority , $ acceptedArguments ) ; } return false ; } | Replace Hooks Function this will replace all existing hooks |
23,959 | public function count ( $ hookName ) : int { $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; if ( ! $ hookName || ! isset ( $ this -> filters [ $ hookName ] ) ) { return 0 ; } return count ( $ this -> filters [ $ hookName ] ) ; } | Count all existences Hook |
23,960 | public function hasDoing ( $ hookName = null ) : bool { if ( null === $ hookName ) { return ! empty ( $ this -> current ) ; } $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; return $ hookName && isset ( $ this -> current [ $ hookName ] ) ; } | Check if hook has doing |
23,961 | public function hasCalled ( $ hookName ) : int { $ hookName = $ this -> sanitizeKeyName ( $ hookName ) ; if ( ! $ hookName || ! isset ( $ this -> actions [ $ hookName ] ) ) { return 0 ; } return $ this -> actions [ $ hookName ] ; } | Check if action hook as execute |
23,962 | public function actionProjectcreate ( ) { $ model = new Project ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'projectview' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'projectcreate' , [ 'model' => $ model , ] ) ; } } | Creates a new Projects model . If creation is successful the browser will be redirected to the view page . |
23,963 | public function actionProjectupdate ( ) { $ id = \ Yii :: $ app -> request -> get ( 'id' ) ; if ( ! isset ( $ id ) ) { return new NotFoundHttpException ( 'The requested project does not exist.' ) ; } $ model = $ this -> findProjectmodel ( $ id ) ; if ( ! $ model instanceof Project ) { return false ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'projectview' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'projectupdate' , [ 'model' => $ model , ] ) ; } } | Updates an existing Projects model . If update is successful the browser will be redirected to the view page . |
23,964 | public function actionTaskcreate ( $ projectid = null , $ parenttask = null ) { if ( ! isset ( $ projectid ) ) { $ projectid = $ this -> getRequestParam ( 'projectid' ) ; } $ model = new Task ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( Url :: toRoute ( [ 'taskview' , 'projectid' => $ projectid , 'id' => $ model -> id , ] ) ) ; } else { $ model -> projectID = $ projectid ; $ model -> parenttask = isset ( $ parenttask ) ? $ parenttask : 0 ; return $ this -> render ( 'taskcreate' , [ 'model' => $ model , ] ) ; } } | Creates a new Tasks model . If creation is successful the browser will be redirected to the view page . |
23,965 | public function actionTaskview ( ) { $ id = $ this -> getRequestParam ( 'id' ) ; $ model = Project :: getTaskModel ( $ id ) ; if ( ! isset ( $ model ) ) { throw new NotFoundHttpException ( 'The Task "' . $ id . '" not found.' ) ; } return $ this -> render ( 'taskview' , [ 'model' => $ model , ] ) ; } | Displays a single Task model . |
23,966 | public function actionTaskUpdate ( $ id ) { $ model = Project :: getTaskModel ( $ id ) ; if ( ! isset ( $ model ) ) { throw new NotFoundHttpException ( 'The Task "' . $ id . '" not found.' ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'taskview' , 'id' => $ model -> id , ] ) ; } else { return $ this -> render ( 'taskupdate' , [ 'model' => $ model , ] ) ; } } | Updates an existing Task model . If update is successful the browser will be redirected to the view page . |
23,967 | public function actionTaskdelete ( $ id ) { $ task = Project :: getTaskModel ( $ id ) ; $ projectid = $ task -> projectID ; $ task -> delete ( ) ; return $ this -> redirect ( [ 'tasklist' , 'projectid' => $ projectid ] ) ; } | Deletes an existing Tasks model . If deletion is successful the browser will be redirected to the index page . |
23,968 | public function actionTasknotecreate ( $ projectid , $ taskid ) { $ model = new TaskNote ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( Url :: toRoute ( [ 'tasknoteview' , 'projectid' => $ projectid , 'taskid' => $ taskid , 'id' => $ model -> id , ] ) ) ; } else { $ model -> taskID = $ taskid ; return $ this -> render ( 'tasknotecreate' , [ 'model' => $ model , ] ) ; } } | Creates a new TaskNote model . If creation is successful the browser will be redirected to the view page . |
23,969 | public function actionTasknoteview ( $ id ) { $ model = Task :: getTaskNoteModel ( $ id ) ; if ( ! isset ( $ model ) ) { throw new NotFoundHttpException ( 'The Task "' . $ id . '" not found.' ) ; } return $ this -> render ( 'tasknoteview' , [ 'model' => Task :: getTaskNoteModel ( $ id ) , 'task' => $ model , ] ) ; } | Displays a single TaskComment model . |
23,970 | public function actionTasknoteupdate ( $ id ) { $ model = Task :: getTaskNoteModel ( $ id ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'tasknoteview' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'tasknoteupdate' , [ 'model' => $ model , ] ) ; } } | Updates an existing TaskComment model . If update is successful the browser will be redirected to the view page . |
23,971 | public function actionTasknotedelete ( $ taskid , $ id ) { Task :: getTaskNoteModel ( $ id ) -> delete ( ) ; return $ this -> redirect ( [ 'tasknotelist' , 'taskid' => $ taskid ] ) ; } | Deletes an existing TaskComment model . If deletion is successful the browser will be redirected to the index page . |
23,972 | public function getPropertyValue ( $ className , $ propertyName , $ concreteClass = NULL , $ options = [ ] ) { $ callConstructor = ( isset ( $ options [ 'callConstructor' ] ) ) ? ( bool ) $ options [ 'callConstructor' ] : FALSE ; $ reflector = new ReflectionClass ( $ className ) ; if ( $ concreteClass === NULL && $ callConstructor === FALSE ) { $ properties = $ reflector -> getDefaultProperties ( ) ; return ( isset ( $ properties [ $ propertyName ] ) ) ? $ properties [ $ propertyName ] : NULL ; } if ( ! $ reflector -> hasProperty ( $ propertyName ) ) { return NULL ; } $ propertyReflector = $ reflector -> getProperty ( $ propertyName ) ; $ propertyReflector -> setAccessible ( TRUE ) ; if ( $ concreteClass !== NULL ) { return $ propertyReflector -> getValue ( $ concreteClass ) ; } if ( $ callConstructor === TRUE ) { $ constructorParams = ( isset ( $ options [ 'constructorParams' ] ) ) ? ( array ) $ options [ 'constructorParams' ] : [ ] ; return $ propertyReflector -> getValue ( $ reflector -> newInstanceArgs ( $ constructorParams ) ) ; } return NULL ; } | Read a property value from a given class or concrete object . This function can handle automatic creation of new instances of the given class . |
23,973 | public function getStaticPropertyValue ( $ object , $ propertyName ) { $ className = $ object ; if ( is_object ( $ className ) ) { $ className = get_class ( $ object ) ; } $ reflector = new ReflectionClass ( $ className ) ; $ properties = $ reflector -> getStaticProperties ( ) ; return ( isset ( $ properties [ $ propertyName ] ) ) ? $ properties [ $ propertyName ] : NULL ; } | Returns a static property from the given class . You can pass this function an object or a FQCN as string . |
23,974 | public function setProperty ( $ object , $ property , $ value ) { $ objectReflector = new ReflectionObject ( $ object ) ; if ( ! $ objectReflector -> hasProperty ( $ property ) ) { throw new Exception ( 'Property cannot be set! This property not exist inside the given object!' ) ; } $ propertyReflector = $ objectReflector -> getProperty ( $ property ) ; $ propertyReflector -> setAccessible ( TRUE ) ; $ propertyReflector -> setValue ( $ object , $ value ) ; return TRUE ; } | Set a property value on the given object . If the property is not found in the given object an Exception will be thrown . |
23,975 | public function singleFunctionaryAction ( ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ this -> settings [ self :: SETTINGS_ASSOCIATION_ID ] , self :: VIEW_VARIABLE_FUNCTIONARY_ID => $ this -> settings [ self :: SETTINGS_FUNCTIONARY_ID ] ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; } | single functionary action . |
23,976 | public function get ( $ route , $ toController , $ alias = null ) { $ route = [ 'route' => $ route , 'toController' => $ toController , 'alias' => $ alias , 'isDynamic' => preg_match ( "/{([^{}?&]+)}/" , $ route ) , ] ; if ( ! is_null ( $ alias ) ) $ this -> routes [ 'GET' ] [ $ alias ] = $ route ; else $ this -> routes [ 'GET' ] [ ] = $ route ; return new RouteMiddleware ( $ this -> appDispatcher , $ route [ 'route' ] ) ; } | GET route method |
23,977 | public function post ( $ route , $ toController , $ alias = null ) { $ route = [ 'route' => $ route , 'toController' => $ toController , 'alias' => $ alias , 'isDynamic' => preg_match ( "/{([^{}?&]+)}/" , $ route ) , ] ; $ this -> routes [ 'POST' ] [ ] = $ route ; } | POST route method |
23,978 | public function getUserEmail ( GenericEvent $ event ) { $ user = $ event -> getSubject ( ) ; if ( ! $ user instanceof UserInterface ) { throw new \ InvalidArgumentException ( 'MailerSubscriber event is expected to contain an instance of User' ) ; } $ this -> mailAddress = $ user -> getEmail ( ) ; $ this -> username = $ user -> getUsername ( ) ; } | Gets the username and mail address of the user to be removed . |
23,979 | public static function request ( $ endpoint ) { return ( new Request ( NULL , NULL , NULL ) ) -> host ( $ endpoint ) -> get ( ) -> path ( '' ) -> accept ( 'application/json' ) ; } | Construct an new Request by providing an endpoint . |
23,980 | public function render ( ) { if ( $ this -> isSentinel ( ) ) { return [ ] ; } $ result = $ this -> tail -> render ( ) ; $ result [ $ this -> key ] = $ this -> value ; return $ result ; } | Traverse the Request calculating the final value for each request parameter . |
23,981 | public function doReplace ( $ data ) { $ data = preg_replace_callback ( '/#([^\s\r#]+)#/' , function ( $ matches ) { if ( defined ( $ matches [ 1 ] ) ) { return constant ( $ matches [ 1 ] ) ; } return $ matches [ 0 ] ; } , $ data ) ; if ( isset ( $ this -> values ) ) { $ values = $ this -> values ; $ data = preg_replace_callback ( '/%([^\s\r%]+)%/' , function ( $ matches ) use ( $ values ) { if ( isset ( $ values [ $ matches [ 1 ] ] ) ) { return $ values [ $ matches [ 1 ] ] ; } return $ matches [ 0 ] ; } , $ data ) ; } return $ data ; } | Performs the replacement on the raw data . |
23,982 | public static function create ( string $ projectRoot , $ default = self :: ENV_PRODUCTION , array $ allowed = [ ] ) : EnvironmentInterface { if ( ! $ allowed ) { $ allowed = [ self :: ENV_PRODUCTION , self :: ENV_STAGING , self :: ENV_TESTING , self :: ENV_DEVELOPMENT , ] ; } $ projectRoot = realpath ( $ projectRoot ) ; $ filename = $ projectRoot . '/.environment' ; if ( ! $ projectRoot || ! file_exists ( $ filename ) ) { return new static ( $ default , $ projectRoot ) ; } $ name = file_get_contents ( $ filename ) ; if ( ! in_array ( $ name , $ allowed ) ) { throw new UnknownEnvironmentException ( 'Unknown environment "' . $ name . '". Either add to the allowed list or provide one of: ' . join ( ', ' , $ allowed ) ) ; } return new static ( $ name , $ projectRoot ) ; } | Create the environment using the default params and by searching the . environment file . |
23,983 | public static function get ( string $ projectRoot , $ default = self :: ENV_PRODUCTION , array $ allowed = [ ] ) : string { return ( static :: create ( $ projectRoot , $ default , $ allowed ) ) -> name ( ) ; } | Get the environment |
23,984 | protected function hashPassword ( $ pw , $ salt = false ) { if ( ! $ salt ) { $ salt = bin2hex ( openssl_random_pseudo_bytes ( self :: HASH_SALT_LENGTH ) ) ; } $ hash = $ this -> generatePbkdf2 ( self :: HASH_ALGORITHM , $ pw , $ salt , self :: HASH_COST , 32 ) ; $ r = new \ stdClass ( ) ; $ r -> output = $ salt . $ hash ; $ r -> salt = $ salt ; $ r -> hash = $ hash ; return $ r ; } | Hash password . |
23,985 | protected function generatePbkdf2 ( $ algorithm , $ password , $ salt , $ count , $ key_length , $ raw_output = false ) { $ algorithm = strtolower ( $ algorithm ) ; if ( ! in_array ( $ algorithm , hash_algos ( ) , true ) ) trigger_error ( 'PBKDF2 ERROR: Invalid hash algorithm.' , E_USER_ERROR ) ; if ( $ count <= 0 || $ key_length <= 0 ) trigger_error ( 'PBKDF2 ERROR: Invalid parameters.' , E_USER_ERROR ) ; if ( function_exists ( "hash_pbkdf2" ) ) { if ( ! $ raw_output ) { $ key_length = $ key_length * 2 ; } return hash_pbkdf2 ( $ algorithm , $ password , $ salt , $ count , $ key_length , $ raw_output ) ; } $ hash_length = strlen ( hash ( $ algorithm , "" , true ) ) ; $ block_count = ceil ( $ key_length / $ hash_length ) ; $ output = "" ; for ( $ i = 1 ; $ i <= $ block_count ; $ i ++ ) { $ last = $ salt . pack ( "N" , $ i ) ; $ last = $ xorsum = hash_hmac ( $ algorithm , $ last , $ password , true ) ; for ( $ j = 1 ; $ j < $ count ; $ j ++ ) { $ xorsum ^= ( $ last = hash_hmac ( $ algorithm , $ last , $ password , true ) ) ; } $ output .= $ xorsum ; } if ( $ raw_output ) return substr ( $ output , 0 , $ key_length ) ; else return bin2hex ( substr ( $ output , 0 , $ key_length ) ) ; } | Checks password correctness based on PBKDF2 |
23,986 | public static function make ( $ resource = '' , $ mode = 'w+b' ) { switch ( gettype ( $ resource ) ) { case 'resource' : return ( new static ( false ) ) -> setResource ( $ resource , $ mode ) ; case 'string' : $ stream = fopen ( 'php://temp' , $ mode ) ; if ( $ resource !== '' ) { fwrite ( $ stream , $ resource ) ; fseek ( $ stream , 0 ) ; } return ( new static ( false ) ) -> setResource ( $ stream , $ mode ) ; case 'object' : if ( $ resource instanceof self ) { return $ resource ; } elseif ( method_exists ( $ resource , '__toString' ) ) { $ resource = ( string ) $ resource ; return static :: make ( $ resource , $ mode ) ; } default : throw new InvalidArgumentException ( sprintf ( 'Invalid resource "%s" provided.' , is_object ( $ resource ) ? get_class ( $ resource ) : gettype ( $ resource ) ) ) ; } } | Makes new stream instance of current stream class . |
23,987 | public static function fopen ( $ resource = 'php://temp' , $ mode = 'w+b' ) { static :: register ( ) ; $ context = stream_context_create ( [ static :: PROTOCOL => [ 'resource' => $ resource ] ] ) ; set_error_handler ( function ( ) { throw new Exception ( 'Failed to open stream.' ) ; } ) ; try { $ fp = fopen ( static :: PROTOCOL . '://' , $ mode , false , $ context ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; throw new InvalidArgumentException ( sprintf ( 'Failed to create resource from "%s".' , is_resource ( $ resource ) ? get_resource_type ( $ resource ) : gettype ( $ resource ) ) , null , $ ex ) ; } restore_error_handler ( ) ; return $ fp ; } | Makes new resource from instance of current stream class . |
23,988 | public static function register ( $ flags = null ) { $ protocol = static :: PROTOCOL ; if ( static :: isRegistered ( ) ) { return true ; } if ( null === $ flags ) { $ flags = STREAM_IS_URL ; } return stream_wrapper_register ( $ protocol , static :: class , $ flags ) ; } | Register the current class as wrapper for class - specified protocol . |
23,989 | public function open ( $ path = null , $ mode = null , $ options = null , & $ openedPath = null ) { $ context = [ ] ; if ( is_resource ( $ this -> context ) ) { $ context = stream_context_get_options ( $ this -> context ) ; } $ resource = 'php://temp' ; if ( isset ( $ context [ static :: PROTOCOL ] [ 'resource' ] ) ) { $ resource = $ context [ static :: PROTOCOL ] [ 'resource' ] ; } if ( is_resource ( $ this -> resource ) ) { fclose ( $ this -> resource ) ; } try { $ this -> setResource ( $ resource , $ mode ) ; } catch ( InvalidArgumentException $ ex ) { return false ; } return true ; } | Opens an stream . Uses by PHP to open an stream for specified protocol . |
23,990 | public function copy ( $ source ) { if ( ! $ this -> resource ) { throw new RuntimeException ( 'No resource available; cannot copy.' ) ; } $ resource = null ; if ( $ source instanceof self ) { $ resource = $ source -> getResource ( ) ; } elseif ( is_resource ( $ source ) ) { $ resource = $ source ; } elseif ( is_string ( $ source ) ) { set_error_handler ( function ( ) { throw new Exception ( 'Failed to open stream.' ) ; } ) ; try { $ resource = fopen ( $ source , 'rb' ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; throw new InvalidArgumentException ( sprintf ( 'Invalid source path "%s" specified.' , $ source ) ) ; } restore_error_handler ( ) ; } else { throw new InvalidArgumentException ( sprintf ( 'Invalid source "%s" provided.' , is_object ( $ source ) ? get_class ( $ source ) : gettype ( $ source ) ) ) ; } $ metadata = stream_get_meta_data ( $ resource ) ; $ mode = $ metadata [ 'mode' ] ; if ( ! ( strstr ( $ mode , 'r' ) || strstr ( $ mode , '+' ) ) ) { throw new InvalidArgumentException ( 'The received source is not readable.' ) ; } $ seekable = $ metadata [ 'seekable' ] ; if ( $ seekable ) { rewind ( $ resource ) ; } stream_copy_to_stream ( $ resource , $ this -> resource ) ; rewind ( $ this -> resource ) ; if ( is_string ( $ source ) ) { fclose ( $ resource ) ; } } | Copies the contents of source . |
23,991 | public function setResource ( $ resource = 'php://temp' , $ mode = 'w+b' ) { if ( is_resource ( $ this -> resource ) ) { throw new DomainException ( 'The resource is already set.' ) ; } if ( is_resource ( $ resource ) ) { $ this -> resource = $ resource ; } elseif ( is_string ( $ resource ) ) { set_error_handler ( function ( ) { throw new Exception ( 'Failed to open stream.' ) ; } , E_WARNING ) ; try { $ this -> resource = fopen ( $ resource , $ mode ) ; } catch ( Exception $ ex ) { restore_error_handler ( ) ; throw new InvalidArgumentException ( sprintf ( 'Invalid path "%s" specified.' , $ resource ) ) ; } restore_error_handler ( ) ; } else { throw new InvalidArgumentException ( sprintf ( 'Invalid resource "%s" provided.' , is_object ( $ resource ) ? get_class ( $ resource ) : gettype ( $ resource ) ) ) ; } return $ this ; } | Sets the resource to wrapper . |
23,992 | public function stat ( ) { $ stat = null ; if ( is_resource ( $ this -> resource ) ) { $ stat = fstat ( $ this -> resource ) ; } return $ stat ; } | Retrieve information about a resource . |
23,993 | public function apply ( Builder $ query , string $ tableAlias = null , string $ customName = null ) { if ( $ this -> hasBeenApplied ( ) ) { return ; } $ name = $ this -> buildDbName ( $ tableAlias , $ customName ) ; $ query -> orderBy ( $ name , $ this -> direction ) ; $ this -> setApplied ( true ) ; } | Applies orderBy on Eloquent query builder |
23,994 | public function bindValues ( ) { $ ret = array ( ) ; if ( $ this -> data ) $ ret = array_values ( $ this -> data ) ; if ( $ this -> getWhereValues ( ) ) $ ret = array_merge ( $ ret , $ this -> getWhereValues ( ) ) ; return \ ChickenTools \ Arry :: flatten ( $ ret ) ; } | Returns the bind values . |
23,995 | public static function reverseOrder ( $ order ) { if ( ! trim ( $ order ) ) return $ order ; $ parts = explode ( ',' , $ order ) ; for ( $ i = 0 , $ n = count ( $ parts ) ; $ i < $ n ; ++ $ i ) { $ v = strtolower ( $ parts [ $ i ] ) ; if ( strpos ( $ v , ' asc' ) !== false ) $ parts [ $ i ] = preg_replace ( '/asc/i' , 'DESC' , $ parts [ $ i ] ) ; elseif ( strpos ( $ v , ' desc' ) !== false ) $ parts [ $ i ] = preg_replace ( '/desc/i' , 'ASC' , $ parts [ $ i ] ) ; else $ parts [ $ i ] .= ' DESC' ; } return join ( ',' , $ parts ) ; } | Reverses an order clause . |
23,996 | public static function createHashFromUnderscoredString ( $ name , & $ values = array ( ) , & $ map = null ) { throw new \ Exception ( "This should be refactored!!!" , 1 ) ; $ parts = preg_split ( '/(_and_|_or_)/i' , $ name ) ; $ hash = array ( ) ; for ( $ i = 0 , $ n = count ( $ parts ) ; $ i < $ n ; ++ $ i ) { $ name = $ map && isset ( $ map [ $ parts [ $ i ] ] ) ? $ map [ $ parts [ $ i ] ] : $ parts [ $ i ] ; $ hash [ $ name ] = $ values [ $ i ] ; } return $ hash ; } | Like create_conditions_from_underscored_string but returns a hash of name = > value array instead . |
23,997 | private function prependTableNameToFields ( $ hash = array ( ) ) { $ new = array ( ) ; $ table = $ this -> connection -> quoteName ( $ this -> table ) ; foreach ( $ hash as $ key => $ value ) { $ k = $ this -> connection -> quoteName ( $ key ) ; $ new [ $ table . '.' . $ k ] = $ value ; } return $ new ; } | prepends table name to hash of field names to get around ambiguous fields when SQL builder has joins |
23,998 | public function setQuery ( $ value ) { if ( is_array ( $ value ) ) { $ this -> setParam ( 'query' , CPS_QueryArray ( $ value ) ) ; } else { $ this -> setParam ( 'query' , $ value ) ; } } | Sets the search query . |
23,999 | public function setList ( $ array ) { $ listString = '' ; foreach ( $ array as $ key => $ value ) { $ listString .= CPS_Term ( $ value , $ key ) ; } $ this -> setParam ( 'list' , $ listString ) ; } | Defines which tags of the search results should be listed in the response |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.