idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
59,900
|
public static function parse ( $ yaml ) { return SymfonyYaml :: parse ( $ yaml , $ exceptionOnInvalidType = true , $ objectSupport = true , $ objectForMap = false ) ; }
|
Parse YAML into an object or array .
|
59,901
|
public static function parseFile ( $ filename ) { $ file = new SplFileInfo ( $ filename ) ; if ( ! $ file -> isFile ( ) ) { throw new RuntimeException ( 'Invalid filename supplied for `RadHam\Yaml::parseFile()`.' ) ; } $ contents = file_get_contents ( $ file -> getPathname ( ) ) ; return self :: parse ( $ contents ) ; }
|
Parse a YAML file into an object or array .
|
59,902
|
public function build ( $ command ) { return sprintf ( '%s %s/%s %s --env=%s --no-debug' , PhpUtils :: getPhp ( ) , $ this -> consoleDir , 'console' , $ command , $ this -> environment ) ; }
|
Build command .
|
59,903
|
protected function taskPhpMd ( $ dir = null , $ format = 'xml' , $ extensions = [ ] ) { return $ this -> task ( PhpMd :: class , $ dir , $ format , $ extensions ) ; }
|
Creates a PHPMD task .
|
59,904
|
public function validate ( IUser $ user ) : bool { if ( null === $ password = make ( IPasswordRepository :: class ) -> getByUser ( $ user ) ) { return false ; } return make ( IPasswordHandler :: class ) -> verify ( $ this -> password , $ password -> value ( ) ) ; }
|
Validate user s credentials
|
59,905
|
private function getFilters ( $ type ) { $ filters = [ ] ; if ( 'contao' === $ type ) { $ filters [ ] = function ( $ package ) { return in_array ( $ package -> getType ( ) , [ 'contao-module' , 'contao-bundle' , 'legacy-contao-module' ] ) ; } ; } return $ filters ; }
|
Get the array of filter closures .
|
59,906
|
private function getRepositorySearch ( $ keywords , $ type , Composer $ composer , $ threshold ) { $ repositoryManager = $ composer -> getRepositoryManager ( ) ; $ localRepository = $ repositoryManager -> getLocalRepository ( ) ; $ repositories = new CompositeRepository ( [ $ localRepository ] ) ; if ( 'installed' !== $ type ) { $ repositories -> addRepository ( new CompositeRepository ( $ repositoryManager -> getRepositories ( ) ) ) ; } $ repositorySearch = new RepositorySearch ( $ repositories ) ; $ repositorySearch -> setSatisfactionThreshold ( $ threshold ) ; if ( false !== strpos ( $ keywords , '/' ) ) { $ repositorySearch -> disableSearchType ( RepositoryInterface :: SEARCH_FULLTEXT ) ; } else { $ repositorySearch -> disableSearchType ( RepositoryInterface :: SEARCH_NAME ) ; } $ searcher = new CompositeSearch ( [ $ repositorySearch ] ) ; $ searcher -> setSatisfactionThreshold ( $ threshold ) ; return $ searcher ; }
|
Create a repository search instance .
|
59,907
|
public static function buildFromSplFileInfo ( \ SplFileInfo $ fileInfo ) { $ uniqueId = $ fileInfo -> getBasename ( ) ; $ file = $ fileInfo -> openFile ( ) ; $ query = '' ; while ( ! $ file -> eof ( ) ) { $ query .= $ file -> fgets ( ) ; } return new UnitOfWork ( new Uid ( $ uniqueId ) , new Workload ( $ query ) , new \ DateTime ( ) ) ; }
|
Builds a UnitOfWork instance from the given \ SplFileInfo
|
59,908
|
public static function setmycookies ( $ status , $ cookies , $ cookiedomain , $ cookiepath , $ expires = 0 , $ secure = 0 , $ httponly = 1 ) { $ options = array ( ) ; $ options [ 'cookiedomain' ] = $ cookiedomain ; $ options [ 'cookiepath' ] = $ cookiepath ; $ options [ 'expires' ] = $ expires ; $ options [ 'secure' ] = $ secure ; $ options [ 'httponly' ] = $ httponly ; $ curl = new Curl ( $ options ) ; $ curl -> cookies = $ cookies ; $ curl -> status = $ status ; return $ curl -> setCookies ( $ cookiedomain , $ cookiepath , $ expires , $ secure , $ httponly ) ; }
|
sets my cookies
|
59,909
|
public static function ipCidrsCheck ( $ p_ip , $ p_cidrs ) { foreach ( $ p_cidrs as $ name => $ range ) { if ( self :: ipCidrCheck ( $ p_ip , $ range ) ) { return true ; } } return false ; }
|
Check Ip in a list of cidrs
|
59,910
|
public static function ipCidrCheck ( $ p_ip , $ p_cidr ) { if ( strpos ( $ p_cidr , '/' ) !== false ) { list ( $ net , $ mask ) = split ( "/" , $ p_cidr ) ; $ ip_net = ip2long ( $ net ) ; $ ip_mask = ~ ( ( 1 << ( 32 - $ mask ) ) - 1 ) ; $ ip_ip = ip2long ( $ p_ip ) ; $ ip_ip_net = $ ip_ip & $ ip_mask ; return ( $ ip_ip_net == $ ip_net ) ; } else { return ( ip2long ( $ p_ip ) == ip2long ( $ p_cidr ) ) ; } }
|
Check ip in a cidr
|
59,911
|
public function check ( Subject $ subject ) : ResultCollection { $ resultCollection = new ResultCollection ( ) ; foreach ( $ this -> collection as $ rule ) { $ resultCollection -> merge ( $ rule -> check ( $ subject ) ) ; } return $ resultCollection ; }
|
Check all rules in collection
|
59,912
|
private function AddCheckedField ( ) { $ field = new Fields \ Checkbox ( 'Checked' , '1' , $ this -> checkbox -> GetChecked ( ) ) ; $ this -> AddField ( $ field ) ; }
|
Adds the checked flag field
|
59,913
|
private function AddCheckedValueField ( ) { $ name = 'CheckedValue' ; $ value = $ this -> checkbox -> GetCheckedValue ( ) ; $ field = Fields \ Input :: Text ( $ name , $ value ? $ value : '1' ) ; $ this -> AddField ( $ field ) ; $ this -> SetRequired ( $ name ) ; }
|
Adds the checked value field
|
59,914
|
public function t ( $ str , $ filename = "template" ) { $ this -> forceUpdateLocale ( ) ; $ key = "{$filename}.{$str}" ; $ transl = Lang :: get ( $ key ) ; if ( $ transl != $ key ) { return $ transl ; } return $ this -> strict_mode ? '' : $ str ; }
|
Translate a string to the current language
|
59,915
|
public function set ( $ lang ) { if ( ! array_key_exists ( $ lang , $ this -> getList ( ) ) ) { throw new LanguageNotPresentException ; } $ this -> locator -> set ( $ lang ) ; return $ lang ; }
|
Sets the current client language
|
59,916
|
public function verifyAndDecodeToken ( $ token , $ checkRevoked = true ) { $ payload = JWT :: decode ( $ token , $ this -> getPublicKey ( ) , [ self :: CRYPTO_ALG ] ) ; if ( $ checkRevoked && $ this -> checkRevokedToken ( $ token , $ payload ) ) throw new TokenRevokedException ( 'Token is revoked.' ) ; return $ payload ; }
|
Verify and decode a JWT token
|
59,917
|
public function getUserInfo ( $ accessToken = null , $ cacheDuration = - 1 ) { try { if ( $ accessToken == null && ! empty ( $ at = $ this -> getAccessToken ( ) ) ) $ accessToken = $ at -> token ; } catch ( Exception $ e ) { Yii :: error ( $ e -> getMessage ( ) ) ; } $ userInfo = null ; if ( ! empty ( $ accessToken ) ) { if ( $ cacheDuration > 0 && Yii :: $ app -> cache ) { $ cacheKey = "UserInfo_" . sha1 ( $ accessToken ) ; $ userInfo = Yii :: $ app -> cache -> get ( $ cacheKey ) ; } if ( empty ( $ userInfo ) ) { $ header = [ 'Authorization' => 'Bearer ' . $ accessToken ] ; try { $ userInfo = $ this -> api ( $ this -> userInfoUrl , 'GET' , [ ] , $ header ) ; } catch ( Exception $ e ) { Yii :: info ( "Error when connect to Oauth server, We are trying to get UserInfo\n with access-token: '$accessToken' \n and message: " . $ e -> getMessage ( ) ) ; if ( $ e instanceof InvalidResponseException ) { Yii :: $ app -> user -> logout ( ) ; $ message = Yii :: t ( 'app' , "Token expired. Please login again!" ) ; } else { $ message = $ e -> getMessage ( ) ; } throw new UnauthorizedHttpException ( $ message , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } if ( $ cacheDuration > 0 && Yii :: $ app -> cache ) { Yii :: $ app -> cache -> set ( $ cacheKey , $ userInfo , $ cacheDuration ) ; } } } return $ userInfo ; }
|
Get user information from OAuth2 provider
|
59,918
|
public function checkRevokedToken ( $ token , $ payload ) { if ( ! empty ( $ payload ) && Yii :: $ app -> cache ) { return Yii :: $ app -> cache -> get ( $ this -> getRevokedTokenCacheKey ( $ token ) ) !== false ; } return false ; }
|
Check if token is revoked
|
59,919
|
public function saveRevokedToken ( $ token , $ payload ) { if ( ! empty ( $ payload ) && property_exists ( $ payload , 'exp' ) && Yii :: $ app -> cache ) { $ duration = ( int ) $ payload -> exp + JWT :: $ leeway - time ( ) ; if ( $ duration > 0 ) Yii :: $ app -> cache -> set ( $ this -> getRevokedTokenCacheKey ( $ token ) , true , $ duration ) ; } }
|
Save revoked token to cache
|
59,920
|
public function logout ( $ globalLogout = true ) { $ this -> isLoggingOut = true ; $ identity = Yii :: $ app -> user -> identity ; if ( $ globalLogout ) Yii :: $ app -> user -> logout ( ) ; try { if ( $ identity != null && ! empty ( $ identity -> sid ) ) { $ token = $ this -> getAccessToken ( ) -> token ; $ headers = [ 'Authorization' => 'Bearer ' . $ token ] ; $ params = [ 'sid' => $ identity -> sid ] ; $ this -> api ( $ this -> logoutUrl , 'GET' , $ params , $ headers ) ; } } catch ( Exception $ e ) { Yii :: $ app -> response -> redirect ( Yii :: $ app -> getHomeUrl ( ) ) ; } return true ; }
|
Logout the current user by identity
|
59,921
|
public static function getInstance ( ) { if ( ! isset ( self :: $ _instance ) ) { $ user = Yii :: $ app -> user ; if ( isset ( $ user -> authClientConfig ) && isset ( $ user -> authClientConfig [ 'collection' ] ) && isset ( $ user -> authClientConfig [ 'id' ] ) ) { $ collection = Yii :: $ app -> get ( $ user -> authClientConfig [ 'collection' ] ) ; if ( $ collection -> hasClient ( $ user -> authClientConfig [ 'id' ] ) ) { self :: $ _instance = $ collection -> getClient ( $ user -> authClientConfig [ 'id' ] ) ; } } } return self :: $ _instance ; }
|
Get singleton instance using Yii s auth client configuration
|
59,922
|
private function configureProcessProperties ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( 'command' ) -> setAllowedTypes ( 'command' , 'string' ) ; $ resolver -> setDefined ( 'process_name' ) -> setAllowedTypes ( 'process_name' , 'string' ) ; $ resolver -> setDefined ( 'numprocs' ) ; $ this -> configureIntegerProperty ( 'numprocs' , $ resolver ) ; $ resolver -> setDefined ( 'numprocs_start' ) ; $ this -> configureIntegerProperty ( 'numprocs_start' , $ resolver ) ; $ resolver -> setDefined ( 'priority' ) ; $ this -> configureIntegerProperty ( 'priority' , $ resolver ) ; }
|
Configures process related properties
|
59,923
|
private function configureStartControlProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'autostart' ) ; $ this -> configureBooleanProperty ( 'autostart' , $ resolver ) ; $ resolver -> setDefined ( 'autorestart' ) -> setAllowedTypes ( 'autorestart' , [ 'bool' , 'string' ] ) -> setAllowedValues ( 'autorestart' , [ true , false , 'true' , 'false' , 'unexpected' ] ) -> setNormalizer ( 'autorestart' , function ( Options $ options , $ value ) { return ( is_bool ( $ value ) or $ value === 'unexpected' ) ? $ value : ( $ value === 'true' ? true : false ) ; } ) ; $ resolver -> setDefined ( 'startsecs' ) ; $ this -> configureIntegerProperty ( 'startsecs' , $ resolver ) ; $ resolver -> setDefined ( 'startretries' ) ; $ this -> configureIntegerProperty ( 'startretries' , $ resolver ) ; }
|
Configures start control related properties
|
59,924
|
private function configureStopControlProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'exitcodes' ) ; $ this -> configureArrayProperty ( 'exitcodes' , $ resolver ) ; $ resolver -> setDefined ( 'stopsignal' ) -> setAllowedTypes ( 'stopsignal' , 'string' ) -> setAllowedValues ( 'stopsignal' , [ 'TERM' , 'HUP' , 'INT' , 'QUIT' , 'KILL' , 'USR1' , 'USR2' ] ) ; $ resolver -> setDefined ( 'stopwaitsecs' ) ; $ this -> configureIntegerProperty ( 'stopwaitsecs' , $ resolver ) ; $ resolver -> setDefined ( 'stopasgroup' ) ; $ this -> configureBooleanProperty ( 'stopasgroup' , $ resolver ) ; $ resolver -> setDefined ( 'killasgroup' ) ; $ this -> configureBooleanProperty ( 'killasgroup' , $ resolver ) ; }
|
Configures stop control related properties
|
59,925
|
private function configureLogProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'redirect_stderr' ) ; $ this -> configureBooleanProperty ( 'redirect_stderr' , $ resolver ) ; $ this -> configureStdoutLogProperties ( $ resolver ) ; $ this -> configureStderrLogProperties ( $ resolver ) ; }
|
Configures log related properties
|
59,926
|
private function configureStderrLogProperties ( OptionsResolver $ resolver ) { $ resolver -> setDefined ( 'stderr_logfile' ) -> setAllowedTypes ( 'stderr_logfile' , 'string' ) ; $ resolver -> setDefined ( 'stderr_logfile_maxbytes' ) ; $ this -> configureByteProperty ( 'stderr_logfile_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_logfile_backups' ) ; $ this -> configureIntegerProperty ( 'stderr_logfile_backups' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_capture_maxbytes' ) ; $ this -> configureByteProperty ( 'stderr_capture_maxbytes' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_events_enabled' ) ; $ this -> configureBooleanProperty ( 'stderr_events_enabled' , $ resolver ) ; $ resolver -> setDefined ( 'stderr_syslog' ) ; $ this -> configureBooleanProperty ( 'stderr_syslog' , $ resolver ) ; }
|
Configures stderr log related properties
|
59,927
|
public static function start ( ) { static :: $ time = microtime ( true ) ; static :: $ memory = memory_get_usage ( true ) ; self :: log ( static :: $ time , _t ( "Start execution time" ) , "info" ) ; }
|
Records the debugger and system start time
|
59,928
|
public static function log ( $ string , $ title = "Console Log" , $ type = "info" , $ typekey = "" , $ console = TRUE , $ logFile = TRUE ) { return static :: _ ( $ string , $ title , $ type , $ typekey , $ console , $ logFile ) ; }
|
Provides an alias for the log message method
|
59,929
|
public static function stop ( ) { $ now = microtime ( true ) ; $ speed = number_format ( 1000 * ( $ now - static :: $ time ) , 2 ) ; $ _memory = memory_get_usage ( ) ; $ units = array ( 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ) ; $ memory = @ round ( $ _memory / pow ( 1024 , ( $ i = floor ( log ( $ _memory , 1024 ) ) ) ) , 2 ) . ' ' . $ units [ $ i ] ; $ queries = '0' ; $ installed = ( bool ) \ Library \ Config :: getParam ( "installed" , FALSE , "database" ) ; if ( $ installed ) : $ database = \ Library \ Database :: getInstance ( ) ; $ queries = $ database -> getTotalQueryCount ( ) ; endif ; self :: log ( $ now , _t ( "Stop execution time" ) , "info" ) ; $ output = \ Library \ Output :: getInstance ( ) ; $ showMessage = \ Library \ Config :: getParam ( "mode" , 1 , "environment" ) ; if ( ( int ) $ showMessage < 2 ) { $ output = \ Library \ Output :: getInstance ( ) ; $ output -> set ( "debug" , array ( "displaylog" => true ) ) ; $ output -> set ( "debug" , array ( "queries" => $ queries ) ) ; $ output -> set ( "debug" , array ( "log" => static :: $ log ) ) ; } $ output -> set ( "debug" , array ( "start" => static :: $ time ) ) ; $ output -> set ( "debug" , array ( "stop" => $ now ) ) ; $ output -> set ( "debug" , array ( "speed" => $ speed ) ) ; $ output -> set ( "debug" , array ( "memory" => $ memory ) ) ; }
|
Records the debugger stop and stystem stop time Ideally the last method to be called before the output is sent to the server
|
59,930
|
public function dataContainsImportFile ( $ data , $ filename ) { if ( ! is_array ( $ data ) || ! isset ( $ data [ 'imports' ] ) || ! is_array ( $ data [ 'imports' ] ) ) { return false ; } foreach ( $ data [ 'imports' ] as $ value ) { if ( $ value [ 'resource' ] === $ filename ) { return true ; } } return false ; }
|
Check if the given data is an array containing a Symfony config import statement for the given file name .
|
59,931
|
public function sortImports ( array $ data , $ prefix = '' ) { if ( ! isset ( $ data [ 'imports' ] ) || ! is_array ( $ data [ 'imports' ] ) ) { return $ data ; } $ importsBeforePrefixed = array ( ) ; $ importsWithPrefix = array ( ) ; $ importsAfterPrefixed = array ( ) ; foreach ( $ data [ 'imports' ] as $ import ) { $ resource = $ import [ 'resource' ] ; if ( empty ( $ prefix ) || 0 === strpos ( $ resource , $ prefix ) ) { $ importsWithPrefix [ ] = $ resource ; } elseif ( count ( $ importsWithPrefix ) ) { $ importsAfterPrefixed [ ] = $ resource ; } else { $ importsBeforePrefixed [ ] = $ resource ; } } sort ( $ importsWithPrefix ) ; $ data = array_merge ( $ importsBeforePrefixed , $ importsWithPrefix , $ importsAfterPrefixed ) ; $ data = array_map ( function ( $ resource ) { return array ( 'resource' => $ resource ) ; } , $ data ) ; return array ( 'imports' => $ data ) ; }
|
Sort the imports key children of the given array by resource name .
|
59,932
|
public function addParameterToFile ( $ filename , $ name , $ value , $ preserveFormatting , $ addComment = null ) { $ content = file_get_contents ( $ filename ) ; $ data = Yaml :: parse ( $ content ) ; if ( $ preserveFormatting ) { $ content = rtrim ( $ content ) ; $ c = Yaml :: dump ( array ( 'parameters' => array ( $ name => $ value , ) , ) , 99 ) ; list ( , $ c ) = explode ( "\n" , $ c , 2 ) ; if ( ! empty ( $ addComment ) ) { $ lines = explode ( "\n" , trim ( $ addComment ) ) ; $ lines = array_map ( function ( $ line ) { return ' # ' . trim ( $ line ) ; } , $ lines ) ; $ content .= "\n\n" . implode ( "\n" , $ lines ) ; } $ content .= "\n" . $ c ; } else { $ data [ 'parameters' ] [ $ name ] = $ value ; $ content = Yaml :: dump ( $ data , 99 ) ; } file_put_contents ( $ filename , $ content ) ; }
|
Add the given parameter name and value to the given parameters . yml file .
|
59,933
|
public function applyTemplateController ( $ ctr ) { if ( $ ctr instanceof TemplateController ) { $ this -> templateController = $ ctr ; array_merge ( $ this -> settings , $ this -> templateController -> getSettings ( ) ) ; $ lang = $ this -> templateController -> getLanguageStrings ( ) ; if ( $ lang != null ) if ( $ this -> language == null ) $ this -> language = new Language ( ) ; $ this -> language -> merge ( $ lang ) ; } else { $ this -> templateController = SubViews :: getInstance ( ) -> getSubView ( $ ctr ) ; } }
|
Allows you to apply a Template to this controller .
|
59,934
|
public function doAction ( $ actionName ) { if ( isset ( $ this -> actions [ $ actionName ] ) ) return call_user_func_array ( array ( $ this , $ this -> actions [ $ actionName ] ) , array ( ) ) ; }
|
Executes the action This will call the function registered earlier
|
59,935
|
protected function registerEvent ( $ eventName , $ funcName ) { \ OWeb \ manage \ events :: getInstance ( ) -> registerEvent ( $ eventName , $ this , $ funcName ) ; }
|
Registers an event to whom this controller needs to respond
|
59,936
|
public function loadParams ( ) { switch ( $ this -> action_mode ) { case self :: ACTION_DOUBLE : $ a = array_merge ( \ OWeb \ OWeb :: getInstance ( ) -> get_post ( ) , \ OWeb \ OWeb :: getInstance ( ) -> get_get ( ) ) ; break ; case self :: ACTION_GET : $ a = \ OWeb \ OWeb :: getInstance ( ) -> get_get ( ) ; break ; case self :: ACTION_POST : $ a = \ OWeb \ OWeb :: getInstance ( ) -> get_post ( ) ; break ; } $ this -> params = $ a ; }
|
Automatically loads parameters throught PHP get and Post variables
|
59,937
|
public function getParam ( $ paramName ) { if ( isset ( $ this -> params [ $ paramName ] ) ) return $ this -> params [ $ paramName ] ; else return null ; }
|
Gets the value of a parameter
|
59,938
|
protected function InitLanguageFile ( ) { if ( $ this -> language == null ) $ this -> language = new Language ( ) ; $ this -> InitRecLanguageFile ( get_class ( $ this ) ) ; }
|
Thiw will activate the usage f the configuration files .
|
59,939
|
public function forceDisplay ( $ ctr = null ) { if ( ! $ this -> viewReady ) { $ this -> prepareView ( $ ctr ) ; } $ this -> view -> display ( ) ; }
|
Displays the controllers view
|
59,940
|
public function notify ( string $ event , array $ arguments = null ) { if ( isset ( $ this -> events [ $ event ] ) ) { foreach ( $ this -> events [ $ event ] as $ priorityKey => $ callbackKey ) { $ output = $ this -> subscriptions [ $ callbackKey ] ( $ this , $ arguments ?? [ ] ) ; if ( isset ( $ output [ 'stop' ] ) && true === $ output [ 'stop' ] ) { break ; } } } }
|
Notifies listeners about an event .
|
59,941
|
public function get ( $ url , $ sloppy304 = false ) { if ( ! $ this -> sendRequest ( $ url ) ) { return false ; } if ( $ this -> rspStatus == 304 && $ sloppy304 ) { return $ this -> rspBody ; } if ( $ this -> rspStatus != 200 ) { return false ; } return $ this -> rspBody ; }
|
fetch the contents of a web page
|
59,942
|
public function post ( $ url , $ data = array ( ) ) { if ( ! $ this -> sendRequest ( $ url , $ data , 'POST' ) ) { return false ; } if ( $ this -> rspStatus != 200 ) { return false ; } return $ this -> rspBody ; }
|
post request data
|
59,943
|
protected function debug ( $ info , $ var = null ) { if ( ! $ this -> debug ) { return ; } print '<b>' . $ info . '</b> ' . ( microtime ( 1 ) - $ this -> start ) . 's<br />' . "\r\n" ; if ( ! is_null ( $ var ) ) { $ content = var_export ( $ var , 1 ) ; print "<pre>\r\n$content\r\n</pre>\r\n" ; } }
|
print debug info
|
59,944
|
protected function parseHeaders ( $ string ) { $ headers = array ( ) ; $ lines = explode ( "\r\n" , trim ( $ string ) ) ; foreach ( $ lines as $ line ) { @ list ( $ key , $ val ) = explode ( ':' , $ line , 2 ) ; $ key = strtolower ( trim ( $ key ) ) ; $ val = trim ( $ val ) ; if ( empty ( $ val ) ) continue ; if ( isset ( $ headers [ $ key ] ) ) { if ( is_array ( $ headers [ $ key ] ) ) { $ headers [ $ key ] [ ] = $ val ; } else { $ headers [ $ key ] = array ( $ headers [ $ key ] , $ val ) ; } } else { $ headers [ $ key ] = $ val ; } } return $ headers ; }
|
convert given header string to Header array
|
59,945
|
protected function buildHeaders ( $ headers ) { $ string = '' ; foreach ( $ headers as $ key => $ value ) { if ( empty ( $ value ) ) continue ; $ string .= $ key . ': ' . $ value . "\r\n" ; } return $ string ; }
|
convert given header array to header string
|
59,946
|
protected function getCookies ( ) { $ headers = '' ; foreach ( $ this -> cookies as $ key => $ val ) { if ( $ headers ) $ headers .= '; ' ; $ headers .= $ key . '=' . $ val ; } if ( $ headers ) { $ headers = "Cookie: $headers" . "\r\n" ; } return $ headers ; }
|
get cookies as http header string
|
59,947
|
protected function buildSuffixesLexer ( FormatToken $ token ) { $ choices = [ ] ; $ i = 0 ; $ repetitions = 0 ; while ( $ label = $ this -> locale -> getNumberOrdinalSuffix ( $ i ++ ) ) { if ( ! in_array ( $ label , $ choices ) ) { $ choices [ ] = $ label ; $ repetitions = 0 ; } elseif ( ++ $ repetitions > 5 ) { break ; } } return new PregChoice ( $ token , $ choices ) ; }
|
Builds a choice lexer based on the getNumberOrdinalSuffix localisation method .
|
59,948
|
public function packageListAction ( Request $ request ) { $ composer = $ this -> getComposer ( ) ; $ converter = new PackageConverter ( $ composer -> getPackage ( ) ) ; $ upgrades = $ this -> getUpgradeRepository ( ) ; $ packages = $ converter -> convertRepositoryToArray ( $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) , ! $ request -> query -> has ( 'all' ) , $ upgrades ) -> getData ( ) ; ksort ( $ packages ) ; return new JsonResponse ( $ packages , 200 ) ; }
|
Retrieve the package list .
|
59,949
|
public function getPackageAction ( $ vendor , $ package ) { $ packageName = $ vendor . '/' . $ package ; $ composer = $ this -> getComposer ( ) ; if ( $ package = $ this -> findPackage ( $ packageName , $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) ) ) { $ converter = new PackageConverter ( $ composer -> getPackage ( ) ) ; return new JsonResponse ( $ converter -> convertPackageToArray ( $ package ) , 200 ) ; } throw new NotFoundHttpException ( 'Package ' . $ packageName . ' not found.' ) ; }
|
Retrieve a package .
|
59,950
|
public function putPackageAction ( $ vendor , $ package , Request $ request ) { $ packageName = $ vendor . '/' . $ package ; $ info = new JsonArray ( $ request -> getContent ( ) ) ; $ name = $ info -> get ( 'name' ) ; if ( ! ( $ info -> has ( 'name' ) && $ info -> has ( 'locked' ) && $ info -> has ( 'constraint' ) ) ) { throw new NotAcceptableHttpException ( 'Invalid package information.' ) ; } if ( $ name !== $ packageName ) { throw new NotAcceptableHttpException ( 'Package name mismatch ' . $ packageName . ' vs. ' . $ name . '.' ) ; } $ composer = $ this -> getComposer ( ) ; $ json = $ this -> get ( 'tenside.composer_json' ) ; $ package = $ this -> findPackage ( $ name , $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) ) ; if ( null === $ package ) { throw new NotFoundHttpException ( 'Package ' . $ packageName . ' not found.' ) ; } $ json -> setLock ( $ package , $ info -> get ( 'locked' ) ) ; return $ this -> forward ( 'TensideCoreBundle:Package:getPackage' ) ; }
|
Update the information of a package in the composer . json .
|
59,951
|
private function findPackage ( $ name , RepositoryInterface $ repository ) { $ packages = $ repository -> findPackages ( $ name ) ; while ( ! empty ( $ packages ) && $ packages [ 0 ] instanceof AliasPackage ) { array_shift ( $ packages ) ; } if ( empty ( $ packages ) ) { return null ; } return $ packages [ 0 ] ; }
|
Search the repository for a package .
|
59,952
|
private function getUpgradeRepository ( ) { $ upgradeFile = $ this -> getTensideDataDir ( ) . DIRECTORY_SEPARATOR . 'upgrades.json' ; if ( ! file_exists ( $ upgradeFile ) ) { return null ; } $ packageLoader = new ArrayLoader ( ) ; $ packageChanges = new WritableArrayRepository ( ) ; $ upgrades = new JsonFile ( $ upgradeFile , null ) ; foreach ( $ upgrades -> getEntries ( '/' ) as $ packageName ) { if ( $ pkgData = $ upgrades -> get ( $ packageName . '/target' ) ) { $ packageChanges -> addPackage ( $ packageLoader -> load ( $ pkgData ) ) ; } } return $ packageChanges ; }
|
Load a repository containing available upgrades .
|
59,953
|
public function offsetGet ( $ columnName ) { $ row = current ( $ this -> _rows ) ; return $ row !== false ? $ row [ $ columnName ] : null ; }
|
Gets the column value .
|
59,954
|
public function insert ( ) : self { $ data = $ this ; if ( ! $ this -> validate ( "post" , $ missing ) ) { throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Annotations for the '" . get_class ( $ this ) . "' class require valid values be set " . "on all of the following properties before attempting an insert():\n> " . implode ( "\n> " , $ missing ) . "\n" ) ; } $ endpoint = self :: post ( $ data ) ; return $ endpoint ; }
|
Attempts to INSERT this Endpoint object using the class s annotated information via a HTTP POST Request .
|
59,955
|
public static function post ( Endpoint $ data , array $ params = [ ] ) : Endpoint { $ class = get_called_class ( ) ; $ annotations = new AnnotationReader ( $ class ) ; $ endpoints = $ annotations -> getClassAnnotation ( "endpoints" ) ; $ endpoint = array_key_exists ( "post" , $ endpoints ) ? $ endpoints [ "post" ] : "" ; if ( $ endpoint === "" ) throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] An annotation like '@endpoints { \"post\": \"/examples\" }' on the '$class' " . "class must be declared in order to resolve this endpoint'" ) ; $ endpoint = Patterns :: interpolateUrl ( $ endpoint , $ params ) ; $ data = ( $ data !== null ) ? $ data -> toArray ( "post" ) : [ ] ; $ response = RestClient :: post ( $ endpoint , $ data ) ; if ( $ response === [ ] ) { throw new \ Exception ( "WTF???" ) ; } if ( array_key_exists ( "code" , $ response ) ) { switch ( $ response [ "code" ] ) { case 401 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The REST Client was not authorized to make this request!" ) ; case 403 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The provided App Key does not have sufficient privileges!" ) ; case 404 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Endpoint '$endpoint' was not found for class '$class'!" ) ; case 422 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Data for endpoint '$endpoint' was improperly formatted!\n" . $ response [ "message" ] . "\n" . json_encode ( $ response [ "errors" ] , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ) ; default : break ; } } return new $ class ( $ response ) ; }
|
Sends a HTTP POST Request on behalf of the Endpoint given optional parameters .
|
59,956
|
public static function get ( string $ override = "" , array $ params = [ ] , array $ query = [ ] ) : Collection { $ class = get_called_class ( ) ; $ excludeId = false ; if ( $ override === "" ) { $ annotations = new AnnotationReader ( $ class ) ; $ endpoints = $ annotations -> getClassAnnotation ( "endpoints" ) ; $ excludeId = $ annotations -> hasClassAnnotation ( "excludeId" ) ; if ( ! array_key_exists ( "get" , $ endpoints ) || $ endpoints [ "get" ] === "" ) throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] An '@Endpoint { \"get\": \"/examples\" }' annotation on the class must " . "be declared in order to resolve this endpoint'" ) ; $ endpoint = Patterns :: interpolateUrl ( $ endpoints [ "get" ] , $ params ) ; } else { $ endpoint = Patterns :: interpolateUrl ( $ override , $ params ) ; } if ( $ query !== [ ] ) { $ pairs = [ ] ; foreach ( $ query as $ key => $ value ) $ pairs [ ] = "$key=$value" ; $ endpoint .= "?" . implode ( "&" , $ pairs ) ; } $ response = RestClient :: get ( $ endpoint ) ; if ( $ response === [ ] ) return new Collection ( $ class , [ ] ) ; if ( array_key_exists ( "code" , $ response ) ) { switch ( $ response [ "code" ] ) { case 401 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The REST Client was not authorized to make this request!" ) ; case 403 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The provided App Key does not have sufficient privileges!" ) ; case 404 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Endpoint '$endpoint' was not found for class '$class'!" ) ; default : break ; } } $ response = Arrays :: is_assoc ( $ response ) ? [ $ response ] : $ response ; $ endpoints = new Collection ( $ class ) ; foreach ( $ response as $ object ) { $ classObject = new $ class ( $ object ) ; if ( $ excludeId ) unset ( $ classObject -> id ) ; $ endpoints -> push ( $ classObject ) ; } return $ endpoints ; }
|
Sends an HTTP GET Request using the calling class s annotated information for all objects at this Endpoint .
|
59,957
|
public static function getById ( int $ id ) : ? Endpoint { $ class = get_called_class ( ) ; $ annotations = new AnnotationReader ( $ class ) ; $ endpoints = $ annotations -> getClassAnnotation ( "endpoints" ) ; if ( ! array_key_exists ( "getById" , $ endpoints ) ) throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] An '@EndpointAnnotation { \"getById\": \"/examples/:id\" }' annotation on " . "the '$class' class must be declared in order to resolve this endpoint'" ) ; $ endpoint = Patterns :: interpolateUrl ( $ endpoints [ "getById" ] , [ "id" => $ id ] ) ; $ response = RestClient :: get ( $ endpoint ) ; if ( $ response === [ ] ) return null ; if ( array_key_exists ( "code" , $ response ) ) { switch ( $ response [ "code" ] ) { case 401 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The REST Client was not authorized to make this request!" ) ; case 403 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] The provided App Key does not have sufficient privileges!" ) ; case 404 : throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Endpoint '$endpoint' was not found for class '$class'!" ) ; default : break ; } } return new $ class ( $ response ) ; }
|
Sends an HTTP GET Request using the calling class s annotated information for a single object given the ID .
|
59,958
|
public function update ( ) : self { $ data = $ this ; if ( ! $ this -> validate ( "patch" , $ missing ) ) { throw new \ Exception ( "[MVQN\REST\Endpoints\Endpoint] Annotations for the '" . get_class ( $ this ) . "' class require valid values be set " . "on all of the following properties before attempting an update():\n> " . implode ( "\n> " , $ missing ) . "\n" ) ; } $ endpoint = self :: patch ( $ data , [ "id" => $ this -> getId ( ) ] ) ; return $ endpoint ; }
|
Attempts to UPDATE this Endpoint object using the class s annotated information via a HTTP PATCH Request .
|
59,959
|
public static function getRoutes ( ) { $ routes = new \ FreeFW \ Router \ RouteCollection ( ) ; $ paths = [ ] ; $ paths [ ] = __DIR__ . '/../resource/routes/restful/v1/routes.php' ; foreach ( $ paths as $ idx => $ onePath ) { $ apiRoutes = @ include ( $ onePath ) ; if ( is_array ( $ apiRoutes ) ) { foreach ( $ apiRoutes as $ idx => $ apiRoute ) { $ myRoute = new \ FreeFW \ Router \ Route ( ) ; $ myRoute -> setMethod ( $ apiRoute [ 'method' ] ) -> setUrl ( $ apiRoute [ 'url' ] ) -> setController ( $ apiRoute [ 'controller' ] ) -> setFunction ( $ apiRoute [ 'function' ] ) -> setSecured ( $ apiRoute [ 'secured' ] ) ; $ routes -> addRoute ( $ myRoute ) ; } } } return $ routes ; }
|
Retourne une liste de routes au format FreeFW
|
59,960
|
protected function prepareValue ( $ value ) { switch ( gettype ( $ value ) ) { case OptionInterface :: TYPE_BOOLEAN : return ( $ value ) ? 'true' : 'false' ; case OptionInterface :: TYPE_NUMBER : return $ value ; case OptionInterface :: TYPE_STRING : return "'" . $ value . "'" ; } }
|
Prepares value to use in DataGrid JS configuration
|
59,961
|
protected function registerDefaultParser ( ) { $ this -> registerMediaTypeParser ( 'application/json' , function ( string $ input ) { $ result = json_decode ( $ input , true ) ; if ( ! is_array ( $ result ) ) { return null ; } return $ result ; } , null ) ; $ this -> registerMediaTypeParser ( 'application/xml' , function ( string $ input ) { $ backup = libxml_disable_entity_loader ( true ) ; $ backup_errors = libxml_use_internal_errors ( true ) ; $ result = simplexml_load_string ( $ input ) ; libxml_disable_entity_loader ( $ backup ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ backup_errors ) ; if ( $ result === false ) { return null ; } return $ result ; } , null ) ; $ this -> registerMediaTypeParser ( 'text/xml' , function ( string $ input ) { $ backup = libxml_disable_entity_loader ( true ) ; $ backup_errors = libxml_use_internal_errors ( true ) ; $ result = simplexml_load_string ( $ input ) ; libxml_disable_entity_loader ( $ backup ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ backup_errors ) ; if ( $ result === false ) { return null ; } return $ result ; } , null ) ; $ this -> registerMediaTypeParser ( 'application/x-www-form-urlencoded' , function ( string $ input ) { parse_str ( $ input , $ data ) ; return $ data ; } , null ) ; }
|
Register Default Parser
|
59,962
|
public function getMediaType ( ) { $ contentType = $ this -> getContentType ( ) ; if ( is_string ( $ contentType ) ) { $ contentTypeParts = preg_split ( '/\s*[;,]\s*/' , $ contentType ) ; return isset ( $ contentTypeParts [ 0 ] ) ? strtolower ( $ contentTypeParts [ 0 ] ) : null ; } return null ; }
|
Get request media type if known .
|
59,963
|
private static function reconstructOriginalKey ( string $ key ) { if ( strpos ( $ key , 'HTTP_' ) === 0 ) { $ key = substr ( $ key , 5 ) ; } return strtr ( ucwords ( strtr ( strtolower ( $ key ) , '_' , ' ' ) ) , ' ' , '-' ) ; }
|
Reconstruct original header name
|
59,964
|
public static function createFromGlobalsResolveCLIRequest ( array $ globals = null ) : Request { $ globals = static :: manipulateIfCLIRequest ( ( $ globals === null ? Uri :: fixSchemeProxyFromGlobals ( $ _SERVER ) : $ globals ) ) ; return static :: createFromGlobals ( $ globals ) ; }
|
Create new HTTP request with data extracted from the application Environment object that Allowed CLI
|
59,965
|
public function name ( string $ string ) : RoleObject { $ this -> role [ ] = $ role = new RoleObject ( $ string ) ; return $ role ; }
|
create new role
|
59,966
|
public function sendMailToAdministrators ( $ envoyeur = 'archi-strasbourg' , $ sujet = '' , $ message = '' , $ criteres = '' , $ writeMailToLogs = false , $ isEnvoiRegroupeDesactive = false , $ logfile = 'mail.log' ) { $ replyTo = "" ; if ( is_array ( $ envoyeur ) ) { $ replyTo = $ envoyeur [ "replyTo" ] ; $ envoyeur = $ envoyeur [ "envoyeur" ] ; } $ authentification = new archiAuthentification ( ) ; $ idUtilisateur = '0' ; if ( $ authentification -> estConnecte ( ) ) { $ idUtilisateur = $ authentification -> getIdUtilisateur ( ) ; } $ sqlNoSendToAdmin = "" ; if ( $ authentification -> estAdmin ( ) ) { $ sqlNoSendToAdmin = "and idUtilisateur!='" . $ idUtilisateur . "'" ; } if ( $ isEnvoiRegroupeDesactive ) { $ sql = "SELECT mail from utilisateur where idProfil='4'" . " and compteActif='1' " . $ criteres . " " . $ sqlNoSendToAdmin ; } else { $ sql = "SELECT mail from utilisateur where idProfil='4' " . "and compteActif='1' and (idPeriodeEnvoiMailsRegroupes='1' " . "OR idPeriodeEnvoiMailsRegroupes='0') " . $ criteres . " " . $ sqlNoSendToAdmin ; } $ res = $ this -> connexionBdd -> requete ( $ sql ) ; while ( $ fetch = mysql_fetch_assoc ( $ res ) ) { $ headers = 'From: "' . $ envoyeur . '"<' . $ envoyeur . '>' . "\r\nReply-To: " . $ replyTo . "\r\nContent-Type: text/html; charset=\"utf-8\"\r\n" ; if ( isset ( $ this -> isSiteLocal ) && $ this -> isSiteLocal == true ) { echo "Envoi d'un mail aux administrateurs<br>" ; echo $ headers ; echo "<br>to : " . $ fetch [ 'mail' ] . "<br>" ; echo "subject : $sujet<br>" ; echo "$message<br>" ; echo "finMail<br>" ; if ( $ writeMailToLogs ) { $ this -> saveMailToLogs ( array ( "envoyeur" => $ envoyeur , "destinataire" => $ fetch [ 'mail' ] , "sujet" => $ sujet , "message" => $ message , "debug" => true , 'logfile' => $ logfile ) ) ; } } else { pia_mail ( $ fetch [ 'mail' ] , $ sujet , $ message , $ headers , null ) ; if ( $ writeMailToLogs ) { $ this -> saveMailToLogs ( array ( "envoyeur" => $ envoyeur , "destinataire" => $ fetch [ 'mail' ] , "sujet" => $ sujet , "message" => $ message , "debug" => false , 'logfile' => $ logfile ) ) ; } } } }
|
Envoi d un mail a tous les administrateurs
|
59,967
|
public function saveMailToLogs ( $ params = array ( ) ) { if ( isset ( $ params [ 'destinataire' ] ) && isset ( $ params [ 'sujet' ] ) && isset ( $ params [ 'message' ] ) && isset ( $ params [ 'debug' ] ) ) { $ debugValue = false ; if ( $ params [ 'debug' ] == true ) { $ debugValue = true ; } $ message = strip_tags ( $ params [ 'message' ] , '<br>' ) ; if ( file_exists ( $ this -> getCheminPhysique ( ) . 'logs/' . $ params [ 'logfile' ] ) ) { $ lastlog = popen ( 'tac ' . escapeshellcmd ( $ this -> getCheminPhysique ( ) . 'logs/' . $ params [ 'logfile' ] ) , 'r' ) ; $ lastline = json_decode ( fgets ( $ lastlog ) ) ; pclose ( $ lastlog ) ; } else { $ lastline [ 3 ] = '' ; } if ( $ lastline [ 3 ] == $ message ) { $ fn = $ this -> getCheminPhysique ( ) . '/logs/' . $ params [ 'logfile' ] ; $ size = filesize ( $ fn ) ; $ block = 4096 ; $ trunc = max ( $ size - $ block , 0 ) ; $ f = fopen ( $ fn , "c+" ) ; if ( flock ( $ f , LOCK_EX ) ) { fseek ( $ f , $ trunc ) ; $ bin = rtrim ( fread ( $ f , $ block ) , "\n" ) ; if ( $ r = strrpos ( $ bin , "\n" ) ) { ftruncate ( $ f , $ trunc + $ r + 1 ) ; } } fclose ( $ f ) ; error_log ( json_encode ( array ( $ lastline [ 0 ] , array_merge ( $ lastline [ 1 ] , array ( $ params [ 'destinataire' ] ) ) , $ params [ 'sujet' ] , $ message ) ) . PHP_EOL , 3 , $ this -> getCheminPhysique ( ) . '/logs/' . $ params [ 'logfile' ] ) ; } else { error_log ( json_encode ( array ( date ( 'c' ) , array ( $ params [ 'destinataire' ] ) , $ params [ 'sujet' ] , $ message ) ) . PHP_EOL , 3 , $ this -> getCheminPhysique ( ) . '/logs/' . $ params [ 'logfile' ] ) ; } } else { echo "mailObject.class.php : " . "sauvegarde dans les logs impossible, il manque un champ.<br>" ; } }
|
Effectue une sauvegarde du mail
|
59,968
|
public function listAction ( Request $ request ) { $ mediaTypeManager = $ this -> get ( 'phlexible_media_type.media_type_manager' ) ; $ iconResolver = $ this -> get ( 'phlexible_media_type.icon_resolver' ) ; $ mediaTypes = [ ] ; foreach ( $ mediaTypeManager -> findAll ( ) as $ mediaType ) { $ mediaTypes [ ] = [ 'id' => $ mediaType -> getName ( ) , 'key' => $ mediaType -> getName ( ) , 'upperkey' => strtoupper ( $ mediaType -> getName ( ) ) , 'type' => $ mediaType -> getCategory ( ) , 'de' => $ mediaType -> getTitle ( 'de' ) , 'en' => $ mediaType -> getTitle ( 'en' ) , 'mimetypes' => $ mediaType -> getMimetypes ( ) , 'icon16' => ( bool ) $ iconResolver -> resolve ( $ mediaType , 16 ) , 'icon32' => ( bool ) $ iconResolver -> resolve ( $ mediaType , 32 ) , 'icon48' => ( bool ) $ iconResolver -> resolve ( $ mediaType , 48 ) , 'icon256' => ( bool ) $ iconResolver -> resolve ( $ mediaType , 256 ) , ] ; } return new JsonResponse ( [ 'totalCount' => count ( $ mediaTypes ) , 'mediatypes' => $ mediaTypes , ] ) ; }
|
List media types .
|
59,969
|
public function isValidLocale ( $ locale ) { foreach ( $ this -> locales as $ validLocale ) { if ( strcmp ( $ validLocale , $ locale ) == 0 ) { return true ; } } return false ; }
|
REturns whether or not the locale is valid
|
59,970
|
public function setUrl ( ) { $ name = preg_replace ( "/[^a-zA-Z0-9]+/" , " " , $ this -> getUsername ( ) ) ; $ name = preg_replace ( '!\s+!' , ' ' , trim ( $ name ) ) ; $ this -> url = '/authors/' . str_replace ( " " , "-" , strtolower ( $ name ) ) . '.html' ; }
|
Set URL of author page
|
59,971
|
public function remove ( $ element ) : bool { if ( ! $ this -> contains ( $ element ) ) { return false ; } $ index = array_search ( $ element , $ this -> elements , true ) ; unset ( $ this -> elements [ $ index ] ) ; return ! $ this -> contains ( $ element ) ; }
|
Removes element and checks if collection not contains it anymore
|
59,972
|
public function animate ( ) { for ( $ time = 0 ; $ time <= $ this -> meta [ 't' ] ; $ time += $ this -> meta [ 'f' ] ) { foreach ( $ this -> frames as $ frame ) { fwrite ( STDOUT , $ frame ) ; $ this -> sleepMilli ( $ this -> meta [ 'f' ] ) ; Console :: moveCursorRel ( - $ this -> meta [ 'w' ] , - $ this -> meta [ 'h' ] ) ; $ time += $ this -> meta [ 'f' ] ; } } Console :: moveCursorRel ( $ this -> meta [ 'w' ] , $ this -> meta [ 'h' ] ) ; fwrite ( STDOUT , "\n" ) ; }
|
Displays animation on screen
|
59,973
|
public function getFullName ( ) { if ( $ this -> firstName && $ this -> lastName ) { return "{$this->firstName} {$this->lastName}" ; } elseif ( $ this -> firstName ) { return $ this -> firstName ; } elseif ( $ this -> lastName ) { return $ this -> lastName ; } else { return '' ; } }
|
Get fullName .
|
59,974
|
public function setViewModel ( ViewModel $ viewModel ) { $ viewModel -> setVariable ( "formName" , $ this -> getName ( ) ) ; if ( $ this -> getFormAction ( ) != "" ) { $ viewModel -> setVariable ( "formAction" , $ this -> getFormAction ( ) ) ; } else { throw new \ Exception ( "You must provide a formAction" ) ; } $ wizardFormCurrentStepViewModel = new ViewModel ( ) ; $ wizardFormCurrentStepViewModel -> setTemplate ( "wizard/wizardFormCurrentStep" ) ; $ wizardFormCurrentStepViewModel -> setVariable ( Wizard :: WIZARD_CURRENT_STEP_IDENTIFIER , $ this -> getName ( ) ) ; $ viewModel -> addChild ( $ wizardFormCurrentStepViewModel , "wizardFormCurrentStep" ) ; $ this -> viewModel = $ viewModel ; }
|
the template of the viewModel must provide variables currentStep and fromName
|
59,975
|
public function getBreaker ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> instances ) ) { $ this -> instances [ $ name ] = new CircuitBreaker ( $ name , $ this -> storage ) ; } return $ this -> instances [ $ name ] ; }
|
Returns a circuit breaker given by name . Will create a new instance if it doesn t exist already or return one that already does .
|
59,976
|
public function save ( array $ options = array ( ) ) { if ( ! $ this -> exists ) { $ this -> recordEvents ( new UserWasRegisteredEvent ( $ this ) ) ; } $ saved = parent :: save ( $ options ) ; return $ saved ; }
|
Save User ensuring all its Relationships are assigned
|
59,977
|
static public function fromArray ( $ id , array $ array = null , callable $ callback , array $ options = [ ] ) { $ form = static :: createInstance ( $ id , $ callback ) ; $ form -> parseOptions ( $ options ) ; $ form -> createResource ( $ array ) ; $ form -> render ( ) ; }
|
Create a form bound to an key - value array .
|
59,978
|
static public function fromObject ( $ obj = null , callable $ callback , array $ options = [ ] ) { $ form = static :: createInstance ( get_class ( $ obj ) , $ callback ) ; $ form -> setNamePattern ( $ obj ) ; $ form -> parseOptions ( $ options ) ; $ form -> createResource ( $ obj ) ; $ form -> addClass ( get_class ( $ obj ) ) ; $ object_id = $ form -> res -> getId ( ) ; if ( $ object_id !== false ) { $ form -> setId ( $ form -> id . "_{$object_id}" ) ; $ form -> hiddenField ( "id" ) ; } $ form -> render ( ) ; }
|
Create a form bound to an object .
|
59,979
|
public function hiddenField ( $ key , $ value = null , array $ attr = [ ] ) { if ( $ value !== null ) { $ attr [ 'value' ] = $ value ; } $ this -> hidden [ ] = $ this -> builder -> factory ( "hidden" , $ key , false , $ attr ) ; }
|
Overridden hidden so child - containers can call this .
|
59,980
|
public function getString ( string $ key , string $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : $ default_value ; } return strval ( $ value ) ; }
|
Get as string value
|
59,981
|
public function getList ( $ key , array $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : new ArrayList ( $ default_value ) ; } return new ArrayList ( $ value ) ; }
|
Get as list value
|
59,982
|
public function getHashMap ( $ key , array $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : new HashMap ( $ default_value ) ; } return new HashMap ( $ value ) ; }
|
Get as associative array value
|
59,983
|
public function getInteger ( $ key , int $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : $ default_value ; } return intval ( $ value ) ; }
|
Get as int value
|
59,984
|
public function getFloat ( $ key , float $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : $ default_value ; } return floatval ( $ value ) ; }
|
Get as float value
|
59,985
|
public function getBoolean ( $ key , bool $ default_value = NULL ) { $ value = $ this -> getPropertyNodeValue ( $ key ) ; if ( NULL === $ value ) { return NULL === $ default_value ? NULL : $ default_value ; } return boolval ( $ value ) ; }
|
Get as bool value
|
59,986
|
private function getPropertyNodeValue ( string $ key ) { $ data = $ this -> toArray ( ) ; if ( strpos ( $ key , '/' ) === false ) { return $ data [ $ key ] ?? NULL ; } $ node_keys = explode ( '/' , $ key ) ; $ node = $ data ; while ( ( $ node_key = array_shift ( $ node_keys ) ) && ( count ( $ node_keys ) > 0 ) ) { if ( ! isset ( $ node [ $ node_key ] ) ) { return NULL ; } $ node = $ node [ $ node_key ] ; } return $ node [ $ node_key ] ?? NULL ; }
|
Get property node
|
59,987
|
public function from ( $ table , $ alias = '' ) { $ tbl = $ this -> fixTable ( $ table , $ alias ) ; $ this -> tables = array_merge ( $ this -> tables , $ tbl ) ; return $ this ; }
|
Append to existing tables
|
59,988
|
protected function updateDocComment ( $ doc , $ properties , $ coveredProperties , $ ref ) { $ lines = explode ( "\n" , trim ( $ doc ) ) ; $ propertyPart = false ; $ propertyPosition = false ; foreach ( $ lines as $ i => $ line ) { if ( substr ( trim ( $ line ) , 0 , 12 ) == '* @property ' ) { $ propertyPart = true ; } elseif ( $ propertyPart && trim ( $ line ) == '*' ) { $ propertyPosition = $ i ; $ propertyPart = false ; } if ( substr ( trim ( $ line ) , 0 , 10 ) == '* @author ' && $ propertyPosition === false ) { $ propertyPosition = $ i - 1 ; $ propertyPart = false ; } if ( $ propertyPart && ! $ ref -> isSubclassOf ( 'yii\base\Model' ) ) { unset ( $ lines [ $ i ] ) ; } elseif ( $ ref -> isSubclassOf ( 'yii\db\ActiveRecord' ) && preg_match ( '/^\* This is the model class for table/' , trim ( $ line ) ) === 1 ) { unset ( $ lines [ $ i ] ) ; } else { foreach ( $ coveredProperties as $ property ) { if ( preg_match ( '/^\* \@property[^\w]' . $ property . '/' , trim ( $ line ) ) === 1 ) { unset ( $ lines [ $ i ] ) ; break ; } } } } $ finalDoc = '' ; foreach ( $ lines as $ i => $ line ) { $ finalDoc .= $ line . "\n" ; if ( $ i == $ propertyPosition ) { $ finalDoc .= $ properties ; } } return $ finalDoc ; }
|
Replace property annotations in doc comment .
|
59,989
|
public function decrementLargeTiles ( ) { if ( $ this -> wide === 0 && $ this -> tall === 0 ) { throw new Exception ( 'Cannot decrement the number of either wide or tall tiles.' ) ; } if ( $ this -> tall === 0 ) { $ decrementWide = true ; } elseif ( $ this -> wide > 0 ) { $ wideRateDelta = $ this -> initialWideRate - $ this -> getWideRate ( ) ; $ tallRateDelta = $ this -> initialTallRate - $ this -> getTallRate ( ) ; $ decrementWide = $ wideRateDelta === $ tallRateDelta ? rand ( 0 , 1 ) === 0 : $ wideRateDelta < $ tallRateDelta ; } else { $ decrementWide = false ; } if ( $ decrementWide ) { $ this -> wide -= 1 ; } else { $ this -> tall -= 1 ; } $ this -> small += 1 ; }
|
Decrement the number of large tiles and increment the number of small tiles .
|
59,990
|
public function incrementLargeTiles ( ) { if ( $ this -> small === 0 ) { throw new Exception ( 'Cannot decrement the number of small tiles, already 0.' ) ; } $ wideRateDelta = $ this -> getWideRate ( ) - $ this -> initialWideRate ; $ tallRateDelta = $ this -> getTallRate ( ) - $ this -> initialTallRate ; $ incrementWide = $ wideRateDelta === $ tallRateDelta ? rand ( 0 , 1 ) === 0 : $ wideRateDelta < $ tallRateDelta ; if ( $ incrementWide ) { $ this -> wide += 1 ; } else { $ this -> tall += 1 ; } $ this -> small -= 1 ; }
|
Increment the number of large tiles and decrement the number of small tiles .
|
59,991
|
public static function fromLargeTiles ( int $ total , int $ tall , int $ wide ) { return new Distribution ( $ total - $ tall - $ wide , $ tall , $ wide ) ; }
|
Convenience method to create a new Distribution from a total number of tiles and number of tall and wide tiles .
|
59,992
|
public function build ( ) { $ value = sprintf ( "'%s'" , $ this -> value ) ; $ where = sprintf ( 'WHERE %s %s %s' , $ this -> column , $ this -> operator , $ value ) ; $ keyword = $ this -> keyword ; if ( ! is_null ( $ keyword ) ) { $ where = sprintf ( ' %s %s' , $ keyword , $ where ) ; } return $ where ; }
|
Builds the current where expression and returns the result .
|
59,993
|
public static function fromJson ( $ jsonFile ) { if ( ! is_file ( $ jsonFile ) && ! is_readable ( $ jsonFile ) ) { throw new \ RuntimeException ( "Either '$jsonFile' is not a file or cannot access it" ) ; } $ content = file_get_contents ( $ jsonFile ) ; if ( ! $ content ) { throw new \ RuntimeException ( "Cannot load empty JSON file '$jsonFile'" ) ; } $ json = json_decode ( $ content , true ) ; if ( ! $ json ) { throw new \ RuntimeException ( "Could not parse JSON from '$jsonFile'" ) ; } return new \ DataFilter \ Profile ( $ json ) ; }
|
Construct from JSON file
|
59,994
|
public function removeAttrib ( $ attribName ) { if ( isset ( $ this -> attribs [ $ attribName ] ) ) { unset ( $ this -> attribs [ $ attribName ] ) ; return true ; } return false ; }
|
Removes a single attribute by name
|
59,995
|
public function setOption ( $ key , $ value ) { if ( 'id' == $ key ) { $ this -> proxyBase -> setOption ( $ key , $ value ) ; return $ this ; } return parent :: setOption ( $ key , $ value ) ; }
|
Set option enhanced to be able to set id
|
59,996
|
public function setType ( $ type ) { if ( empty ( static :: $ type ) ) { $ this -> proxyBase -> type = $ type ; } elseif ( static :: $ type != $ type ) { throw new LogicException ( 'Cannot alter type after creation' ) ; } return $ this ; }
|
Set type of the paragraph
|
59,997
|
public function getRootParagraph ( ) { if ( $ this -> proxyBase -> rootId && ( null === $ this -> rootParagraph || $ this -> rootParagraph -> id != $ this -> proxyBase -> rootId ) ) { $ this -> rootParagraph = $ this -> getMapper ( ) -> find ( $ this -> proxyBase -> rootId ) ; } return $ this -> rootParagraph ; }
|
Get root paragraph
|
59,998
|
public static function getAllowedFunctions ( ) { $ properties = array ( static :: PROPERTY_DRAG , static :: PROPERTY_DROP , static :: PROPERTY_EDIT , static :: PROPERTY_DELETE , ) ; $ class = get_called_class ( ) ; if ( is_a ( $ class , __NAMESPACE__ . '\RepresentsTextContentInterface' , true ) ) { $ properties [ ] = static :: PROPERTY_REPRESENTS_TEXT ; } if ( is_a ( $ class , __NAMESPACE__ . '\RepresentsImageContentsInterface' , true ) ) { $ properties [ ] = static :: PROPERTY_REPRESENTS_IMAGES ; } return $ properties ; }
|
This paragraph - type functions
|
59,999
|
public function getResourceId ( ) { if ( null === $ this -> aclResourceId ) { $ this -> aclResourceId = 'paragraph.' . $ this -> getType ( ) . '.' . ( ( int ) $ this -> getId ( ) ) ; } return $ this -> aclResourceId ; }
|
Returns the string identifier of the Resource
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.