mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-02 22:50:27 +00:00
More codestyle
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
This commit is contained in:
parent
8b0f33e99e
commit
aeb58bebef
@ -14,7 +14,8 @@ use Joomla\Registry\Registry;
|
|||||||
*/
|
*/
|
||||||
trait GithubCredentialsTrait
|
trait GithubCredentialsTrait
|
||||||
{
|
{
|
||||||
protected function getCredentials(): Registry {
|
protected function getCredentials(): Registry
|
||||||
|
{
|
||||||
$state = new Registry();
|
$state = new Registry();
|
||||||
$params = ComponentHelper::getParams('com_patchtester');
|
$params = ComponentHelper::getParams('com_patchtester');
|
||||||
$state->set('github_user', $params->get('org', 'joomla'));
|
$state->set('github_user', $params->get('org', 'joomla'));
|
||||||
|
@ -183,7 +183,8 @@ class PullModel extends BaseDatabaseModel
|
|||||||
$result = null;
|
$result = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result === null
|
if (
|
||||||
|
$result === null
|
||||||
|| ($result->getStatusCode() !== 200
|
|| ($result->getStatusCode() !== 200
|
||||||
&& $result->getStatusCode() !== 310)
|
&& $result->getStatusCode() !== 310)
|
||||||
) {
|
) {
|
||||||
@ -262,7 +263,8 @@ class PullModel extends BaseDatabaseModel
|
|||||||
|
|
||||||
if (file_exists($tempPath . '/' . $file)) {
|
if (file_exists($tempPath . '/' . $file)) {
|
||||||
// Create directories if they don't exist until file
|
// Create directories if they don't exist until file
|
||||||
if (!file_exists(JPATH_ROOT . '/' . $filePath)
|
if (
|
||||||
|
!file_exists(JPATH_ROOT . '/' . $filePath)
|
||||||
|| !is_dir(
|
|| !is_dir(
|
||||||
JPATH_ROOT . '/' . $filePath
|
JPATH_ROOT . '/' . $filePath
|
||||||
)
|
)
|
||||||
@ -323,7 +325,9 @@ class PullModel extends BaseDatabaseModel
|
|||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
||||||
$exception->getMessage()
|
$exception->getMessage()
|
||||||
), $exception->getCode(), $exception
|
),
|
||||||
|
$exception->getCode(),
|
||||||
|
$exception
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +353,9 @@ class PullModel extends BaseDatabaseModel
|
|||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
||||||
$exception->getMessage()
|
$exception->getMessage()
|
||||||
), $exception->getCode(), $exception
|
),
|
||||||
|
$exception->getCode(),
|
||||||
|
$exception
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,10 +390,7 @@ class PullModel extends BaseDatabaseModel
|
|||||||
array_walk(
|
array_walk(
|
||||||
$composerFiles,
|
$composerFiles,
|
||||||
static function ($composerFile) use (&$filesToCheck, $path) {
|
static function ($composerFile) use (&$filesToCheck, $path) {
|
||||||
if (file_exists(
|
if (file_exists($path . '/libraries/vendor/composer/' . $composerFile) === false) {
|
||||||
$path . '/libraries/vendor/composer/' . $composerFile
|
|
||||||
) === false
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,20 +404,20 @@ class PullModel extends BaseDatabaseModel
|
|||||||
$autoload,
|
$autoload,
|
||||||
$match
|
$match
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$resultMatch) {
|
if (!$resultMatch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the class is already defined
|
// Check if the class is already defined
|
||||||
$autoloadClass = '\Composer\Autoload\ComposerStaticInit'
|
$autoloadClass = '\Composer\Autoload\ComposerStaticInit' . $match[1];
|
||||||
. $match[1];
|
|
||||||
if (class_exists($autoloadClass)) {
|
if (class_exists($autoloadClass)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $path
|
require_once $path . '/libraries/vendor/composer/autoload_static.php';
|
||||||
. '/libraries/vendor/composer/autoload_static.php';
|
|
||||||
// Get all the files
|
|
||||||
$files = $autoloadClass::$files;
|
$files = $autoloadClass::$files;
|
||||||
$filesToCheck = array_merge($filesToCheck, $files);
|
$filesToCheck = array_merge($filesToCheck, $files);
|
||||||
} else {
|
} else {
|
||||||
@ -434,13 +437,14 @@ class PullModel extends BaseDatabaseModel
|
|||||||
* @param array $files The list of files to check
|
* @param array $files The list of files to check
|
||||||
* @param string $path The path where the temporary patch resides
|
* @param string $path The path where the temporary patch resides
|
||||||
*
|
*
|
||||||
* @return boolean True if all files exist | False otherwise.
|
* @return bool True if all files exist | False otherwise.
|
||||||
*
|
*
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
private function checkFilesExist(array $files, string $path): bool
|
private function checkFilesExist(array $files, string $path): bool
|
||||||
{
|
{
|
||||||
$path = Path::clean($path);
|
$path = Path::clean($path);
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (is_array($file)) {
|
if (is_array($file)) {
|
||||||
$this->checkFilesExist($file, $path);
|
$this->checkFilesExist($file, $path);
|
||||||
|
Loading…
Reference in New Issue
Block a user