started popsu_migrate module
This commit is contained in:
		@@ -19,6 +19,8 @@
 | 
				
			|||||||
        "drupal/core-composer-scaffold": "^9.1",
 | 
					        "drupal/core-composer-scaffold": "^9.1",
 | 
				
			||||||
        "drupal/core-project-message": "^9.1",
 | 
					        "drupal/core-project-message": "^9.1",
 | 
				
			||||||
        "drupal/core-recommended": "^9.1",
 | 
					        "drupal/core-recommended": "^9.1",
 | 
				
			||||||
 | 
					        "drupal/migrate_plus": "^5.1",
 | 
				
			||||||
 | 
					        "drupal/migrate_tools": "5.x-dev@dev",
 | 
				
			||||||
        "drupal/paragraphs": "1.x-dev@dev",
 | 
					        "drupal/paragraphs": "1.x-dev@dev",
 | 
				
			||||||
        "drupal/smart_date": "^3.1",
 | 
					        "drupal/smart_date": "^3.1",
 | 
				
			||||||
        "wikimedia/composer-merge-plugin": "^2.0"
 | 
					        "wikimedia/composer-merge-plugin": "^2.0"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										681
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										681
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -84,6 +84,7 @@ module:
 | 
				
			|||||||
  path_alias_xt: 0
 | 
					  path_alias_xt: 0
 | 
				
			||||||
  pathologic: 0
 | 
					  pathologic: 0
 | 
				
			||||||
  persistent_login: 0
 | 
					  persistent_login: 0
 | 
				
			||||||
 | 
					  popsu_migrate: 0
 | 
				
			||||||
  redirect: 0
 | 
					  redirect: 0
 | 
				
			||||||
  redis: 0
 | 
					  redis: 0
 | 
				
			||||||
  responsive_image: 0
 | 
					  responsive_image: 0
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								config/sync/migrate_drupal.settings.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								config/sync/migrate_drupal.settings.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					enforce_source_module_tags:
 | 
				
			||||||
 | 
					  - 'Drupal 6'
 | 
				
			||||||
 | 
					  - 'Drupal 7'
 | 
				
			||||||
 | 
					follow_up_migration_tags:
 | 
				
			||||||
 | 
					  - 'Follow-up migration'
 | 
				
			||||||
 | 
					_core:
 | 
				
			||||||
 | 
					  default_config_hash: 1daEO2inZc1i3d0Sn-ADIq9mUIU7tSLCxn579NT6f2g
 | 
				
			||||||
 | 
					langcode: fr
 | 
				
			||||||
							
								
								
									
										47
									
								
								config/sync/migrate_plus.migration.d7_allpublicfiles.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								config/sync/migrate_plus.migration.d7_allpublicfiles.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					uuid: 101cfd3b-9212-4433-9848-30b4222281ee
 | 
				
			||||||
 | 
					langcode: fr
 | 
				
			||||||
 | 
					status: true
 | 
				
			||||||
 | 
					dependencies: {  }
 | 
				
			||||||
 | 
					_core:
 | 
				
			||||||
 | 
					  default_config_hash: XagShwkgw7JHJgs5_hzHHgOo5FszkzhugcQ7yf4F29U
 | 
				
			||||||
 | 
					id: d7_allpublicfiles
 | 
				
			||||||
 | 
					class: null
 | 
				
			||||||
 | 
					field_plugin_method: null
 | 
				
			||||||
 | 
					cck_plugin_method: null
 | 
				
			||||||
 | 
					migration_tags:
 | 
				
			||||||
 | 
					  - 'Drupal 7'
 | 
				
			||||||
 | 
					  - Content
 | 
				
			||||||
 | 
					  - Popsu
 | 
				
			||||||
 | 
					  - Files
 | 
				
			||||||
 | 
					migration_group: d7_popsu
 | 
				
			||||||
 | 
					label: 'Public files'
 | 
				
			||||||
 | 
					source:
 | 
				
			||||||
 | 
					  plugin: d7_pubic_file
 | 
				
			||||||
 | 
					  batch_size: 5000
 | 
				
			||||||
 | 
					  scheme: public
 | 
				
			||||||
 | 
					  constants:
 | 
				
			||||||
 | 
					    source_base_path: ../../../d7
 | 
				
			||||||
 | 
					process:
 | 
				
			||||||
 | 
					  filename: filename
 | 
				
			||||||
 | 
					  source_full_path:
 | 
				
			||||||
 | 
					    -
 | 
				
			||||||
 | 
					      plugin: concat
 | 
				
			||||||
 | 
					      delimiter: /
 | 
				
			||||||
 | 
					      source:
 | 
				
			||||||
 | 
					        - constants/source_base_path
 | 
				
			||||||
 | 
					        - filepath
 | 
				
			||||||
 | 
					    -
 | 
				
			||||||
 | 
					      plugin: urlencode
 | 
				
			||||||
 | 
					  uri:
 | 
				
			||||||
 | 
					    plugin: file_copy
 | 
				
			||||||
 | 
					    source:
 | 
				
			||||||
 | 
					      - '@source_full_path'
 | 
				
			||||||
 | 
					      - uri
 | 
				
			||||||
 | 
					  filemime: filemime
 | 
				
			||||||
 | 
					  status: status
 | 
				
			||||||
 | 
					  created: timestamp
 | 
				
			||||||
 | 
					  changed: timestamp
 | 
				
			||||||
 | 
					  uid: uid
 | 
				
			||||||
 | 
					destination:
 | 
				
			||||||
 | 
					  plugin: 'entity:file'
 | 
				
			||||||
 | 
					migration_dependencies: null
 | 
				
			||||||
							
								
								
									
										19
									
								
								config/sync/migrate_plus.migration_group.d7_popsu.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								config/sync/migrate_plus.migration_group.d7_popsu.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					uuid: 0f8e929c-ac82-44c2-a18d-705fbeadd9dc
 | 
				
			||||||
 | 
					langcode: fr
 | 
				
			||||||
 | 
					status: true
 | 
				
			||||||
 | 
					dependencies:
 | 
				
			||||||
 | 
					  enforced:
 | 
				
			||||||
 | 
					    module:
 | 
				
			||||||
 | 
					      - migrate_plus
 | 
				
			||||||
 | 
					      - migrate_tools
 | 
				
			||||||
 | 
					      - popsu_migrate
 | 
				
			||||||
 | 
					_core:
 | 
				
			||||||
 | 
					  default_config_hash: QSerr7Rm3POhidZhxFUan7sJGKOXGQk5MWa9EdLaJEc
 | 
				
			||||||
 | 
					id: d7_popsu
 | 
				
			||||||
 | 
					label: 'D7 Popsu'
 | 
				
			||||||
 | 
					description: 'Drupal 7 popsu content migration to Drupal 9.'
 | 
				
			||||||
 | 
					source_type: 'Drupal 7'
 | 
				
			||||||
 | 
					module: null
 | 
				
			||||||
 | 
					shared_configuration:
 | 
				
			||||||
 | 
					  source:
 | 
				
			||||||
 | 
					    key: d7
 | 
				
			||||||
							
								
								
									
										10
									
								
								config/sync/migrate_plus.migration_group.default.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								config/sync/migrate_plus.migration_group.default.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					uuid: 713c224d-0d68-4308-a3c8-8c2dad1ddd68
 | 
				
			||||||
 | 
					langcode: fr
 | 
				
			||||||
 | 
					status: true
 | 
				
			||||||
 | 
					dependencies: {  }
 | 
				
			||||||
 | 
					id: default
 | 
				
			||||||
 | 
					label: Default
 | 
				
			||||||
 | 
					description: 'A container for any migrations not explicitly assigned to a group.'
 | 
				
			||||||
 | 
					source_type: null
 | 
				
			||||||
 | 
					module: null
 | 
				
			||||||
 | 
					shared_configuration: null
 | 
				
			||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					# Every migration that references a file by Drupal 7 fid should specify this
 | 
				
			||||||
 | 
					# migration as an optional dependency.
 | 
				
			||||||
 | 
					id: d7_allpublicfiles
 | 
				
			||||||
 | 
					label: Public files
 | 
				
			||||||
 | 
					migration_group: d7_popsu
 | 
				
			||||||
 | 
					audit: true
 | 
				
			||||||
 | 
					migration_tags:
 | 
				
			||||||
 | 
					  - Drupal 7
 | 
				
			||||||
 | 
					  - Content
 | 
				
			||||||
 | 
					  - Popsu
 | 
				
			||||||
 | 
					  - Files
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source:
 | 
				
			||||||
 | 
					  plugin: d7_pubic_file
 | 
				
			||||||
 | 
					  batch_size: 5000
 | 
				
			||||||
 | 
					  scheme: public
 | 
				
			||||||
 | 
					  constants:
 | 
				
			||||||
 | 
					    # The tool configuring this migration must set source_base_path. It
 | 
				
			||||||
 | 
					    # represents the fully qualified path relative to which URIs in the files
 | 
				
			||||||
 | 
					    # table are specified, and must end with a /. See source_full_path
 | 
				
			||||||
 | 
					    # configuration in this migration's process pipeline as an example.
 | 
				
			||||||
 | 
					    source_base_path: '../../../d7'
 | 
				
			||||||
 | 
					process:
 | 
				
			||||||
 | 
					  # If you are using this file to build a custom migration consider removing
 | 
				
			||||||
 | 
					  # the fid field to allow incremental migrations.
 | 
				
			||||||
 | 
					  # fid: fid
 | 
				
			||||||
 | 
					  filename: filename
 | 
				
			||||||
 | 
					  source_full_path:
 | 
				
			||||||
 | 
					    -
 | 
				
			||||||
 | 
					      plugin: concat
 | 
				
			||||||
 | 
					      delimiter: /
 | 
				
			||||||
 | 
					      source:
 | 
				
			||||||
 | 
					        - constants/source_base_path
 | 
				
			||||||
 | 
					        - filepath
 | 
				
			||||||
 | 
					    -
 | 
				
			||||||
 | 
					      plugin: urlencode
 | 
				
			||||||
 | 
					  uri:
 | 
				
			||||||
 | 
					    plugin: file_copy
 | 
				
			||||||
 | 
					    source:
 | 
				
			||||||
 | 
					      - '@source_full_path'
 | 
				
			||||||
 | 
					      - uri
 | 
				
			||||||
 | 
					  filemime: filemime
 | 
				
			||||||
 | 
					  # No need to migrate filesize, it is computed when file entities are saved.
 | 
				
			||||||
 | 
					  # filesize: filesize
 | 
				
			||||||
 | 
					  status: status
 | 
				
			||||||
 | 
					  # Drupal 7 didn't keep track of the file's creation or update time -- all it
 | 
				
			||||||
 | 
					  # had was the vague "timestamp" column. So we'll use it for both.
 | 
				
			||||||
 | 
					  created: timestamp
 | 
				
			||||||
 | 
					  changed: timestamp
 | 
				
			||||||
 | 
					  uid: uid
 | 
				
			||||||
 | 
					destination:
 | 
				
			||||||
 | 
					  plugin: entity:file
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					id: d7_popsu
 | 
				
			||||||
 | 
					label: D7 Popsu
 | 
				
			||||||
 | 
					description: Drupal 7 popsu content migration to Drupal 9.
 | 
				
			||||||
 | 
					source_type: Drupal 7
 | 
				
			||||||
 | 
					shared_configuration:
 | 
				
			||||||
 | 
					  source:
 | 
				
			||||||
 | 
					    key: d7
 | 
				
			||||||
 | 
					dependencies:
 | 
				
			||||||
 | 
					  enforced:
 | 
				
			||||||
 | 
					    module:
 | 
				
			||||||
 | 
					      - migrate_plus
 | 
				
			||||||
 | 
					      - migrate_tools
 | 
				
			||||||
 | 
					      - popsu_migrate
 | 
				
			||||||
							
								
								
									
										36
									
								
								web/modules/custom/popsu_migrate/popsu_migrate.info.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								web/modules/custom/popsu_migrate/popsu_migrate.info.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					name: Popsu Migration
 | 
				
			||||||
 | 
					type: module
 | 
				
			||||||
 | 
					description: Defines custom migration for popsu (from d7 to d9).
 | 
				
			||||||
 | 
					core_version_requirement: ^8.8 || ^9
 | 
				
			||||||
 | 
					package: Popsu
 | 
				
			||||||
 | 
					dependencies:
 | 
				
			||||||
 | 
					  - drupal:migrate
 | 
				
			||||||
 | 
					  - drupal:migrate_drupal
 | 
				
			||||||
 | 
					  - migrate_plus:migrate_plus
 | 
				
			||||||
 | 
					  - migrate_tools:migrate_tools
 | 
				
			||||||
 | 
					  # - config_devel
 | 
				
			||||||
 | 
					  # - drupal:migrate_drupal_multilingual
 | 
				
			||||||
 | 
					  # - drupal:field_group_migrate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# https://www.liip.ch/en/blog/using-the-new-drupal-8-migration-api-module
 | 
				
			||||||
 | 
					config_devel:
 | 
				
			||||||
 | 
					 install:
 | 
				
			||||||
 | 
					  - migrate_plus.migration_group.d7_popsu
 | 
				
			||||||
 | 
					  - migrate_plus.migration.d7_allpublicfiles
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_users
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_company
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_uc_roles_license
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_simplenews_subscribers
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_node_article
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_simplenews_nodes
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_node_materiau
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_node_materiau_i18n
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_node_article_i18n
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_user_profile
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_showroom
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_tags_i18n
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_tags
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_thesaurus_i18n
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_taxonomy_term_thesaurus
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_flaglists
 | 
				
			||||||
 | 
					  # - migrate_plus.migration.d7_flaglistitems
 | 
				
			||||||
							
								
								
									
										37
									
								
								web/modules/custom/popsu_migrate/readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								web/modules/custom/popsu_migrate/readme.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					[debugging-migrations](https://www.drupal.org/docs/8/api/migrate-api/debugging-migrations)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://www.drupaleasy.com/blogs/ultimike/2016/04/drupal-6-drupal-81x-custom-content-migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://thinkshout.com/blog/2017/05/skipping-a-version-migrating-from-drupal-6-to-drupal-8-with-drupal-migrate/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://drupal.stackexchange.com/questions/164612/how-do-i-remove-a-configuration-object-from-the-active-configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://www.metaltoad.com/blog/drupal-8-migrations-part-3-migrating-taxonomies-drupal-7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://www.sitepoint.com/your-first-drupal-8-migration/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://evolvingweb.ca/blog/drupal-8-migration-migrating-taxonomy-term-references-part-2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[text to taxonomy term](http://boylesoftware.com/blog/drupal-8-migration-taxonomy-term-lookups/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Upgrading Drupal 6 and i18n Content Translation to Drupal 8](https://www.dunix-data.de/blog/upgrading_drupal_6_and_i18n_content_translation_to_drupal_8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Migrating Drupal 7 File Entities to Drupal 8 Media Entities](https://www.previousnext.com.au/blog/migrating-drupal-7-file-entities-drupal-8-media-entities)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[D6 Taxonomy Term Reference Field is not migrated to D8 Field](https://www.drupal.org/node/2884240)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8](https://www.drupalfacile.org/sites/drupalfacile/files/blog/2016/06/dcnantes2016-migrerd6d7versd8.pdf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Migrating Aliases and Redirects to Drupal 8](https://evolvingweb.ca/blog/migrating-aliases-and-redirects-drupal-8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Migrating Drupal 7 redirects to Drupal 8](http://activelamp.com/blog/drupal/migrating-drupal-8-redirects/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[How to refresh new migrations in Drupal 8 migration module?](https://drupal.stackexchange.com/questions/191435/how-to-refresh-new-migrations-in-drupal-8-migration-module)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Drupal 8 Migrations: Taxonomy and Nodes](https://www.phase2technology.com/blog/drupal-8-migrations)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Migrating Content Translated with "Content Translation" from Drupal 7 to Drupal 8](https://evolvingweb.ca/blog/migrating-content-translated-content-translation-drupal-7-drupal-8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Drupal 8 Migration Survival Strategies](http://pnijjar.freeshell.org/2017/drupal8-migrate/)
 | 
				
			||||||
@@ -0,0 +1,119 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Drupal\popsu_migrate\Plugin\migrate\source;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Drupal\Core\Database\Query\Condition;
 | 
				
			||||||
 | 
					use Drupal\migrate\Row;
 | 
				
			||||||
 | 
					use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Drupal 7 file source from database.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @MigrateSource(
 | 
				
			||||||
 | 
					 *   id = "d7_pubic_file",
 | 
				
			||||||
 | 
					 *   source_module = "file"
 | 
				
			||||||
 | 
					 * )
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class D7PublicFile extends DrupalSqlBase {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * The public file directory path.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @var string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  protected $publicPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * The private file directory path, if any.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @var string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  protected $privatePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * The temporary file directory path.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @var string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  protected $temporaryPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * {@inheritdoc}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function query() {
 | 
				
			||||||
 | 
					    $query = $this->select('file_managed', 'f')
 | 
				
			||||||
 | 
					      ->fields('f')
 | 
				
			||||||
 | 
					      ->condition('uri', 'temporary://%', 'NOT LIKE')
 | 
				
			||||||
 | 
					      ->orderBy('f.timestamp');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Filter by scheme(s), if configured.
 | 
				
			||||||
 | 
					    if (isset($this->configuration['scheme'])) {
 | 
				
			||||||
 | 
					      $schemes = [];
 | 
				
			||||||
 | 
					      // Remove 'temporary' scheme.
 | 
				
			||||||
 | 
					      $valid_schemes = array_diff((array) $this->configuration['scheme'], ['temporary']);
 | 
				
			||||||
 | 
					      // Accept either a single scheme, or a list.
 | 
				
			||||||
 | 
					      foreach ((array) $valid_schemes as $scheme) {
 | 
				
			||||||
 | 
					        $schemes[] = rtrim($scheme) . '://';
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      $schemes = array_map([$this->getDatabase(), 'escapeLike'], $schemes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // Add conditions, uri LIKE 'public://%' OR uri LIKE 'private://%'.
 | 
				
			||||||
 | 
					      $conditions = new Condition('OR');
 | 
				
			||||||
 | 
					      foreach ($schemes as $scheme) {
 | 
				
			||||||
 | 
					        $conditions->condition('uri', $scheme . '%', 'LIKE');
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      $query->condition($conditions);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return $query;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * {@inheritdoc}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  protected function initializeIterator() {
 | 
				
			||||||
 | 
					    $this->publicPath = $this->variableGet('file_public_path', 'sites/default/files');
 | 
				
			||||||
 | 
					    $this->privatePath = $this->variableGet('file_private_path', NULL);
 | 
				
			||||||
 | 
					    $this->temporaryPath = $this->variableGet('file_temporary_path', '/tmp');
 | 
				
			||||||
 | 
					    return parent::initializeIterator();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * {@inheritdoc}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function prepareRow(Row $row) {
 | 
				
			||||||
 | 
					    // Compute the filepath property, which is a physical representation of
 | 
				
			||||||
 | 
					    // the URI relative to the Drupal root.
 | 
				
			||||||
 | 
					    $path = str_replace(['public:/', 'private:/', 'temporary:/'], [$this->publicPath, $this->privatePath, $this->temporaryPath], $row->getSourceProperty('uri'));
 | 
				
			||||||
 | 
					    // At this point, $path could be an absolute path or a relative path,
 | 
				
			||||||
 | 
					    // depending on how the scheme's variable was set. So we need to shear out
 | 
				
			||||||
 | 
					    // the source_base_path in order to make them all relative.
 | 
				
			||||||
 | 
					    $path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path);
 | 
				
			||||||
 | 
					    $row->setSourceProperty('filepath', $path);
 | 
				
			||||||
 | 
					    return parent::prepareRow($row);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * {@inheritdoc}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function fields() {
 | 
				
			||||||
 | 
					    return [
 | 
				
			||||||
 | 
					      'fid' => $this->t('File ID'),
 | 
				
			||||||
 | 
					      'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
 | 
				
			||||||
 | 
					      'filename' => $this->t('File name'),
 | 
				
			||||||
 | 
					      'filepath' => $this->t('File path'),
 | 
				
			||||||
 | 
					      'filemime' => $this->t('File MIME Type'),
 | 
				
			||||||
 | 
					      'status' => $this->t('The published status of a file.'),
 | 
				
			||||||
 | 
					      'timestamp' => $this->t('The time that the file was added.'),
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * {@inheritdoc}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function getIds() {
 | 
				
			||||||
 | 
					    $ids['fid']['type'] = 'integer';
 | 
				
			||||||
 | 
					    return $ids;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user