Advertisement
Guest User

Untitled

a guest
May 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @file
  5. * Contains \Drupal\unicef_migration\Plugin\migrate\source\NodeBlogFeaturedImage.
  6. */
  7.  
  8. namespace Drupal\unicef_migration\Plugin\migrate\source;
  9.  
  10. use Drupal\file\Plugin\migrate\source\d6\File;
  11. use Drupal\Core\Database\Query\Condition;
  12. use Drupal\migrate\Row;
  13.  
  14. /**
  15. * Blog Featured Image
  16. *
  17. * @MigrateSource(
  18. * id = "unicef_migration_blog_featured_image"
  19. * )
  20. */
  21. class NodeBlogFeaturedImage extends File {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function query() {
  26. $query = $this->select('files', 'f');
  27.  
  28. // Join data from 'content_type_blog', which is d6's way of storing field data.
  29. $query->join('content_type_blog', 'ctb', 'ctb.field_blog_feature_img_fid = f.fid');
  30.  
  31. // Join data from 'node' table
  32. $query->join('node', 'n', 'n.nid = ctb.nid');
  33.  
  34. $query->fields('f', ['fid', 'uid', 'filename', 'filepath', 'filemime', 'status', 'timestamp'])
  35. ->distinct()
  36. ->condition('n.type', 'blog')
  37. ->orderBy('n.changed', 'DESC');
  38.  
  39. return $query;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement