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
35 changes: 11 additions & 24 deletions Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="true"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="Contacts Extension">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Classes/</directory>
</whitelist>
</filter>
<phpunit backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" convertErrorsToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" verbose="false" beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="Contacts Extension">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Classes/</directory>
</whitelist>
</filter>
</phpunit>
38 changes: 12 additions & 26 deletions Build/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
<testsuites>
<testsuite name="Contacts Extension">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Classes/</directory>
</whitelist>
</filter>
</phpunit>
<phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" colors="true" convertErrorsToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" verbose="false">
<testsuites>
<testsuite name="Contacts Extension">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../Classes/</directory>
</whitelist>
</filter>
</phpunit>
35 changes: 16 additions & 19 deletions Classes/Command/GeocodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* LICENSE file that was distributed with this source code.
*/

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -17,17 +18,11 @@
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

#[AsCommand('contacts:geocode', 'Geocode addresses of contact extension')]
class GeocodeCommand extends Command
{
/**
* @var string
*/
protected $tableName = 'tx_contacts_domain_model_address';

/**
* @var string
*/
protected $googleMapsApiKey = '';
protected string $tableName = 'tx_contacts_domain_model_address';
protected string $googleMapsApiKey = '';

protected function configure(): void
{
Expand All @@ -45,14 +40,14 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
$this->googleMapsApiKey = $contactsConfiguration['googleMapsApiKey'];
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('');

if (empty($this->googleMapsApiKey)) {
$output->writeln('ApiKey is missing!');
$output->writeln('');
return;
return Command::FAILURE;
}

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
Expand All @@ -64,33 +59,32 @@ protected function execute(InputInterface $input, OutputInterface $output): void
->where(
$queryBuilder->expr()->eq('deleted', 0)
)
->execute()
->fetchColumn(0);
->executeQuery()
->fetchOne();

$addresses = $queryBuilder
->select('uid', 'lat', 'lon', 'street', 'street_number', 'zip', 'city')
->from($this->tableName)
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->and(
$queryBuilder->expr()->eq('deleted', 0),
$queryBuilder->expr()->eq('lat', 0),
$queryBuilder->expr()->eq('lon', 0)
)
)
->execute()
->fetchAll();
->executeQuery()
->fetchAllAssociative();

$cntAddressesToProcess = count($addresses);
$addressesProcessed = $addressCountAll - $cntAddressesToProcess;

if ($cntAddressesToProcess === 0) {
$output->writeln('Nothing to do here.');
$output->writeln('');
return;
return Command::SUCCESS;
}

$progress = new ProgressBar($output, $addressCountAll);

$progress->start();
$progress->advance($addressesProcessed);

Expand All @@ -116,7 +110,8 @@ protected function execute(InputInterface $input, OutputInterface $output): void
)
->set('lat', $lat)
->set('lon', $lng)
->execute();
->executeStatement();

$posResult++;
} else {
$negResult++;
Expand All @@ -130,6 +125,8 @@ protected function execute(InputInterface $input, OutputInterface $output): void
$output->writeln('');

$progress->finish();

return Command::SUCCESS;
}

protected function geocode(string $address): array
Expand Down
27 changes: 8 additions & 19 deletions Classes/Controller/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,19 @@

class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @var CategoryRepository
*/
protected $categoryRepository;

/**
* @var \TYPO3\CMS\Core\Domain\Repository\PageRepository
*/
protected $pageRepository;

/**
* @param CategoryRepository $categoryRepository
*/
public function injectCategoryRepository(CategoryRepository $categoryRepository)
protected CategoryRepository $categoryRepository;
protected PageRepository $pageRepository;

public function injectPageRepository(PageRepository $pageRepository): void
{
$this->categoryRepository = $categoryRepository;
$this->pageRepository = $pageRepository;
}

/**
* @param \TYPO3\CMS\Core\Domain\Repository\PageRepository $pageRepository
*/
public function injectPageRepository(PageRepository $pageRepository)
public function injectCategoryRepository(CategoryRepository $categoryRepository): void
{
$this->pageRepository = $pageRepository;
$this->categoryRepository = $categoryRepository;
}

/**
Expand Down Expand Up @@ -80,7 +69,7 @@ protected function createDemandObjectFromSettings(array $settings) : Demand
/**
* @param Demand $demand
*/
protected function addCategoriesToDemandObjectFromSettings(&$demand)
protected function addCategoriesToDemandObjectFromSettings(&$demand): void
{
if ($this->settings['categoriesList']) {
$selectedCategories = GeneralUtility::intExplode(
Expand Down
34 changes: 11 additions & 23 deletions Classes/Controller/AddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,18 @@
use Extcode\Contacts\Domain\Repository\ZipRepository;
use Extcode\Contacts\Hooks\AddressSearchAddressesLoadedHookInterface;
use Extcode\Contacts\Utility\PageUtility;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class AddressController extends ActionController
{
/**
* @var AddressRepository
*/
protected $addressRepository;
public function __construct(
protected AddressRepository $addressRepository,
protected ZipRepository $zipRepository)
{}

/**
* @var ZipRepository
*/
protected $zipRepository;

public function injectAddressRepository(AddressRepository $addressRepository): void
{
$this->addressRepository = $addressRepository;
}

public function injectZipRepository(ZipRepository $zipRepository): void
{
$this->zipRepository = $zipRepository;
}

public function searchAction(): void
public function searchAction(): ResponseInterface
{
$addressSearch = new AddressSearch();
if ($this->settings['orderBy']) {
Expand Down Expand Up @@ -77,8 +63,8 @@ public function searchAction(): void

$addressSearch->setPids(
PageUtility::extendPidListByChildren(
$this->configurationManager->getContentObject()->data['pages'],
$this->configurationManager->getContentObject()->data['recursive']
$this->request->getAttribute('currentContentObject')->data['pages'] ?? '',
$this->request->getAttribute('currentContentObject')->data['recursive'] ?? ''
)
);

Expand All @@ -96,14 +82,16 @@ public function searchAction(): void
}

$this->view->assign('addresses', $addresses);
return $this->htmlResponse();
}

public function showAction(Address $address = null): void
public function showAction(Address $address = null): ResponseInterface
{
if (!$address) {
$address = $this->addressRepository->findByUid($this->settings['address']);
}

$this->view->assign('address', $address);
return $this->htmlResponse();
}
}
Loading