idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
45,500
public function addAccessibility ( $ items ) : array { global $ wp ; $ current_url = home_url ( add_query_arg ( array ( ) , $ wp -> request ) ) ; if ( ! isset ( $ _GET [ 'readable' ] ) && get_field ( 'easy_reading_select' ) == true ) { $ items [ ] = '<a href="' . add_query_arg ( 'readable' , '1' , $ current_url ) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __ ( 'Easy to read' , 'easy-reading' ) . '</a>' ; } elseif ( isset ( $ _GET [ 'readable' ] ) && $ _GET [ 'readable' ] == '1' && get_field ( 'easy_reading_select' ) == true ) { $ items [ ] = '<a href="' . remove_query_arg ( 'readable' , $ current_url ) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __ ( 'Default version' , 'easy-reading' ) . '</a>' ; } return $ items ; }
Add easy to read link to accessibility nav
45,501
public function easyReadingLead ( $ lead ) { if ( isset ( $ _GET [ 'readable' ] ) && $ _GET [ 'readable' ] == '1' && get_field ( 'easy_reading_select' ) == true && in_the_loop ( ) && is_main_query ( ) ) { return '' ; } return $ lead ; }
Remove the lead
45,502
public function easyReadingContent ( $ content ) { global $ post ; if ( isset ( $ _GET [ 'readable' ] ) && $ _GET [ 'readable' ] == '1' && get_field ( 'easy_reading_select' ) == true && is_object ( $ post ) && isset ( $ post -> post_content ) && in_the_loop ( ) && is_main_query ( ) ) { $ post_content = $ post -> post_content ; if ( strpos ( $ post_content , '<!--more ) !== false ) { $ content_parts = explode ( '<!--more , $ post_content ) ; $ post_content = $ content_parts [ 1 ] ; } $ post_content = preg_replace ( '/[^a-z]/i' , '' , sanitize_text_field ( $ post_content ) ) ; $ sanitized_content = preg_replace ( '/[^a-z]/i' , '' , sanitize_text_field ( $ content ) ) ; if ( $ post_content == $ sanitized_content ) { $ content = get_field ( 'easy_reading_content' ) ; if ( strpos ( $ content , '<!--more ) !== false ) { $ content_parts = explode ( '<!--more , $ content ) ; $ content = '<p class="lead">' . sanitize_text_field ( $ content_parts [ 0 ] ) . '</p>' . $ content_parts [ 1 ] ; } } } return $ content ; }
Switch content to alternate version
45,503
public function executeUpdate ( ) : bool { $ temp = false ; if ( $ this -> build ( ) ) { $ this -> conect -> query ( $ this -> generate ) ; $ this -> generate = "" ; $ temp = true ; } return $ temp ; }
Permite haser una escritura de los datos .
45,504
public function setContext ( FormContext $ context ) { $ old = $ this -> context ; $ this -> context = $ context ; return $ old ; }
Change context .
45,505
public function hiddenField ( $ key , $ value = null , array $ attr = [ ] ) { $ this -> context -> hiddenField ( $ key , $ value , $ attr ) ; }
Add hidden field . All hiddens are placed at the beginning of the form no matter where used .
45,506
public function textField ( $ key , $ label = null , array $ attr = [ ] ) { $ field = $ this -> factory ( "text" , $ key , $ label , $ attr ) ; return $ this -> addField ( $ field ) ; }
Regular text input .
45,507
public function hint ( $ text , $ label = null , array $ attr = [ ] ) { if ( $ this -> unbuffered ( ) ) { trigger_error ( "Cannot use hint in unbuffered mode" , E_USER_ERROR ) ; } $ field = $ this -> factory ( "hint" , $ text , $ label , $ attr ) ; return $ this -> addField ( $ field ) ; }
Add a help text .
45,508
public function manual ( $ key , $ label , $ content , $ hint = false ) { $ field = new ManualField ( $ key , $ label , $ content , $ hint ) ; $ this -> addField ( $ field ) ; if ( $ this -> unbuffered ( ) ) { echo $ field -> getContent ( ) . "\n" ; } return $ field ; }
Create a manual field from HTML .
45,509
public function uploadField ( $ key , $ label = null , array $ attr = [ ] ) { $ remove = false ; $ current = false ; if ( array_key_exists ( 'remove' , $ attr ) ) { $ remove = $ attr [ 'remove' ] ; unset ( $ attr [ 'remove' ] ) ; } if ( array_key_exists ( 'current' , $ attr ) ) { $ current = $ attr [ 'current' ] ; unset ( $ attr [ 'current' ] ) ; } $ attr [ 'name' ] = $ key ; $ upload = $ this -> factory ( "file" , $ key , $ label , $ attr ) ; $ this -> fields [ ] = $ upload ; $ this -> addField ( $ upload ) ; if ( $ current !== false ) { $ attr = [ ] ; list ( $ id , $ name , ) = $ this -> generateData ( $ key . '_current' , $ attr ) ; $ field = new ManualField ( "{$key}_current" , '' , "<label>$current</label>" , false ) ; return $ this -> addField ( $ field ) ; } if ( $ remove ) { $ attr = [ ] ; list ( $ id , $ name , ) = $ this -> generateData ( $ key . '_remove' , $ attr ) ; $ field = new ManualField ( "{$key}_remove" , '' , "<label><input type='checkbox' name='$name' id='$id' value='1' />Ta bort</label>" , false ) ; return $ this -> addField ( $ field ) ; } return $ upload ; }
File upload field .
45,510
public function group ( $ label , callable $ callback , array $ attr = [ ] ) { if ( $ this -> unbuffered ( ) ) { trigger_error ( "Cannot use Form groups in unbuffered mode" , E_USER_ERROR ) ; } $ field = new FormGroup ( $ this -> context , $ label , $ callback , $ attr ) ; return $ this -> addField ( $ field ) ; }
Create a field group where all fields is aligned horizontaly useful for buttons checkboxes and radiobuttons .
45,511
public function fieldset ( $ label , callable $ callback ) { if ( $ this -> unbuffered ( ) ) { trigger_error ( "Cannot use Form fieldsets in unbuffered mode" , E_USER_ERROR ) ; } $ field = new FormFieldset ( $ this -> context , $ label , $ callback ) ; return $ this -> addField ( $ field ) ; }
Form fieldset .
45,512
public function staticValue ( $ key , $ label = false , array $ attr = [ ] ) { $ field = $ this -> factory ( 'static' , $ key , $ label , $ attr ) ; return $ this -> addField ( $ field ) ; }
Display a value from the resource but provides no editable field .
45,513
public function link ( $ text , $ href , $ label = false , array $ attr = [ ] ) { $ field = $ this -> factory ( 'link' , false , $ label , array_merge ( array ( 'text' => $ text , 'href' => $ href ) , $ attr ) ) ; return $ this -> addField ( $ field ) ; }
Similar to static but provides a link as well .
45,514
public function checkbox ( $ key , $ text , $ label = null , array $ attr = [ ] ) { $ this -> hiddenField ( $ key , '0' ) ; $ attr [ 'text' ] = $ text ; $ field = $ this -> factory ( 'checkbox' , $ key , $ label , $ attr ) ; return $ this -> addField ( $ field ) ; }
Checkbox field .
45,515
public function fieldsFor ( $ id , $ obj , callable $ callback ) { $ this -> context -> fieldsFor ( $ id , $ obj , $ callback ) ; }
Changes the resource object to another object . Used to generate forms for multiple object at the same times . Objects doesn t have to be of the same type but ID must be unique .
45,516
public function split ( $ separator ) { $ hash = new Hash ( explode ( ( string ) $ separator , ( string ) $ this ) ) ; return $ hash -> map ( function ( $ value ) { return new String ( $ value ) ; } ) ; }
Splits the string
45,517
public function at ( $ start = null , $ length = null ) { return new String ( mb_substr ( ( string ) $ this , $ start , $ length , 'UTF-8' ) ) ; }
Returns part of a string
45,518
protected function getSitemapEntries ( ProfileInterface $ profile ) { $ now = new \ DateTime ( ) ; $ urlEntries = $ profile -> getUrlEntries ( ) ; $ numberOfSitemap = $ this -> getNumberOfSitemap ( $ urlEntries ) ; if ( 1 === $ numberOfSitemap ) { $ this -> writeFile ( $ this -> helper -> getSitemapEntryFilePath ( $ this -> getFilename ( $ profile ) ) , $ this -> render -> renderSitemap ( $ urlEntries ) ) ; return array ( new SitemapEntry ( $ this -> helper -> getSitemapEntryFileUrl ( $ this -> getFilename ( $ profile ) ) , $ now ) ) ; } $ sitemapEntries = array ( ) ; for ( $ number = 0 ; $ number < $ numberOfSitemap ; $ number ++ ) { $ filename = $ this -> getFilename ( $ profile , $ number ) ; $ entries = array_slice ( $ urlEntries , $ number * $ this -> maxPerSitemap , $ this -> maxPerSitemap ) ; $ this -> writeFile ( $ this -> helper -> getSitemapEntryFilePath ( $ filename ) , $ this -> render -> renderSitemap ( $ entries ) ) ; $ sitemapEntries [ ] = new SitemapEntry ( $ this -> helper -> getSitemapEntryFileUrl ( $ filename ) , $ now ) ; } return $ sitemapEntries ; }
Get sitemap entries .
45,519
private function getNumberOfSitemap ( array $ urlEntries ) { $ total = count ( $ urlEntries ) ; if ( $ total <= $ this -> maxPerSitemap ) { return 1 ; } return intval ( ceil ( $ total / $ this -> maxPerSitemap ) ) ; }
Get number of sitemap .
45,520
private function writeFile ( $ path , $ data ) { if ( false === @ file_put_contents ( $ path , $ data ) ) { throw new DumperException ( sprintf ( 'Unable to write file "%s"' , $ path ) ) ; } }
Write file .
45,521
public static function mySQLconnection ( $ array ) { if ( env ( 'APP_ENV' ) === 'local' && in_array ( env ( 'DB_HOST' ) , [ 'localhost' , '127.0.0.1' ] ) ) { $ path = '/Applications/MAMP/tmp/mysql/mysql.sock' ; $ mampSocket = ( file_exists ( $ path ) ) ? $ path : '' ; $ array [ 'unix_socket' ] = env ( 'DB_SOCKET' , $ mampSocket ) ; } return $ array ; }
If on local environment DB_SOCKET is an available . env option if we can find a MAMP socket that s the default
45,522
public function createView ( $ object ) { if ( is_array ( $ object ) ) { return array_map ( [ $ this , 'createView' ] , $ object ) ; } $ view = $ this -> factory -> createView ( $ object ) ; if ( false === $ view instanceof View ) { return $ this -> notSuitableFactoryFor ( $ object ) ; } if ( $ view instanceof RootViewFactoryAware ) { $ view -> setRootViewFactory ( $ this ) ; } return $ view ; }
Create a view for the object allows arrays recursively
45,523
private function notSuitableFactoryFor ( $ object ) { switch ( $ this -> notFoundBehaviour ) { case self :: NOT_FOUND_RETURNS_NULL : return null ; case self :: NOT_FOUND_RETURN_SOURCE : return $ object ; case self :: NOT_FOUND_THROWS_EXCEPTION : default : throw new Exception \ UnsupportedObjectException ( sprintf ( 'Can\'t create a View from object of type "%s"' , is_object ( $ object ) ? get_class ( $ object ) : gettype ( $ object ) ) ) ; } }
Behaviour when a suitable view factory can t be found
45,524
public function getHTML ( ) { $ tag = '<form' ; $ q = $ this -> quoteType ; foreach ( $ this -> attrs as $ name => $ value ) { if ( $ value === true ) $ tag .= " $name" ; elseif ( is_string ( $ value ) ) $ tag .= " {$name}={$q}{$value}{$q}" ; } $ tag .= '>' ; if ( $ this -> hasChildren ( ) ) { for ( $ i = 0 ; $ i < count ( $ this -> children ) ; $ i ++ ) { if ( $ this -> children [ $ i ] instanceof Element \ Datalist ) { $ tag .= $ this -> children [ $ i ] -> getHTML ( ) ; } else { $ tag .= $ this -> decorator -> element ( $ this -> children [ $ i ] -> getHTML ( ) , $ this -> titles [ $ i ] ) ; } } } $ tag .= "</form>" ; return $ this -> decorator -> form ( $ tag ) ; }
Returns the HTML string .
45,525
public function setData ( array $ array ) { foreach ( $ array as $ name => $ value ) { if ( ! isset ( $ this -> nameHash [ $ name ] ) ) { continue ; } $ element = $ this -> nameHash [ $ name ] ; $ element -> setAttribute ( 'value' , ( string ) $ value ) ; } }
Sets the form elements values given an array of name = > value pairs .
45,526
public function setSeparator ( $ separator ) { if ( ! is_string ( $ separator ) ) { throw new Exception \ InvalidArgumentException ( '"' . $ separator . '" is not a valid separator.' ) ; } $ this -> separator = $ separator ; return $ this ; }
Sets a new separator
45,527
public function assert ( $ assertion , $ message ) { $ this -> test -> incrementAssertionCount ( ) ; $ assertion = $ this -> negative ? ! ( ( bool ) $ assertion ) : ( bool ) $ assertion ; if ( $ assertion === false ) { return call_user_func_array ( [ $ this , 'fail' ] , $ message ) ; } return true ; }
Check the resolution of a function .
45,528
private function fail ( ) { $ args = func_get_args ( ) ; $ format = array_shift ( $ args ) ; $ regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/' ; preg_match_all ( $ regex , $ format , $ matches ) ; $ replacements = $ this -> negative ? $ matches [ 'negative' ] : $ matches [ 'positive' ] ; foreach ( $ matches [ 0 ] as $ i => $ match ) { $ format = str_replace ( $ match , $ replacements [ $ i ] , $ format ) ; } $ format = preg_replace ( '/\s+/' , ' ' , $ format ) ; foreach ( $ args as & $ arg ) { if ( is_array ( $ arg ) ) { $ arg = 'Array' ; continue ; } if ( is_object ( $ arg ) ) { $ arg = 'Object of type "' . get_class ( $ arg ) . '"' ; continue ; } if ( $ arg === true ) { $ arg = 'TRUE' ; continue ; } if ( $ arg === false ) { $ arg = 'FALSE' ; continue ; } if ( $ arg === null ) { $ arg = 'NULL' ; continue ; } if ( is_string ( $ arg ) ) { $ arg = '"' . $ arg . '"' ; continue ; } } array_unshift ( $ args , $ format ) ; $ msg = ( new ReflectionFunction ( 'sprintf' ) ) -> invokeArgs ( $ args ) ; throw new AssertionFailureException ( $ msg ) ; }
Convert arguments into a string - safe exception message then throw an assertion failure .
45,529
public function boolean ( ) { $ message = [ '%s is {{not|}} a boolean' , $ this -> value ] ; $ this -> assert ( is_bool ( $ this -> value ) , $ message ) ; return $ this ; }
Assert that the value is a boolean type .
45,530
public function true ( ) { $ message = [ '%s is {{not|}} true' , $ this -> value ] ; $ this -> assert ( ( $ this -> value === true ) , $ message ) ; return $ this ; }
Assert that the value is true .
45,531
public function false ( ) { $ message = [ '%s is {{not|}} false' , $ this -> value ] ; $ this -> assert ( ( $ this -> value === false ) , $ message ) ; return $ this ; }
Assert that the value is false .
45,532
public function equal ( $ value ) { $ message = [ '%s is {{not|}} equal to %s' , $ this -> value , $ value ] ; $ this -> assert ( ( $ this -> value === $ value ) , $ message ) ; return $ this ; }
Assert that two values are equal .
45,533
public function equivalentTo ( $ value ) { $ message = [ '%s is {{not|}} equivalent to %s' , $ this -> value , $ value ] ; $ this -> assert ( ( $ this -> value == $ value ) , $ message ) ; return $ this ; }
Assert that two values are equivalent .
45,534
public function size ( $ len ) { $ len = ( int ) $ len ; if ( is_string ( $ this -> value ) ) { $ message = [ '%s {{does not have|has}} a string length of %s' , $ this -> value , $ len ] ; $ this -> assert ( ( strlen ( $ this -> value ) === $ len ) , $ message ) ; } if ( is_int ( $ this -> value ) ) { $ message = [ 'Integer %s {{does not have|has}} a size of %s' , $ this -> value , $ len ] ; $ this -> assert ( ( $ this -> value === $ len ) , $ message ) ; } if ( is_array ( $ this -> value ) ) { $ message = [ 'Array {{does not have|has}} a size of %s' , $ len ] ; $ this -> assert ( ( count ( $ this -> value ) === $ len ) , $ message ) ; } return $ this ; }
Check the size of the value .
45,535
public function blank ( ) { $ message = [ '%s is {{not|}} empty' , $ this -> value ] ; $ this -> assert ( ( empty ( $ this -> value ) ) , $ message ) ; return $ this ; }
Assert that the value is empty .
45,536
public function anArray ( ) { $ message = [ '%s is {{not|}} an array' , $ this -> value ] ; $ this -> assert ( ( is_array ( $ this -> value ) ) , $ message ) ; return $ this ; }
Assert that the value is an array .
45,537
public function implement ( $ interface ) { $ message = [ 'Class %s {{does not implement|implements}} interface %s' , $ this -> value , $ interface ] ; $ this -> assert ( ( in_array ( $ interface , class_implements ( $ this -> value ) ) ) , $ message ) ; return $ this ; }
Assert that the value implements the given interface .
45,538
public function match ( $ regex ) { $ matches = preg_match ( $ regex , $ this -> value ) ; $ message = [ '%s {{does not match|matches}} the regular expression %s' , $ this -> value , $ regex ] ; $ this -> assert ( ( ! empty ( $ matches ) ) , $ message ) ; return $ this ; }
Assert that the value matches a given regular expression .
45,539
public function addClass ( $ class ) { if ( isset ( $ this -> attr [ 'class' ] ) ) { $ classes = explode ( ' ' , $ this -> attr [ 'class' ] ) ; if ( ! in_array ( $ class , $ classes ) ) { $ classes [ ] = $ class ; } $ this -> attr [ 'class' ] = implode ( ' ' , $ classes ) ; } else { $ this -> attr [ 'class' ] = $ class ; } }
Add class to the class attribute .
45,540
public function removeClass ( $ class ) { if ( isset ( $ this -> attr [ 'class' ] ) ) { $ classes = explode ( ' ' , $ this -> attr [ 'class' ] ) ; if ( in_array ( $ class , $ classes ) ) { $ classes = array_diff ( $ classes , [ $ class ] ) ; } if ( empty ( $ classes ) ) { unset ( $ this -> attr [ 'class' ] ) ; } else { $ this -> attr [ 'class' ] = implode ( ' ' , $ classes ) ; } } }
Remove class from the class attribute .
45,541
public function setValidations ( ArrayObject $ validations ) { foreach ( $ validations as $ param => $ validation ) { $ this -> setValidation ( $ param , $ validation ) ; } return $ this ; }
ajoute plusieur validations
45,542
public function setValidation ( $ param , $ validation ) { $ validation = \ preg_replace ( '`\((?=[^?][^:])`' , '(?:' , $ validation ) ; $ this -> Validations [ $ param ] = $ validation ; return $ this ; }
ajoute une validation
45,543
public static function scaffold ( $ tables = null ) { if ( empty ( $ tables ) ) { if ( ! \ Cli :: option ( 'all' , false ) ) { \ Cli :: write ( 'No table names specified to run scaffolding on.' , 'red' ) ; exit ( ) ; } try { $ list = \ DB :: list_tables ( null , \ Cli :: option ( 'db' , null ) ) ; } catch ( \ FuelException $ e ) { \ Cli :: write ( 'The database driver configured does not support listing tables. Please specify them manually.' , 'red' ) ; exit ( ) ; } $ prefix = \ DB :: table_prefix ( ) ; $ migration = \ Config :: get ( 'migrations.table' , 'migration' ) ; $ tables = array ( ) ; foreach ( $ list as $ table ) { if ( ! empty ( $ prefix ) and strpos ( $ table , $ prefix ) === 0 ) { $ table = substr ( $ table , strlen ( $ prefix ) ) ; } $ table == $ migration or $ tables [ ] = $ table ; } } is_array ( $ tables ) or $ tables = explode ( ',' , $ tables ) ; $ subfolder = \ Cli :: option ( 'crud' ) ? 'crud' : 'orm' ; foreach ( $ tables as $ table ) { \ Oil \ Generate :: $ create_files = array ( ) ; if ( \ Cli :: option ( 'admin' , \ Cli :: option ( 'a' , false ) ) ) { call_user_func ( '\\Oil\\Generate_Admin::forge' , static :: arguments ( $ table ) , $ subfolder ) ; } else { call_user_func ( '\\Oil\\Generate_Scaffold::forge' , static :: arguments ( $ table ) , $ subfolder ) ; } } }
Generate scaffold for a database table .
45,544
protected static function arguments ( $ table ) { try { $ columns = \ DB :: list_columns ( trim ( $ table ) , null , \ Cli :: option ( 'db' , null ) ) ; } catch ( \ Exception $ e ) { \ Cli :: write ( $ e -> getMessage ( ) , 'red' ) ; exit ( ) ; } $ arguments = array ( $ table ) ; $ include_timestamps = false ; $ timestamp_is_int = true ; foreach ( $ columns as $ column ) { isset ( $ column [ 'data_type' ] ) or $ column [ 'data_type' ] = $ column [ 'type' ] ; if ( $ column [ 'name' ] == 'id' ) { continue ; } if ( in_array ( $ column [ 'name' ] , array ( 'created_at' , 'updated_at' ) ) ) { $ include_timestamps = true ; $ timestamp_is_int = $ column [ 'data_type' ] == 'int' ; continue ; } $ constraint = '' ; foreach ( array ( 'length' , 'character_maximum_length' , 'display' ) as $ idx ) { if ( isset ( $ column [ $ idx ] ) and ! in_array ( $ column [ $ idx ] , array ( '65535' , '4294967295' ) ) ) { $ constraint = '[' . $ column [ $ idx ] . ']' ; break ; } } if ( in_array ( $ column [ 'data_type' ] , array ( 'set' , 'enum' ) ) ) { $ constraint = '[' . implode ( ',' , $ column [ 'options' ] ) . ']' ; } $ arguments [ ] = $ column [ 'name' ] . ':' . $ column [ 'data_type' ] . $ constraint ; } \ Cli :: set_option ( 'no-timestamp' , $ include_timestamps === false ) ; \ Cli :: set_option ( 'mysql-timestamp' , $ timestamp_is_int === false ) ; return $ arguments ; }
Construct the argument list
45,545
public static function typed ( string $ type , iterable $ input = [ ] ) : Set { $ resolver = Resolver :: typed ( $ type ) ; return new static ( $ input , $ resolver ) ; }
Set named constructor .
45,546
public function flush ( ) { if ( ! $ this -> config [ "blocking" ] && ! empty ( $ this -> asyncBuffer ) ) { $ wrote = fwrite ( $ this -> destinationHandler , $ this -> asyncBuffer ) ; $ this -> asyncBuffer = substr ( $ this -> asyncBuffer , $ wrote ) ; } return empty ( $ this -> asyncBuffer ) ; }
Forces pushing remaining data from buffer to destination . This method only makes sense in non - blocking mode .
45,547
public function rotate ( $ resetTimer = true ) { if ( ! $ this -> config [ "blocking" ] ) { while ( ! empty ( $ this -> asyncBuffer ) ) { $ this -> flush ( ) ; } } if ( $ resetTimer ) { $ this -> lastRotationTime = time ( ) ; } $ this -> log ( self :: INFO , "Rotating log file..." ) ; fclose ( $ this -> destinationHandler ) ; $ this -> createFileHandler ( ) ; }
Rotate log file
45,548
public function setMaximumLogLevel ( $ level ) { if ( $ level !== null && ! is_numeric ( $ level ) ) { throw new InvalidArgumentException ( "Maximum log level must be a number or null" ) ; } $ this -> config [ "maximumLogLevel" ] = $ level ; }
Every log level contains it s numeric value ( default ones are defined by Table 2 . Syslog Message Severities of RFC 5424 . This method allows to specify maximum log level delivered to destination eg . if you set it to 1 only ALERT and EMERGENCY message will pass .
45,549
public function run ( $ command ) { return $ this -> getGitConsole ( ) -> run ( GitApi :: getBin ( ) . " " . $ command , $ this -> getRepositoryPath ( ) ) ; }
Run a git command in the git repository
45,550
public function getBranchesList ( $ keep_asterisk = false ) { $ branchArray = explode ( "\n" , $ this -> run ( "branch" ) ) ; foreach ( $ branchArray as $ i => & $ branch ) { $ branch = trim ( $ branch ) ; if ( ! $ keep_asterisk ) { $ branch = str_replace ( "* " , "" , $ branch ) ; } if ( $ branch == "" ) { unset ( $ branchArray [ $ i ] ) ; } } return $ branchArray ; }
Runs a git branch call
45,551
protected function anatomy ( ) { $ this -> members = Strings :: splite ( $ this -> key , ' ' ) ; $ this -> command = $ this -> members [ 0 ] ; $ y = '' ; for ( $ i = 1 ; $ i < count ( $ this -> members ) ; $ i ++ ) { $ y .= $ this -> members [ $ i ] . ' ' ; } $ rest2 = [ ] ; $ rest = Strings :: splite ( $ y , '} ' ) ; for ( $ i = 0 ; $ i < count ( $ rest ) - 1 ; $ i ++ ) { $ rest2 [ ] = $ rest [ $ i ] . '}' ; } $ this -> members = $ rest2 ; return $ this -> members ; }
Set members including command and args and options .
45,552
protected function params ( ) { $ params = [ ] ; for ( $ i = 0 ; $ i < count ( $ this -> members ) ; $ i ++ ) { $ params [ ] = $ this -> members [ $ i ] ; } $ this -> params = $ params ; return $ params ; }
get the params from members .
45,553
protected function setParams ( ) { $ this -> params ( ) ; foreach ( $ this -> params as $ key => $ value ) { $ cont = $ this -> strip ( $ value ) ; if ( Strings :: length ( $ cont ) > 2 ) { if ( $ cont [ 0 ] == '-' && $ cont [ 1 ] == '-' ) { $ this -> setOption ( $ cont ) ; } elseif ( $ cont [ 0 ] != '-' && $ cont [ 1 ] != '-' ) { $ this -> setArgument ( $ cont ) ; } } else { $ this -> setArgument ( $ cont ) ; } } }
set the args and options .
45,554
protected function setArgument ( $ arg ) { if ( $ this -> checkDiscription ( $ arg ) ) { $ this -> advanceArg ( $ arg ) ; } else { $ this -> simpleArg ( $ arg ) ; } }
set the args and check if ther is description .
45,555
protected function simpleArg ( $ key , $ desc = '' ) { if ( $ this -> isOption ( $ key ) ) { $ name = substr ( $ key , 0 , - 1 ) ; $ this -> addArgument ( $ name , InputArgument :: OPTIONAL , $ desc ) ; $ this -> addArgumentInput ( $ name , InputArgument :: OPTIONAL , $ desc ) ; } else { $ this -> addArgument ( $ key , InputArgument :: REQUIRED , $ desc ) ; $ this -> addArgumentInput ( $ key , InputArgument :: REQUIRED , $ desc ) ; } }
set simple arg with optional description .
45,556
protected function advanceArg ( $ key ) { $ data = Strings :: splite ( $ key , ' : ' ) ; $ arg = $ data [ 0 ] ; $ desc = $ data [ 1 ] ; $ this -> simpleArg ( $ arg , $ desc ) ; }
set advanced arg with required description .
45,557
protected function addArgumentInput ( $ name , $ requirement , $ description = '' ) { $ this -> inputs [ ] = new Argument ( $ name , $ requirement , $ description ) ; }
add ARgument to inputs array .
45,558
protected function setOption ( $ opt ) { if ( $ this -> checkDiscription ( $ opt ) ) { $ this -> advanceOpt ( $ opt ) ; } else { $ this -> simpleOpt ( $ opt ) ; } }
check if ther is description .
45,559
protected function simpleOpt ( $ opt , $ disc = '' ) { $ type = $ this -> getOptionType ( $ opt ) ; $ key = $ this -> stripOpt ( $ opt ) ; if ( $ type == self :: REQUIRED ) { $ key = substr ( $ key , 0 , - 1 ) ; $ this -> addOption ( $ key , null , InputOption :: VALUE_REQUIRED , $ disc ) ; $ this -> addOptionInput ( $ key , InputOption :: VALUE_REQUIRED , $ disc ) ; } elseif ( $ type == self :: OPTIONAL ) { $ this -> addOption ( $ key , null , InputOption :: VALUE_NONE , $ disc ) ; $ this -> addOptionInput ( $ key , InputOption :: VALUE_NONE , $ disc ) ; } elseif ( $ type == self :: VALUE ) { $ value = $ this -> getOptionalValue ( $ key ) ; $ key = $ this -> getOptionalKeyValue ( $ key ) ; $ this -> addOption ( $ key , null , InputOption :: VALUE_OPTIONAL , $ disc , $ value ) ; $ this -> addOptionInput ( $ key , InputOption :: VALUE_OPTIONAL , $ disc , $ value ) ; } }
set simple option with optional description .
45,560
protected function advanceOpt ( $ opt ) { $ data = Strings :: splite ( $ opt , ' : ' ) ; $ opt = $ data [ 0 ] ; $ disc = $ data [ 1 ] ; $ this -> simpleOpt ( $ opt , $ disc ) ; }
set advanced option with optional description .
45,561
protected function addOptionInput ( $ name , $ requirement = null , $ description = '' , $ value = null ) { $ this -> inputs [ ] = new Option ( $ name , $ requirement , $ description , $ value ) ; }
add Option to inputs array .
45,562
protected function getOptionType ( $ opt ) { if ( substr ( $ opt , - 1 ) == '=' ) { return self :: REQUIRED ; } elseif ( Strings :: contains ( $ opt , '=' ) ) { return self :: VALUE ; } else { return self :: OPTIONAL ; } }
get the type of the option .
45,563
public function info ( $ text , $ sameLine = false ) { $ output = $ this -> console -> info ( $ text ) ; if ( $ sameLine ) { $ this -> console -> write ( $ output ) ; } else { $ this -> console -> line ( $ output ) ; } }
to write text in green color in the console .
45,564
public function title ( $ sub = '' , $ title = 'Vinala Lumos' ) { if ( $ title != '' ) { $ this -> console -> line ( "\n" . $ title ) ; $ underline = '' ; for ( $ i = 0 ; $ i < strlen ( $ title ) ; $ i ++ ) { $ underline .= '=' ; } $ this -> console -> line ( $ underline ) ; } if ( $ sub != '' ) { $ this -> console -> line ( "\n" . $ sub ) ; } }
Show to Vinala lumos title .
45,565
public function confirm ( $ text , $ default = false ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new ConfirmationQuestion ( $ this -> console -> question ( $ text . ' ' ) , $ default ) ; return $ helper -> ask ( $ this -> input , $ this -> output , $ question ) ; }
ask user for confirmation .
45,566
public function hidden ( $ text ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new Question ( $ this -> console -> question ( $ text . ' ' ) ) ; $ question -> setHidden ( true ) ; $ question -> setHiddenFallback ( true ) ; return $ helper -> ask ( $ this -> input , $ this -> output , $ question ) ; }
ask user for password .
45,567
public function table ( $ header , $ data ) { $ table = new Table ( $ this -> output ) ; $ table -> setHeaders ( $ header ) -> setRows ( $ data ) ; $ table -> render ( ) ; }
display Table .
45,568
private function create ( ) : CookieAuthSession { $ response = $ this -> request ( $ this -> endpoint . $ this -> path , [ RequestOptions :: JSON => [ 'username' => $ this -> username , 'password' => $ this -> password , ] , ] ) ; $ body = $ response -> getBody ( ) ; $ body -> seek ( 0 ) ; $ contents = $ body -> getContents ( ) ; $ contents = json_decode ( $ contents , true ) ; if ( isset ( $ contents [ 'session' ] [ 'name' ] , $ contents [ 'session' ] [ 'value' ] ) ) { return new CookieAuthSession ( $ contents [ 'session' ] [ 'name' ] , $ contents [ 'session' ] [ 'value' ] ) ; } throw new \ Exception ( 'Failed to create ' . CookieAuthSession :: class . '.' ) ; }
Creates cookie auth session
45,569
private function request ( $ url , array $ options ) { $ response = $ this -> client -> request ( 'POST' , $ url , $ options ) ; $ body = $ response -> getBody ( ) ; if ( $ response -> getStatusCode ( ) != 200 || ! isset ( $ body ) ) { throw new \ Exception ( 'Failed request to ' . $ this -> endpoint . '.' ) ; } return $ response ; }
Requires a cookie authentication session
45,570
public function isTensideConfigured ( ) { if ( isset ( $ this -> isTensideConfigured ) ) { return $ this -> isTensideConfigured ; } return $ this -> isTensideConfigured = file_exists ( $ this -> home -> tensideDataDir ( ) . DIRECTORY_SEPARATOR . 'tenside.json' ) ; }
Check if a tenside . json is present .
45,571
public function isProjectPresent ( ) { if ( isset ( $ this -> isProjectPresent ) ) { return $ this -> isProjectPresent ; } return $ this -> isProjectPresent = file_exists ( $ this -> home -> homeDir ( ) . DIRECTORY_SEPARATOR . 'composer.json' ) ; }
Check if a project composer . json is present .
45,572
public function isProjectInstalled ( ) { if ( isset ( $ this -> isProjectInstalled ) ) { return $ this -> isProjectInstalled ; } return $ this -> isProjectInstalled = is_dir ( $ this -> home -> homeDir ( ) . DIRECTORY_SEPARATOR . 'vendor' ) ; }
Check if the vendor directory is present .
45,573
public function createFlatArrayWithValuesAsAttributeName ( $ attribute_name ) { $ a = [ ] ; foreach ( $ this -> getCollection ( ) as $ key => $ object ) { $ object_array = $ object -> toArray ( ) ; if ( isset ( $ object_array [ $ attribute_name ] ) ) { $ a [ $ key ] = $ object_array [ $ attribute_name ] ; } } return $ a ; }
solutions for reducing Collection just to one attribute - flat array
45,574
public function getErrorMessage ( bool $ appendPreviousByNewline = false ) : string { $ prev = $ this -> getPrevious ( ) ; if ( null === $ prev ) { return \ sprintf ( '%s(%d): %s' , static :: GetCodeName ( $ this -> getCode ( ) ) , $ this -> getCode ( ) , $ this -> getMessage ( ) ) ; } $ separator = $ appendPreviousByNewline ? "\n" : ' ' ; if ( $ prev instanceof NiirrtyException ) { return \ sprintf ( '%s(%d): %s%s%s' , static :: GetCodeName ( $ this -> getCode ( ) ) , $ this -> getCode ( ) , $ this -> getMessage ( ) , $ separator , $ prev -> getErrorMessage ( $ appendPreviousByNewline ) ) ; } return \ sprintf ( '%s(%d): %s%s%s' , static :: GetCodeName ( $ this -> getCode ( ) ) , $ this -> getCode ( ) , $ this -> getMessage ( ) , $ separator , $ prev -> getMessage ( ) ) ; }
Extends the origin getMessage method so also previous messages are included if defined .
45,575
public function toCustomString ( int $ subExceptionLevel = 0 , string $ indentSpaces = ' ' ) : string { $ msg = \ sprintf ( '%s%s in %s[%d]. %s' , \ str_repeat ( $ indentSpaces , $ subExceptionLevel ) , \ get_class ( $ this ) , $ this -> file , $ this -> line , \ str_replace ( "\n" , "\n" . \ str_repeat ( $ indentSpaces , $ subExceptionLevel ) , $ this -> message ) ) ; $ previous = $ this -> getPrevious ( ) ; if ( null === $ previous || ! ( $ previous instanceof \ Throwable ) ) { return $ msg ; } if ( $ previous instanceof NiirrtyException ) { $ msg .= "\n" . $ previous -> toCustomString ( $ subExceptionLevel + 1 , $ indentSpaces ) ; return $ msg ; } $ msg .= \ sprintf ( "\n%s%s %s in %s[%d]\n %s" , \ str_repeat ( $ indentSpaces , $ subExceptionLevel + 1 ) , \ get_class ( $ previous ) , static :: GetCodeName ( $ previous -> getCode ( ) ) , $ previous -> file , $ previous -> line , \ str_replace ( "\n" , "\n" . \ str_repeat ( $ indentSpaces , $ subExceptionLevel + 1 ) , $ previous -> message ) ) ; return $ msg ; }
Allows the definition of the sub exception level if there is a parent exception that contains this exception .
45,576
public function updatePassword ( UpdateProfilePasswordRequest $ request ) { $ user = $ this -> user -> find ( $ this -> auth -> id ( ) ) ; $ credentials = [ 'id' => $ this -> auth -> id ( ) , 'email' => $ user -> email , 'password' => $ request -> old_password , ] ; if ( ! $ this -> auth -> attempt ( $ credentials ) ) { Flash :: error ( trans ( 'user::messages.invalid old password' ) ) ; return redirect ( ) -> back ( ) ; } $ this -> user -> update ( $ request -> all ( ) , $ this -> auth -> id ( ) ) ; flash ( trans ( 'user::messages.password updated' ) ) ; return redirect ( ) -> back ( ) ; }
Update the password of the given user .
45,577
private function isColumnInIndex ( TableInterface $ table , ColumnInterface $ column ) { $ indexes = $ table -> getAddedIndexes ( ) ; if ( in_array ( $ column -> getName ( ) , $ table -> getPrimaryKey ( ) ) ) { return true ; } foreach ( $ indexes as $ columnNames ) { if ( in_array ( $ column -> getName ( ) , $ columnNames ) ) { return true ; } } return false ; }
Check if a column is marked as index
45,578
protected function buildTopMatter ( ) { $ topMatterBuilder = SectionBuilder :: begin ( ) -> setType ( SectionBuilder :: TYPE_SPAN ) ; if ( $ this -> breadCrumbTitles !== [ ] ) { $ breadCrumbsBuilder = SectionBuilder :: begin ( ) -> setType ( SectionBuilder :: TYPE_BREADCRUMBS ) ; foreach ( $ this -> breadCrumbTitles as $ index => $ breadCrumbTitle ) { $ breadCrumbLink = $ this -> breadCrumbLinks [ $ index ] ; if ( $ breadCrumbLink !== '' ) { $ breadCrumbsBuilder -> addWritable ( LinkBuilder :: begin ( ) -> setText ( $ breadCrumbTitle ) -> setURI ( $ breadCrumbLink ) -> build ( ) ) ; } else { $ breadCrumbsBuilder -> addContent ( $ breadCrumbTitle ) ; } } $ topMatterBuilder -> addWritable ( $ breadCrumbsBuilder -> build ( ) ) ; } if ( $ this -> header !== null ) { $ topMatterBuilder -> addWritable ( SectionBuilder :: begin ( ) -> setType ( SectionBuilder :: TYPE_HEADER ) -> addLiteralContent ( $ this -> header ) -> build ( ) ) ; } $ topMatterBuilder -> addWritable ( SectionBuilder :: begin ( ) -> setType ( SectionBuilder :: TYPE_DIV ) -> setId ( 'top-filters' ) -> build ( ) ) ; if ( $ this -> subHeader !== null ) { $ topMatterBuilder -> addWritable ( SectionBuilder :: begin ( ) -> setType ( SectionBuilder :: TYPE_SUBHEADER ) -> addLiteralContent ( $ this -> subHeader ) -> build ( ) ) ; } return $ topMatterBuilder -> build ( ) ; }
Build the bread crumbs header sub header etc . of the page .
45,579
protected function validateRenderer ( ) { if ( $ this -> renderer === null ) { $ settingsInstance = $ this -> getSettingsInstance ( ) ; if ( $ this -> type === static :: TYPE_EXCEL ) { $ writerClasses = $ settingsInstance -> getDefaultExcelWriterClasses ( ) ; $ rendererClass = $ settingsInstance -> getDefaultExcelRendererClass ( ) ; } elseif ( $ this -> type === static :: TYPE_PDF ) { $ writerClasses = $ settingsInstance -> getDefaultPDFWriterClasses ( ) ; $ rendererClass = $ settingsInstance -> getDefaultPDFRendererClass ( ) ; } else { $ writerClasses = $ settingsInstance -> getDefaultWriterClasses ( ) ; $ rendererClass = $ settingsInstance -> getDefaultRendererClass ( ) ; } $ writerInstances = [ ] ; foreach ( $ writerClasses as $ writerClass ) { $ writerInstances [ ] = new $ writerClass ( ) ; } $ this -> renderer = new $ rendererClass ( $ writerInstances ) ; } }
Construct a renderer from setting defaults if none has been provided .
45,580
protected function validateInitializer ( ) { if ( $ this -> renderer === null ) { $ settingsInstance = $ this -> getSettingsInstance ( ) ; if ( $ this -> type === static :: TYPE_EXCEL ) { $ initializerClass = $ settingsInstance -> getDefaultExcelInitializerClass ( ) ; } elseif ( $ this -> type === static :: TYPE_PDF ) { $ initializerClass = $ settingsInstance -> getDefaultPDFInitializerClass ( ) ; } else { $ initializerClass = $ settingsInstance -> getDefaultInitializerClass ( ) ; } $ this -> initializer = new $ initializerClass ; } }
Construct an initializer from setting defaults if none has been provided .
45,581
public function validate ( string $ key , array $ scope = [ ] , array $ input = [ ] ) : void { $ value = $ key == '*' ? '*' : $ scope [ $ key ] ?? null ; ( $ this -> validate ) ( $ value , $ key , $ scope , $ input ) ; }
Execute the validate callable . Inject the value to validate the key to validate within the injected scope and the whole input .
45,582
protected function getService ( ) { if ( ! isset ( $ this -> service ) ) { $ this -> service = $ this -> getServiceLocator ( ) -> get ( $ this -> getModuleNamespace ( ) . '\Service\\' . $ this -> getEntityName ( ) ) ; } return $ this -> service ; }
Retrieve the service
45,583
public static function Refco ( $ phpa , $ tc , $ rh , $ wl , & $ refa , & $ refb ) { $ optic ; $ p ; $ t ; $ r ; $ w ; $ ps ; $ pw ; $ tk ; $ wlsq ; $ gamma ; $ beta ; $ optic = ( $ wl <= 100.0 ) ; $ t = max ( $ tc , - 150.0 ) ; $ t = min ( $ t , 200.0 ) ; $ p = max ( $ phpa , 0.0 ) ; $ p = min ( $ p , 10000.0 ) ; $ r = max ( $ rh , 0.0 ) ; $ r = min ( $ r , 1.0 ) ; $ w = max ( $ wl , 0.1 ) ; $ w = min ( $ w , 1e6 ) ; if ( $ p > 0.0 ) { $ ps = pow ( 10.0 , ( 0.7859 + 0.03477 * $ t ) / ( 1.0 + 0.00412 * $ t ) ) * ( 1.0 + $ p * ( 4.5e-6 + 6e-10 * $ t * $ t ) ) ; $ pw = $ r * $ ps / ( 1.0 - ( 1.0 - $ r ) * $ ps / $ p ) ; } else { $ pw = 0.0 ; } $ tk = $ t + 273.15 ; if ( $ optic ) { $ wlsq = $ w * $ w ; $ gamma = ( ( 77.53484e-6 + ( 4.39108e-7 + 3.666e-9 / $ wlsq ) / $ wlsq ) * $ p - 11.2684e-6 * $ pw ) / $ tk ; } else { $ gamma = ( 77.6890e-6 * $ p - ( 6.3938e-6 - 0.375463 / $ tk ) * $ pw ) / $ tk ; } $ beta = 4.4474e-6 * $ tk ; if ( ! $ optic ) $ beta -= 0.0074 * $ pw * $ beta ; $ refa = $ gamma * ( 1.0 - $ beta ) ; $ refb = - $ gamma * ( $ beta - $ gamma / 2.0 ) ; }
- - - - - - - - - i a u R e f c o - - - - - - - - -
45,584
public function getAnswers ( \ Composer \ IO \ IOInterface $ io , array $ questions ) : array { $ answers = [ ] ; foreach ( $ questions as $ key => $ question ) { $ answers [ $ key ] = $ io -> ask ( $ question -> getQuestion ( ) , $ question -> getDefault ( ) ) ; } return $ answers ; }
Iterates over the given questions and uses them to ask the questions via the given io and feed with the defaults .
45,585
private function validateTimezoneTime ( int $ hour , int $ minutes ) : bool { if ( ! $ this -> validateHour ( $ hour ) ) { return false ; } if ( ! $ this -> validateMinutes ( $ minutes ) ) { return false ; } return true ; }
Validates timezone time
45,586
public function childElementtypesAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ elementSourceManager = $ this -> get ( 'phlexible_element.element_source_manager' ) ; $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ iconResolver = $ this -> get ( 'phlexible_element.icon_resolver' ) ; $ elementtype = $ elementSourceManager -> findElementtype ( $ id ) ; $ childElementtypes = $ elementService -> findAllowedChildren ( $ elementtype ) ; $ data = [ ] ; foreach ( $ childElementtypes as $ childElementtype ) { $ data [ $ childElementtype -> getTitle ( ) . $ childElementtype -> getId ( ) ] = [ 'id' => $ childElementtype -> getId ( ) , 'title' => $ childElementtype -> getTitle ( ) , 'icon' => $ iconResolver -> resolveElementtype ( $ childElementtype ) , ] ; } ksort ( $ data ) ; $ data = array_values ( $ data ) ; return new JsonResponse ( [ 'elementtypes' => $ data ] ) ; }
List all element child elementtypes .
45,587
public function childElementsAction ( Request $ request ) { $ tid = $ request -> get ( 'tree_id' ) ; $ layoutareaId = $ request -> get ( 'layoutarea_id' ) ; $ language = $ request -> get ( 'language' , 'de' ) ; $ translator = $ this -> get ( 'translator' ) ; $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; $ teaserManager = $ this -> get ( 'phlexible_teaser.teaser_manager' ) ; $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ iconResolver = $ this -> get ( 'phlexible_element.icon_resolver' ) ; $ data = [ ] ; $ data [ ] = [ 'id' => '0' , 'title' => $ translator -> trans ( 'elements.first' , [ ] , 'gui' ) , 'icon' => $ iconResolver -> resolveIcon ( '_top.gif' ) , ] ; $ tree = $ treeManager -> getByNodeId ( $ tid ) ; $ treeNode = $ tree -> get ( $ tid ) ; $ treeNodePath = $ tree -> getPath ( $ treeNode ) ; $ layoutarea = $ elementtypeService -> findElementtype ( $ layoutareaId ) ; $ teasers = $ teaserManager -> findForLayoutAreaAndTreeNodePath ( $ layoutarea , $ treeNodePath ) ; foreach ( $ teasers as $ teaser ) { $ teaserElement = $ elementService -> findElement ( $ teaser -> getTypeId ( ) ) ; $ teaserElementVersion = $ elementService -> findLatestElementVersion ( $ teaserElement ) ; $ data [ ] = [ 'id' => $ teaser -> getId ( ) , 'title' => $ teaserElementVersion -> getBackendTitle ( $ language ) , 'icon' => $ iconResolver -> resolveTeaser ( $ teaser , $ language ) , ] ; } return new JsonResponse ( [ 'elements' => $ data ] ) ; }
List all child element types .
45,588
protected function wrapCursor ( \ RiakCursor $ cursor , $ query , $ fields ) { return new LoggableCursor ( $ this , $ cursor , $ query , $ fields , $ this -> numRetries , $ this -> loggerCallable ) ; }
Wraps a RiakCursor instance with a LoggableCursor .
45,589
public function setMaximumLength ( $ maximumLength ) { if ( $ maximumLength <= $ this -> minimalLength ) { throw new Exception \ InvalidArgumentException ( 'Maximum length must be larger than minimal length.' ) ; } $ this -> maximumLength = $ maximumLength ; return $ this ; }
Sets the MaximumLength value .
45,590
public function before_insert ( Orm \ Model $ obj ) { if ( $ obj instanceof Orm \ Model_Temporal ) { if ( $ obj -> { $ obj -> temporal_property ( 'end_column' ) } !== $ obj -> temporal_property ( 'max_timestamp' ) ) { return false ; } } if ( $ user_id = \ Auth :: get_user_id ( ) ) { $ obj -> { $ this -> _property } = $ user_id [ 1 ] ; } }
Sets the CreatedBy property to the current user id
45,591
public function load ( $ resource , $ type = null ) { $ routes = new RouteCollection ( ) ; $ pattern = '/_pygments_bundle/style.css' ; $ defaults = array ( '_controller' => 'CypressPygmentsElephantBundle:Main:css' , ) ; $ route = new Route ( $ pattern , $ defaults ) ; $ routes -> add ( 'pygments_bundle_style' , $ route ) ; return $ routes ; }
Loads a resource
45,592
public function actionAssign ( $ id ) { $ model = Yii :: createObject ( [ 'class' => Assignment :: className ( ) , 'user_id' => $ id , ] ) ; if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) && $ model -> updateAssignments ( ) ) { } return \ matacms \ rbac \ widgets \ Assignments :: widget ( [ 'model' => $ model , ] ) ; }
Show form with auth items for user .
45,593
public static function getBytes ( $ value ) { $ value = trim ( $ value ) ; $ unit = $ value { strlen ( $ value ) - 1 } ; $ value = floatval ( $ value ) ; switch ( strtolower ( $ unit ) ) { case 'g' : $ multiplier = 1073741824 ; break ; case 'm' : $ multiplier = 1048576 ; break ; case 'k' : $ multiplier = 1024 ; break ; default : ExceptionHandler :: notice ( 'Number::getBytes() expects unit to be either "g", "m" or "k"' ) ; $ multiplier = 1 ; } return $ multiplier * $ value ; }
Get the number of bytes in a pretty - formated binary size string .
45,594
public static function formatNumber ( $ number , $ decimals = 0 , $ invalid = '-' ) { if ( ! is_numeric ( $ number ) ) return $ invalid ; $ locale = localeconv ( ) ; return number_format ( $ number , $ decimals , $ locale [ 'decimal_point' ] , $ locale [ 'thousands_sep' ] ) ; }
Locale aware number - format .
45,595
public static function formatTime ( $ format , $ time = null ) { if ( empty ( $ time ) ) $ time = time ( ) ; if ( PHP_OS == 'WINNT' ) { $ mapping = [ '%C' => sprintf ( '%02d' , date ( 'Y' , $ time ) / 100 ) , '%D' => '%m/%d/%y' , '%e' => sprintf ( '%\' 2d' , date ( 'j' , $ time ) ) , '%h' => '%b' , '%n' => "\n" , '%r' => date ( 'h:i:s' , $ time ) . ' %p' , '%R' => date ( 'H:i' , $ time ) , '%t' => "\t" , '%T' => '%H:%M:%S' , '%u' => ( ( $ w = date ( 'w' , $ time ) ) ? $ w : 7 ) ] ; $ format = str_replace ( array_keys ( $ mapping ) , array_values ( $ mapping ) , $ format ) ; } return strftime ( $ format , $ time ) ; }
Format timestamp as a human - readable string .
45,596
public static function isValidTelephoneNumber ( $ telephone ) { $ numbers = str_split ( $ telephone ) ; $ nums = [ ] ; foreach ( $ numbers as $ number ) { if ( ctype_digit ( $ number ) ) { $ nums [ ] = $ number ; } } if ( count ( $ nums ) > 8 ) { return true ; } return false ; }
Check if a phone number has at least 8 numbers .
45,597
public static function formatSocialNumber ( $ number ) { assert ( 'is_integer($number)' ) ; if ( ! is_integer ( $ number ) ) return $ number ; if ( $ number > 10000000 ) { $ number = round ( $ number / 1000000 ) . 'M' ; } elseif ( $ number > 1000000 ) { $ number = round ( $ number / 1000000 , 1 ) . 'M' ; } elseif ( $ number > 10000 ) { $ number = round ( $ number / 1000 ) . 'K' ; } elseif ( $ number > 1000 ) { $ number = round ( $ number / 1000 , 1 ) . 'K' ; } return $ number ; }
Formats the numer to populate 1 10 100 1 . 1K 10K 1 . 1M 10M
45,598
protected function handleSignal ( int $ signo , $ siginfo ) : void { $ this -> log ( "Signal received: $signo" , LOG_DEBUG , "syslog" ) ; if ( $ signo === SIGTERM || $ signo === SIGINT || $ signo === SIGQUIT ) { $ this -> log ( "Termination signal received. Shutting down." , LOG_INFO , [ "syslog" , STDOUT ] , true ) ; $ this -> shutdown ( ) ; } elseif ( $ signo === SIGHUP ) { $ this -> config -> reload ( ) ; } }
An overridable function for signal handling
45,599
public function toArray ( $ recursive = true ) { $ values = $ this -> values ; if ( ! $ recursive ) { return $ values ; } foreach ( $ values as $ key => $ value ) { if ( gettype ( $ value ) === 'object' ) { if ( $ value instanceof Hash ) { $ value = $ value -> toArray ( $ recursive ) ; } } $ values [ $ key ] = $ value ; } return $ values ; }
Converts hash to array