idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
6,600
|
protected static function getDefaultRoutes ( ) { if ( self :: $ _defaultRoutes === null ) { $ manager = self :: getAuthManager ( ) ; $ roles = $ manager -> defaultRoles ; if ( $ manager -> cache && ( $ routes = $ manager -> cache -> get ( $ roles ) ) !== false ) { self :: $ _defaultRoutes = $ routes ; } else { $ permissions = self :: $ _defaultRoutes = [ ] ; foreach ( $ roles as $ role ) { $ permissions = array_merge ( $ permissions , $ manager -> getPermissionsByRole ( $ role ) ) ; } foreach ( $ permissions as $ item ) { if ( $ item -> name [ 0 ] === '/' ) { self :: $ _defaultRoutes [ $ item -> name ] = true ; } } if ( $ manager -> cache ) { $ manager -> cache -> set ( $ roles , self :: $ _defaultRoutes , $ manager -> cacheDuration , new TagDependency ( [ 'tags' => $ manager -> cacheTag ] ) ) ; } } } return self :: $ _defaultRoutes ; }
|
Get assigned routes by default roles
|
6,601
|
public static function getRoutesByUser ( $ userId ) { if ( ! isset ( self :: $ _userRoutes [ $ userId ] ) ) { $ manager = self :: getAuthManager ( ) ; if ( $ manager -> cache && ( $ routes = $ manager -> cache -> get ( [ __METHOD__ , $ userId ] ) ) !== false ) { self :: $ _userRoutes [ $ userId ] = $ routes ; } else { $ routes = static :: getDefaultRoutes ( ) ; foreach ( $ manager -> getPermissionsByUser ( $ userId ) as $ item ) { if ( $ item -> name [ 0 ] === '/' ) { $ routes [ $ item -> name ] = true ; } } self :: $ _userRoutes [ $ userId ] = $ routes ; if ( $ manager -> cache ) { $ manager -> cache -> set ( [ __METHOD__ , $ userId ] , $ routes , $ manager -> cacheDuration , new TagDependency ( [ 'tags' => $ manager -> cacheTag ] ) ) ; } } } return self :: $ _userRoutes [ $ userId ] ; }
|
Get assigned routes of user .
|
6,602
|
protected function setIo ( InputInterface $ input , OutputInterface $ output ) { $ this -> input = $ input ; $ this -> output = $ output ; return $ this ; }
|
Attach IO to command for easier access between methods .
|
6,603
|
protected function createGulpProcess ( $ task , array $ options = [ ] ) { $ config = $ this -> container [ 'config' ] ; return ProcessBuilder :: create ( array_flatten ( [ $ config [ 'gulp.bin' ] , $ task , $ options , '--source' , $ config [ 'source.directory' ] , '--dest' , $ config [ 'build.directory' ] , '--gulpfile' , $ config [ 'source.directory' ] . DIRECTORY_SEPARATOR . $ config [ 'gulp.file' ] , '--phpwd' , getcwd ( ) , '--color' , ] ) ) -> getProcess ( ) ; }
|
Create a process builder for the given gulp task .
|
6,604
|
public static function collect ( ) { $ params = func_get_args ( ) ; $ scriptFeatures = array ( ) ; foreach ( $ params as $ object ) { if ( $ object instanceof ScriptFeature ) { $ scriptFeatures = static :: addScriptFeature ( $ scriptFeatures , $ object ) ; } else if ( $ object instanceof ScriptFeatureable ) { $ scriptFeatures = static :: addScriptFeature ( $ scriptFeatures , $ object -> getScriptFeatures ( ) ) ; } else if ( is_array ( $ object ) ) { foreach ( $ object as $ subObject ) { $ scriptFeatures = static :: addScriptFeature ( $ scriptFeatures , static :: collect ( $ subObject ) ) ; } } } return $ scriptFeatures ; }
|
Collect the Script Features of the given objects
|
6,605
|
public static function addScriptFeature ( array $ scriptFeatures , $ newScriptFeatures ) { if ( ! $ newScriptFeatures ) { return $ scriptFeatures ; } if ( $ newScriptFeatures instanceof ScriptFeature ) { if ( ! in_array ( $ newScriptFeatures , $ scriptFeatures , true ) ) { array_push ( $ scriptFeatures , $ newScriptFeatures ) ; } } else if ( is_array ( $ newScriptFeatures ) ) { foreach ( $ newScriptFeatures as $ newScriptFeature ) { $ scriptFeatures = static :: addScriptFeature ( $ scriptFeatures , $ newScriptFeature ) ; } } return $ scriptFeatures ; }
|
Add one or more Script Features to an Array of Features if they are not already contained
|
6,606
|
protected function loadGlobal ( $ group ) { if ( ! isset ( $ GLOBALS [ $ group ] ) ) { $ this -> throwError ( Message :: get ( Message :: CONFIG_GLOBAL_UNKNOWN , $ group ) , Message :: CONFIG_GLOBAL_UNKNOWN ) ; } $ this -> config -> addNode ( $ group , $ GLOBALS [ $ group ] ) ; return $ this ; }
|
Load super globals
|
6,607
|
protected function getGroupName ( $ id ) { return explode ( $ this -> config -> getDelimiter ( ) , ltrim ( $ id , $ this -> config -> getDelimiter ( ) ) ) [ 0 ] ; }
|
Get group name
|
6,608
|
private function isFilterable ( $ filter ) { if ( is_string ( $ filter ) && ! class_exists ( $ filter ) ) { throw new Exceptions \ InvalidFilterException ( "The [$filter] class does not exits." ) ; } if ( ! in_array ( Filterable :: class , class_implements ( $ filter ) ) ) { throw new Exceptions \ InvalidFilterException ( 'The filter must be a Closure or a class implementing the Filterable interface.' ) ; } }
|
Check if filter is filterable .
|
6,609
|
protected function advance ( ) { $ this -> cursor = $ this -> token -> getEnd ( ) ; return $ this -> token = $ this -> lexer -> readToken ( $ this -> cursor ) ; }
|
Moves the internal parser object to the next lexed token .
|
6,610
|
protected function skip ( $ type ) { if ( $ match = ( $ this -> token -> getType ( ) === $ type ) ) { $ this -> advance ( ) ; } return $ match ; }
|
If the next token is of the given kind return true after advancing the parser . Otherwise do not change the parser state and return false .
|
6,611
|
protected function expect ( $ type ) { if ( $ this -> token -> getType ( ) !== $ type ) { throw new \ Exception ( sprintf ( 'Expected %s, found %s' , Token :: typeToString ( $ type ) , ( string ) $ this -> token ) ) ; } $ token = $ this -> token ; $ this -> advance ( ) ; return $ token ; }
|
If the next token is of the given kind return that token after advancing the parser . Otherwise do not change the parser state and return false .
|
6,612
|
protected function expectKeyword ( $ value ) { if ( $ this -> token -> getType ( ) !== Token :: NAME_TYPE || $ this -> token -> getValue ( ) !== $ value ) { throw new \ Exception ( sprintf ( 'Expected %s, found %s' , $ value , $ this -> token -> getDescription ( ) ) ) ; } return $ this -> advance ( ) ; }
|
If the next token is a keyword with the given value return that token after advancing the parser . Otherwise do not change the parser state and return false .
|
6,613
|
protected function unexpected ( Token $ atToken = NULL ) { $ token = $ atToken ? : $ this -> token ; return new \ Exception ( sprintf ( 'Unexpected %s' , $ token -> getDescription ( ) ) ) ; }
|
Helper protected function for creating an error when an unexpected lexed token is encountered .
|
6,614
|
protected function many ( $ openKind , $ parseFn , $ closeKind ) { $ this -> expect ( $ openKind ) ; $ nodes = [ $ parseFn ( $ this ) ] ; while ( ! $ this -> skip ( $ closeKind ) ) { array_push ( $ nodes , $ parseFn ( $ this ) ) ; } return $ nodes ; }
|
Returns a non - empty list of parse nodes determined by the parseFn .
|
6,615
|
public function setFilters ( array $ filters ) { if ( empty ( $ this -> filters ) ) { $ this -> filters = $ this -> getDefaultFilters ( ) ; } $ this -> filters = array_merge ( $ this -> filters , $ filters ) ; return $ this ; }
|
Set filters .
|
6,616
|
public function sanitize ( array $ data , array $ rules = [ ] , array $ filters = [ ] ) { $ this -> setRules ( $ rules ) ; $ this -> setFilters ( $ filters ) ; foreach ( $ data as $ name => $ value ) { $ data [ $ name ] = $ this -> sanitizeAttribute ( $ name , $ value ) ; } return $ data ; }
|
Sanitize the given data .
|
6,617
|
protected function sanitizeAttribute ( $ attribute , $ value ) { foreach ( $ this -> rules -> get ( $ attribute ) as $ rule ) { $ value = $ this -> applyFilter ( $ rule [ 'name' ] , $ value , $ rule [ 'options' ] ) ; } return $ value ; }
|
Sanitize the given attribute
|
6,618
|
protected function applyFilter ( $ name , $ value , $ options = [ ] ) { $ this -> hasFilter ( $ name ) ; if ( empty ( $ value ) ) return $ value ; $ filter = $ this -> filters [ $ name ] ; if ( $ filter instanceof Closure ) { return call_user_func_array ( $ filter , compact ( 'value' , 'options' ) ) ; } $ filterable = new $ filter ; return $ filterable -> filter ( $ value , $ options ) ; }
|
Apply the given filter by its name .
|
6,619
|
private function getDefaultFilters ( ) { return [ 'capitalize' => Filters \ CapitalizeFilter :: class , 'email' => Filters \ EmailFilter :: class , 'escape' => Filters \ EscapeFilter :: class , 'format_date' => Filters \ FormatDateFilter :: class , 'lowercase' => Filters \ LowercaseFilter :: class , 'slug' => Filters \ SlugFilter :: class , 'trim' => Filters \ TrimFilter :: class , 'uppercase' => Filters \ UppercaseFilter :: class , 'url' => Filters \ UrlFilter :: class , ] ; }
|
Get default filters .
|
6,620
|
public static function getURL ( $ section , $ flags = 0x000000 , Array $ queryVars = array ( ) ) { if ( $ section === NULL ) { $ url = $ _SERVER [ 'PHP_SELF' ] ; if ( ! isset ( $ _SERVER [ 'PHP_SELF' ] ) ) { throw new \ Psc \ Exception ( 'SERVER[PHP_SELF] not set!' ) ; } } elseif ( $ section instanceof Routable ) { return $ section -> getRoutingURL ( ) ; } else { $ url = $ section ; } if ( $ flags & self :: ENV_QUERY_VARS ) { $ queryVars = ( array ) $ _GET ; } elseif ( $ flags & self :: MERGE_QUERY_VARS ) { $ queryVars = array_merge ( ( array ) $ _GET , $ queryVars ) ; } elseif ( $ flags & self :: MY_QUERY_VARS ) { $ queryVars = ( array ) $ queryVars ; } $ queryVars = array_filter ( $ queryVars , create_function ( '$a' , 'return $a != ""; ' ) ) ; if ( count ( $ queryVars ) > 0 ) { if ( mb_substr ( $ url , - 1 ) != '/' && mb_substr ( $ url , - 5 ) != '.html' && mb_substr ( $ url , - 4 ) != '.php' ) $ url .= '/' ; $ url .= '?' ; $ url .= http_build_query ( $ queryVars ) ; } if ( $ flags & self :: ABSOLUTE ) $ url = self :: absolute ( $ url ) ; return $ url ; }
|
Konstruiert eine URL
|
6,621
|
public function create ( $ token , array $ properties = array ( ) , $ customer = null ) { $ parameters = array_merge ( [ 'paymentMethodNonce' => $ token , ] , $ properties ) ; $ response = BraintreeCustomer :: create ( $ parameters ) ; return $ response ; }
|
Subscribe to the plan for the first time .
|
6,622
|
public function addRadioButton ( CheckBox $ radioButton ) { if ( ! in_array ( $ radioButton , $ this -> radioButtons , true ) ) { array_push ( $ this -> radioButtons , $ radioButton ) ; } return $ this ; }
|
Add a new RadioButton
|
6,623
|
protected function prepareRadioButtonIdsConstant ( Script $ script ) { $ radioButtonIds = array ( ) ; foreach ( $ this -> radioButtons as $ radioButton ) { $ radioButtonIds [ $ radioButton -> getName ( ) ] = Builder :: getId ( $ radioButton -> getQuad ( ) ) ; } $ script -> addScriptConstant ( $ this -> getRadioButtonIdsConstantName ( ) , $ radioButtonIds ) ; return $ this ; }
|
Prepare the Constant containing the RadioButton Ids
|
6,624
|
protected function prepareOnRadioButtonClickFunction ( Script $ script ) { $ script -> addScriptFunction ( self :: FUNCTION_ON_RADIO_BUTTON_CLICK , "Void " . self :: FUNCTION_ON_RADIO_BUTTON_CLICK . "(CMlQuad _RadioButtonQuad, CMlEntry _RadioButtonGroupEntry, Text[Text] _RadioButtonIds) { // update group entry with name of selected radio button declare " . CheckBoxFeature :: VAR_CHECKBOX_ENABLED . " as RadioButtonEnabled for _RadioButtonQuad = False; if (_RadioButtonGroupEntry != Null) { declare RadioButtonGroupValue = \"\"; if (RadioButtonEnabled && _RadioButtonIds.exists(_RadioButtonQuad.ControlId)) { RadioButtonGroupValue = _RadioButtonIds.keyof(_RadioButtonQuad.ControlId); } _RadioButtonGroupEntry.Value = RadioButtonGroupValue; } // disable other radio buttons if (RadioButtonEnabled) { foreach (OtherRadioButtonId in _RadioButtonIds) { declare OtherRadioButtonQuad <=> (Page.GetFirstChild(OtherRadioButtonId) as CMlQuad); if (OtherRadioButtonQuad != Null && OtherRadioButtonQuad != _RadioButtonQuad) { declare " . CheckBoxFeature :: VAR_CHECKBOX_ENABLED . " as OtherRadioButtonEnabled for OtherRadioButtonQuad = False; if (OtherRadioButtonEnabled) { " . CheckBoxFeature :: FUNCTION_UPDATE_QUAD_DESIGN . "(OtherRadioButtonQuad); } } } }}" ) ; return $ this ; }
|
Build the RadioButton click handler function
|
6,625
|
protected function prepareRadioButtonClickScript ( Script $ script ) { $ script -> appendGenericScriptLabel ( ScriptLabel :: MOUSECLICK2 , "if (" . $ this -> getRadioButtonIdsConstantName ( ) . ".exists(Event.ControlId)) { declare RadioButtonQuad <=> (Event.Control as CMlQuad); declare RadioButtonGroupEntry <=> (Page.GetFirstChild(\"" . Builder :: getId ( $ this -> entry ) . "\") as CMlEntry); " . self :: FUNCTION_ON_RADIO_BUTTON_CLICK . "(RadioButtonQuad, RadioButtonGroupEntry, " . $ this -> getRadioButtonIdsConstantName ( ) . ");}" ) ; return $ this ; }
|
Prepare the script for RadioButton clicks
|
6,626
|
protected function configureOutput ( ) { $ this -> output = new ConsoleOutput ( ) ; $ this -> output -> getFormatter ( ) -> setStyle ( 'path' , new OutputFormatterStyle ( 'green' , null , [ 'bold' ] ) ) ; $ this -> output -> getFormatter ( ) -> setStyle ( 'time' , new OutputFormatterStyle ( 'cyan' , null , [ 'bold' ] ) ) ; $ this -> output -> getFormatter ( ) -> setStyle ( 'b' , new OutputFormatterStyle ( null , null , [ 'bold' ] ) ) ; }
|
Configure the console output with custom styles .
|
6,627
|
protected function loadExternalConfig ( ) { $ config = new Repository ( static :: getDefaultConfig ( ) ) ; $ filesystem = new Filesystem ( ) ; foreach ( $ this -> getConfigFiles ( $ filesystem ) as $ filename ) { $ this -> output -> writeln ( "<info>Reading config from <path>{$filename}</path></info>" ) ; if ( $ filesystem -> extension ( $ filename ) == 'php' ) { $ configValues = $ filesystem -> getRequire ( $ filename ) ; } else { $ configValues = Yaml :: parse ( $ filesystem -> get ( $ filename ) ) ; } $ config -> set ( array_dot ( $ configValues ) ) ; } $ this -> container -> instance ( 'config' , $ config ) ; }
|
Load the external config files specified by the command line option .
|
6,628
|
protected function getConfigFiles ( $ files , array $ defaults = [ 'steak.yml' , 'steak.php' ] ) { $ option = ( new ArgvInput ( ) ) -> getParameterOption ( [ '--config' , '-c' ] ) ; if ( ! $ option ) { foreach ( $ defaults as $ default ) { if ( $ files -> exists ( $ default ) ) { $ option = ( $ option ? ',' : '' ) . $ default ; } } } return $ option ? explode ( ',' , $ option ) : [ ] ; }
|
Parse the command line option for config file to use .
|
6,629
|
public function registerCommand ( $ commandClass ) { $ command = $ this -> container -> make ( $ commandClass ) ; $ command -> setContainer ( $ this -> container ) ; return $ this -> symfony -> add ( $ command ) ; }
|
Register a single command .
|
6,630
|
public function setScriptInclude ( $ file , $ namespace = null ) { if ( $ file instanceof ScriptInclude ) { $ scriptInclude = $ file ; } else { $ scriptInclude = new ScriptInclude ( $ file , $ namespace ) ; } $ this -> includes [ $ scriptInclude -> getNamespace ( ) ] = $ scriptInclude ; return $ this ; }
|
Set a Script Include
|
6,631
|
public function addScriptConstant ( $ name , $ value = null ) { if ( $ name instanceof ScriptConstant ) { $ scriptConstant = $ name ; } else { $ scriptConstant = new ScriptConstant ( $ name , $ value ) ; } if ( ! in_array ( $ scriptConstant , $ this -> constants ) ) { array_push ( $ this -> constants , $ scriptConstant ) ; } return $ this ; }
|
Add a Script Constant
|
6,632
|
public function addScriptFunction ( $ name , $ text = null ) { if ( $ name instanceof ScriptFunction ) { $ scriptFunction = $ name ; } else { $ scriptFunction = new ScriptFunction ( $ name , $ text ) ; } if ( ! in_array ( $ scriptFunction , $ this -> functions ) ) { array_push ( $ this -> functions , $ scriptFunction ) ; } return $ this ; }
|
Add a Script Function
|
6,633
|
public function addCustomScriptLabel ( $ name , $ text = null ) { if ( $ name instanceof ScriptLabel ) { $ scriptLabel = $ name ; } else { $ scriptLabel = new ScriptLabel ( $ name , $ text ) ; } if ( ! in_array ( $ scriptLabel , $ this -> customLabels ) ) { array_push ( $ this -> customLabels , $ scriptLabel ) ; } return $ this ; }
|
Add a custom Script text
|
6,634
|
public function appendGenericScriptLabel ( $ name , $ text = null , $ isolated = false ) { if ( $ name instanceof ScriptLabel ) { $ scriptLabel = $ name ; } else { $ scriptLabel = new ScriptLabel ( $ name , $ text , $ isolated ) ; } if ( ! in_array ( $ scriptLabel , $ this -> genericLabels ) ) { array_push ( $ this -> genericLabels , $ scriptLabel ) ; } return $ this ; }
|
Append a generic Script text for the next rendering
|
6,635
|
public function addFeature ( ScriptFeature $ feature ) { if ( ! in_array ( $ feature , $ this -> features , true ) ) { array_push ( $ this -> features , $ feature ) ; } return $ this ; }
|
Add a Script Feature
|
6,636
|
public function buildScriptText ( ) { $ scriptText = PHP_EOL ; $ scriptText .= $ this -> getHeaderComment ( ) ; $ scriptText .= $ this -> getIncludes ( ) ; $ scriptText .= $ this -> getConstants ( ) ; $ scriptText .= $ this -> getFunctions ( ) ; $ scriptText .= $ this -> getLabels ( ) ; $ scriptText .= $ this -> getMainFunction ( ) ; return $ scriptText ; }
|
Build the complete Script text
|
6,637
|
public function render ( \ DOMDocument $ domDocument ) { $ this -> loadFeatures ( $ this -> features ) ; $ scriptXml = $ domDocument -> createElement ( "script" ) ; $ scriptText = $ this -> buildScriptText ( ) ; $ scriptComment = $ domDocument -> createComment ( $ scriptText ) ; $ scriptXml -> appendChild ( $ scriptComment ) ; return $ scriptXml ; }
|
Render the Script
|
6,638
|
protected function getLabels ( ) { $ customLabelsText = implode ( PHP_EOL , $ this -> customLabels ) ; $ genericLabelsText = implode ( PHP_EOL , $ this -> genericLabels ) ; return $ customLabelsText . $ genericLabelsText ; }
|
Get the Labels text
|
6,639
|
protected function getMainFunction ( ) { $ mainFunction = 'Void FML_Dummy() {}main() { declare ' . self :: VAR_ScriptStart . ' = Now; +++' . ScriptLabel :: ONINIT . '+++ declare ' . self :: VAR_LoopCounter . ' = 0; declare ' . self :: VAR_LastTick . ' = 0; while (True) { yield; foreach (Event in PendingEvents) { switch (Event.Type) { case CMlEvent::Type::EntrySubmit: { +++' . ScriptLabel :: ENTRYSUBMIT . '+++ } case CMlEvent::Type::KeyPress: { +++' . ScriptLabel :: KEYPRESS . '+++ } case CMlEvent::Type::MouseClick: { +++' . ScriptLabel :: MOUSECLICK . '+++ +++' . ScriptLabel :: MOUSECLICK2 . '+++ } case CMlEvent::Type::MouseOut: { +++' . ScriptLabel :: MOUSEOUT . '+++ } case CMlEvent::Type::MouseOver: { +++' . ScriptLabel :: MOUSEOVER . '+++ } } } +++' . ScriptLabel :: LOOP . '+++ ' . self :: VAR_LoopCounter . ' += 1; if (' . self :: VAR_LastTick . ' + ' . self :: TICKINTERVAL . ' > Now) continue; +++' . ScriptLabel :: TICK . '+++ ' . self :: VAR_LastTick . ' = Now; }}' ; return $ mainFunction ; }
|
Get the main function text
|
6,640
|
protected function setData ( & $ connect , $ data , $ content_type ) { if ( $ content_type == "application/json" ) { if ( gettype ( $ data ) == "string" ) { json_decode ( $ data , true ) ; } else { $ data = json_encode ( $ data ) ; } if ( function_exists ( 'json_last_error' ) ) { $ json_error = json_last_error ( ) ; if ( $ json_error != JSON_ERROR_NONE ) { throw new Exception ( "JSON Error [{$json_error}] - Data: {$data}" ) ; } } } curl_setopt ( $ connect , CURLOPT_POSTFIELDS , $ data ) ; }
|
Sets the data request
|
6,641
|
protected function exec ( $ method , $ uri , $ data , $ content_type ) { $ connect = $ this -> getConnect ( $ uri , $ method , $ content_type ) ; if ( $ data ) { $ this -> setData ( $ connect , $ data , $ content_type ) ; } $ api_result = curl_exec ( $ connect ) ; $ api_http_code = curl_getinfo ( $ connect , CURLINFO_HTTP_CODE ) ; $ api_http_time = curl_getinfo ( $ connect , CURLINFO_TOTAL_TIME ) ; $ response = array ( "status" => $ api_http_code , "total_time" => $ api_http_time , ) ; if ( $ content_type == "application/json" ) { $ response [ "response" ] = json_decode ( $ api_result , true ) ; } elseif ( $ content_type == "text/html" ) { $ response [ "response" ] = $ api_result ; } if ( $ response [ 'status' ] >= 400 ) { throw new Exception ( $ response [ 'response' ] , $ response [ 'status' ] ) ; } curl_close ( $ connect ) ; return $ response ; }
|
Executes the request
|
6,642
|
public function status ( ) { if ( $ this -> status === null ) { $ stdClass = $ this -> decoded ( ) ; if ( ! $ stdClass instanceof stdClass ) return null ; $ this -> status = $ this -> resolveStatusFromStdClass ( $ stdClass ) ; } return $ this -> status ; }
|
returns the status model
|
6,643
|
private function getLocationByObject ( ValueObject $ object ) { $ contentInfo = $ this -> contentService -> loadContentInfo ( $ object -> data [ 'content_id' ] ) ; $ locations = $ this -> locationService -> loadLocations ( $ contentInfo ) ; foreach ( $ locations as $ loc ) { if ( $ loc -> parentLocationId === $ object -> data [ 'parent_location_id' ] ) { return $ loc ; } } return ; }
|
Get location by content_id and parent_location_id .
|
6,644
|
public function toggleVisibility ( Location $ location ) { if ( $ location -> hidden ) { return $ this -> unHide ( $ location ) ; } return $ this -> hide ( $ location ) ; }
|
Toggles location visibility .
|
6,645
|
public static function cleanDirectory ( string $ directory ) : bool { self :: removeDirectory ( $ directory ) ; return self :: createDirectory ( $ directory ) ; }
|
Empty the specified directory of all files and folders .
|
6,646
|
public static function isAbsolutePath ( $ path ) : bool { return strspn ( $ path , '/\\' , 0 , 1 ) || ( strlen ( $ path ) > 3 && ctype_alpha ( $ path [ 0 ] ) && ':' === $ path [ 1 ] && strspn ( $ path , '/\\' , 2 , 1 ) ) || null !== parse_url ( $ path , PHP_URL_SCHEME ) ; }
|
Returns whether the file path is an absolute path .
|
6,647
|
public static function path ( $ name , $ time = null ) { if ( is_null ( $ time ) ) { $ time = time ( ) ; } $ namespace = null ; if ( strpos ( $ name , '::' ) !== false ) { list ( $ namespace , $ name ) = explode ( '::' , $ name ) ; } $ name = explode ( '/' , $ name ) ; foreach ( $ name as $ key => $ value ) { $ name [ $ key ] = \ CCStr :: clean_url ( $ value , '_' ) ; } $ name = implode ( '/' , $ name ) ; return \ CCPath :: get ( ( $ namespace ? $ namespace . '::' : '' ) . $ name . '_' . $ time , \ ClanCats :: directory ( 'migration' ) , '.sql' ) ; }
|
Get a migration path by name
|
6,648
|
public static function migrate ( $ silent = false ) { $ migrations = $ silent ? static :: available ( ) : static :: unstaged ( ) ; foreach ( $ migrations as $ key => $ value ) { if ( empty ( $ value ) ) { continue ; } if ( \ ClanCats :: is_cli ( ) ) { \ CCCli :: info ( 'found new "' . $ key . '" migrations.' ) ; } foreach ( $ value as $ time => $ path ) { $ migration = new static ( $ path ) ; $ migration -> up ( ) ; if ( \ ClanCats :: is_cli ( ) ) { \ CCCli :: success ( 'migrated ' . $ migration -> name ( ) ) ; } } static :: $ config -> set ( $ key . '.revision' , $ time ) ; } if ( ! $ silent ) { static :: $ config -> write ( ) ; } }
|
Run all new migration
|
6,649
|
public static function rollback ( ) { $ available = static :: available ( ) ; foreach ( $ available as $ key => $ migrations ) { foreach ( $ migrations as $ time => $ migration ) { if ( $ time > static :: $ config -> get ( $ key . '.revision' , 0 ) ) { unset ( $ available [ $ key ] [ $ time ] ) ; } } } $ revisions = array ( ) ; foreach ( $ available as $ key => $ value ) { if ( empty ( $ value ) ) { continue ; } foreach ( $ value as $ name => $ path ) { $ revisions [ $ name . '::' . $ key ] = $ path ; } } if ( empty ( $ revisions ) ) { if ( \ ClanCats :: is_cli ( ) ) { \ CCCli :: warning ( 'nothing to rollback to.' ) ; } return false ; } ksort ( $ revisions ) ; end ( $ revisions ) ; list ( $ time , $ key ) = explode ( '::' , key ( $ revisions ) ) ; $ migration = new static ( array_pop ( $ revisions ) ) ; $ migration -> down ( ) ; $ others = \ CCArr :: get ( $ key , $ available ) ; ksort ( $ others ) ; array_pop ( $ others ) ; end ( $ others ) ; static :: $ config -> set ( $ key . '.revision' , key ( $ others ) ) ; static :: $ config -> write ( ) ; return true ; }
|
Revert the last migration
|
6,650
|
public static function hard_reset ( $ database = null ) { $ tables = DB :: fetch ( 'SHOW TABLES' , array ( ) , $ database , array ( 'assoc' ) ) ; foreach ( $ tables as $ table ) { DB :: run ( 'DROP TABLE IF EXISTS ' . reset ( $ table ) , array ( ) , $ database ) ; } }
|
The hard reset method deletes all tables from the database
|
6,651
|
public static function unstaged ( ) { $ available = static :: available ( ) ; foreach ( $ available as $ key => $ migrations ) { foreach ( $ migrations as $ time => $ migration ) { if ( $ time <= static :: $ config -> get ( $ key . '.revision' , 0 ) ) { unset ( $ available [ $ key ] [ $ time ] ) ; } } } return $ available ; }
|
Returns the unstaged migrations based on the configuration
|
6,652
|
private function run_queries ( $ group ) { if ( ! $ handle = fopen ( $ this -> path , "r" ) ) { throw new Exception ( "Could not read migration: " . $ this -> path ) ; } $ mode = null ; $ query = '' ; while ( ! feof ( $ handle ) ) { $ buffer = trim ( fgets ( $ handle , 4096 ) ) ; $ this -> parse_mode ( $ mode , $ buffer ) ; if ( $ this -> is_comment ( $ buffer ) ) { continue ; } if ( $ mode === $ group ) { $ query .= $ buffer ; if ( substr ( rtrim ( $ query ) , - 1 ) == ';' ) { DB :: run ( $ query ) ; $ query = '' ; } } } fclose ( $ handle ) ; }
|
Run all queries of specified group
|
6,653
|
private function parse_mode ( & $ mode , $ buffer ) { if ( substr ( trim ( $ buffer ) , 0 , 6 ) === '# - ) { $ mode = trim ( substr ( $ buffer , 6 ) ) ; } }
|
Try to parse the current mode
|
6,654
|
private function is_comment ( $ buffer ) { if ( is_string ( $ buffer ) && strlen ( $ buffer ) >= 1 ) { if ( $ buffer [ 0 ] == '#' ) { return true ; } if ( substr ( $ buffer , 0 , 2 ) == '--' ) { return true ; } } else { return true ; } return false ; }
|
Is this string an sql comment?
|
6,655
|
protected function autoLoad ( ) { if ( ! $ this -> disableAutoLoad ) { $ constructCode = $ this -> createConstructCode ( $ this -> jooseClass , $ this -> constructParams , FALSE ) ; if ( mb_strpos ( $ this -> html -> getTemplate ( ) , '%autoLoadJoose%' ) === FALSE ) { $ this -> html -> templateAppend ( "\n" . '%autoLoadJoose%' ) ; } $ this -> html -> getTemplateContent ( ) -> autoLoadJoose = jsHelper :: embed ( jsHelper :: requireLoad ( array_merge ( array ( 'jquery' ) , array_map ( function ( $ class ) { return str_replace ( '.' , '/' , $ class ) ; } , $ this -> dependencies ) ) , array ( 'jQuery' ) , $ constructCode ) ) ; } return $ this ; }
|
Erstellt das Objekt direkt nachdem das HTML geladen wird per inline - Javascript
|
6,656
|
public static function get ( $ path , $ prefix = '' , $ suffix = '' ) { if ( substr ( $ path , 0 , 1 ) == '/' || substr ( $ path , 0 , 3 ) == "::/" ) { return $ path . $ suffix ; } if ( strpos ( $ path , '::' ) === false ) { return \ APPPATH . $ prefix . $ path . $ suffix ; } $ name = explode ( '::' , $ path ) ; if ( array_key_exists ( $ name [ 0 ] , \ CCFinder :: $ bundles ) ) { return \ CCFinder :: $ bundles [ $ name [ 0 ] ] . $ prefix . $ name [ 1 ] . $ suffix ; } return false ; }
|
generate an path an path can conatin an namespace for example core
|
6,657
|
public static function success ( $ percent , $ htmlOptions = array ( ) ) { ArrayHelper :: addValue ( 'class' , Enum :: COLOR_SUCCESS , $ htmlOptions ) ; return static :: bar ( $ percent , $ htmlOptions ) ; }
|
Generates success coloured progress bar
|
6,658
|
private function createCharsetTableVariables ( array $ config , $ encoding_type = 'utf8' ) { if ( isset ( $ config [ 'sphinxsearch' ] ) && file_exists ( __DIR__ . '/config/sphinx.charset.utf8.config.php' ) ) { $ charsetConfig = include __DIR__ . '/config/sphinx.charset.utf8.config.php' ; $ languages = $ charsetConfig [ 'languages' ] ; $ defaults = $ charsetConfig [ 'defaults' ] ; $ prefix = 'charset_' . $ encoding_type . '_' ; foreach ( $ defaults as $ name => $ table ) { $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . $ name ] = $ table ; } $ default = implode ( ', ' , $ defaults ) ; $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . 'default' ] = $ default ; foreach ( $ languages as $ lang => $ table ) { if ( empty ( $ table ) ) { $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . $ lang ] = $ default ; } else { $ alphanum = '' ; $ alphanum .= $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . 'digits' ] . ', ' ; $ alphanum .= $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . 'alphabet' ] ; $ config [ 'sphinxsearch' ] [ 'variables' ] [ $ prefix . $ lang ] = $ alphanum . ', ' . $ table ; } } } return $ config ; }
|
Read Sphinx Search charset tables and create variables to expose them
|
6,659
|
public function rewind ( ) { if ( ! $ this -> sorted ) { $ this -> entities = array_reverse ( $ this -> entities ) ; $ this -> sorted = true ; } parent :: rewind ( ) ; }
|
Make sure we have the items in the right order reverse order
|
6,660
|
public function toString ( ) { if ( null === $ this -> composedURI ) { $ this -> composedURI = '' ; if ( null !== $ this -> scheme ) { $ this -> composedURI .= $ this -> scheme ; $ this -> composedURI .= ':' ; } if ( null !== $ this -> host ) { $ this -> composedURI .= '//' ; if ( null !== $ this -> username ) { $ this -> composedURI .= $ this -> username ; if ( null !== $ this -> password ) { $ this -> composedURI .= ':' ; $ this -> composedURI .= $ this -> password ; } $ this -> composedURI .= '@' ; } $ this -> composedURI .= $ this -> host ; } $ this -> composedURI .= $ this -> path ; if ( null !== $ this -> query ) { $ this -> composedURI .= '?' ; $ this -> composedURI .= $ this -> query ; } if ( null !== $ this -> fragment ) { $ this -> composedURI .= '#' ; $ this -> composedURI .= $ this -> fragment ; } } return $ this -> composedURI ; }
|
Recomposes the components of this Uri as a string .
|
6,661
|
private function resolveRelativeReference ( ) { if ( null !== $ this -> scheme ) { $ this -> normalizeDotSegments ( ) ; } else { $ this -> scheme = $ this -> baseUri -> scheme ; if ( null !== $ this -> authority ) { $ this -> normalizeDotSegments ( ) ; } else { $ this -> authority = $ this -> baseUri -> authority ; $ this -> parseUserInfoHostPort ( ) ; if ( '' === $ this -> path ) { $ this -> path = $ this -> baseUri -> path ; if ( null === $ this -> query ) { $ this -> query = $ this -> baseUri -> query ; } } else { if ( 0 === strpos ( $ this -> path , '/' ) ) { $ this -> normalizeDotSegments ( ) ; } else { $ this -> mergeBasePath ( ) ; $ this -> normalizeDotSegments ( ) ; } } } } }
|
From RFC 3986 paragraph 4 . 2
|
6,662
|
private function normalizeDotSegments ( ) { $ input = explode ( '/' , $ this -> path ) ; $ output = array ( ) ; while ( ! empty ( $ input ) ) { if ( '..' === $ input [ 0 ] ) { if ( 1 === count ( $ input ) ) { array_shift ( $ input ) ; if ( '' !== end ( $ output ) ) { array_pop ( $ output ) ; } array_push ( $ output , '' ) ; } else { array_shift ( $ input ) ; if ( '' !== end ( $ output ) ) { array_pop ( $ output ) ; } } } elseif ( '.' === $ input [ 0 ] ) { if ( 1 === count ( $ input ) ) { array_shift ( $ input ) ; array_push ( $ output , '' ) ; } else { array_shift ( $ input ) ; } } else { array_push ( $ output , array_shift ( $ input ) ) ; } } $ this -> path = implode ( '/' , $ output ) ; }
|
From RFC 3986 paragraph 5 . 2 . 4
|
6,663
|
private function mergeBasePath ( ) { if ( null !== $ this -> baseUri -> authority && '' === $ this -> baseUri -> path ) { $ this -> path = '/' . $ this -> path ; } else { if ( false !== $ lastSlashPos = strrpos ( $ this -> baseUri -> path , '/' ) ) { $ basePath = substr ( $ this -> baseUri -> path , 0 , $ lastSlashPos + 1 ) ; $ this -> path = $ basePath . $ this -> path ; } } }
|
From RFC 3986 paragraph 5 . 2 . 3
|
6,664
|
private function parseUriReference ( ) { $ this -> parseScheme ( ) ; $ this -> parseAuthority ( ) ; $ this -> parsePath ( ) ; $ this -> parseQuery ( ) ; $ this -> parseFragment ( ) ; $ this -> doSchemeSpecificPostProcessing ( ) ; if ( strlen ( $ this -> remaining ) ) { throw new ErrorException ( "Still something left after parsing, shouldn't happen: '$this->remaining'" ) ; } }
|
From RFC 3986 paragraph 4 . 1
|
6,665
|
protected function printBoolean ( OutputInterface $ output , $ success , $ fail , $ value , $ line = true ) { if ( $ value ) { $ message = '<info>' . $ success . '</info>' ; } else { $ message = '<error>' . $ fail . '</error>' ; } if ( false === $ line ) { return $ message ; } $ output -> writeln ( $ message ) ; }
|
prints a simple boolean .
|
6,666
|
protected function printMessage ( OutputInterface $ output , array $ response ) { $ this -> printBoolean ( $ output , $ response [ 'message' ] , $ response [ 'message' ] , true === $ response [ 'success' ] ) ; }
|
prints a simple message .
|
6,667
|
private function getColumnWidth ( array $ headings ) { $ width = 0 ; foreach ( $ headings as $ heading ) { $ width = strlen ( $ heading ) > $ width ? strlen ( $ heading ) : $ width ; } return $ width + 5 ; }
|
calculates the max width of a given set of string .
|
6,668
|
public function generate ( ) { $ this -> loadWebMasterTags ( ) ; $ title = $ this -> getTitle ( ) ; $ description = $ this -> getDescription ( ) ; $ keywords = $ this -> getKeywords ( ) ; $ metatags = $ this -> metatags ; $ html = [ ] ; if ( $ title ) : $ html [ ] = "<title>$title</title>" ; endif ; if ( ! empty ( $ description ) ) : $ html [ ] = "<meta name=\"description\" content=\"{$description}\" />" ; endif ; if ( ! empty ( $ keywords ) ) : $ keywords = implode ( ',' , $ keywords ) ; $ html [ ] = "<meta name=\"keywords\" content=\"{$keywords}\" />" ; endif ; foreach ( $ metatags as $ key => $ value ) : $ name = $ value [ 0 ] ; $ content = $ value [ 1 ] ; $ html [ ] = "<meta {$name}=\"{$key}\" content=\"{$content}\" />" ; endforeach ; return implode ( PHP_EOL , $ html ) ; }
|
Generates meta tags
|
6,669
|
public function setTitle ( $ title , $ suffix = '' , $ has_suffix = true ) { $ title = strip_tags ( $ title ) ; $ suffix = strip_tags ( $ suffix ) ; $ this -> title_session = $ title ; $ this -> title = $ this -> parseTitle ( $ title , $ suffix , $ has_suffix ) ; return $ this ; }
|
Sets the title
|
6,670
|
public function setKeywords ( $ keywords ) { if ( ! is_array ( $ keywords ) ) : $ keywords = explode ( ', ' , $ this -> keywords ) ; endif ; $ keywords = array_map ( 'strip_tags' , $ keywords ) ; $ this -> keywords = $ keywords ; return $ this ; }
|
Sets the list of keywords you can send an array or string separated with commas also clears the previously set keywords
|
6,671
|
public function addKeyword ( $ keyword ) { if ( is_array ( $ keyword ) ) : $ this -> keywords = array_merge ( $ keyword , $ this -> keywords ) ; else : $ this -> keywords [ ] = strip_tags ( $ keyword ) ; endif ; return $ this ; }
|
Add a keyword
|
6,672
|
protected function parseTitle ( $ title , $ suffix , $ has_suffix ) { if ( ! $ has_suffix ) : return $ title ; elseif ( ! empty ( $ suffix ) ) : return $ title . $ this -> getTitleSeperator ( ) . $ suffix ; else : return $ this -> config -> get ( 'defaults.title' ) ? $ title . $ this -> getTitleSeperator ( ) . $ this -> config -> get ( 'defaults.title' , null ) : $ title ; endif ; }
|
Get parsed title .
|
6,673
|
public function getDatatable ( DatatableViewInterface $ datatableView ) { $ type = $ datatableView -> getAjax ( ) -> getType ( ) ; $ entity = $ datatableView -> getEntity ( ) ; if ( 'GET' === strtoupper ( $ type ) ) { $ this -> parameterBag = $ this -> request -> query ; } if ( 'POST' === strtoupper ( $ type ) ) { $ this -> parameterBag = $ this -> request -> request ; } $ params = $ this -> parameterBag -> all ( ) ; $ metadata = $ this -> doctrine -> getManager ( ) -> getClassMetadata ( $ entity ) ; $ em = $ this -> doctrine -> getManager ( ) ; $ datatableQuery = new DatatableQuery ( $ params , $ metadata , $ em ) ; $ virtualColumns = $ datatableView -> getColumnBuilder ( ) -> getVirtualColumnNames ( ) ; $ datatableData = new DatatableData ( $ params , $ metadata , $ em , $ this -> serializer , $ datatableQuery , $ virtualColumns ) ; $ datatableData -> setLineFormatter ( $ datatableView -> getLineFormatter ( ) ) ; return $ datatableData ; }
|
Get Datatable .
|
6,674
|
public function create ( $ name , $ extends = null , $ implements = null ) { $ this -> name = $ name ; $ this -> extends = $ extends ; if ( ! is_array ( $ implements ) && ! is_null ( $ implements ) ) { $ implements = array ( $ implements ) ; } $ this -> implements = $ implements ; }
|
Start new class builder
|
6,675
|
public function add ( ) { $ args = func_get_args ( ) ; $ component = array_shift ( $ args ) ; $ method = 'build_' . strtolower ( $ component ) ; if ( ! method_exists ( $ this , $ method ) ) { throw new CCException ( 'CCShipyard_Class invalid component builder "' . $ component . '".' ) ; } $ this -> output .= call_user_func_array ( array ( $ this , $ method ) , $ args ) ; }
|
Add a component to the class
|
6,676
|
public function setValue ( $ search , $ replace ) { if ( substr ( $ search , 0 , 2 ) !== '${' && substr ( $ search , - 1 ) !== '}' ) { $ search = '${' . $ search . '}' ; } $ this -> _documentXML = str_replace ( $ search , $ replace , $ this -> _documentXML ) ; }
|
Set a Template value
|
6,677
|
public function render ( \ DOMDocument $ domDocument ) { $ style3dXml = $ domDocument -> createElement ( "style3d" ) ; $ this -> checkId ( ) ; if ( $ this -> styleId ) { $ style3dXml -> setAttribute ( "id" , $ this -> styleId ) ; } if ( $ this -> model ) { $ style3dXml -> setAttribute ( "model" , $ this -> model ) ; } if ( $ this -> thickness ) { $ style3dXml -> setAttribute ( "thickness" , $ this -> thickness ) ; } if ( $ this -> color ) { $ style3dXml -> setAttribute ( "color" , $ this -> color ) ; } if ( $ this -> focusColor ) { $ style3dXml -> setAttribute ( "fcolor" , $ this -> focusColor ) ; } if ( $ this -> lightColor ) { $ style3dXml -> setAttribute ( "lightcolor" , $ this -> lightColor ) ; } if ( $ this -> focusLightColor ) { $ style3dXml -> setAttribute ( "flightcolor" , $ this -> focusLightColor ) ; } if ( $ this -> yOffset ) { $ style3dXml -> setAttribute ( "yoffset" , $ this -> yOffset ) ; } if ( $ this -> focusYOffset ) { $ style3dXml -> setAttribute ( "fyoffset" , $ this -> focusYOffset ) ; } if ( $ this -> zOffset ) { $ style3dXml -> setAttribute ( "zoffset" , $ this -> zOffset ) ; } if ( $ this -> focusZOffset ) { $ style3dXml -> setAttribute ( "fzoffset" , $ this -> focusZOffset ) ; } return $ style3dXml ; }
|
Render the Style3d
|
6,678
|
protected function setupSources ( ) { $ config = $ this -> container [ 'config' ] ; $ cwd = getcwd ( ) ; $ source = [ ] ; $ this -> output -> writeln ( "Working directory is <path>{$cwd}</path>" ) ; $ this -> title ( 'Sources' ) ; if ( $ this -> isGitRepo ( '.' ) ) { $ this -> output -> writeln ( "It looks your project already has a git repository.\n" ) ; if ( $ this -> confirm ( 'Would you like to store your steak sources in a <b>separate</b> repo/branch?' , false ) ) { $ source [ 'git.directory' ] = $ this -> ask ( "Where should we check out the site sources <b>repository</b>?" , $ config -> get ( 'source.directory' , 'steak' ) ) ; $ source [ 'git.url' ] = $ this -> ask ( "Enter the source repository URL:" , $ config -> get ( 'source.git.url' , $ this -> getPushUrl ( '.' ) ) ) ; $ source [ 'git.branch' ] = $ this -> ask ( "Specify the branch to use:" , $ config -> get ( 'source.git.branch' , 'gh-pages-src' ) ) ; } else { $ this -> output -> writeln ( [ " Okay, no problem, just commit your steak sources as part of your standard workflow." , " The <comment>steak pull</comment> command will have no effect." , "" ] ) ; $ source [ 'directory' ] = $ this -> ask ( "Where are the <b>source files</b> kept?" , $ config -> get ( 'source.directory' , 'source' ) ) ; } } else { $ this -> output -> writeln ( "working directory not under git" , OutputInterface :: VERBOSITY_VERBOSE ) ; if ( $ this -> confirm ( 'Would you like to store your steak sources in a git repo?' ) ) { $ source [ 'directory' ] = $ this -> ask ( "Where should we check out the site sources <b>repository</b>?" , $ config -> get ( 'source.directory' , 'steak' ) ) ; $ source [ 'git.url' ] = $ this -> ask ( "Enter the source repository URL:" , $ config -> get ( 'source.git.url' ) , $ this -> valueRequiredValidator ( ) ) ; $ source [ 'git.branch' ] = $ this -> ask ( "Specify the branch to use:" , $ config -> get ( 'source.git.branch' , 'master' ) ) ; } else { $ this -> output -> writeln ( " Okay, no git." ) ; $ source [ 'directory' ] = $ this -> ask ( "Where to put the steak <b>source files</b>?" , $ config -> get ( 'source.directory' , 'sources' ) ) ; } } return $ source ; }
|
Get the config values related to steak sources .
|
6,679
|
protected function setupBuild ( ) { $ config = $ this -> container [ 'config' ] ; $ build = [ ] ; $ this -> title ( 'Build' ) ; $ build [ 'directory' ] = $ this -> ask ( "Where should we put the generated site files?" , $ config [ 'build.directory' ] ) ; return $ build ; }
|
Get the config values related to the build process .
|
6,680
|
protected function setupDeploy ( ) { $ config = $ this -> container [ 'config' ] ; $ this -> title ( 'Deployment via Git' ) ; $ deploy = [ ] ; if ( $ this -> confirm ( 'Push the generated static site to a git repository?' ) ) { $ deploy [ 'git.url' ] = $ this -> ask ( "Specify a destination repository for the <path>steak deploy</path> command to use:" , $ config -> get ( 'deploy.git.url' , $ this -> getPushUrl ( '.' ) ) , $ this -> valueRequiredValidator ( ) ) ; $ deploy [ 'git.branch' ] = $ this -> ask ( "Specify the branch to use:" , $ config -> get ( 'deploy.git.branch' , 'gh-pages' ) ) ; } else { $ this -> output -> writeln ( [ " Okay, no problem, steak will not attempt deployments." , " The <comment>steak deploy</comment> command will have no effect." , ] ) ; } return $ deploy ; }
|
Get the config values related to deployment .
|
6,681
|
protected function setupGulp ( ) { $ config = $ this -> container [ 'config' ] ; $ this -> title ( 'Gulp' ) ; $ gulp = [ ] ; $ this -> output -> writeln ( [ "steak uses the gulp taskrunner to:" , " 1. publish non-PHP files from your source directory to the build directory with <comment>steak:publish</comment>" , " 2. run the local development server and rebuild the site on change with <comment>steak:serve</comment>" , ] ) ; $ gulp [ 'file' ] = $ this -> ask ( "Which gulpfile should steak use?" , $ config [ 'gulp.file' ] ) ; return $ gulp ; }
|
Get the config values related to gulp .
|
6,682
|
protected function setupServe ( array $ newConfig ) { $ newConfig = array_dot ( $ newConfig ) ; if ( array_get ( $ newConfig , 'deploy.git.branch' ) != 'gh-pages' ) { return [ ] ; } $ this -> title ( 'Local development server' ) ; $ this -> output -> writeln ( [ "When you publish to github pages, your site is available from username.github.io/projectname" , "To help avoid problems with relative URLs, use a matching subdirectory for the local server." , "" , ] ) ; return [ 'subdirectory' => $ this -> ask ( "Subdirectory to use for the <comment>steak serve</comment> command?" , $ this -> git -> parseRepositoryName ( array_get ( $ newConfig , 'deploy.git.url' ) ) ) ] ; }
|
Get the config values related to the development server .
|
6,683
|
protected function confirm ( $ text , $ default = true ) { $ choices = $ default ? 'Yn' : 'yN' ; $ confirm = new ConfirmationQuestion ( "$text [$choices] " , $ default ) ; return $ this -> getHelper ( 'question' ) -> ask ( $ this -> input , $ this -> output , $ confirm ) ; }
|
Ask for user confirmation .
|
6,684
|
protected function select ( $ text , $ choices , $ default = null ) { $ question = new ChoiceQuestion ( $ text , $ choices , $ default ) ; return $ this -> getHelper ( 'question' ) -> ask ( $ this -> input , $ this -> output , $ question ) ; }
|
Ask user to choose from a list of options .
|
6,685
|
protected function getPushUrl ( $ dir , $ throws = false ) { try { $ remotes = $ this -> git -> workingCopy ( $ dir ) -> remote ( 'show' , 'origin' , '-n' ) -> getOutput ( ) ; if ( preg_match ( '!Push\s*URL:\s*([^\s#]+)!' , $ remotes , $ matches ) ) { return $ matches [ 1 ] ; } } catch ( GitException $ exception ) { if ( $ throws ) { throw $ exception ; } } return null ; }
|
Get the origin s push URL .
|
6,686
|
protected function createYaml ( array $ config ) { $ nested = [ ] ; array_walk ( array_dot ( $ config ) , function ( $ value , $ key ) use ( & $ nested ) { array_set ( $ nested , $ key , $ value ) ; } ) ; return $ this -> yaml -> dump ( $ nested , 4 ) ; }
|
Create a YML string from a dotted array .
|
6,687
|
protected function dirExists ( $ dir ) { if ( $ this -> files -> exists ( $ dir ) ) { if ( ! $ this -> files -> isDirectory ( $ dir ) ) { throw new RuntimeException ( "The given directory [$dir] is not a directory." ) ; } return true ; } return false ; }
|
Check if a directory exists .
|
6,688
|
private function rewriteCountQuery ( string $ sql ) : string { if ( preg_match ( '/^\s*SELECT\s+\bDISTINCT\b/is' , $ sql ) || preg_match ( '/\s+GROUP\s+BY\s+/is' , $ sql ) ) { throw new CountQueryException ( $ sql ) ; } $ openParenthesis = '(?:\()' ; $ closeParenthesis = '(?:\))' ; $ subQueryInSelect = $ openParenthesis . '.*\bFROM\b.*' . $ closeParenthesis ; $ pattern = '/(?:.*' . $ subQueryInSelect . '.*)\bFROM\b\s+/Uims' ; if ( preg_match ( $ pattern , $ sql ) ) { throw new CountQueryException ( $ sql ) ; } $ subQueryWithLimitOrder = $ openParenthesis . '.*\b(LIMIT|ORDER)\b.*' . $ closeParenthesis ; $ pattern = '/.*\bFROM\b.*(?:.*' . $ subQueryWithLimitOrder . '.*).*/Uims' ; if ( preg_match ( $ pattern , $ sql ) ) { throw new CountQueryException ( $ sql ) ; } $ queryCount = preg_replace ( '/(?:.*)\bFROM\b\s+/Uims' , 'SELECT COUNT(*) FROM ' , $ sql , 1 ) ; if ( ! is_string ( $ queryCount ) ) { throw new CountQueryException ( $ sql ) ; } list ( $ queryCount ) = preg_split ( '/\s+ORDER\s+BY\s+/is' , $ queryCount ) ; if ( ! is_string ( $ queryCount ) ) { throw new CountQueryException ( $ sql ) ; } list ( $ queryCount ) = preg_split ( '/\bLIMIT\b/is' , $ queryCount ) ; if ( ! is_string ( $ queryCount ) ) { throw new CountQueryException ( $ sql ) ; } return trim ( $ queryCount ) ; }
|
Return count query
|
6,689
|
public function set ( $ name , $ value ) { if ( ! $ this -> has ( $ name ) ) { $ this -> vars [ $ name ] = $ value ; } else { return false ; } }
|
Set var session
|
6,690
|
public function action_class ( $ params ) { $ options = \ CCDataObject :: assign ( $ params ) ; $ name = $ options -> get ( 0 , null ) ; while ( ! $ name ) { $ name = $ this -> read ( 'Please enter the class name: ' ) ; } if ( ! $ path = \ CCPath :: classes ( str_replace ( '_' , '/' , $ name ) , EXT ) ) { $ this -> error ( 'Could not resolve the path. Check if the namespace is registered.' ) ; return ; } $ class = \ CCShipyard :: create ( 'class' , $ name , $ options -> get ( 'extends' , null ) , explode ( ',' , $ options -> get ( 'implements' , null ) ) ) ; if ( ! $ options -> get ( 'no-init' , false ) ) { $ class -> add ( 'function' , '_init' , 'public static' , '//' , "static class initialisation\n@return void" ) ; } if ( file_exists ( $ path ) ) { if ( ! $ this -> confirm ( "The class already exists. Do you wish to overwrite it?" , true ) ) { return ; } } \ CCFile :: write ( $ path , $ class -> output ( ) ) ; }
|
generate an class
|
6,691
|
public function action_model ( $ params ) { $ options = \ CCDataObject :: assign ( $ params ) ; $ name = $ options -> get ( 0 , null ) ; $ table = $ options -> get ( 1 , null ) ; while ( ! $ name ) { $ name = $ this -> read ( 'Please enter the class name: ' ) ; } while ( ! $ table ) { $ table = $ this -> read ( 'Please enter the table name: ' ) ; } if ( ! $ path = \ CCPath :: classes ( str_replace ( '_' , '/' , $ name ) , EXT ) ) { $ this -> error ( 'Could not resolve the path. Check if the namespace is registered.' ) ; return ; } $ model = \ CCShipyard :: create ( 'dbmodel' , $ name , $ table ) ; $ model -> timestamps ( $ options -> get ( 'timestamps' , false ) ) ; if ( file_exists ( $ path ) ) { if ( ! CCCli :: confirm ( "The class already exists. Do you wish to overwrite it?" , true ) ) { return ; } } \ CCFile :: write ( $ path , $ model -> output ( ) ) ; }
|
generate a model class
|
6,692
|
public function action_controller ( $ params ) { $ options = \ CCDataObject :: assign ( $ params ) ; $ name = $ options -> get ( 0 , null ) ; $ parent = $ options -> get ( 1 , null ) ; while ( ! $ name ) { $ name = $ this -> read ( 'Please enter the controller name: ' ) ; } if ( substr ( $ name , ( strlen ( 'Controller' ) * - 1 ) ) != 'Controller' ) { $ name .= 'Controller' ; } if ( ! $ path = \ CCPath :: controllers ( str_replace ( '_' , '/' , $ name ) , EXT ) ) { $ this -> error ( 'Could not resolve the path. Check if the namespace is registered.' ) ; return ; } if ( is_null ( $ parent ) ) { $ parent = '\\CCController' ; } if ( $ options -> get ( 'view' , false ) ) { $ parent = '\\CCViewController' ; } $ class = \ CCShipyard :: create ( 'class' , $ name , $ parent ) ; $ actions = array ( 'index' ) ; if ( $ options -> get ( 'actions' , false ) ) { $ actions = array_merge ( $ actions , explode ( ',' , $ options -> get ( 'actions' ) ) ) ; } foreach ( $ actions as $ action ) { $ action = trim ( $ action ) ; $ class -> add ( 'function' , 'action_' . $ action , 'protected' , 'echo "' . $ name . ' ' . $ action . ' action";' , ucfirst ( $ action ) . " action\n@return void|CCResponse" ) ; $ class -> add ( 'line' , 2 ) ; } if ( ! $ options -> get ( 'no-events' , false ) ) { $ class -> add ( 'function' , 'wake' , 'protected' , '//' , "Controller wake\n@return void|CCResponse" ) ; $ class -> add ( 'line' , 2 ) ; $ class -> add ( 'function' , 'sleep' , 'protected' , '//' , "Controller wake\n@return void" ) ; } if ( file_exists ( $ path ) ) { if ( ! $ this -> confirm ( "The class already exists. Do you wish to overwrite it?" , true ) ) { return ; } } \ CCFile :: write ( $ path , $ class -> output ( ) ) ; }
|
generate an controller
|
6,693
|
protected function getMethodArguments ( $ methodName ) { if ( ! empty ( $ this -> _magicMethodArgumentNames ) ) { return ArrayHelper :: getValue ( $ this -> _magicMethodArgumentNames , $ methodName , [ ] ) ; } try { $ reflectionClass = new \ ReflectionClass ( $ this ) ; $ comment = $ reflectionClass -> getDocComment ( ) ; $ lines = preg_split ( '/[\r\n]/' , $ comment ) ; $ regexp = '#\s*\*\s*@method ((?:.*) )?([a-zA-Z_]+)\(((?:[\\a-zA-Z]+\s+)?\$(?:[a-zA-Z_]+),?\s*)*\)#' ; foreach ( $ lines as $ line ) { $ matches = [ ] ; if ( preg_match ( $ regexp , $ line , $ matches ) ) { @ list ( $ null , $ returnType , $ method , $ argumentString ) = $ matches ; if ( is_null ( $ argumentString ) ) { $ arguments = [ ] ; } else { $ arguments = array_map ( 'trim' , explode ( ',' , $ argumentString ) ) ; foreach ( $ arguments as $ k => $ argument ) { if ( empty ( $ argument ) ) { continue ; } if ( strpos ( $ argument , ' ' ) !== false ) { $ tmp = explode ( ' ' , $ argument ) ; $ arguments [ $ k ] = [ 'name' => ltrim ( $ tmp [ 1 ] , '$' ) , 'type' => $ tmp [ 0 ] ] ; } else { $ arguments [ $ k ] = [ 'name' => ltrim ( $ argument , '$' ) , 'type' => 'mixed' ] ; } } } $ this -> _magicMethodArgumentNames [ $ method ] = $ arguments ; } } } catch ( \ ReflectionException $ e ) { } return ArrayHelper :: getValue ( $ this -> _magicMethodArgumentNames , $ methodName , [ ] ) ; }
|
Get argument names and positions and data types from phpdoc class comment
|
6,694
|
public static function colorize ( $ string , $ fg = null , $ at = null , $ bg = null ) { if ( ! static :: isSupportedShell ( ) ) { return $ string ; } $ colored = '' ; if ( isset ( static :: $ _fg [ $ fg ] ) ) { $ colored .= "\033[" . static :: $ _fg [ $ fg ] . "m" ; } if ( isset ( static :: $ _bg [ $ bg ] ) ) { $ colored .= "\033[" . static :: $ _bg [ $ bg ] . "m" ; } if ( isset ( static :: $ _at [ $ at ] ) ) { $ colored .= "\033[" . static :: $ _at [ $ at ] . "m" ; } $ colored .= $ string . "\033[0m" ; return $ colored ; }
|
Colorizes the string using provided colors .
|
6,695
|
public static function info ( $ msg ) { $ msg = 'Info: ' . $ msg ; $ space = strlen ( $ msg ) + 4 ; $ out = static :: colorize ( str_pad ( ' ' , $ space ) , Color :: FG_WHITE , Color :: AT_BOLD , Color :: BG_BLUE ) . PHP_EOL ; $ out .= static :: colorize ( ' ' . $ msg . ' ' , Color :: FG_WHITE , Color :: AT_BOLD , Color :: BG_BLUE ) . PHP_EOL ; $ out .= static :: colorize ( str_pad ( ' ' , $ space ) , Color :: FG_WHITE , Color :: AT_BOLD , Color :: BG_BLUE ) . PHP_EOL ; return $ out ; }
|
Color style for info messages .
|
6,696
|
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ pluginManagerClass = static :: PLUGIN_MANAGER_CLASS ; $ plugins = new $ pluginManagerClass ; $ plugins -> setServiceLocator ( $ serviceLocator ) ; $ configuration = $ serviceLocator -> get ( 'Config' ) ; if ( isset ( $ configuration [ 'di' ] ) && $ serviceLocator -> has ( 'Di' ) ) { $ di = $ serviceLocator -> get ( 'Di' ) ; $ plugins -> addAbstractFactory ( new DiAbstractServiceFactory ( $ di , DiAbstractServiceFactory :: USE_SL_BEFORE_DI ) ) ; } return $ plugins ; }
|
Create and return the MVC controller plugin manager
|
6,697
|
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof UserRoleQuery ) { return $ criteria ; } $ query = new UserRoleQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
|
Returns a new UserRoleQuery object .
|
6,698
|
public function filterByRole ( $ role , $ comparison = null ) { if ( $ role instanceof Role ) { return $ this -> addUsingAlias ( UserRolePeer :: ROLE_ID , $ role -> getId ( ) , $ comparison ) ; } elseif ( $ role instanceof PropelObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( UserRolePeer :: ROLE_ID , $ role -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByRole() only accepts arguments of type Role or PropelCollection' ) ; } }
|
Filter the query by a related Role object
|
6,699
|
public function useRoleQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinRole ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Role' , '\Slashworks\BackendBundle\Model\RoleQuery' ) ; }
|
Use the Role relation Role object
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.