Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id: mom_files
- label: Files for Media
- migration_group: mom
- source:
- plugin: mom_files
- constants:
- source_base_path: 'sites/default/files/'
- old_files_path: 'sites/default/files/migration-files/'
- process:
- filename: id
- source_full_path:
- -
- plugin: concat
- delimiter: /
- source:
- - constants/old_files_path
- - filepath
- -
- plugin: urlencode
- uri:
- plugin: file_copy
- source:
- - '@source_full_path'
- - uri
- created:
- plugin: callback
- source: created
- callable: strtotime
- changed: '@created'
- fid: id
- destination:
- plugin: entity:file
- migration_dependencies:
- required:
- - mom_teachers
- <?php
- namespace Drupalmom_migratePluginmigratesource;
- use DrupalmigratePluginmigratesourceSqlBase;
- use DrupalmigrateRow;
- /**
- * Source plugin for Mom files.
- *
- * @MigrateSource(
- * id = "mom_files",
- * )
- */
- class MomFiles extends SqlBase {
- /**
- * {@inheritdoc}
- */
- public function query() {
- $query = $this->select('images', 'im')
- ->fields('im', ['id', 'created']);
- return $query;
- }
- /**
- * {@inheritdoc}
- */
- public function prepareRow(Row $row) {
- if ($value = $row->getSourceProperty('id')) {
- $row->setSourceProperty('filename', $id);
- $row->setSourceProperty('uri', substr($id, -1) . '/');
- }
- return parent::prepareRow($row);
- }
- /**
- * {@inheritdoc}
- */
- public function fields() {
- return array(
- 'id' => $this->t('File ID'),
- 'filename' => $this->t('File name'),
- 'uri' => $this->t('The URI to access the file'),
- 'created' => $this->t('The time that the file was added.'),
- );
- }
- /**
- * {@inheritdoc}
- */
- public function getIds() {
- $ids['id']['type'] = 'integer';
- return $ids;
- }
- }
- User error: "1" is an invalid render array key in DrupalCoreRenderElement::children() (line 97 of /var/www/html/media/core/lib/Drupal/Core/Render/Element.php)
- Could not create or write to directory ''
Add Comment
Please, Sign In to add comment