Created
May 25, 2016 18:39
-
-
Save wluisi/1bace0add128021698ef5319810e56da to your computer and use it in GitHub Desktop.
client_migration_blog_featured_image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php | |
/** | |
* @file | |
* Contains \Drupal\client_migration\Plugin\migrate\source\NodeBlogFeaturedImage. | |
*/ | |
namespace Drupal\client_migration\Plugin\migrate\source; | |
use Drupal\file\Plugin\migrate\source\d6\File; | |
use Drupal\Core\Database\Query\Condition; | |
use Drupal\migrate\Row; | |
/** | |
* Blog Featured Image | |
* | |
* @MigrateSource( | |
* id = "client_migration_blog_featured_image" | |
* ) | |
*/ | |
class NodeBlogFeaturedImage extends File { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function query() { | |
$query = $this->select('files', 'f'); | |
// Join data from 'content_type_blog', which is d6's way of storing field data. | |
$query->join('content_type_blog', 'ctb', 'ctb.field_blog_feature_img_fid = f.fid'); | |
// Join data from 'node' table | |
$query->join('node', 'n', 'n.nid = ctb.nid'); | |
$query->fields('f', ['fid', 'uid', 'filename', 'filepath', 'filemime', 'status', 'timestamp']) | |
->distinct() | |
->condition('n.type', 'blog') | |
->orderBy('n.changed', 'DESC'); | |
return $query; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment