Commit 1aac02c2 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen
Browse files

Fixing CGL

parent 9f84c03b
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace T3o\TerFe2\Command;
/*
......@@ -74,8 +75,8 @@ class PackagistCommandController extends CommandController
$extensions = $this->extensionRepository->findWithComposerName($limit);
// User-Agent https://twitter.com/seldaek/status/1095420243315511297
$options = array('http' => array('user_agent' => 'Thanks a bunch! Fetching packagist Download Data for https://extensions.typo3.org - https://typo3.org/community/teams/typo3org/'));
$context = stream_context_create($options);
$options = ['http' => ['user_agent' => 'Thanks a bunch! Fetching packagist Download Data for https://extensions.typo3.org - https://typo3.org/community/teams/typo3org/']];
$context = stream_context_create($options);
/** @var Extension $extension */
foreach ($extensions as $extension) {
......@@ -86,7 +87,6 @@ class PackagistCommandController extends CommandController
$downloadData = json_decode(file_get_contents($packagistUrl, false, $context), true);
foreach ($downloadData['package']['downloads']['versions'] as $version => $downloads) {
$versionFound = $this->versionRepository->findOneByExtensionAndVersionString($extension, $version);
if (null === $versionFound) {
continue;
......@@ -105,4 +105,4 @@ class PackagistCommandController extends CommandController
}
}
}
}
\ No newline at end of file
}
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace T3o\TerFe2\Domain\Model;
/*
......@@ -124,6 +124,4 @@ class Download extends AbstractEntity
{
$this->source = $source;
}
}
\ No newline at end of file
}
<?php
namespace T3o\TerFe2\Domain\Model;
/*
......@@ -588,15 +589,15 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
public function getDownloadsByTimeIntervalAsJson(): string
{
if(empty($this->versions)) {
if (empty($this->versions)) {
return '';
}
$intervals = [];
// The for loop is turned around to ensure the sorting order in the multi dimensional array.
for ($i = 5; $i >= 0 ; $i--) {
$time = strtotime("-" . $i . "month");
for ($i = 5; $i >= 0; $i--) {
$time = strtotime('-' . $i . 'month');
$month = date('Ym', $time);
$downloads = $this->downloadRepository->findDownloadCounterByMonthAndExtensionKeyTotal($month, $this->getExtKey());
$intervals['release'][] = $month;
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace T3o\TerFe2\Domain\Repository;
/*
......@@ -35,6 +35,7 @@ class DownloadRepository extends AbstractRepository
* @var QueryBuilder
*/
protected $queryBuilder = QueryBuilder::class;
/**
* QueueRepository constructor.
*/
......@@ -56,7 +57,6 @@ class DownloadRepository extends AbstractRepository
*/
public function findDownloadCounterByMonthAndExtensionKey($month, $extensionKey, $versionId, $source)
{
$query = $this->createQuery();
$query->matching(
$query->logicalAnd(
......@@ -107,5 +107,4 @@ class DownloadRepository extends AbstractRepository
return $total;
}
}
\ No newline at end of file
}
<?php
namespace T3o\TerFe2\Utility;
/*
......@@ -45,7 +46,7 @@ class VersionUtility
$parts = [
substr($versionString, 0, 3),
substr($versionString, 3, 3),
substr($versionString, 6, 3)
substr($versionString, 6, 3),
];
return (int)$parts[0] . '.' . (int)$parts[1] . '.' . (int)$parts[2];
......@@ -70,7 +71,7 @@ class VersionUtility
return false;
}
/**
* Generates a list with compatible TYPO3 versions from given dependencies
*
......@@ -190,7 +191,7 @@ class VersionUtility
$parts = explode('.', $versionString) ?: [];
return (int)array_shift($parts);
}
/**
* @param String $extensionKey
* @param int $versionId
......@@ -212,7 +213,7 @@ class VersionUtility
$downloadRepository = $objectManager->get(DownloadRepository::class);
/** @var Download $downloadInfo */
$downloadInfo = $downloadRepository->findDownloadCounterByMonthAndExtensionKey($month,$extensionKey,$versionId, $source);
$downloadInfo = $downloadRepository->findDownloadCounterByMonthAndExtensionKey($month, $extensionKey, $versionId, $source);
if (null === $downloadInfo) {
$downloadInfo = new Download();
......@@ -223,7 +224,7 @@ class VersionUtility
$downloadInfo->setCounter($counter);
$downloadRepository->add($downloadInfo);
} elseif ($downloadInfo->getCounter() > 0) {
$downloadInfo->setCounter($downloadInfo->getCounter()+1);
$downloadInfo->setCounter($downloadInfo->getCounter() + 1);
$downloadRepository->update($downloadInfo);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment