Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Tasks/Build/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,51 @@ public function getDate()
return date('Y-m-d');
}

/**
* Copy the media files for an extension to the build folder
*
* @param string $name The name of the extension to copy media files for
*
* @return bool
*
* @since 1.0
*/
public function buildMediaFiles($name)
{
$verbosity = $this->verbosityThreshold();
$this->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE);
$type = substr($name, 0, 3);
$source = $this->getSourceFolder() . '/media/' . $name;
$target = $this->getBuildFolder() . '/media/' . $name;

if ($type == 'lib') {
$source = $this->getSourceFolder() . '/media/' . substr($name, 3);
$target = $this->getBuildFolder() . '/media/' . substr($name, 3);
}

$this->printTaskInfo("Building media folder " . $source . " for " . $name);

if (!file_exists($source)) {
$this->printTaskInfo("Folder " . $source . " does not exist!");

return false;
}

$this->taskFilesystemStack()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE)
->mkdir($target)
->run();

$map = $this->copyTarget($source, $target);

$this->addFiles('media', $map);

$this->printTaskSuccess("Finished building media folder " . $source . " for " . $name);
$this->setVerbosityThreshold($verbosity);

return true;
}

/**
* Generate a list of files
*
Expand Down
6 changes: 1 addition & 5 deletions src/Tasks/Build/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ public function run()
// Build media (relative path)
if ($this->hasMedia) {
$this->logger->log(LogLevel::INFO, 'Copy media files', $this->getTaskContext());
$media = $this->buildMedia("media/com_" . $this->getExtensionName(), 'com_' . $this->getExtensionName(), $this->params);
$media->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

$this->addFiles('media', $media->getResultFiles());
$this->buildMediaFiles('com_' . $this->getExtensionName());
}

// Build language files for the component
Expand Down
6 changes: 0 additions & 6 deletions src/Tasks/Build/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ public function run()
$this->addFiles('frontend', $frontendFiles);
}

// Build media (relative path)
$media = $this->buildMedia("media/com_" . $this->getExtensionName(), 'com_' . $this->getExtensionName());
$media->run();

$this->addFiles('media', $media->getResultFiles());

// Build language files for the component
$language = $this->buildLanguage("com_" . $this->getExtensionName());
$language->run();
Expand Down
6 changes: 1 addition & 5 deletions src/Tasks/Build/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ public function run()
}

// Build media (relative path)
$media = $this->buildMedia("media/" . $lib, $lib);
$media->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

$this->addFiles('media', $media->getResultFiles());
$this->buildMediaFiles($this->libName);

// Build language files for the component
$language = $this->buildLanguage($lib)
Expand Down
109 changes: 0 additions & 109 deletions src/Tasks/Build/Media.php

This file was deleted.

6 changes: 1 addition & 5 deletions src/Tasks/Build/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ public function run()
$files = $this->copyTarget($this->source, $this->target);

// Build media (relative path)
$media = $this->buildMedia("media/" . $this->modName, $this->modName);
$media->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

$this->addFiles('media', $media->getResultFiles());
$this->buildMediaFiles($this->modName);

// Build language files for the module
if (is_dir($this->getSourceFolder() . '/language')) {
Expand Down
6 changes: 1 addition & 5 deletions src/Tasks/Build/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public function run()
$files = $this->copyTarget($this->source, $this->target);

// Build media (relative path)
$media = $this->buildMedia("media/plg_" . $this->plgType . "_" . $this->plgName, 'plg_' . $this->plgType . "_" . $this->plgName);
$media->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

$this->addFiles('media', $media->getResultFiles());
$this->buildMediaFiles('plg_' . $this->plgType . '_' . $this->plgName);

// Build language files
if (is_dir($this->getSourceFolder() . '/administrator/language')) {
Expand Down
15 changes: 0 additions & 15 deletions src/Tasks/Build/Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ protected function buildComponent($name, $params = [])
return $this->task(Component::class, $name, $params);
}

/**
* Build media folder
*
* @param string $source The media folder (an extension could have multiple)
* @param string $extName The extension name (e.g. mod_xy)
*
* @return CollectionBuilder
*
* @since 1.0
*/
protected function buildMedia($source, $extName, $params = [])
{
return $this->task(Media::class, $source, $extName, $params);
}

/**
* Build language folder
*
Expand Down
6 changes: 1 addition & 5 deletions src/Tasks/Build/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ public function run()
$files = $this->copyTarget($this->source, $this->target);

// Build media (relative path)
$media = $this->buildMedia("media/" . $this->templateName, $this->templateName);
$media->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

$this->addFiles('media', $media->getResultFiles());
$this->buildMediaFiles('tpl_' . $this->templateName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->buildMediaFiles('tpl_' . $this->templateName);
$this->buildMediaFiles($this->templateName);

templates don't use the tpl_ prefix

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just handing in the name of the extension and the prefix lets the system discover which type it is. In this case, the tpl_ is necessary.


// Build language files for the component
if (is_dir($this->getSourceFolder() . '/language')) {
Expand Down