31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-06-03 14:10:47 +00:00

Merge pull request #281 from SharkyKZ/namespace-mapper

[4.0] Use namespace mapper to regenerate namespace map
This commit is contained in:
Roland Dalmulder 2020-05-11 14:15:29 +02:00 committed by GitHub
commit c6aacb4cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,6 +72,29 @@ class PullModel extends AbstractModel
'crowdin.yaml',
);
/**
* The namespace mapper
*
* @var \JNamespacePsr4Map
* @since __DEPLOY_VERSION__
*/
protected $namespaceMapper;
/**
* Instantiate the model.
*
* @param Registry $state The model state.
* @param \JDatabaseDriver $db The database adpater.
*
* @since __DEPLOY_VERSION__
*/
public function __construct(Registry $state = null, \JDatabaseDriver $db = null)
{
parent::__construct($state, $db);
$this->namespaceMapper = new \JNamespacePsr4Map;
}
/**
* Patches the code with the supplied pull request
* However uses different methods for different repositories.
@ -270,11 +293,8 @@ class PullModel extends AbstractModel
$this->saveAppliedPatch($id, $files, $sha);
// Remove the autoloader file
if (file_exists(JPATH_CACHE . '/autoload_psr4.php'))
{
File::delete(JPATH_CACHE . '/autoload_psr4.php');
}
// Update the autoloader file
$this->namespaceMapper->create();
// Change the media version
$version = new Version;
@ -680,11 +700,8 @@ class PullModel extends AbstractModel
$this->saveAppliedPatch($pull->number, $parsedFiles, $pull->head->sha);
// Remove the autoloader file
if (file_exists(JPATH_CACHE . '/autoload_psr4.php'))
{
File::delete(JPATH_CACHE . '/autoload_psr4.php');
}
// Update the autoloader file
$this->namespaceMapper->create();
// Change the media version
$version = new Version;
@ -871,11 +888,8 @@ class PullModel extends AbstractModel
Folder::delete($backupsPath);
// Remove the autoloader file
if (file_exists(JPATH_CACHE . '/autoload_psr4.php'))
{
File::delete(JPATH_CACHE . '/autoload_psr4.php');
}
// Update the autoloader file
$this->namespaceMapper->create();
// Change the media version
$version = new Version;
@ -1048,11 +1062,8 @@ class PullModel extends AbstractModel
}
}
// Remove the autoloader file
if (file_exists(JPATH_CACHE . '/autoload_psr4.php'))
{
File::delete(JPATH_CACHE . '/autoload_psr4.php');
}
// Update the autoloader file
$this->namespaceMapper->create();
// Change the media version
$version = new Version;