class DataSourcesAdminController extends BaseAdminController

The DataSourcesAdminController class is the controller that handles all actions of the datasources management interface.

These actions are:

  • Creation of a data source
  • Modification of a data source
  • Deletion of a data source
  • Creation of a data source table
  • Modification of a data source table structure
  • Dropping a data source table
  • Adding a row in a data source table
  • Updating a row in a data source table
  • Deletion of a row in a data source table
  • Restoring a row in a data source table
  • Import / Export of a data source

Traits

This class implements common functions needed in G6KBundle controllers.
This class implements common functions needed in G6KBundle controllers.

Properties

protected mixed $projectDir from BaseAdminController
protected mixed $translator from BaseAdminController
protected mixed $kernel from BaseAdminController
protected mixed $userManager from BaseAdminController
protected mixed $authorizationChecker from BaseAdminController
protected mixed $fileUploader from BaseAdminController
protected mixed $deployer from BaseAdminController
string $databasesDir from BaseAdminController
string $simulatorsDir from BaseAdminController
string $publicDir from BaseAdminController
string $viewsDir from BaseAdminController
protected array $datatypes from DatasourcesTrait
private SimpleXMLElement $datasources
private Request $request
private int $script

Methods

void
__construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, UserManagerInterface $userManager, FileUploader $fileUploader, Deployer $deployer, mixed $projectDir)

Constructor of class BaseAdminController

Response
errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

zip(array $contents)

Zip file creation function.

int
unix2DosTime(int $unixtime = 0)

Converts unix time to MS DOS time

void
initialize()

Initialization of common directories

KernelInterface
getKernel()

Returns the Symfony kernel

TranslatorInterface
getTranslator()

Returns the translator interface

bool
hasParameter($parameters)

Checks if a parameter exists or not

string
getLocale()

Returns the 'locale' from config parameters

string
getLanguage()

Returns the 'app_language' from config parameters

string
getBrowserEngine(Request $request)

Returns the browser engine from the user agent

string|null
formatParamValue(Parameter $param)

Formats a source parameter value

getDatasource(Source $source)

Returns the data source accessed by a source query

mixed
processSource(Source $source)

Process a source query and returns the result of that query.

void
populateChoiceWithSource(Data $data)

Populates the list of values of a data item of type choice from a data source.

void
populateChoice(Data $data, ChoiceSource $choiceSource)

Populates the list of values of a data item of type choice from a data source where columns are in the given ChoiceSource object.

string
replaceVariable(array $matches)

Returns the formatted value of the data item where the ID is in the first element of the given array.

RichText|string
replaceVariables(RichText|string $target)

Replaces all data ID by their corresponding value into the given text.

string
replaceDataTag(array $matches)

Prefix with a # and returns the prefixed ID of the data item where the ID is in the first element of the given array.

RichText|string
replaceDataTagByVariable(RichText|string $target)

Replaces all the html tag data containing the ID of a data item by # followed by the ID

string
replaceDfnTag(array $matches)

Composes a footnote reference string [text^ID(title)] with the elements of the given array.

RichText|string
replaceDfnTagByFootnote(RichText|string $target)

Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]

string
replaceSpecialTags(string $target)

Replaces all the html tag dfn and data with their text equivalent

array
getWidgets()

Returns the list of available widgets.

array
getWidgetsByType()

Returns the list of available widgets by type (g6k type).

array
getWidgetsByInputType()

Returns the list of available widgets by form input type.

array
getFunctions()

Returns the label of available functions.

Data|null
getDataById(int $id)

Retrieves the Data object of a data item of the current simulator by its ID.

array|null
findAction(string $name, array $fromNode)

Retrieves an action node by its name in the actions tree from the supplied node

array|null
findActionField(array $fields, array $currentNode)

Retrieves an action field node in the given fields list for the given current option node

array|null
findActionOption(string $name, string $value, array $node)

Retrieves an action field option node by its value in the field list of the given action node

string|null
makeDateString(array $dateArray)

Makes a date string from an array [year, month, day], according to the date format.

String
getRelativePath(String $base, String $path)

Return a relative path to a file or directory using base directory.

bool
runConsoleCommand(array $command, array|null $report = null)

Run a console command.

StreamedResponse
runStreamedConsoleCommand(array $command, callable $start, callable $end)

Run a streamed console command.

bool
isDevelopmentEnvironment()

Determines whether the symfony kernel is in development mode or not.

string
getEnvironment()

Returns the current environment

getDatabase(int $dsid, SimpleXMLElement $datasources, string|null $databasesDir = null, bool $withDbName = true)

Constructs a Database object

array|string|bool|null
tablesList(Database $database)

Returns the list of tables of a database

array|string|bool|null
tableInfos(Database $database, string $table)

Returns informations about a table of a database

array
infosColumns(SimpleXMLElement $datasources, Database $database, string $table)

Returns informations about the columns of a table

array
infosColumnsToForm(string $table, array $infosColumns)

Constructs a form fields with informations about the columns of a table

array
getChoicesFromSource(SimpleXMLElement $source, array|null $result)

Retrieves the choice values of a data in the result list of a query on a data source

array|string|null
executeSource(SimpleXMLElement $source, SimpleXMLElement $datasources, string|null $databasesDir = null)

Executes the query from a source

array|null
filterResult(array|string $result, SimpleXMLElement $source)

Filters the result set of a query on the source return path

array
filterResultByLines(array $result, string $filter)

Filters the result set of a query on the source return path

string|bool
insertRowIntoTable(array $row, string $table, array $infosColumns, Database $database, TranslatorInterface $translator = null, bool $restore = false, bool $fromOtherTable = false)

Inserts a row into a table

bool|string
updateRowInTable(array $row, string $table, SimpleXMLElement $datasources, Database $database, TranslatorInterface $translator = null, bool $fromOtherTable = false)

Updates a table row

string|true
deleteRowFromTable(array $row, string $table, Database $database, TranslatorInterface $translator = null)

Deletes a row from a table

string|bool
checkColumnValue(array $info, string|null $value, TranslatorInterface $translator = null, bool $fromOtherTable = false)

Checks the value of a column

string|true
migrateDatabase(int $dsid, string $dbtype, SimpleXMLElement $datasources, SimpleXMLElement $fromDatasources, Database $fromDatabase, string|null $databasesDir = null, TranslatorInterface $translator = null, callable|null $fprogress = null)

Does the migration of data from a database to another.

string|true
createDatabase(int $dsid, string $dbtype, SimpleXMLElement $datasources, string|null $databasesDir = null, TranslatorInterface $translator = null)

Creates a database

string|true
createDatabaseTable(array $form, Database $database, TranslatorInterface $translator = null)

Creates a database table

string|true
dropDatabaseTable(string $table, Database $database, TranslatorInterface $translator = null)

Drops a table

string|true
editTableStructure(array $form, string $table, Database $database, SimpleXMLElement $datasources, TranslatorInterface $translator = null)

Edits a table structure

bool
alterSQLiteTable(string $table, string $alterdefs, Database $database, TranslatorInterface $translator = null)

Emulates a 'ALTER TABLE' for columns of a SQLite database.

Response|RedirectResponse
index(Request $request, int|null $dsid = null, string|null $table = null, string|null $crud = null)

Entry point for the route paths begining by /admin/datasources

Response|RedirectResponse
runIndex(Request $request, int|null $dsid, string|null $table, string|null $crud)

Processes the index action

Response|RedirectResponse
dispatch(Request $request, int|null $dsid, string|null $table, string|null $crud, array $form)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

bool
hasConfigParameter(string $parameter)

Checks if a parameter exists.

string
getConfigParameter(string $parameter)

Gets a parameter with its name.

Response
showDatasources(Request $request, int|null $dsid, string|null $table = null, string $action = 'show')

Shows the data sources management interface.

Response
doExportDatasource(int $dsid)

Exports a data source

string
makeDatasourceReportHeader(Request $request, string $datasource, string $heading)

Makes the header for a datasource action report

string
makeDatasourceReportFooter(Request $request, string $datasource, string $dsid)

Makes the footer for a datasource action report

StreamedResponse
doImportDatasource(Request $request)

