code_file
Writes, replaces or removes one code or design file below the allowed folders, with a backup and checksums.
A step of a YAML migration with type: code_file. The class expMigrationStepCodeFile (kernel/classes/migration/steps/expmigrationstepcodefile.php) is registered in settings/migration.ini [StepSettings] StepTypeList[code_file].
Modes
mode: is one of create, update, ensure, delete; without it, ensure.
Keys
| Key | Type | Modes | Default | What it is |
|---|---|---|---|---|
path | string | all | required | the file, relative to the installation, below a folder of [FileStepSettings] AllowedRootList[] (design, extension) |
source | string | create, update, ensure | the new content: a file below the folder of the migration file (files/page.tpl) | |
content | string | create, update, ensure | the new content itself (instead of source:) | |
checksum | string | create, update, ensure | the SHA-256 the new content must have (64 hex digits) | |
expect | string | all | the SHA-256 the file must have before the step, or absent: it must not exist |
Besides these, every step takes the keys of the engine: type, mode, if, references, environments, engines and comment (the file format). A key of type identifier names a node, an object or another part of the installation by id, remote id, path or name (identifiers).
Values for references
references: { <name>: <value> } keeps a value of the step's result as ${ref.<name>} for the steps and migrations after it:
| Value | What it is |
|---|---|
path | the file, relative to the installation |
changed | true when the file changed |
before | its SHA-256 before (empty: it did not exist) |
after | its SHA-256 after (empty: removed) |
Undoing
Every step of this type undoes itself when its migration is rolled back without down:.
It touches no cache.
Example
- type: code_file
mode: ensure
path: design/mysite/templates/page_footer.tpl
source: files/page_footer.tplRelated
Generated by ./console exp:help:examples from settings/migration.ini, kernel/classes/migration/steps/expmigrationstepcodefile.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.