idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
51,400 | public function getDbCommandArgs ( $ command , array $ database , $ schema = null ) { if ( $ schema === null ) { $ schema = $ database [ 'path' ] ; } switch ( $ command ) { case 'psql' : case 'pg_dump' : $ url = sprintf ( 'postgresql://%s:%s@%s:%d' , $ database [ 'username' ] , $ database [ 'password' ] , $ database [ ... | Returns command - line arguments to connect to a database . |
51,401 | public static function & getNestedArrayValue ( array & $ array , array $ parents , & $ keyExists = false ) { $ ref = & $ array ; foreach ( $ parents as $ parent ) { if ( is_array ( $ ref ) && array_key_exists ( $ parent , $ ref ) ) { $ ref = & $ ref [ $ parent ] ; } else { $ keyExists = false ; $ null = null ; return $... | Get a nested value in an array . |
51,402 | public static function setNestedArrayValue ( array & $ array , array $ parents , $ value , $ force = false ) { $ ref = & $ array ; foreach ( $ parents as $ parent ) { if ( $ force && isset ( $ ref ) && ! is_array ( $ ref ) ) { $ ref = [ ] ; } $ ref = & $ ref [ $ parent ] ; } $ ref = $ value ; } | Set a nested value in an array . |
51,403 | protected function keyExistsByFingerprint ( $ fingerprint ) { foreach ( $ this -> api ( ) -> getClient ( ) -> getSshKeys ( ) as $ existingKey ) { if ( $ existingKey -> fingerprint === $ fingerprint ) { return true ; } } return false ; } | Check whether the SSH key already exists in the user s account . |
51,404 | protected function getNewKeyPath ( $ number = 1 ) { $ basename = self :: DEFAULT_BASENAME ; if ( $ number > 1 ) { $ basename = strpos ( $ basename , '.key' ) ? str_replace ( '.key' , '.' . $ number . 'key' , $ basename ) : $ basename . '.' . $ number ; } $ fs = $ this -> getService ( 'fs' ) ; $ filename = $ fs -> getHo... | Find the path for a new SSH key . |
51,405 | public static function configureInput ( InputDefinition $ definition ) { $ definition -> addOption ( new InputOption ( 'date-fmt' , null , InputOption :: VALUE_REQUIRED , 'The date format (as a PHP date format string)' , ( new Config ( ) ) -> getWithDefault ( 'application.date_format' , 'c' ) ) ) ; } | Add options to a command s input definition . |
51,406 | public function displayData ( OutputInterface $ output , array $ data , $ property = null ) { $ key = null ; if ( $ property ) { $ parents = explode ( '.' , $ property ) ; $ key = end ( $ parents ) ; $ data = NestedArrayUtil :: getNestedArrayValue ( $ data , $ parents , $ keyExists ) ; if ( ! $ keyExists ) { throw new ... | Display a complex data structure . |
51,407 | protected function isTunnelOpen ( array $ tunnel ) { foreach ( $ this -> getTunnelInfo ( ) as $ info ) { if ( $ this -> tunnelsAreEqual ( $ tunnel , $ info ) ) { if ( isset ( $ info [ 'pid' ] ) && function_exists ( 'posix_kill' ) && ! posix_kill ( $ info [ 'pid' ] , 0 ) ) { $ this -> debug ( sprintf ( 'The tunnel at po... | Check whether a tunnel is already open . |
51,408 | protected function getTunnelInfo ( $ open = true ) { if ( ! isset ( $ this -> tunnelInfo ) ) { $ this -> tunnelInfo = [ ] ; $ filename = $ this -> config ( ) -> getWritableUserDir ( ) . '/tunnel-info.json' ; if ( file_exists ( $ filename ) ) { $ this -> debug ( sprintf ( 'Loading tunnel info from %s' , $ filename ) ) ;... | Get info on currently open tunnels . |
51,409 | protected function closeTunnel ( array $ tunnel ) { $ success = true ; if ( isset ( $ tunnel [ 'pid' ] ) && function_exists ( 'posix_kill' ) ) { $ success = posix_kill ( $ tunnel [ 'pid' ] , SIGTERM ) ; if ( ! $ success ) { $ this -> stdErr -> writeln ( sprintf ( 'Failed to kill process <error>%d</error> (POSIX error %... | Close an open tunnel . |
51,410 | protected function getPort ( $ default = 30000 ) { $ ports = [ ] ; foreach ( $ this -> getTunnelInfo ( ) as $ tunnel ) { $ ports [ ] = $ tunnel [ 'localPort' ] ; } return PortUtil :: getPort ( $ ports ? max ( $ ports ) + 1 : $ default ) ; } | Automatically determine the best port for a new tunnel . |
51,411 | protected function readChainFiles ( array $ chainPaths ) { $ chainFiles = [ ] ; foreach ( $ chainPaths as $ chainPath ) { if ( ! is_readable ( $ chainPath ) ) { throw new \ Exception ( "The chain file could not be read: $chainPath" ) ; } $ chainFiles [ $ chainPath ] = trim ( file_get_contents ( $ chainPath ) ) ; } retu... | Get the contents of multiple chain files . |
51,412 | protected function offerBranchChoice ( Project $ project , $ projectRoot ) { $ environments = $ this -> api ( ) -> getEnvironments ( $ project ) ; $ currentEnvironment = $ this -> getCurrentEnvironment ( $ project ) ; if ( $ currentEnvironment ) { $ this -> stdErr -> writeln ( "The current environment is " . $ this -> ... | Prompt the user to select a branch to checkout . |
51,413 | public function render ( $ placeholder = '.' ) { if ( $ this -> lastFrameTime !== null ) { $ timeSince = ( microtime ( true ) - $ this -> lastFrameTime ) * 1000000 ; if ( $ timeSince < $ this -> interval ) { usleep ( $ this -> interval - $ timeSince ) ; } } if ( $ this -> lastFrame !== null ) { if ( ! $ this -> output ... | Display the current frame and advance the pointer to the next one . |
51,414 | private function getDfColumn ( $ line , $ columnName ) { $ columnPatterns = [ 'filesystem' => '#^(.+?)(\s+[0-9])#' , 'total' => '#([0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+%\s+#' , 'used' => '#([0-9]+)\s+[0-9]+\s+[0-9]+%\s+#' , 'available' => '#([0-9]+)\s+[0-9]+%\s+#' , 'path' => '#%\s+(/.+)$#' , ] ; if ( ! isset ( $ columnPa... | Get a column from a line of df output . |
51,415 | private function parseDf ( $ dfOutput , $ appDir , array $ mountPaths ) { $ results = [ ] ; foreach ( explode ( "\n" , $ dfOutput ) as $ i => $ line ) { if ( $ i === 0 ) { continue ; } try { $ path = $ this -> getDfColumn ( $ line , 'path' ) ; } catch ( \ RuntimeException $ e ) { $ this -> debug ( $ e -> getMessage ( )... | Parse the output of df building a list of results per FS volume . |
51,416 | private function parseDu ( $ duOutput , array $ mountPaths ) { $ mountSizes = [ ] ; $ duOutputSplit = explode ( "\n" , $ duOutput , count ( $ mountPaths ) ) ; foreach ( $ mountPaths as $ i => $ mountPath ) { if ( ! isset ( $ duOutputSplit [ $ i ] ) ) { throw new \ RuntimeException ( "Failed to find row $i of 'du' comma... | Parse the du output . |
51,417 | protected function getAppConfig ( $ appName , $ refresh = true ) { $ webApp = $ this -> api ( ) -> getCurrentDeployment ( $ this -> getSelectedEnvironment ( ) , $ refresh ) -> getWebApp ( $ appName ) ; return AppConfig :: fromWebApp ( $ webApp ) -> getNormalized ( ) ; } | Get the remote application config . |
51,418 | protected function getMountsAsOptions ( array $ mounts ) { $ options = [ ] ; foreach ( $ mounts as $ path => $ definition ) { if ( $ definition [ 'source' ] === 'local' && isset ( $ definition [ 'source_path' ] ) ) { $ options [ $ path ] = sprintf ( '<question>%s</question> (shared:files/%s)' , $ path , $ definition [ ... | Format the mounts as an array of options for a ChoiceQuestion . |
51,419 | protected function validateDirectory ( $ directory , $ writable = false ) { if ( ! is_dir ( $ directory ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Directory not found: %s' , $ directory ) ) ; } elseif ( ! is_readable ( $ directory ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Directory not readab... | Validate a directory argument . |
51,420 | protected function runSync ( $ appName , $ mountPath , $ localPath , $ up , array $ options = [ ] ) { $ shell = $ this -> getService ( 'shell' ) ; $ sshUrl = $ this -> getSelectedEnvironment ( ) -> getSshUrl ( $ appName ) ; $ params = [ 'rsync' , '--archive' , '--compress' , '--human-readable' ] ; if ( $ this -> stdErr... | Push the local contents to the chosen mount . |
51,421 | public function renderSimple ( array $ values , array $ propertyNames ) { $ data = [ ] ; foreach ( $ propertyNames as $ key => $ label ) { $ data [ ] = [ $ label , $ values [ $ key ] ] ; } $ this -> render ( $ data , [ 'Property' , 'Value' ] ) ; } | Render an single - dimensional array of values with their property names . |
51,422 | public function render ( array $ rows , array $ header = [ ] , $ defaultColumns = [ ] ) { $ format = $ this -> getFormat ( ) ; $ columnsToDisplay = $ this -> columnsToDisplay ( ) ? : $ defaultColumns ; $ rows = $ this -> filterColumns ( $ rows , $ header , $ columnsToDisplay ) ; $ header = $ this -> filterColumns ( [ 0... | Render a table of data to output . |
51,423 | protected function columnsToDisplay ( ) { if ( ! $ this -> input -> hasOption ( 'columns' ) ) { return [ ] ; } $ columns = $ this -> input -> getOption ( 'columns' ) ; if ( count ( $ columns ) === 1 ) { $ columns = preg_split ( '/\s*,\s*/' , $ columns [ 0 ] ) ; } return $ columns ; } | Get the columns specified by the user . |
51,424 | private function filterColumns ( array $ rows , array $ header , array $ columnsToDisplay ) { if ( empty ( $ columnsToDisplay ) ) { return $ rows ; } $ availableColumns = [ ] ; foreach ( $ header as $ key => $ column ) { $ columnName = is_string ( $ key ) ? $ key : $ column ; $ availableColumns [ strtolower ( $ columnN... | Filter rows by column names . |
51,425 | protected function getFormat ( ) { if ( $ this -> input -> hasOption ( 'format' ) && $ this -> input -> getOption ( 'format' ) ) { return strtolower ( $ this -> input -> getOption ( 'format' ) ) ; } return null ; } | Get the user - specified format . |
51,426 | protected function renderCsv ( array $ rows , array $ header , $ delimiter = ',' ) { if ( ! empty ( $ header ) ) { array_unshift ( $ rows , $ header ) ; } $ this -> output -> write ( ( new Csv ( $ delimiter , "\n" ) ) -> format ( $ rows ) ) ; } | Render CSV output . |
51,427 | protected function renderTable ( array $ rows , array $ header ) { $ table = new AdaptiveTable ( $ this -> output ) ; $ table -> setHeaders ( $ header ) ; $ table -> setRows ( $ rows ) ; $ table -> render ( ) ; } | Render a Symfony Console table . |
51,428 | private function parseParents ( $ sha ) { if ( ! strpos ( $ sha , '^' ) && ! strpos ( $ sha , '~' ) ) { return [ ] ; } preg_match_all ( '#[\^~][0-9]*#' , $ sha , $ matches ) ; $ parents = [ ] ; foreach ( $ matches [ 0 ] as $ match ) { $ sign = $ match [ 0 ] ; $ number = intval ( substr ( $ match , 1 ) ? : 1 ) ; if ( $ ... | Parse the parents in a Git commit spec . |
51,429 | public function getCommit ( Environment $ environment , $ sha = null ) { $ sha = $ this -> normalizeSha ( $ environment , $ sha ) ; if ( $ sha === null ) { return false ; } $ parents = $ this -> parseParents ( $ sha ) ; $ sha = preg_replace ( '/[\^~].*$/' , '' , $ sha ) ; $ commit = $ this -> getCommitByShaHash ( $ env... | Get a Git Commit object for an environment . |
51,430 | private function getCommitByShaHash ( Environment $ environment , $ sha ) { $ cacheKey = $ environment -> project . ':' . $ sha ; $ client = $ this -> api -> getHttpClient ( ) ; if ( $ cached = $ this -> cache -> fetch ( $ cacheKey ) ) { return new Commit ( $ cached [ 'data' ] , $ cached [ 'uri' ] , $ client , true ) ;... | Get a specific commit from the API . |
51,431 | private function normalizeSha ( Environment $ environment , $ sha = null ) { if ( $ environment -> head_commit === null ) { return null ; } if ( $ sha === null ) { return $ environment -> head_commit ; } if ( strpos ( $ sha , 'HEAD' ) === 0 ) { $ sha = $ environment -> head_commit . substr ( $ sha , 4 ) ; } return $ sh... | Normalize a commit SHA for API and caching purposes . |
51,432 | public function readFile ( $ filename , Environment $ environment , $ commitSha = null ) { $ commitSha = $ this -> normalizeSha ( $ environment , $ commitSha ) ; $ cacheKey = implode ( ':' , [ 'raw' , $ environment -> project , $ filename , $ commitSha ] ) ; $ data = $ this -> cache -> fetch ( $ cacheKey ) ; if ( ! is_... | Read a file in the environment using the Git Data API . |
51,433 | protected function buildEnvironmentTree ( array $ environments , $ parent = null ) { $ children = [ ] ; foreach ( $ environments as $ environment ) { if ( $ environment -> parent === $ parent || ( $ parent === null && ! isset ( $ environments [ $ environment -> parent ] ) ) ) { $ this -> children [ $ environment -> id ... | Build a tree out of a list of environments . |
51,434 | protected function buildEnvironmentRows ( array $ tree , $ indent = true , $ indicateCurrent = true , $ indentAmount = 0 ) { $ rows = [ ] ; foreach ( $ tree as $ environment ) { $ row = [ ] ; $ id = $ environment -> id ; if ( $ indent ) { $ id = str_repeat ( ' ' , $ indentAmount ) . $ id ; } $ cellOptions = [ ] ; if ... | Recursively build rows of the environment table . |
51,435 | public function getNormalized ( ) { if ( ! isset ( $ this -> normalizedConfig ) ) { $ this -> normalizedConfig = $ this -> normalizeConfig ( $ this -> config ) ; } return $ this -> normalizedConfig ; } | Get normalized configuration . |
51,436 | private function normalizeConfig ( array $ config ) { if ( isset ( $ config [ 'toolstack' ] ) ) { if ( ! strpos ( $ config [ 'toolstack' ] , ':' ) ) { throw new InvalidConfigException ( "Invalid value for 'toolstack'" ) ; } list ( $ config [ 'type' ] , $ config [ 'build' ] [ 'flavor' ] ) = explode ( ':' , $ config [ 't... | Normalize the application config . |
51,437 | private function inPath ( $ dir ) { $ PATH = getenv ( 'PATH' ) ; $ realpath = realpath ( $ dir ) ; if ( ! $ PATH || ! $ realpath ) { return false ; } return in_array ( $ realpath , explode ( ':' , $ PATH ) ) ; } | Check if a directory is in the PATH . |
51,438 | private function formatSourceArg ( $ filename ) { $ arg = $ filename ; if ( DIRECTORY_SEPARATOR !== '\\' ) { $ realpath = realpath ( $ filename ) ; $ homeDir = Filesystem :: getHomeDirectory ( ) ; if ( $ realpath && strpos ( $ realpath , $ homeDir ) === 0 ) { $ arg = '~/' . ltrim ( substr ( $ realpath , strlen ( $ home... | Transform a filename into an argument for the source command . |
51,439 | private function getShortPath ( $ filename ) { if ( getcwd ( ) === dirname ( $ filename ) ) { return basename ( $ filename ) ; } $ homeDir = Filesystem :: getHomeDirectory ( ) ; if ( strpos ( $ filename , $ homeDir ) === 0 ) { return str_replace ( $ homeDir , '~' , $ filename ) ; } return $ filename ; } | Shorten a filename for display . |
51,440 | protected function findShellConfigFile ( ) { $ envPrefix = $ this -> config ( ) -> get ( 'service.env_prefix' ) ; if ( getenv ( $ envPrefix . 'PROJECT' ) !== false && getenv ( $ envPrefix . 'APP_DIR' ) !== false && getenv ( $ envPrefix . 'APP_DIR' ) === Filesystem :: getHomeDirectory ( ) ) { return getenv ( $ envPrefix... | Finds a shell configuration file for the user . |
51,441 | public function has ( $ name , $ notNull = true ) { $ value = NestedArrayUtil :: getNestedArrayValue ( self :: $ config , explode ( '.' , $ name ) , $ exists ) ; return $ exists && ( ! $ notNull || $ value !== null ) ; } | Check if a configuration value is defined . |
51,442 | public function get ( $ name ) { $ value = NestedArrayUtil :: getNestedArrayValue ( self :: $ config , explode ( '.' , $ name ) , $ exists ) ; if ( ! $ exists ) { throw new \ RuntimeException ( 'Configuration not defined: ' . $ name ) ; } return $ value ; } | Get a configuration value . |
51,443 | public function getWithDefault ( $ name , $ default ) { $ value = NestedArrayUtil :: getNestedArrayValue ( self :: $ config , explode ( '.' , $ name ) , $ exists ) ; if ( ! $ exists ) { return $ default ; } return $ value ; } | Get a configuration value specifying a default if it does not exist . |
51,444 | public function getUserConfigDir ( $ absolute = true ) { $ path = $ this -> get ( 'application.user_config_dir' ) ; return $ absolute ? $ this -> fs ( ) -> getHomeDirectory ( ) . '/' . $ path : $ path ; } | Get the directory where the CLI is normally installed and configured . |
51,445 | public function isCommandEnabled ( $ name ) { if ( ! empty ( self :: $ config [ 'application' ] [ 'disabled_commands' ] ) && in_array ( $ name , self :: $ config [ 'application' ] [ 'disabled_commands' ] ) ) { return false ; } if ( ! empty ( self :: $ config [ 'application' ] [ 'experimental_commands' ] ) && in_array (... | Test if a command should be enabled . |
51,446 | public function getVersion ( ) { if ( isset ( $ this -> version ) ) { return $ this -> version ; } $ version = $ this -> get ( 'application.version' ) ; if ( substr ( $ version , 0 , 1 ) === '@' && substr ( $ version , - 1 ) === '@' ) { $ tag = ( new Shell ( ) ) -> execute ( [ 'git' , 'describe' , '--tags' ] , CLI_ROOT... | Returns this application version . |
51,447 | private function readFile ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new \ Exception ( sprintf ( 'File not found: %s' , $ filename ) ) ; } if ( ! is_readable ( $ filename ) || ( $ content = file_get_contents ( $ filename ) ) === false ) { throw new \ Exception ( sprintf ( 'Failed to read file: %s' , $... | Reads a file and throws appropriate exceptions on failure . |
51,448 | private function processTags ( $ config , $ filename ) { if ( ! is_array ( $ config ) ) { return $ this -> processSingleTag ( $ config , $ filename ) ; } foreach ( $ config as $ key => $ item ) { if ( is_array ( $ item ) ) { $ config [ $ key ] = $ this -> processTags ( $ item , $ filename ) ; } else { $ config [ $ key ... | Processes custom tags in the parsed config . |
51,449 | private function processSingleTag ( $ item , $ filename , $ configKey = '' ) { if ( $ item instanceof TaggedValue ) { $ tag = $ item -> getTag ( ) ; $ value = $ item -> getValue ( ) ; } elseif ( is_string ( $ item ) && strlen ( $ item ) && $ item [ 0 ] === '!' && preg_match ( '/\!([a-z]+)[ \t]+(.+)$/i' , $ item , $ mat... | Processes a single config item which may be a custom tag . |
51,450 | private function resolveInclude ( $ value , $ filename , $ configKey = '' ) { if ( is_string ( $ value ) ) { $ includeType = 'yaml' ; $ includePath = $ value ; } elseif ( is_array ( $ value ) ) { if ( $ missing = array_diff ( [ 'type' , 'path' ] , array_keys ( $ value ) ) ) { throw new InvalidConfigException ( 'The !in... | Resolve an !include config tag value . |
51,451 | public function addColumn ( string $ name ) : void { if ( ! in_array ( $ name , $ this -> columns , true ) ) { $ this -> columns [ ] = $ name ; } } | Adds column to the key . |
51,452 | public function render ( TableStructure $ table ) : string { $ output = '' ; foreach ( $ this -> dropColumn as $ name ) { $ output .= " \$this->dropColumn('" . $ table -> renderName ( ) . "', '{$name}');\n" ; } foreach ( $ this -> addColumn as $ name => $ column ) { $ output .= " \$this->addColumn('" . $ ... | Renders migration changes . |
51,453 | public static function identifySchema ( ? string $ schemaClass ) : string { switch ( $ schemaClass ) { case 'yii\db\mssql\Schema' : return self :: SCHEMA_MSSQL ; case 'yii\db\oci\Schema' : return self :: SCHEMA_OCI ; case 'yii\db\pgsql\Schema' : return self :: SCHEMA_PGSQL ; case 'yii\db\sqlite\Schema' : return self ::... | Returns schema code based on its class name . |
51,454 | public function renderName ( ) : string { $ tableName = $ this -> name ; if ( ! $ this -> usePrefix ) { return $ tableName ; } if ( $ this -> dbPrefix && strpos ( $ this -> name , $ this -> dbPrefix ) === 0 ) { $ tableName = substr ( $ this -> name , mb_strlen ( $ this -> dbPrefix , 'UTF-8' ) ) ; } return '{{%' . $ tab... | Renders table name . |
51,455 | public function render ( ) : string { return $ this -> renderTable ( ) . $ this -> renderPk ( ) . $ this -> renderIndexes ( ) . $ this -> renderForeignKeys ( ) . "\n" ; } | Renders the migration structure . |
51,456 | public function renderPk ( ) : string { $ output = '' ; if ( $ this -> primaryKey -> isComposite ( ) ) { $ output .= "\n" . $ this -> primaryKey -> render ( $ this ) ; } return $ output ; } | Renders the primary key . |
51,457 | public function renderIndexes ( ) : string { $ output = '' ; if ( $ this -> indexes ) { foreach ( $ this -> indexes as $ index ) { foreach ( $ this -> foreignKeys as $ foreignKey ) { if ( $ foreignKey -> name === $ index -> name ) { continue 2 ; } } $ output .= "\n" . $ index -> render ( $ this ) ; } } return $ output ... | Renders the indexes . |
51,458 | public function renderForeignKeys ( ) : string { $ output = '' ; if ( $ this -> foreignKeys ) { foreach ( $ this -> foreignKeys as $ foreignKey ) { $ output .= "\n" . $ foreignKey -> render ( $ this ) ; } } return $ output ; } | Renders the foreign keys . |
51,459 | protected function buildGeneralDefinition ( TableStructure $ table ) : void { array_unshift ( $ this -> definition , '$this' ) ; if ( $ this -> isUnsignedPossible && $ this -> isUnsigned ) { $ this -> definition [ ] = 'unsigned()' ; } if ( $ this -> isNotNullPossible && $ this -> isNotNull ) { $ this -> definition [ ] ... | Builds general methods chain for column definition . |
51,460 | public function renderDefinition ( TableStructure $ table ) : string { $ this -> buildSpecificDefinition ( $ table ) ; $ this -> buildGeneralDefinition ( $ table ) ; return implode ( '->' , $ this -> definition ) ; } | Renders column definition . |
51,461 | public function render ( TableStructure $ table , int $ indent = 12 ) : string { return str_repeat ( ' ' , $ indent ) . "'{$this->name}' => " . $ this -> renderDefinition ( $ table ) . ',' ; } | Renders the column . |
51,462 | public function isColumnInPK ( TablePrimaryKey $ pk ) : bool { return in_array ( $ this -> name , $ pk -> columns , true ) ; } | Checks if column is a part of primary key . |
51,463 | public function isColumnAppendPK ( ) : bool { if ( empty ( $ this -> append ) ) { return false ; } if ( $ this -> schema === TableStructure :: SCHEMA_MSSQL ) { if ( stripos ( $ this -> append , 'IDENTITY' ) !== false && stripos ( $ this -> append , 'PRIMARY KEY' ) !== false ) { return true ; } } elseif ( stripos ( $ th... | Checks if information of primary key is set in append property . |
51,464 | public function prepareSchemaAppend ( bool $ primaryKey , bool $ autoIncrement ) : ? string { switch ( $ this -> schema ) { case TableStructure :: SCHEMA_MSSQL : $ append = $ primaryKey ? 'IDENTITY PRIMARY KEY' : '' ; break ; case TableStructure :: SCHEMA_OCI : case TableStructure :: SCHEMA_PGSQL : $ append = $ primary... | Prepares append SQL based on schema . |
51,465 | public function removePKAppend ( ) : ? string { if ( ! $ this -> isColumnAppendPK ( ) ) { return null ; } $ uppercaseAppend = preg_replace ( '/\s+/' , ' ' , mb_strtoupper ( $ this -> append , 'UTF-8' ) ) ; switch ( $ this -> schema ) { case TableStructure :: SCHEMA_MSSQL : $ formattedAppend = str_replace ( [ 'PRIMARY K... | Removes information of primary key in append property . |
51,466 | public function init ( ) : void { parent :: init ( ) ; $ this -> _currentTable = $ this -> tableName ; foreach ( $ this -> skipMigrations as $ index => $ migration ) { $ this -> skipMigrations [ $ index ] = trim ( $ migration , '\\' ) ; } } | Sets current table name and clears skipped migrations names . |
51,467 | protected function gatherChanges ( array $ changes ) : bool { if ( ! isset ( $ changes [ $ this -> _currentTable ] ) ) { return true ; } $ data = array_reverse ( $ changes [ $ this -> _currentTable ] ) ; foreach ( $ data as $ tableChange ) { if ( $ tableChange -> method === 'dropTable' ) { return false ; } if ( $ table... | Gathers applied changes . |
51,468 | protected function extract ( string $ migration ) : array { if ( strpos ( $ migration , '\\' ) === false ) { $ file = Yii :: getAlias ( $ this -> migrationPath . DIRECTORY_SEPARATOR . $ migration . '.php' ) ; if ( ! file_exists ( $ file ) ) { throw new ErrorException ( "File '{$file}' can not be found! Check migration ... | Extracts migration data structures . |
51,469 | public function getOldTable ( ) : TableStructure { if ( $ this -> _oldTable === null ) { $ this -> _oldTable = new TableStructure ( [ 'schema' => get_class ( $ this -> db -> schema ) , 'generalSchema' => $ this -> generalSchema , 'usePrefix' => $ this -> useTablePrefix , 'dbPrefix' => $ this -> db -> tablePrefix , ] ) ... | Returns the table structure as applied in gathered migrations . |
51,470 | public function displayValue ( $ value ) : string { if ( $ value === null ) { return 'NULL' ; } if ( $ value === true ) { return 'TRUE' ; } if ( $ value === false ) { return 'FALSE' ; } if ( is_array ( $ value ) ) { return Json :: encode ( $ value ) ; } return '"' . str_replace ( '"' , '\"' , $ value ) . '"' ; } | Returns values as a string . |
51,471 | protected function confirmCompositePrimaryKey ( array $ newKeys ) : bool { if ( count ( $ this -> table -> primaryKey -> columns ) === 1 && count ( $ newKeys ) === 1 ) { foreach ( $ this -> plan -> addColumn as $ name => $ column ) { if ( $ name === $ newKeys [ 0 ] && $ column -> isColumnAppendPK ( ) ) { return false ;... | Confirms adding composite primary key and removes excessive PK statements . |
51,472 | public function isUpdateRequired ( ) : bool { $ history = $ this -> fetchHistory ( ) ; if ( ! empty ( $ history ) ) { $ this -> setDummyMigrationClass ( ) ; foreach ( $ history as $ migration => $ time ) { $ migration = trim ( $ migration , '\\' ) ; if ( in_array ( $ migration , $ this -> skipMigrations , true ) ) { co... | Checks if new updating migration is required . |
51,473 | public static function build ( array $ configuration = [ ] ) : ? TableColumn { if ( ! array_key_exists ( 'type' , $ configuration ) ) { throw new InvalidConfigException ( 'Configuration for TableColumnFactory is missing "type" key.' ) ; } switch ( $ configuration [ 'type' ] ) { case Schema :: TYPE_PK : return new Table... | Builds table column object based on the type . |
51,474 | protected function extractColumns ( $ columns ) { $ schema = [ ] ; foreach ( $ columns as $ name => $ data ) { $ schema [ $ name ] = $ this -> extractColumn ( $ data ) ; } return $ schema ; } | Returns extracted columns data . |
51,475 | public function fillTypeMapProperties ( $ type , $ keyToDb , $ dbToKey ) { $ schema = [ ] ; if ( ! array_key_exists ( $ type , $ keyToDb ) ) { $ schema [ 'type' ] = $ type ; return $ schema ; } $ builder = $ keyToDb [ $ type ] ; if ( strpos ( $ builder , 'NOT NULL' ) !== false ) { $ schema [ 'isNotNull' ] = true ; $ bu... | Updates column properties based on schema type map . |
51,476 | public function addChange ( $ table , $ method , $ data ) { $ table = $ this -> getRawTableName ( $ table ) ; if ( ! isset ( $ this -> changes [ $ table ] ) ) { $ this -> changes [ $ table ] = [ ] ; } $ this -> changes [ $ table ] [ ] = new TableChange ( [ 'schema' => TableStructure :: identifySchema ( get_class ( $ th... | Adds method of structure change and its data |
51,477 | public function getTableSchema ( ) : ? TableSchema { if ( $ this -> _tableSchema === null ) { $ this -> _tableSchema = $ this -> db -> getTableSchema ( $ this -> tableName ) ; } return $ this -> _tableSchema ; } | Returns table schema . |
51,478 | protected function getTablePrimaryKey ( ) : TablePrimaryKey { $ data = [ ] ; $ constraint = $ this -> db -> schema -> getTablePrimaryKey ( $ this -> tableName , true ) ; if ( $ constraint ) { $ data = [ 'columns' => $ constraint -> columnNames , 'name' => $ constraint -> name , ] ; } elseif ( $ this -> db -> schema ins... | Returns table primary key . |
51,479 | protected function getTableColumns ( array $ indexes = [ ] , ? string $ schema = null ) : array { $ columns = [ ] ; if ( $ this -> tableSchema instanceof TableSchema ) { $ indexData = ! empty ( $ indexes ) ? $ indexes : $ this -> getTableIndexes ( ) ; foreach ( $ this -> tableSchema -> columns as $ column ) { $ isUniqu... | Returns columns structure . |
51,480 | protected function getTableForeignKeys ( ) : array { $ data = [ ] ; $ fks = $ this -> db -> schema -> getTableForeignKeys ( $ this -> tableName , true ) ; foreach ( $ fks as $ fk ) { $ data [ $ fk -> name ] = new TableForeignKey ( [ 'name' => $ fk -> name , 'columns' => $ fk -> columnNames , 'refTable' => $ fk -> forei... | Returns foreign keys structure . |
51,481 | protected function getTableIndexes ( ) : array { $ data = [ ] ; $ idxs = $ this -> db -> schema -> getTableIndexes ( $ this -> tableName , true ) ; foreach ( $ idxs as $ idx ) { if ( ! $ idx -> isPrimary ) { $ data [ $ idx -> name ] = new TableIndex ( [ 'name' => $ idx -> name , 'unique' => $ idx -> isUnique , 'columns... | Returns table indexes . |
51,482 | public function getTable ( ) : TableStructure { if ( $ this -> _table === null ) { $ indexes = $ this -> getTableIndexes ( ) ; $ this -> _table = new TableStructure ( [ 'name' => $ this -> tableName , 'schema' => get_class ( $ this -> db -> schema ) , 'generalSchema' => $ this -> generalSchema , 'usePrefix' => $ this -... | Returns table data |
51,483 | public function init ( ) : void { parent :: init ( ) ; foreach ( [ 'useTablePrefix' , 'showOnly' , 'generalSchema' , 'fixHistory' ] as $ property ) { if ( $ this -> $ property !== true ) { if ( $ this -> $ property === 'true' || $ this -> $ property === 1 ) { $ this -> $ property = true ; } $ this -> $ property = ( boo... | Makes sure boolean properties are boolean . |
51,484 | public function preparePathDirectory ( string $ path ) : string { $ translatedPath = Yii :: getAlias ( $ path ) ; if ( ! is_dir ( $ translatedPath ) ) { FileHelper :: createDirectory ( $ translatedPath ) ; } return $ translatedPath ; } | Prepares path directory . |
51,485 | protected function addMigrationHistory ( string $ version , ? string $ namespace = null ) : void { $ this -> stdout ( ' > Adding migration history entry ...' , Console :: FG_YELLOW ) ; $ this -> db -> createCommand ( ) -> insert ( $ this -> migrationTable , [ 'version' => ( $ namespace ? $ namespace . '\\' : '' ) . $ v... | Adds migration history entry . |
51,486 | public function actionList ( ) : int { $ tables = $ this -> db -> schema -> getTableNames ( ) ; if ( ! $ tables ) { $ this -> stdout ( " > Your database does not contain any tables yet.\n" ) ; } else { $ this -> stdout ( ' > Your database contains ' . count ( $ tables ) . " tables:\n" ) ; foreach ( $ tables as $ table ... | Lists all tables in the database . |
51,487 | public function actionCreate ( string $ table ) : int { $ tables = [ $ table ] ; if ( strpos ( $ table , ',' ) !== false ) { $ tables = explode ( ',' , $ table ) ; } $ migrationsGenerated = 0 ; foreach ( $ tables as $ name ) { $ this -> stdout ( " > Generating create migration for table '{$name}' ..." , Console :: FG_Y... | Creates new migration for the given tables . |
51,488 | public function actionCreateAll ( ) : int { $ tables = $ this -> removeExcludedTables ( $ this -> db -> schema -> getTableNames ( ) ) ; if ( ! $ tables ) { $ this -> stdout ( ' > Your database does not contain any tables yet.' , Console :: FG_YELLOW ) ; return ExitCode :: OK ; } if ( $ this -> confirm ( ' > Are you sur... | Creates new migrations for every table in database . Since 3 . 0 . 0 migration history table is skipped . |
51,489 | public function actionUpdateAll ( ) : int { $ tables = $ this -> removeExcludedTables ( $ this -> db -> schema -> getTableNames ( ) ) ; if ( ! $ tables ) { $ this -> stdout ( ' > Your database does not contain any tables yet.' , Console :: FG_YELLOW ) ; return ExitCode :: OK ; } if ( $ this -> confirm ( ' > Are you sur... | Creates new update migrations for every table in database . Since 3 . 0 . 0 migration history table is skipped . |
51,490 | public function removeExcludedTables ( array $ tables ) : array { if ( ! $ tables ) { return [ ] ; } $ filteredTables = [ ] ; $ excludedTables = array_merge ( [ $ this -> db -> schema -> getRawTableName ( $ this -> migrationTable ) ] , $ this -> excludeTables ) ; foreach ( $ tables as $ table ) { if ( ! in_array ( $ ta... | Removes excluded tables names from the tables list . |
51,491 | public function render ( TableStructure $ table , int $ indent = 8 ) { return str_repeat ( ' ' , $ indent ) . "\$this->createIndex('{$this->name}', '" . $ table -> renderName ( ) . "', " . ( count ( $ this -> columns ) === 1 ? "'{$this->columns[0]}'" : "['" . implode ( "', '" , $ this -> columns ) . "']" ) . ( $ this -... | Renders the index . |
51,492 | public function init ( ) : void { parent :: init ( ) ; if ( $ this -> default !== '' && $ this -> default !== null && ! is_array ( $ this -> default ) ) { try { $ default = Json :: decode ( $ this -> default ) ; if ( is_array ( $ default ) ) { $ this -> default = $ default ; } } catch ( InvalidArgumentException $ excep... | Checks if default value is JSONed array . If so it s decoded . |
51,493 | public function renderName ( TableStructure $ table ) : string { if ( $ this -> name === null || is_numeric ( $ this -> name ) ) { return "fk-{$table->name}-" . implode ( '-' , $ this -> columns ) ; } return $ this -> name ; } | Renders key name . |
51,494 | public function renderRefTableName ( TableStructure $ table ) : string { $ tableName = $ this -> refTable ; if ( ! $ table -> usePrefix ) { return $ tableName ; } if ( $ table -> dbPrefix && strpos ( $ this -> refTable , $ table -> dbPrefix ) === 0 ) { $ tableName = substr ( $ this -> refTable , mb_strlen ( $ table -> ... | Renders reference table name . |
51,495 | public function getFullHost ( ) { if ( null === $ this -> suffix ) { return $ this -> hostname ; } if ( null === $ this -> subdomain ) { return $ this -> hostname . '.' . $ this -> suffix ; } return implode ( '.' , [ $ this -> subdomain , $ this -> hostname , $ this -> suffix ] ) ; } | Method that returns full host record . |
51,496 | public function getRegistrableDomain ( ) { if ( null === $ this -> suffix ) { return null ; } return null === $ this -> hostname ? null : $ this -> hostname . '.' . $ this -> suffix ; } | Returns registrable domain or null . |
51,497 | public function setExtractionMode ( $ extractionMode = null ) { if ( null === $ extractionMode ) { $ this -> extractionMode = static :: MODE_ALLOW_ICANN | static :: MODE_ALLOW_PRIVATE | static :: MODE_ALLOW_NOT_EXISTING_SUFFIXES ; return ; } if ( ! is_int ( $ extractionMode ) ) { throw new RuntimeException ( 'Invalid a... | Sets extraction mode option that will control extraction process . |
51,498 | private function extractHostname ( $ url ) { $ url = trim ( Str :: lower ( $ url ) ) ; $ url = preg_replace ( static :: SCHEMA_PATTERN , '' , $ url ) ; $ url = $ this -> fixUriParts ( $ url ) ; $ hostname = Arr :: first ( explode ( '/' , $ url , 2 ) ) ; $ hostname = Arr :: last ( explode ( '@' , $ hostname ) ) ; $ last... | Method that extracts the hostname or IP address from a URL . |
51,499 | protected function suffixExists ( $ entry ) { if ( ! $ this -> suffixStore -> isExists ( $ entry ) ) { return false ; } $ type = $ this -> suffixStore -> getType ( $ entry ) ; if ( $ this -> extractionMode & static :: MODE_ALLOW_ICANN && $ type === Store :: TYPE_ICANN ) { return true ; } return $ this -> extractionMode... | Method that checks existence of entry in Public Suffix List database including provided options . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.