Imports a data source from a JSON data file and a JSON schema file

string
makeTableReportHeader(Request $request, int $dsid, string $table, string $heading)

Makes the header for a table action report

string
makeTableReportFooter(Request $request, int $dsid, string $table)

Makes the footer for a datasource action report

StreamedResponse
doImportTable(Request $request, array $form, int $dsid, string|null $table, Database $database)

Imports a delimited text file into a table of a data source

RedirectResponse
createDatasource(array $form)

Creates a data source

string|true
migrateDB(int $dsid, string $dbtype, Database $fromDatabase)

Migrates data from a database to another.

string|true
createDB(int $dsid, string $dbtype)

Creates a database

string|true
createDBTable(array $form, Database $database)

Creates a table

string|true
editDBTable(array $form, string $table, Database $database)

Edits a table structure

string|bool
addDBTableRow(array $form, string $table, Database $database, bool $restore = false)

Inserts a row into a table

bool|string
updateDBTableRow(array $form, string $table, Database $database)

Updates a table row

string|true
deleteDBTableRow(array $form, string $table, Database $database)

Deletes a row from a table

string|true
dropDBTable(string $table, Database $database)

Drops a table

RedirectResponse
createTable(array $form, Database $database)

Creates a table

void
saveDatasources(DOMDocument $dom)

Saves DataSources.xml from a DOM document

Response
addTableRow(array $form, string $table, Database $database)

Adds a table row

Response
restoreTableRow(array $form, string $table, Database $database)

Restores a table row

Response
updateTableRow(array $form, string $table, Database $database)

Updates a table row

Response
deleteTableRow(array $form, string $table, Database $database)

Deletes a table row

RedirectResponse
doEditTable(array $form, string $table, Database $database)

Edits a table structure

void
addColumnsToTable(DOMDocument $dom, array $form, DOMElement $table)

Adds columns to a table

RedirectResponse
dropTable(array $form, string $table, Database $database)

Drops a table

RedirectResponse
doEditDatasource(int $dsid, array $form)

Edits a data source

RedirectResponse
dropDatasource(int $dsid)

Drops a data source

Details

in BaseAdminController at line 150
void __construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, UserManagerInterface $userManager, FileUploader $fileUploader, Deployer $deployer, mixed $projectDir)

Constructor of class BaseAdminController

Parameters

TranslatorInterface $translator
KernelInterface $kernel
AuthorizationCheckerInterface $authorizationChecker
UserManagerInterface $userManager
FileUploader $fileUploader
Deployer $deployer
mixed $projectDir

Return Value

void

in BaseAdminController at line 169
protected Response errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

Parameters

array $form The form fields
string $error The error message

Return Value

Response

in BaseAdminController at line 189
protected zip(array $contents)

Zip file creation function.

Makes zip files. Derivated from PhpMyAdmin package The $contents parameter is an array of associative array where keys are : - name: name of the zip - modtime: modification time - data: data to compress

Parameters

array $contents The array of contents to be compressed

See also

Official ZIP file format: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

in BaseAdminController at line 264
protected int unix2DosTime(int $unixtime = 0)

Converts unix time to MS DOS time

Parameters

int $unixtime (default: 0) The unix time

Return Value

int The MS DOS time

in ControllersTrait at line 66
protected void initialize()

Initialization of common directories

Return Value

void

in ControllersTrait at line 81
KernelInterface getKernel()

Returns the Symfony kernel

Return Value

KernelInterface $kernel The Symfony kernel

in ControllersTrait at line 92
TranslatorInterface getTranslator()

Returns the translator interface

Return Value

TranslatorInterface The translator interface

in ControllersTrait at line 103
bool hasParameter($parameters)

Checks if a parameter exists or not

Parameters

$parameters

Return Value

bool true the parameter exists, false otherwise

in ControllersTrait at line 119
string getLocale()

Returns the 'locale' from config parameters

Return Value

string The locale

in ControllersTrait at line 130
string getLanguage()

Returns the 'app_language' from config parameters

Return Value

string The app_language

in ControllersTrait at line 142
protected string getBrowserEngine(Request $request)

Returns the browser engine from the user agent

Parameters

Request $request the active request

Return Value

string The browser engine

in ControllersTrait at line 187
protected string|null formatParamValue(Parameter $param)

Formats a source parameter value

Parameters

Parameter $param The source parameter

Return Value

string|null The formatted value

in ControllersTrait at line 247
protected DataSource getDatasource(Source $source)

Returns the data source accessed by a source query

Parameters

Source $source The source

Return Value

DataSource The data source

in ControllersTrait at line 265
mixed processSource(Source $source)

Process a source query and returns the result of that query.

Parameters

Source $source The source

Return Value

mixed The result of the query.

in ControllersTrait at line 442
void populateChoiceWithSource(Data $data)

Populates the list of values of a data item of type choice from a data source.

Parameters

Data $data &$data The data item of type choice

Return Value

void

in ControllersTrait at line 466
protected void populateChoice(Data $data, ChoiceSource $choiceSource)

Populates the list of values of a data item of type choice from a data source where columns are in the given ChoiceSource object.

Parameters

Data $data &$data The data item of type choice
ChoiceSource $choiceSource The given ChoiceSource object

Return Value

void

in ControllersTrait at line 505
protected string replaceVariable(array $matches)

Returns the formatted value of the data item where the ID is in the first element of the given array.

If the second element of the given array is 'L' and if the data item is a choice, the label is returned instead of the value.

Parameters

array $matches The given array

Return Value

string The formatted value of the data item

in ControllersTrait at line 559
RichText|string replaceVariables(RichText|string $target)

Replaces all data ID by their corresponding value into the given text.

Parameters

RichText|string $target The target text

Return Value

RichText|string The result text

in ControllersTrait at line 587
protected string replaceDataTag(array $matches)

Prefix with a # and returns the prefixed ID of the data item where the ID is in the first element of the given array.

Parameters

array $matches The given array

Return Value

string The prefixed ID

in ControllersTrait at line 604
RichText|string replaceDataTagByVariable(RichText|string $target)

Replaces all the html tag data containing the ID of a data item by # followed by the ID

Parameters

RichText|string $target The target text

Return Value

RichText|string The result text

in ControllersTrait at line 627
protected string replaceDfnTag(array $matches)

Composes a footnote reference string [text^ID(title)] with the elements of the given array.

Parameters

array $matches The given array

Return Value

string The footnote reference string

in ControllersTrait at line 643
RichText|string replaceDfnTagByFootnote(RichText|string $target)

Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]

Parameters

RichText|string $target The target text

Return Value

RichText|string The result text

in ControllersTrait at line 666
string replaceSpecialTags(string $target)

Replaces all the html tag dfn and data with their text equivalent

Parameters

string $target The target text

Return Value

string The result text

in ControllersTrait at line 679
array getWidgets()

Returns the list of available widgets.

Return Value

array The list of available widgets

in ControllersTrait at line 696
array getWidgetsByType()

Returns the list of available widgets by type (g6k type).

Return Value

array The list of available widgets

in ControllersTrait at line 726
array getWidgetsByInputType()

Returns the list of available widgets by form input type.

Return Value

array The list of available widgets

in ControllersTrait at line 756
array getFunctions()

Returns the label of available functions.

Return Value

array The label of available functions

in ControllersTrait at line 783
Data|null getDataById(int $id)

Retrieves the Data object of a data item of the current simulator by its ID.

Parameters

int $id The ID of the data item.

Return Value

Data|null The Data object

in ControllersTrait at line 796
array|null findAction(string $name, array $fromNode)

Retrieves an action node by its name in the actions tree from the supplied node

Parameters

string $name The name of the action
array $fromNode The supplied node

Return Value

array|null The action node

in ControllersTrait at line 814
array|null findActionField(array $fields, array $currentNode)

Retrieves an action field node in the given fields list for the given current option node

Parameters

array $fields The fields list
array $currentNode The current option node

Return Value

array|null The action field node

in ControllersTrait at line 837
array|null findActionOption(string $name, string $value, array $node)

Retrieves an action field option node by its value in the field list of the given action node

Parameters

string $name The field name
string $value The option value
array $node The action node

Return Value

array|null The action field option node

in ControllersTrait at line 860
protected string|null makeDateString(array $dateArray)

Makes a date string from an array [year, month, day], according to the date format.

Parameters

array $dateArray The given array

Return Value

string|null The date string

in ControllersTrait at line 898
private String getRelativePath(String $base, String $path)

Return a relative path to a file or directory using base directory.

Parameters

String $base A base path used to construct relative path. For example /website
String $path A full path to file or directory used to construct relative path. For example /website/store/library.php

Return Value

String

in ControllersTrait at line 916
private bool runConsoleCommand(array $command, array|null $report = null)

Run a console command.

Parameters

array $command The command
array|null $report &$report An array for receiving the output of the command

Return Value

bool

in ControllersTrait at line 954
private StreamedResponse runStreamedConsoleCommand(array $command, callable $start, callable $end)

Run a streamed console command.

Parameters

array $command The command
callable $start a callback function to be called at the begining of the stream
callable $end a callback function to be called at the end of the stream

Return Value

StreamedResponse

in ControllersTrait at line 980
bool isDevelopmentEnvironment()

Determines whether the symfony kernel is in development mode or not.

Return Value

bool true if the symfony kernel is in development mode, false otherwise

in ControllersTrait at line 991
string getEnvironment()

Returns the current environment

Return Value

string The first letters of the current environment

in DatasourcesTrait at line 192
protected Database getDatabase(int $dsid, SimpleXMLElement $datasources, string|null $databasesDir = null, bool $withDbName = true)

Constructs a Database object

Parameters

int $dsid The datasource ID
SimpleXMLElement $datasources DataSources.xml content
string|null $databasesDir The database directory ID
bool $withDbName (default: true) if false, the name of the database will not be inserted in the dsn string.

Return Value

Database The Database object

in DatasourcesTrait at line 211
protected array|string|bool|null tablesList(Database $database)

Returns the list of tables of a database

Parameters

Database $database The Database object

Return Value

array|string|bool|null The list of tables

in DatasourcesTrait at line 249
protected array|string|bool|null tableInfos(Database $database, string $table)

Returns informations about a table of a database

Parameters

Database $database The Database object
string $table The table name

Return Value

array|string|bool|null Informations about a table

in DatasourcesTrait at line 302
protected array infosColumns(SimpleXMLElement $datasources, Database $database, string $table)

Returns informations about the columns of a table

Parameters

SimpleXMLElement $datasources The DataSources.xml content
Database $database The Database object
string $table The table name

Return Value

array Informations about the columns

in DatasourcesTrait at line 361
protected array infosColumnsToForm(string $table, array $infosColumns)

Constructs a form fields with informations about the columns of a table

Parameters

string $table The table name
array $infosColumns Informations about the columns

Return Value

array

in DatasourcesTrait at line 398
protected array getChoicesFromSource(SimpleXMLElement $source, array|null $result)

Retrieves the choice values of a data in the result list of a query on a data source

Parameters

SimpleXMLElement $source The source definition extracted from DataSources.xml
array|null $result The result list of a query

Return Value

array The choices list

in DatasourcesTrait at line 461
protected array|string|null executeSource(SimpleXMLElement $source, SimpleXMLElement $datasources, string|null $databasesDir = null)

Executes the query from a source

Parameters

SimpleXMLElement $source The source definition extracted from DataSources.xml
SimpleXMLElement $datasources The DataSources.xml content
string|null $databasesDir The database directory

Return Value

array|string|null The result set of the query

in DatasourcesTrait at line 523
protected array|null filterResult(array|string $result, SimpleXMLElement $source)

Filters the result set of a query on the source return path

Parameters

array|string $result The result set of a query
SimpleXMLElement $source The source definition extracted from DataSources.xml

Return Value

array|null The filtered result set

in DatasourcesTrait at line 548
protected array filterResultByLines(array $result, string $filter)

Filters the result set of a query on the source return path

Parameters

array $result The result set of a query
string $filter The filter

Return Value

array The filtered result set

in DatasourcesTrait at line 589
protected string|bool insertRowIntoTable(array $row, string $table, array $infosColumns, Database $database, TranslatorInterface $translator = null, bool $restore = false, bool $fromOtherTable = false)

Inserts a row into a table

Parameters

array $row The row to insert
string $table The table name
array $infosColumns The informations about the columns
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise
bool $restore (default: false) true if the row is to be restored, false otherwise
bool $fromOtherTable (default: false) true if the row comes from another table

Return Value

string|bool

in DatasourcesTrait at line 638
protected bool|string updateRowInTable(array $row, string $table, SimpleXMLElement $datasources, Database $database, TranslatorInterface $translator = null, bool $fromOtherTable = false)

Updates a table row

Parameters

array $row The row
string $table The table name
SimpleXMLElement $datasources The DataSources.xml content
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise
bool $fromOtherTable (default: false) true if the row comes from another table

Return Value

bool|string

in DatasourcesTrait at line 685
protected string|true deleteRowFromTable(array $row, string $table, Database $database, TranslatorInterface $translator = null)

Deletes a row from a table

Parameters

array $row The row
string $table The table name
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

string|true

in DatasourcesTrait at line 709
protected string|bool checkColumnValue(array $info, string|null $value, TranslatorInterface $translator = null, bool $fromOtherTable = false)

Checks the value of a column

Parameters

array $info Informations about the column
string|null $value The value to check
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise
bool $fromOtherTable (default: false) true if the row comes from another table

Return Value

string|bool An error message or true if no error.

in DatasourcesTrait at line 847
protected string|true migrateDatabase(int $dsid, string $dbtype, SimpleXMLElement $datasources, SimpleXMLElement $fromDatasources, Database $fromDatabase, string|null $databasesDir = null, TranslatorInterface $translator = null, callable|null $fprogress = null)

Does the migration of data from a database to another.

Parameters

int $dsid The datasource ID
string $dbtype The target database type
SimpleXMLElement $datasources The origin DataSources.xml content
SimpleXMLElement $fromDatasources The origin DataSources.xml content
Database $fromDatabase The origin Database object
string|null $databasesDir The database directory
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise
callable|null $fprogress a function receiving the row number that's inserted

Return Value

string|true

in DatasourcesTrait at line 895
protected string|true createDatabase(int $dsid, string $dbtype, SimpleXMLElement $datasources, string|null $databasesDir = null, TranslatorInterface $translator = null)

Creates a database

Parameters

int $dsid The datasource ID
string $dbtype The target database type
SimpleXMLElement $datasources The DataSources.xml content
string|null $databasesDir The database directory
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

string|true

in DatasourcesTrait at line 953
protected string|true createDatabaseTable(array $form, Database $database, TranslatorInterface $translator = null)

Creates a database table

Parameters

array $form The form fields
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

string|true

in DatasourcesTrait at line 1032
protected string|true dropDatabaseTable(string $table, Database $database, TranslatorInterface $translator = null)

Drops a table

Parameters

string $table The table name
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

string|true

in DatasourcesTrait at line 1057
protected string|true editTableStructure(array $form, string $table, Database $database, SimpleXMLElement $datasources, TranslatorInterface $translator = null)

Edits a table structure

Parameters

array $form The form fields
string $table The table name
Database $database The Database object
SimpleXMLElement $datasources The DataSources.xml content
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

string|true

in DatasourcesTrait at line 1277
protected bool alterSQLiteTable(string $table, string $alterdefs, Database $database, TranslatorInterface $translator = null)

Emulates a 'ALTER TABLE' for columns of a SQLite database.

ALTER TABLE tbl_name alter_specification [, alter_specification] ...

alter_specification: ADD column_definition | DROP column_definition | CHANGE old_col_name column_definition

column_definition: same as for create table statements

Parameters

string $table The table name
string $alterdefs Comma separated alter specifications
Database $database The Database object
TranslatorInterface $translator (default: null) true if the row is to be restored, false otherwise

Return Value

bool Always true

at line 113
Response|RedirectResponse index(Request $request, int|null $dsid = null, string|null $table = null, string|null $crud = null)

Entry point for the route paths begining by /admin/datasources

These route paths are :

  • /admin/datasources
  • /admin/datasources/{dsid}
  • /admin/datasources/{dsid}/{table}
  • /admin/datasources/{dsid}/{table}/{crud}

Parameters

Request $request The request
int|null $dsid (default: null) The datasource ID
string|null $table (default: null) The table name
string|null $crud (default: null) operation to execute on the data source (create-datasource, import-datasource, doimport-datasource, export-datasource, edit-datasource, doedit-datasource, drop-datasource, edit, import, add, update, delete, create, doedit, doimport, drop, restore)

Return Value

Response|RedirectResponse

at line 131
protected Response|RedirectResponse runIndex(Request $request, int|null $dsid, string|null $table, string|null $crud)

Processes the index action

Parameters

Request $request The request
int|null $dsid The datasource ID
string|null $table The table name
string|null $crud (default: null) operation to execute on the data source (create-datasource, import-datasource, doimport-datasource, export-datasource, edit-datasource, doedit-datasource, drop-datasource, edit, import, add, update, delete, create, doedit, doimport, drop, restore)

Return Value

Response|RedirectResponse

at line 164
protected Response|RedirectResponse dispatch(Request $request, int|null $dsid, string|null $table, string|null $crud, array $form)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

Parameters

Request $request The request
int|null $dsid The datasource ID
string|null $table The table name
string|null $crud (default: null) operation to execute on the data source (create-datasource, import-datasource, doimport-datasource, export-datasource, edit-datasource, doedit-datasource, drop-datasource, edit, import, add, update, delete, create, doedit, doimport, drop, restore)
array $form The form fields

Return Value

Response|RedirectResponse

at line 216
protected bool hasConfigParameter(string $parameter)

Checks if a parameter exists.

Parameters

string $parameter The parameter name

Return Value

bool true if the parameter exists, false if not

at line 228
protected string getConfigParameter(string $parameter)

Gets a parameter with its name.

Parameters

string $parameter The parameter name

Return Value

string The parameter value

at line 243
protected Response showDatasources(Request $request, int|null $dsid, string|null $table = null, string $action = 'show')

Shows the data sources management interface.

Parameters

Request $request The request
int|null $dsid The datasource ID
string|null $table (default: null) The table name
string $action (default: 'show')

Return Value

Response

at line 558
protected Response doExportDatasource(int $dsid)

Exports a data source

Route path : /admin/datasources/{dsid}/dummy/export-datasource

Creates a JSON data file and a JSON schema file from the source database. Compresses these two files into one for its download.

Parameters

int $dsid The datasource ID

Return Value

Response

at line 612
protected string makeDatasourceReportHeader(Request $request, string $datasource, string $heading)

Makes the header for a datasource action report

Parameters

Request $request
string $datasource The name of the datasource
string $heading The title of the header

Return Value

string

at line 651
protected string makeDatasourceReportFooter(Request $request, string $datasource, string $dsid)

Makes the footer for a datasource action report

Parameters

Request $request
string $datasource The name of the datasource
string $dsid The id of the datasource

Return Value

string

at line 678
protected StreamedResponse doImportDatasource(Request $request)

Imports a data source from a JSON data file and a JSON schema file

These files must have been exported from a G6K instance and must conform to the jsonschema.org specification.

Route path : /admin/datasources/0/dummy/doimport-datasource

Parameters

Request $request

Return Value

StreamedResponse

at line 764
protected string makeTableReportHeader(Request $request, int $dsid, string $table, string $heading)

Makes the header for a table action report

Parameters

Request $request
int $dsid The id of the datasource
string $table The name of the datasource
string $heading The title of the header

Return Value

string

at line 803
protected string makeTableReportFooter(Request $request, int $dsid, string $table)

Makes the footer for a datasource action report

Parameters

Request $request
int $dsid The id of the datasource
string $table The name of the table

Return Value

string

at line 833
protected StreamedResponse doImportTable(Request $request, array $form, int $dsid, string|null $table, Database $database)

Imports a delimited text file into a table of a data source

Route path : /admin/datasources/{dsid}/{table}/doimport

Parameters

Request $request
array $form The form fields
int $dsid The datasource ID
string|null $table The table name
Database $database The database object

Return Value

StreamedResponse

Exceptions

Exception

at line 909
protected RedirectResponse createDatasource(array $form)

Creates a data source

Parameters

array $form The form fields

Return Value

RedirectResponse

at line 933
protected string|true migrateDB(int $dsid, string $dbtype, Database $fromDatabase)

Migrates data from a database to another.

Parameters

int $dsid The datasource ID
string $dbtype The target database type
Database $fromDatabase The origin Database object

Return Value

string|true

at line 946
protected string|true createDB(int $dsid, string $dbtype)

Creates a database

Parameters

int $dsid The datasource ID
string $dbtype The target database type

Return Value

string|true

at line 959
protected string|true createDBTable(array $form, Database $database)

Creates a table

Parameters

array $form The form fields
Database $database The Database object

Return Value

string|true

at line 973
protected string|true editDBTable(array $form, string $table, Database $database)

Edits a table structure

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

string|true

at line 988
protected string|bool addDBTableRow(array $form, string $table, Database $database, bool $restore = false)

Inserts a row into a table

Parameters

array $form The form fields
string $table The table name
Database $database The Database object
bool $restore (default: false) true if the row is to be restored, false otherwise

Return Value

string|bool

at line 1003
protected bool|string updateDBTableRow(array $form, string $table, Database $database)

Updates a table row

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

bool|string

at line 1017
protected string|true deleteDBTableRow(array $form, string $table, Database $database)

Deletes a row from a table

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

string|true

at line 1030
protected string|true dropDBTable(string $table, Database $database)

Drops a table

Parameters

string $table The table name
Database $database The Database object

Return Value

string|true

at line 1045
protected RedirectResponse createTable(array $form, Database $database)

Creates a table

Route path : /admin/datasources/{dsid}/new/create

Parameters

array $form The form fields
Database $database The Database object

Return Value

RedirectResponse

at line 1083
protected void saveDatasources(DOMDocument $dom)

Saves DataSources.xml from a DOM document

Parameters

DOMDocument $dom The DOM document of DataSources.xml

Return Value

void

at line 1107
protected Response addTableRow(array $form, string $table, Database $database)

Adds a table row

Route path : /admin/datasources/{dsid}/{table}/add

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

Response

at line 1133
protected Response restoreTableRow(array $form, string $table, Database $database)

Restores a table row

Route path : /admin/datasources/{dsid}/{table}/restore

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

Response

at line 1155
protected Response updateTableRow(array $form, string $table, Database $database)

Updates a table row

Route path : /admin/datasources/{dsid}/{table}/update

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

Response

at line 1180
protected Response deleteTableRow(array $form, string $table, Database $database)

Deletes a table row

Route path : /admin/datasources/{dsid}/{table}/delete

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

Response

at line 1205
protected RedirectResponse doEditTable(array $form, string $table, Database $database)

Edits a table structure

Route path : /admin/datasources/{dsid}/{table}/doedit

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

RedirectResponse

at line 1261
protected void addColumnsToTable(DOMDocument $dom, array $form, DOMElement $table)

Adds columns to a table

Parameters

DOMDocument $dom The DOM document of DataSources.xml
array $form The form fields
DOMElement $table &$table The table element in DataSources.xml

Return Value

void

at line 1325
protected RedirectResponse dropTable(array $form, string $table, Database $database)

Drops a table

Route path : /admin/datasources/{dsid}/{table}/drop

Parameters

array $form The form fields
string $table The table name
Database $database The Database object

Return Value

RedirectResponse

at line 1357
protected RedirectResponse doEditDatasource(int $dsid, array $form)

Edits a data source

Route path : /admin/datasources/{dsid}/dummy/doedit-datasource

Parameters

int $dsid The datasource ID
array $form The form fields

Return Value

RedirectResponse

at line 1487
protected RedirectResponse dropDatasource(int $dsid)

Drops a data source

Route path : /admin/datasources/{dsid}/dummy/drop-datasource

Parameters

int $dsid The datasource ID

Return Value

RedirectResponse