Skip to content

Commit

Permalink
chore: removed indexing api integration (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjasper authored Aug 30, 2024
1 parent 8b0f55e commit cb8141d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 684 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed development resources being contained in dist archive (#149)
- Fixed issue there would be an error when no sender email was configured in the plugin, the system email is now used as fallback (#150)

### Removed

- Removed already disabled code for the indexing API integration, in favor of sitemap only setup
- Removed confusing TypoScript setting settings.googleJobs.enable which had no effect

## [3.0.4] - 2023-11-24 Squashed some major bugs

### Fixed
Expand Down
53 changes: 1 addition & 52 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@

namespace ITX\Jobapplications\Controller;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\Controller;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
use TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException;
Expand All @@ -48,11 +46,7 @@
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use ITX\Jobapplications\Service\ApplicationFileService;
use ITX\Jobapplications\Domain\Model\Contact;
use ITX\Jobapplications\Domain\Model\Posting;
use ITX\Jobapplications\Domain\Model\Status;
use ITX\Jobapplications\Utility\GoogleIndexingApiConnector;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException;

/**
Expand Down Expand Up @@ -103,11 +97,8 @@ class BackendController extends ActionController
*/
protected $applicationFileService;

protected GoogleIndexingApiConnector $connector;

public function __construct(GoogleIndexingApiConnector $connector, protected readonly ModuleTemplateFactory $moduleTemplateFactory,)
public function __construct(protected readonly ModuleTemplateFactory $moduleTemplateFactory,)
{
$this->connector = $connector;
}

/**
Expand Down Expand Up @@ -376,48 +367,6 @@ public function settingsAction(): ResponseInterface
$this->addFlashMessage('Finished!');
}

if ($this->request->hasArgument('batch_index'))
{
$postings = $this->postingRepository->findAllIncludingHiddenAndDeleted();

$removeCounter = 0;
$updateCounter = 0;
$error_bit = false;

/** @var Posting $posting */
foreach ($postings as $posting)
{
if ($posting->isHidden() || $posting->isDeleted())
{
if (!$this->connector->updateGoogleIndex($posting->getUid(), true, $posting))
{
$error_bit = true;
}
else
{
$removeCounter++;
}
}
else if (!$this->connector->updateGoogleIndex($posting->getUid(), false, $posting))
{
$error_bit = true;
}
else
{
$updateCounter++;
}
}
if ($error_bit)
{
$this->addFlashMessage('Not successful updated/added '.$updateCounter.' and removed '.$removeCounter.' postings', '', FlashMessage::ERROR);
}
else
{
$this->addFlashMessage('Done with updating/adding '.$updateCounter.' and removing '.$removeCounter.' postings');
}

}

$this->view->assign('admin', $GLOBALS['BE_USER']->isAdmin());

$moduleTemplate->setContent($this->view->render());
Expand Down
101 changes: 0 additions & 101 deletions Classes/Hooks/TCEmainHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
namespace ITX\Jobapplications\Hooks;

use ITX\Jobapplications\Domain\Model\Application;
use ITX\Jobapplications\Domain\Model\Posting;
use ITX\Jobapplications\Domain\Repository\ApplicationRepository;
use ITX\Jobapplications\Service\ApplicationFileService;
use ITX\Jobapplications\Utility\GoogleIndexingApiConnector;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;

/**
Expand All @@ -21,96 +17,12 @@
*/
class TCEmainHook
{
protected GoogleIndexingApiConnector $connector;
protected ApplicationFileService $applicationFileService;
protected ApplicationRepository $applicationRepository;
protected DataMapper $dataMapper;

public function __construct()
{
// TODO: Move to events if they eventually become available for data handler

return;
/*
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->connector = $objectManager->get(GoogleIndexingApiConnector::class);
$this->applicationFileService = $objectManager->get(ApplicationFileService::class);
$this->applicationRepository = $objectManager->get(ApplicationRepository::class);
$this->dataMapper = $objectManager->get(DataMapper::class);
*/
}

/**
* @param $status
* @param $table
* @param $id
* @param array $fieldArray
* @param DataHandler $pObj
*
* @throws \Exception
*/
public function processDatamap_afterDatabaseOperations($status, $table, $id, array $fieldArray, DataHandler $pObj): void
{
return;
if ($table === 'tx_jobapplications_domain_model_posting')
{
$enabled = GeneralUtility::makeInstance(ExtensionConfiguration::class)
->get('jobapplications', 'indexing_api');

if ($enabled !== "1")
{
return;
}

if ($status === "new")
{
$uid = $pObj->substNEWwithIDs[$id] ?? null;
if ($uid === null) {
return;
}

$fieldArray['uid'] = $uid;

$posting = $this->dataMapper->map(Posting::class, [$fieldArray]);

$this->connector->updateGoogleIndex($uid, false, $posting);
}
}
}

/**
* @param $command
* @param $table
* @param $uid
* @param $value
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj
*
* @throws \Exception
*/
public function processDatamap_postProcessFieldArray($command, $table, $uid, $value, DataHandler $pObj)
{
return;
if ($table === "tx_jobapplications_domain_model_posting")
{
$enabled = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('jobapplications', 'indexing_api');
if ($enabled !== "1")
{
return;
}

if ($command === "update")
{
if (($value['hidden']?? '') === '1')
{
$this->connector->updateGoogleIndex($uid, true);
}
else
{
$this->connector->updateGoogleIndex($uid, false);
}
}
}
}

/**
Expand All @@ -126,19 +38,6 @@ public function processDatamap_postProcessFieldArray($command, $table, $uid, $va
*/
public function processCmdmap_deleteAction($table, $uid, array $record, &$recordWasDeleted, DataHandler $dataHandler)
{
return;
if ($table === "tx_jobapplications_domain_model_posting")
{
$enabled = GeneralUtility::makeInstance(ExtensionConfiguration::class)
->get('jobapplications', 'indexing_api');
if ($enabled !== "1")
{
return;
}

$this->connector->updateGoogleIndex($uid, true);
}

if ($table === "tx_jobapplications_domain_model_application")
{
if ($record['hidden'] === 1)
Expand Down
Loading

0 comments on commit cb8141d

Please sign in to comment.