DataSourcesAdminController
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
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
Constructor of class BaseAdminController
Returns a JSON response formed with the data of a form and an error message.
Returns the browser engine from the user agent
Populates the list of values of a data item of type choice from a data source.
Populates the list of values of a data item of type choice from a data source where columns are in the given ChoiceSource object.
Returns the formatted value of the data item where the ID is in the first element of the given array.
Replaces all data ID by their corresponding value into the given text.
Prefix with a # and returns the prefixed ID of the data item where the ID is in the first element of the given array.
Replaces all the html tag data containing the ID of a data item by # followed by the ID
Composes a footnote reference string [text^ID(title)] with the elements of the given array.
Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]
Replaces all the html tag dfn and data with their text equivalent
Returns the list of available widgets by type (g6k type).
Returns the list of available widgets by form input type.
Retrieves the Data object of a data item of the current simulator by its ID.
Retrieves an action node by its name in the actions tree from the supplied node
Retrieves an action field node in the given fields list for the given current option node
Retrieves an action field option node by its value in the field list of the given action node
Makes a date string from an array [year, month, day], according to the date format.
Return a relative path to a file or directory using base directory.
Run a console command.
Run a streamed console command.
Determines whether the symfony kernel is in development mode or not.
Constructs a Database object
Returns informations about the columns of a table
Constructs a form fields with informations about the columns of a table
Retrieves the choice values of a data in the result list of a query on a data source
Executes the query from a source
Filters the result set of a query on the source return path
Filters the result set of a query on the source return path
Inserts a row into a table
Updates a table row
Deletes a row from a table
Checks the value of a column
Does the migration of data from a database to another.
Creates a database
Creates a database table
Drops a table
Edits a table structure
Emulates a 'ALTER TABLE' for columns of a SQLite database.
Entry point for the route paths begining by /admin/datasources
Processes the index action
Dispatches the index action to the appropriate processing based on the value of the crud parameter.
Checks if a parameter exists.
Gets a parameter with its name.
Shows the data sources management interface.
Exports a data source
Makes the header for a datasource action report
Makes the footer for a datasource action report
Imports a data source from a JSON data file and a JSON schema file
Makes the header for a table action report
Makes the footer for a datasource action report
Imports a delimited text file into a table of a data source
Creates a data source
Creates a database
Inserts a row into a table
Edits a data source
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
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.
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
in BaseAdminController at line 264
protected int
unix2DosTime(int $unixtime = 0)
Converts unix time to MS DOS time
in ControllersTrait at line 66
protected void
initialize()
Initialization of common directories
in ControllersTrait at line 81
KernelInterface
getKernel()
Returns the Symfony kernel
in ControllersTrait at line 92
TranslatorInterface
getTranslator()
Returns the translator interface
in ControllersTrait at line 103
bool
hasParameter($parameters)
Checks if a parameter exists or not
in ControllersTrait at line 119
string
getLocale()
Returns the 'locale' from config parameters
in ControllersTrait at line 130
string
getLanguage()
Returns the 'app_language' from config parameters
in ControllersTrait at line 142
protected string
getBrowserEngine(Request $request)
Returns the browser engine from the user agent
in ControllersTrait at line 187
protected string|null
formatParamValue(Parameter $param)
Formats a source parameter value
in ControllersTrait at line 247
protected DataSource
getDatasource(Source $source)
Returns the data source accessed by a source query
in ControllersTrait at line 265
mixed
processSource(Source $source)
Process a source query and returns the result of that 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.
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.
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.
in ControllersTrait at line 559
RichText|string
replaceVariables(RichText|string $target)
Replaces all data ID by their corresponding value into the given 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.
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
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.
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)]
in ControllersTrait at line 666
string
replaceSpecialTags(string $target)
Replaces all the html tag dfn and data with their text equivalent
in ControllersTrait at line 679
array
getWidgets()
Returns the list of available widgets.
in ControllersTrait at line 696
array
getWidgetsByType()
Returns the list of available widgets by type (g6k type).
in ControllersTrait at line 726
array
getWidgetsByInputType()
Returns the list of available widgets by form input type.
in ControllersTrait at line 756
array
getFunctions()
Returns 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.
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
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
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
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.
in ControllersTrait at line 898
private String
getRelativePath(String $base, String $path)
Return a relative path to a file or directory using base directory.
in ControllersTrait at line 916
private bool
runConsoleCommand(array $command, array|null $report = null)
Run a console command.
in ControllersTrait at line 954
private StreamedResponse
runStreamedConsoleCommand(array $command, callable $start, callable $end)
Run a streamed console command.
in ControllersTrait at line 980
bool
isDevelopmentEnvironment()
Determines whether the symfony kernel is in development mode or not.
in ControllersTrait at line 991
string
getEnvironment()
Returns 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
in DatasourcesTrait at line 211
protected array|string|bool|null
tablesList(Database $database)
Returns the list of tables of a database
in DatasourcesTrait at line 249
protected array|string|bool|null
tableInfos(Database $database, string $table)
Returns informations about a table of a database
in DatasourcesTrait at line 302
protected array
infosColumns(SimpleXMLElement $datasources, Database $database, string $table)
Returns informations about the columns of a table
in DatasourcesTrait at line 361
protected array
infosColumnsToForm(string $table, array $infosColumns)
Constructs a form fields with informations about the columns of a table
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
in DatasourcesTrait at line 461
protected array|string|null
executeSource(SimpleXMLElement $source, SimpleXMLElement $datasources, string|null $databasesDir = null)
Executes the query from a source
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
in DatasourcesTrait at line 548
protected array
filterResultByLines(array $result, string $filter)
Filters the result set of a query on the source return path
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
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
in DatasourcesTrait at line 685
protected string|true
deleteRowFromTable(array $row, string $table, Database $database, TranslatorInterface $translator = null)
Deletes a row from a table
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
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.
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
in DatasourcesTrait at line 953
protected string|true
createDatabaseTable(array $form, Database $database, TranslatorInterface $translator = null)
Creates a database table
in DatasourcesTrait at line 1032
protected string|true
dropDatabaseTable(string $table, Database $database, TranslatorInterface $translator = null)
Drops a table
in DatasourcesTrait at line 1057
protected string|true
editTableStructure(array $form, string $table, Database $database, SimpleXMLElement $datasources, TranslatorInterface $translator = null)
Edits a table structure
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
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}
at line 131
protected Response|RedirectResponse
runIndex(Request $request, int|null $dsid, string|null $table, string|null $crud)
Processes the index action
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.
at line 216
protected bool
hasConfigParameter(string $parameter)
Checks if a parameter exists.
at line 228
protected string
getConfigParameter(string $parameter)
Gets a parameter with its name.
at line 243
protected Response
showDatasources(Request $request, int|null $dsid, string|null $table = null, string $action = 'show')
Shows the data sources management interface.
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.
at line 612
protected string
makeDatasourceReportHeader(Request $request, string $datasource, string $heading)
Makes the header for a datasource action report
at line 651
protected string
makeDatasourceReportFooter(Request $request, string $datasource, string $dsid)
Makes the footer for a datasource action report
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
at line 764
protected string
makeTableReportHeader(Request $request, int $dsid, string $table, string $heading)
Makes the header for a table action report
at line 803
protected string
makeTableReportFooter(Request $request, int $dsid, string $table)
Makes the footer for a datasource action report
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
at line 909
protected RedirectResponse
createDatasource(array $form)
Creates a data source
at line 933
protected string|true
migrateDB(int $dsid, string $dbtype, Database $fromDatabase)
Migrates data from a database to another.
at line 946
protected string|true
createDB(int $dsid, string $dbtype)
Creates a database
at line 959
protected string|true
createDBTable(array $form, Database $database)
Creates a table
at line 973
protected string|true
editDBTable(array $form, string $table, Database $database)
Edits a table structure
at line 988
protected string|bool
addDBTableRow(array $form, string $table, Database $database, bool $restore = false)
Inserts a row into a table
at line 1003
protected bool|string
updateDBTableRow(array $form, string $table, Database $database)
Updates a table row
at line 1017
protected string|true
deleteDBTableRow(array $form, string $table, Database $database)
Deletes a row from a table
at line 1030
protected string|true
dropDBTable(string $table, Database $database)
Drops a table
at line 1045
protected RedirectResponse
createTable(array $form, Database $database)
Creates a table
Route path : /admin/datasources/{dsid}/new/create
at line 1083
protected void
saveDatasources(DOMDocument $dom)
Saves DataSources.xml from a DOM document
at line 1107
protected Response
addTableRow(array $form, string $table, Database $database)
Adds a table row
Route path : /admin/datasources/{dsid}/{table}/add
at line 1133
protected Response
restoreTableRow(array $form, string $table, Database $database)
Restores a table row
Route path : /admin/datasources/{dsid}/{table}/restore
at line 1155
protected Response
updateTableRow(array $form, string $table, Database $database)
Updates a table row
Route path : /admin/datasources/{dsid}/{table}/update
at line 1180
protected Response
deleteTableRow(array $form, string $table, Database $database)
Deletes a table row
Route path : /admin/datasources/{dsid}/{table}/delete
at line 1205
protected RedirectResponse
doEditTable(array $form, string $table, Database $database)
Edits a table structure
Route path : /admin/datasources/{dsid}/{table}/doedit
at line 1261
protected void
addColumnsToTable(DOMDocument $dom, array $form, DOMElement $table)
Adds columns to a table
at line 1325
protected RedirectResponse
dropTable(array $form, string $table, Database $database)
Drops a table
Route path : /admin/datasources/{dsid}/{table}/drop
at line 1357
protected RedirectResponse
doEditDatasource(int $dsid, array $form)
Edits a data source
Route path : /admin/datasources/{dsid}/dummy/doedit-datasource
at line 1487
protected RedirectResponse
dropDatasource(int $dsid)
Drops a data source
Route path : /admin/datasources/{dsid}/dummy/drop-datasource