make.project.inc

  1. 8.0.x commands/make/make.project.inc
  2. 6.x commands/make/make.project.inc
  3. 7.x commands/make/make.project.inc
  4. 5.x commands/make/make.project.inc
  5. master commands/make/make.project.inc

Drush Make processing classes.

Classes

Namesort descending Description
DrushMakeProject The base project class.
DrushMakeProject_Core For processing Drupal core projects.
DrushMakeProject_Library For processing libraries.
DrushMakeProject_Module For processing modules.
DrushMakeProject_Profile For processing installation profiles.
DrushMakeProject_Theme For processing themes.
DrushMakeProject_Translation For processing translations.

File

commands/make/make.project.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Drush Make processing classes.
  5. */
  6. use Drush\Log\LogLevel;
  7. /**
  8. * The base project class.
  9. */
  10. class DrushMakeProject {
  11. /**
  12. * TRUE if make() has been called, otherwise FALSE.
  13. */
  14. protected $made = FALSE;
  15. /**
  16. * TRUE if download() method has been called successfully, otherwise FALSE.
  17. */
  18. protected $downloaded = NULL;
  19. /**
  20. * Download location to use.
  21. */
  22. protected $download_location = NULL;
  23. /**
  24. * Keep track of instances.
  25. *
  26. * @see DrushMakeProject::getInstance()
  27. */
  28. protected static $self = array();
  29. /**
  30. * Keeps track of projects being processed to prevent recursive conflicts.
  31. *
  32. * Simple array of machine names.
  33. *
  34. * @var array
  35. */
  36. protected $manifest = array();
  37. /**
  38. * Default to overwrite to allow recursive builds to process properly.
  39. *
  40. * TODO refactor this to be more selective. Ideally a merge would take place
  41. * instead of an overwrite.
  42. */
  43. protected $overwrite = TRUE;
  44. /**
  45. * Recursively process any makefiles found in downloaded projects.
  46. */
  47. protected $do_recursion = TRUE;
  48. /**
  49. * Set attributes and retrieve project information.
  50. */
  51. protected function __construct($project) {
  52. $project['base_contrib_destination'] = $project['contrib_destination'];
  53. foreach ($project as $key => $value) {
  54. $this->{$key} = $value;
  55. }
  56. if (!empty($this->options['working-copy'])) {
  57. $this->download['working-copy'] = TRUE;
  58. }
  59. }
  60. /**
  61. * Get an instance for the type and project.
  62. *
  63. * @param string $type
  64. * Type of project: core, library, module, profile, or translation.
  65. * @param array $project
  66. * Project information.
  67. *
  68. * @return mixed
  69. * An instance for the project or FALSE if invalid type.
  70. */
  71. public static function getInstance($type, $project) {
  72. if (!isset(self::$self[$type][$project['name']])) {
  73. $class = 'DrushMakeProject_' . $type;
  74. self::$self[$type][$project['name']] = class_exists($class) ? new $class($project) : FALSE;
  75. }
  76. return self::$self[$type][$project['name']];
  77. }
  78. /**
  79. * Set the manifest array.
  80. *
  81. * @param array $manifest
  82. * An array of projects as generated by `make_projects`.
  83. */
  84. public function setManifest($manifest) {
  85. $this->manifest = $manifest;
  86. }
  87. /**
  88. * Download a project.
  89. */
  90. function download() {
  91. $this->downloaded = TRUE;
  92. // In some cases, make_download_factory() is going to need to know the
  93. // full version string of the project we're trying to download. However,
  94. // the version is a project-level attribute, not a download-level
  95. // attribute. So, if we don't already have a full version string in the
  96. // download array (e.g. if it was initialized via the release history XML
  97. // for the PM case), we take the version info from the project-level
  98. // attribute, convert it into a full version string, and stuff it into
  99. // $this->download so that the download backend has access to it, too.
  100. if (!empty($this->version) && empty($this->download['full_version'])) {
  101. $full_version = '';
  102. $matches = array();
  103. // Core needs different conversion rules than contrib.
  104. if (!empty($this->type) && $this->type == 'core') {
  105. // Generally, the version for core is already set properly.
  106. $full_version = $this->version;
  107. // However, it might just be something like '7' or '7.x', in which
  108. // case we need to turn that into '7.x-dev';
  109. if (preg_match('/^\d+(\.x)?$/', $this->version, $matches)) {
  110. // If there's no '.x' already, append it.
  111. if (empty($matches[1])) {
  112. $full_version .= '.x';
  113. }
  114. $full_version .= '-dev';
  115. }
  116. }
  117. // Contrib.
  118. else {
  119. // If the version doesn't already define a core version, prepend it.
  120. if (!preg_match('/^\d+\.x-\d+.*$/', $this->version)) {
  121. // Just find the major version from $this->core so we don't end up
  122. // with version strings like '7.12-2.0'.
  123. $core_parts = explode('.', $this->core);
  124. $full_version = $core_parts[0] . '.x-';
  125. }
  126. $full_version .= $this->version;
  127. // If the project-level version attribute is just a number it's a major
  128. // version.
  129. if (preg_match('/^\d+(\.x)?$/', $this->version, $matches)) {
  130. // If there's no '.x' already, append it.
  131. if (empty($matches[1])) {
  132. $full_version .= '.x';
  133. }
  134. $full_version .= '-dev';
  135. }
  136. }
  137. $this->download['full_version'] = $full_version;
  138. }
  139. if (make_download_factory($this->name, $this->type, $this->download, $this->download_location) === FALSE) {
  140. $this->downloaded = FALSE;
  141. }
  142. return $this->downloaded;
  143. }
  144. /**
  145. * Build a project.
  146. */
  147. function make() {
  148. if ($this->made) {
  149. drush_log(dt('Attempt to build project @project more then once prevented.', array('@project' => $this->name)));
  150. return TRUE;
  151. }
  152. $this->made = TRUE;
  153. if (!isset($this->download_location)) {
  154. $this->download_location = $this->findDownloadLocation();
  155. }
  156. if ($this->download() === FALSE) {
  157. return FALSE;
  158. }
  159. if (!$this->addLockfile($this->download_location)) {
  160. return FALSE;
  161. }
  162. if (!$this->applyPatches($this->download_location)) {
  163. return FALSE;
  164. }
  165. if (!$this->getTranslations($this->download_location)) {
  166. return FALSE;
  167. }
  168. // Handle .info file re-writing (if so desired).
  169. if (!drush_get_option('no-gitinfofile', FALSE) && isset($this->download['type']) && $this->download['type'] == 'git') {
  170. $this->processGitInfoFiles();
  171. }
  172. // Clean-up .git directories.
  173. if (!_get_working_copy_option($this->download)) {
  174. $this->removeGitDirectory();
  175. }
  176. if (!$this->recurse($this->download_location)) {
  177. return FALSE;
  178. }
  179. return TRUE;
  180. }
  181. /**
  182. * Determine the location to download project to.
  183. */
  184. function findDownloadLocation() {
  185. $this->path = $this->generatePath();
  186. $this->project_directory = !empty($this->directory_name) ? $this->directory_name : $this->name;
  187. $this->download_location = $this->path . '/' . $this->project_directory;
  188. // This directory shouldn't exist yet -- if it does, stop,
  189. // unless overwrite has been set to TRUE.
  190. if (is_dir($this->download_location) && !$this->overwrite) {
  191. return drush_set_error('MAKE_DIRECTORY_EXISTS', dt('Directory not empty: !directory', array('!directory' => $this->download_location)));
  192. }
  193. elseif ($this->download['type'] === 'pm') {
  194. // pm-download will create the final contrib directory.
  195. drush_mkdir(dirname($this->download_location));
  196. }
  197. else {
  198. drush_mkdir($this->download_location);
  199. }
  200. return $this->download_location;
  201. }
  202. /**
  203. * Rewrite relative URLs and file:/// URLs
  204. *
  205. * relative path -> absolute path using the make_directory
  206. * local file:/// urls -> local paths
  207. *
  208. * @param mixed &$info
  209. * Either an array or a simple url string. The `$info` variable will be
  210. * transformed into an array.
  211. */
  212. protected function preprocessLocalFileUrl(&$info) {
  213. if (is_string($info)) {
  214. $info = array('url' => $info, 'local' => FALSE);
  215. }
  216. if (!_drush_is_url($info['url']) && !drush_is_absolute_path($info['url'])) {
  217. $info['url'] = $this->make_directory . '/' . $info['url'];
  218. $info['local'] = TRUE;
  219. } elseif (substr($info['url'], 0, 8) == 'file:///') {
  220. $info['url'] = substr($info['url'], 7);
  221. $info['local'] = TRUE;
  222. }
  223. }
  224. /**
  225. * Retrieve and apply any patches specified by the makefile to this project.
  226. */
  227. function applyPatches($project_directory) {
  228. if (empty($this->patch)) {
  229. return TRUE;
  230. }
  231. $patches_txt = '';
  232. $local_patches = array();
  233. $ignore_checksums = drush_get_option('ignore-checksums');
  234. foreach ($this->patch as $info) {
  235. $this->preprocessLocalFileUrl($info);
  236. // Download the patch.
  237. if ($filename = _make_download_file($info['url'])) {
  238. $patched = FALSE;
  239. $output = '';
  240. // Test each patch style; -p1 is the default with git. See
  241. // http://drupal.org/node/1054616
  242. $patch_levels = array('-p1', '-p0');
  243. foreach ($patch_levels as $patch_level) {
  244. $checked = drush_shell_cd_and_exec($project_directory, 'git --git-dir=. apply --check %s %s --verbose', $patch_level, $filename);
  245. if ($checked) {
  246. // Apply the first successful style.
  247. $patched = drush_shell_cd_and_exec($project_directory, 'git --git-dir=. apply %s %s --verbose', $patch_level, $filename);
  248. break;
  249. }
  250. }
  251. // In some rare cases, git will fail to apply a patch, fallback to using
  252. // the 'patch' command.
  253. if (!$patched) {
  254. foreach ($patch_levels as $patch_level) {
  255. // --no-backup-if-mismatch here is a hack that fixes some
  256. // differences between how patch works on windows and unix.
  257. if ($patched = drush_shell_exec("patch %s --no-backup-if-mismatch -d %s < %s", $patch_level, $project_directory, $filename)) {
  258. break;
  259. }
  260. }
  261. }
  262. if ($output = drush_shell_exec_output()) {
  263. // Log any command output, visible only in --verbose or --debug mode.
  264. drush_log(implode("\n", $output));
  265. }
  266. // Set up string placeholders to pass to dt().
  267. $dt_args = array(
  268. '@name' => $this->name,
  269. '@filename' => basename($filename),
  270. );
  271. if ($patched) {
  272. if (!$ignore_checksums && !_make_verify_checksums($info, $filename)) {
  273. return FALSE;
  274. }
  275. $patch_url = $info['url'];
  276. // If this is a local patch, copy that into place as well.
  277. if ($info['local']) {
  278. $local_patches[] = $info['url'];
  279. // Use a local path for the PATCHES.txt file.
  280. $pathinfo = pathinfo($patch_url);
  281. $patch_url = $pathinfo['basename'];
  282. }
  283. $patches_txt .= '- ' . $patch_url . "\n";
  284. drush_log(dt('@name patched with @filename.', $dt_args), LogLevel::OK);
  285. }
  286. else {
  287. make_error('PATCH_ERROR', dt("Unable to patch @name with @filename.", $dt_args));
  288. }
  289. drush_op('unlink', $filename);
  290. }
  291. else {
  292. make_error('DOWNLOAD_ERROR', 'Unable to download ' . $info['url'] . '.');
  293. return FALSE;
  294. }
  295. }
  296. if (!empty($patches_txt) && !drush_get_option('no-patch-txt') && !file_exists($project_directory . '/PATCHES.txt')) {
  297. $patches_txt = "The following patches have been applied to this project:\n" .
  298. $patches_txt .
  299. "\nThis file was automatically generated by Drush Make (http://drupal.org/project/drush).";
  300. file_put_contents($project_directory . '/PATCHES.txt', $patches_txt);
  301. drush_log('Generated PATCHES.txt file for ' . $this->name, LogLevel::OK);
  302. // Copy local patches into place.
  303. foreach ($local_patches as $url) {
  304. $pathinfo = pathinfo($url);
  305. drush_copy_dir($url, $project_directory . '/' . $pathinfo['basename']);
  306. }
  307. }
  308. return TRUE;
  309. }
  310. /**
  311. * Process info files when downloading things from git.
  312. */
  313. function processGitInfoFiles() {
  314. // Bail out if this isn't hosted on Drupal.org (unless --force-gitinfofile option was specified).
  315. if (!drush_get_option('force-gitinfofile', FALSE) && isset($this->download['url']) && strpos($this->download['url'], 'drupal.org') === FALSE) {
  316. return;
  317. }
  318. // Figure out the proper version string to use based on the .make file.
  319. // Best case is the .make file author told us directly.
  320. if (!empty($this->download['full_version'])) {
  321. $full_version = $this->download['full_version'];
  322. }
  323. // Next best is if we have a tag, since those are identical to versions.
  324. elseif (!empty($this->download['tag'])) {
  325. $full_version = $this->download['tag'];
  326. }
  327. // If we have a branch, append '-dev'.
  328. elseif (!empty($this->download['branch'])) {
  329. $full_version = $this->download['branch'] . '-dev';
  330. }
  331. // Ugh. Not sure what else we can do in this case.
  332. elseif (!empty($this->download['revision'])) {
  333. $full_version = $this->download['revision'];
  334. }
  335. // Probably can never reach this case.
  336. else {
  337. $full_version = 'unknown';
  338. }
  339. // If the version string ends in '.x-dev' do the Git magic to figure out
  340. // the appropriate 'rebuild version' string, e.g. '7.x-1.2+7-dev'.
  341. $matches = array();
  342. if (preg_match('/^(.+).x-dev$/', $full_version, $matches)) {
  343. require_once dirname(__FILE__) . '/../pm/package_handler/git_drupalorg.inc';
  344. $rebuild_version = drush_pm_git_drupalorg_compute_rebuild_version($this->download_location, $matches[1]);
  345. if ($rebuild_version) {
  346. $full_version = $rebuild_version;
  347. }
  348. }
  349. require_once dirname(__FILE__) . '/../pm/pm.drush.inc';
  350. if (drush_shell_cd_and_exec($this->download_location, 'git log -1 --pretty=format:%ct')) {
  351. $output = drush_shell_exec_output();
  352. $datestamp = $output[0];
  353. }
  354. else {
  355. $datestamp = time();
  356. }
  357. drush_pm_inject_info_file_metadata($this->download_location, $this->name, $full_version, $datestamp);
  358. }
  359. /**
  360. * Remove the .git directory from a project.
  361. */
  362. function removeGitDirectory() {
  363. if (isset($this->download['type']) && $this->download['type'] == 'git' && file_exists($this->download_location . '/.git')) {
  364. drush_delete_dir($this->download_location . '/.git', TRUE);
  365. }
  366. }
  367. /**
  368. * Add a lock file.
  369. */
  370. function addLockfile($project_directory) {
  371. if (!empty($this->lock)) {
  372. file_put_contents($project_directory . '/.drush-lock-update', $this->lock);
  373. }
  374. return TRUE;
  375. }
  376. /**
  377. * Retrieve translations for this project.
  378. */
  379. function getTranslations($project_directory) {
  380. static $cache = array();
  381. $langcodes = $this->translations;
  382. if ($langcodes && in_array($this->type, array('core', 'module', 'profile', 'theme'), TRUE)) {
  383. // Support the l10n_path, l10n_url keys from l10n_update. Note that the
  384. // l10n_server key is not supported.
  385. if (isset($this->l10n_path)) {
  386. $update_url = $this->l10n_path;
  387. }
  388. else {
  389. if (isset($this->l10n_url)) {
  390. $l10n_server = $this->l10n_url;
  391. }
  392. else {
  393. $l10n_server = FALSE;
  394. }
  395. if ($l10n_server) {
  396. if (!isset($cache[$l10n_server])) {
  397. $this->preprocessLocalFileUrl($l10n_server);
  398. $l10n_server = $l10n_server['url'];
  399. if ($filename = _make_download_file($l10n_server)) {
  400. $server_info = simplexml_load_string(file_get_contents($filename));
  401. $cache[$l10n_server] = !empty($server_info->update_url) ? $server_info->update_url : FALSE;
  402. }
  403. }
  404. if ($cache[$l10n_server]) {
  405. $update_url = $cache[$l10n_server];
  406. }
  407. else {
  408. make_error('XML_ERROR', dt("Could not retrieve l10n update url for !project.", array('!project' => $project['name'])));
  409. return FALSE;
  410. }
  411. }
  412. }
  413. if ($update_url) {
  414. $failed = array();
  415. foreach ($langcodes as $langcode) {
  416. $variables = array(
  417. '%project' => $this->name,
  418. '%release' => $this->download['full_version'],
  419. '%core' => $this->core,
  420. '%language' => $langcode,
  421. '%filename' => '%filename',
  422. );
  423. $url = strtr($update_url, $variables);
  424. // Download the translation file. Since its contents are volatile,
  425. // cache for only 4 hours.
  426. if ($filename = _make_download_file($url, 3600 * 4)) {
  427. // If this is the core project type, download the translation file
  428. // and place it in every profile and an additional copy in
  429. // modules/system/translations where it can be detected for import
  430. // by other non-default install profiles.
  431. if ($this->type === 'core') {
  432. $profiles = drush_scan_directory($project_directory . '/profiles', '/.*/', array(), 0, FALSE, 'filename', 0, TRUE);
  433. foreach ($profiles as $profile) {
  434. if (is_dir($project_directory . '/profiles/' . $profile->basename)) {
  435. drush_mkdir($project_directory . '/profiles/' . $profile->basename . '/translations');
  436. drush_copy_dir($filename, $project_directory . '/profiles/' . $profile->basename . '/translations/' . $langcode . '.po');
  437. }
  438. }
  439. drush_mkdir($project_directory . '/modules/system/translations');
  440. drush_copy_dir($filename, $project_directory . '/modules/system/translations/' . $langcode . '.po');
  441. }
  442. else {
  443. drush_mkdir($project_directory . '/translations');
  444. drush_copy_dir($filename, $project_directory . '/translations/' . $langcode . '.po', FILE_EXISTS_OVERWRITE);
  445. }
  446. }
  447. else {
  448. $failed[] = $langcode;
  449. }
  450. }
  451. if (empty($failed)) {
  452. drush_log('All translations downloaded for ' . $this->name, LogLevel::OK);
  453. }
  454. else {
  455. drush_log('Unable to download translations for ' . $this->name . ': ' . implode(', ', $failed), LogLevel::WARNING);
  456. }
  457. }
  458. }
  459. return TRUE;
  460. }
  461. /**
  462. * Generate the proper path for this project type.
  463. *
  464. * @param boolean $base
  465. * Whether include the base part (tmp dir). Defaults to TRUE.
  466. */
  467. protected function generatePath($base = TRUE) {
  468. $path = array();
  469. if ($base) {
  470. $path[] = make_tmp();
  471. $path[] = '__build__';
  472. }
  473. if (!empty($this->contrib_destination)) {
  474. $path[] = $this->contrib_destination;
  475. }
  476. if (!empty($this->subdir)) {
  477. $path[] = $this->subdir;
  478. }
  479. return implode('/', $path);
  480. }
  481. /**
  482. * Return the proper path for dependencies to be placed in.
  483. *
  484. * @return string
  485. * The path that dependencies will be placed in.
  486. */
  487. protected function buildPath($directory) {
  488. return $this->base_contrib_destination;
  489. }
  490. /**
  491. * Recurse to process additional makefiles that may be found during
  492. * processing.
  493. */
  494. function recurse($path) {
  495. if (!$this->do_recursion || drush_get_option('no-recursion')) {
  496. drush_log(dt("Preventing recursive makefile parsing for !project",
  497. array("!project" => $this->name)), LogLevel::NOTICE);
  498. return TRUE;
  499. }
  500. $candidates = array(
  501. $this->name . '.make.yml',
  502. $this->name . '.make',
  503. 'drupal-org.make.yml',
  504. 'drupal-org.make',
  505. );
  506. $makefile = FALSE;
  507. foreach ($candidates as $filename) {
  508. if (file_exists($this->download_location . '/' . $filename)) {
  509. $makefile = $this->download_location . '/' . $filename;
  510. break;
  511. }
  512. }
  513. if (!$makefile) {
  514. return TRUE;
  515. }
  516. drush_log(dt("Found makefile: !makefile", array("!makefile" => basename($makefile))), LogLevel::OK);
  517. // Save the original state of the 'custom' context.
  518. $custom_context = &drush_get_context('custom');
  519. $original_custom_context_values = $custom_context;
  520. $info = make_parse_info_file($makefile, TRUE, $this->options);
  521. if (!($info = make_validate_info_file($info))) {
  522. $result = FALSE;
  523. }
  524. else {
  525. // Inherit the translations specified in the extender makefile.
  526. if (!empty($this->translations)) {
  527. $info['translations'] = $this->translations;
  528. }
  529. // Strip out any modules that have already been processed before this.
  530. foreach ($this->manifest as $name) {
  531. unset($info['projects'][$name]);
  532. }
  533. $build_path = $this->buildPath($this->name);
  534. make_projects(TRUE, trim($build_path, '/'), $info, $this->build_path, $this->download_location);
  535. make_libraries(TRUE, trim($build_path, '/'), $info, $this->build_path, $this->download_location);
  536. $result = TRUE;
  537. }
  538. // Restore original 'custom' context so that any
  539. // settings changes made are used.
  540. $custom_context = $original_custom_context_values;
  541. return $result;
  542. }
  543. }
  544. /**
  545. * For processing Drupal core projects.
  546. */
  547. class DrushMakeProject_Core extends DrushMakeProject {
  548. /**
  549. * Override constructor for core to adjust project info.
  550. */
  551. protected function __construct(&$project) {
  552. parent::__construct($project);
  553. // subdir and contrib_destination are not allowed for core.
  554. $this->subdir = '';
  555. $this->contrib_destination = '';
  556. }
  557. /**
  558. * Determine the location to download project to.
  559. */
  560. function findDownloadLocation() {
  561. $this->path = $this->download_location = $this->generatePath();
  562. $this->project_directory = '';
  563. if (is_dir($this->download_location)) {
  564. return drush_set_error('MAKE_DIRECTORY_EXISTS', dt('Directory not empty: !directory', array('!directory' => $this->download_location)));
  565. }
  566. elseif ($this->download['type'] === 'pm') {
  567. // pm-download will create the final __build__ directory, so nothing to do
  568. // here.
  569. }
  570. else {
  571. drush_mkdir($this->download_location);
  572. }
  573. return $this->download_location;
  574. }
  575. }
  576. /**
  577. * For processing libraries.
  578. */
  579. class DrushMakeProject_Library extends DrushMakeProject {
  580. /**
  581. * Override constructor for libraries to properly set contrib destination.
  582. */
  583. protected function __construct(&$project) {
  584. parent::__construct($project);
  585. // Allow libraries to specify where they should live in the build path.
  586. if (isset($project['destination'])) {
  587. $project_path = $project['destination'];
  588. }
  589. else {
  590. $project_path = 'libraries';
  591. }
  592. $this->contrib_destination = ($this->base_contrib_destination != '.' ? $this->base_contrib_destination . '/' : '') . $project_path;
  593. }
  594. /**
  595. * No recursion for libraries, sorry :-(
  596. */
  597. function recurse($path) {
  598. // Return TRUE so that processing continues in the make() method.
  599. return TRUE;
  600. }
  601. /**
  602. * No translations for libraries.
  603. */
  604. function getTranslations($download_location) {
  605. // Return TRUE so that processing continues in the make() method.
  606. return TRUE;
  607. }
  608. }
  609. /**
  610. * For processing modules.
  611. */
  612. class DrushMakeProject_Module extends DrushMakeProject {
  613. /**
  614. * Override constructor for modules to properly set contrib destination.
  615. */
  616. protected function __construct(&$project) {
  617. parent::__construct($project);
  618. $this->contrib_destination = ($this->base_contrib_destination != '.' ? $this->base_contrib_destination . '/' : '') . 'modules';
  619. }
  620. }
  621. /**
  622. * For processing installation profiles.
  623. */
  624. class DrushMakeProject_Profile extends DrushMakeProject {
  625. /**
  626. * Override contructor for installation profiles to properly set contrib
  627. * destination.
  628. */
  629. protected function __construct(&$project) {
  630. parent::__construct($project);
  631. $this->contrib_destination = (!empty($this->destination) ? $this->destination : 'profiles');
  632. }
  633. /**
  634. * Find the build path.
  635. */
  636. protected function buildPath($directory) {
  637. return $this->generatePath(FALSE) . '/' . $directory;
  638. }
  639. }
  640. /**
  641. * For processing themes.
  642. */
  643. class DrushMakeProject_Theme extends DrushMakeProject {
  644. /**
  645. * Override contructor for themes to properly set contrib destination.
  646. */
  647. protected function __construct(&$project) {
  648. parent::__construct($project);
  649. $this->contrib_destination = ($this->base_contrib_destination != '.' ? $this->base_contrib_destination . '/' : '') . 'themes';
  650. }
  651. }
  652. /**
  653. * For processing translations.
  654. */
  655. class DrushMakeProject_Translation extends DrushMakeProject {
  656. /**
  657. * Override constructor for translations to properly set contrib destination.
  658. */
  659. protected function __construct(&$project) {
  660. parent::__construct($project);
  661. switch ($project['core']) {
  662. case '5.x':
  663. // Don't think there's an automatic place we can put 5.x translations,
  664. // so we'll toss them in a translations directory in the Drupal root.
  665. $this->contrib_destination = ($this->base_contrib_destination != '.' ? $this->base_contrib_destination . '/' : '') . 'translations';
  666. break;
  667. default:
  668. $this->contrib_destination = '';
  669. break;
  670. }
  671. }
  672. }