Skip to content

Commit

Permalink
Merge pull request #89 from kitodo/fix-78
Browse files Browse the repository at this point in the history
fix #78: replace all instantiation strings by new PHP (>5.5) "::class" notation
  • Loading branch information
claussni authored Apr 20, 2018
2 parents 40c1653 + d0743c6 commit e1e23bc
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 98 deletions.
2 changes: 0 additions & 2 deletions Classes/Command/TransferCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function transferCommand()

$success = true;

$repository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');

return true;
}
}
17 changes: 11 additions & 6 deletions Classes/Configuration/ClientConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* The TYPO3 project - inspiring people to share!
*/

class ClientConfigurationManager
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use EWW\Dpf\Domain\Repository\ClientRepository;

class ClientConfigurationManager
{

/**
Expand Down Expand Up @@ -54,11 +59,11 @@ class ClientConfigurationManager
* @var array
*/
protected $extensionConfiguration = array();

public function __construct()
{
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\Object\\ObjectManager');
$clientRepository = $objectManager->get("EWW\\Dpf\\Domain\\Repository\\ClientRepository");
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class);
$clientRepository = $objectManager->get(ClientRepository::class);

if (TYPO3_MODE === 'BE')
{
Expand All @@ -67,7 +72,7 @@ public function __construct()
{
$this->client = $clientRepository->findAll()->current();

$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
$configurationManager = $objectManager->get(BackendConfigurationManager::class);
$settings = $configurationManager->getConfiguration(NULL,NULL);
$this->settings = $settings; //['settings'];
}
Expand All @@ -77,7 +82,7 @@ public function __construct()
{
$this->client = $clientRepository->findAll()->current();

$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
$configurationManager = $objectManager->get(ConfigurationManager::class);
$this->settings = $configurationManager->getConfiguration(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
);
Expand Down
29 changes: 18 additions & 11 deletions Classes/Controller/AbstractDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
* The TYPO3 project - inspiring people to share!
*/

use EWW\Dpf\Domain\Model\Document;
use EWW\Dpf\Services\Email\Notifier;
use EWW\Dpf\Services\Transfer\ElasticsearchRepository;
use EWW\Dpf\Helper\DocumentMapper;
use EWW\Dpf\Helper\ElasticsearchMapper;
use EWW\Dpf\Helper\FormDataReader;

/**
* DocumentFormController
*/
Expand Down Expand Up @@ -144,9 +151,9 @@ public function initializeNewAction()
} elseif (array_key_exists('documentType', $requestArguments)) {
$docTypeUid = $this->request->getArgument('documentType');
$documentType = $this->documentTypeRepository->findByUid($docTypeUid);
$document = $this->objectManager->get('\EWW\Dpf\Domain\Model\Document');
$document = $this->objectManager->get(Document::class);
$document->setDocumentType($documentType);
$mapper = $this->objectManager->get('EWW\Dpf\Helper\DocumentMapper');
$mapper = $this->objectManager->get(DocumentMapper::class);
$docForm = $mapper->getDocumentForm($document);
} elseif (array_key_exists('newDocumentForm', $requestArguments)) {
$docForm = $this->request->getArgument('newDocumentForm');
Expand Down Expand Up @@ -176,7 +183,7 @@ public function initializeCreateAction()
if ($this->request->hasArgument('documentData')) {
$documentData = $this->request->getArgument('documentData');

$formDataReader = $this->objectManager->get('EWW\Dpf\Helper\FormDataReader');
$formDataReader = $this->objectManager->get(FormDataReader::class);
$formDataReader->setFormData($documentData);

$docForm = $formDataReader->getDocumentForm();
Expand Down Expand Up @@ -206,7 +213,7 @@ public function initializeCreateAction()
public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm)
{

$documentMapper = $this->objectManager->get('EWW\Dpf\Helper\DocumentMapper');
$documentMapper = $this->objectManager->get(DocumentMapper::class);
$newDocument = $documentMapper->getDocument($newDocumentForm);

$this->documentRepository->add($newDocument);
Expand All @@ -230,15 +237,15 @@ public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm
}
}

$notifier = $this->objectManager->get('\EWW\Dpf\Services\Email\Notifier');
$notifier = $this->objectManager->get(Notifier::class);

$notifier->sendNewDocumentNotification($newDocument);

$requestArguments = $this->request->getArguments();

if (array_key_exists('savecontinue', $requestArguments)) {

$tmpDocument = $this->objectManager->get('\EWW\Dpf\Domain\Model\Document');
$tmpDocument = $this->objectManager->get(Document::class);

$tmpDocument->setTitle($newDocument->getTitle());
$tmpDocument->setAuthors($newDocument->getAuthors());
Expand All @@ -260,7 +267,7 @@ public function initializeEditAction()
if (array_key_exists('document', $requestArguments)) {
$documentUid = $this->request->getArgument('document');
$document = $this->documentRepository->findByUid($documentUid);
$mapper = $this->objectManager->get('EWW\Dpf\Helper\DocumentMapper');
$mapper = $this->objectManager->get(DocumentMapper::class);
$documentForm = $mapper->getDocumentForm($document);
} elseif (array_key_exists('documentForm', $requestArguments)) {
$documentForm = $this->request->getArgument('documentForm');
Expand Down Expand Up @@ -289,7 +296,7 @@ public function initializeUpdateAction()
if ($this->request->hasArgument('documentData')) {
$documentData = $this->request->getArgument('documentData');

$formDataReader = $this->objectManager->get('EWW\Dpf\Helper\FormDataReader');
$formDataReader = $this->objectManager->get(FormDataReader::class);
$formDataReader->setFormData($documentData);
$docForm = $formDataReader->getDocumentForm();

Expand Down Expand Up @@ -321,7 +328,7 @@ public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm)

$requestArguments = $this->request->getArguments();

$documentMapper = $this->objectManager->get('EWW\Dpf\Helper\DocumentMapper');
$documentMapper = $this->objectManager->get(DocumentMapper::class);
$updateDocument = $documentMapper->getDocument($documentForm);

$objectIdentifier = $updateDocument->getObjectIdentifier();
Expand All @@ -348,10 +355,10 @@ public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm)
}

// add document to local es index
$elasticsearchMapper = $this->objectManager->get('EWW\Dpf\Helper\ElasticsearchMapper');
$elasticsearchMapper = $this->objectManager->get(ElasticsearchMapper::class);
$json = $elasticsearchMapper->getElasticsearchJson($updateDocument);

$elasticsearchRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\ElasticsearchRepository');
$elasticsearchRepository = $this->objectManager->get(ElasticsearchRepository::class);
// send document to index
$elasticsearchRepository->add($updateDocument, $json);

Expand Down
3 changes: 2 additions & 1 deletion Classes/Controller/AbstractSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use EWW\Dpf\Services\ElasticSearch;

abstract class AbstractSearchController extends \EWW\Dpf\Controller\AbstractController
{
Expand All @@ -32,7 +33,7 @@ abstract class AbstractSearchController extends \EWW\Dpf\Controller\AbstractCont
public function getResultList($query, $type)
{

$elasticSearch = new \EWW\Dpf\Services\ElasticSearch();
$elasticSearch = $this->objectManager->get(ElasticSearch::class);
$results = $elasticSearch->search($query, $type);

return $results;
Expand Down
10 changes: 7 additions & 3 deletions Classes/Controller/AjaxDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* The TYPO3 project - inspiring people to share!
*/

use EWW\Dpf\Services\Identifier\Urn;
use EWW\Dpf\Services\Transfer\DocumentTransferManager;
use EWW\Dpf\Services\Transfer\FedoraRepository;

/**
* DocumentFormController
*/
Expand Down Expand Up @@ -154,13 +158,13 @@ public function deleteFileAction($fileUid, $isPrimary = 0)
public function fillOutAction($qucosaId)
{

$urnService = $this->objectManager->get('EWW\\Dpf\\Services\\Identifier\\Urn');
$urnService = $this->objectManager->get(Urn::class);

if (!empty($qucosaId)) {
$urn = $urnService->getUrn($qucosaId);
} else {
$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

$qucosaId = $documentTransferManager->getNextDocumentId();
Expand Down
14 changes: 9 additions & 5 deletions Classes/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
use EWW\Dpf\Configuration\InputOption\Iso6392b;
use EWW\Dpf\\Helper\InputOption\Translator;
use EWW\Dpf\Domain\Model\InputOptionList;
/**
* ClientController
*/
Expand Down Expand Up @@ -68,7 +72,7 @@ protected function initializeAction()

$this->pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->selectedPageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));

$configManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
$configManager = $this->objectManager->get(BackendConfigurationManager::class);

$this->settings = $configManager->getConfiguration(
$this->request->getControllerExtensionName(),
Expand Down Expand Up @@ -198,13 +202,13 @@ protected function isValidClientFolder()
protected function addBaseInputOptionLists($storagePid)
{

$iso6392b = $this->objectManager->get('EWW\\Dpf\\Configuration\\InputOption\\Iso6392b');
$iso6392b = $this->objectManager->get(Iso6392b::class);

$inputOptionTranslator = $this->objectManager->get('EWW\\Dpf\\Helper\\InputOption\\Translator');
$inputOptionTranslator = $this->objectManager->get(Translator::class);
$inputOptionTranslator->init(get_class($iso6392b));

// create input option list for the default language
$languageOptionList = $this->objectManager->get('EWW\\Dpf\\Domain\\Model\\InputOptionList');
$languageOptionList = $this->objectManager->get(InputOptionList::class);
$languageOptionList->setName('languageList');
$languageOptionList->setPid($storagePid);
$languageOptionList->setSysLanguageUid(0);
Expand Down Expand Up @@ -236,7 +240,7 @@ protected function addBaseInputOptionLists($storagePid)
$valueLabelList = $inputOptionTranslator->translate($iso6392b->getValues(), $langIsoCode);
$displayName = $inputOptionTranslator->translate(array('languageList'), $langIsoCode);

$translatedOptionList = $this->objectManager->get('EWW\\Dpf\\Domain\\Model\\InputOptionList');
$translatedOptionList = $this->objectManager->get(InputOptionList::class);
$translatedOptionList->setDisplayName(implode('', $displayName));
$translatedOptionList->setPid($storagePid);
$translatedOptionList->setSysLanguageUid($installedLanguage->getUid());
Expand Down
47 changes: 28 additions & 19 deletions Classes/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
* The TYPO3 project - inspiring people to share!
*/

use EWW\Dpf\Domain\Model\Document;
use EWW\Dpf\Services\Transfer\ElasticsearchRepository;
use EWW\Dpf\Services\Transfer\DocumentTransferManager;
use EWW\Dpf\Services\Transfer\FedoraRepository;
use EWW\Dpf\Services\ProcessNumber\ProcessNumberGenerator;
use EWW\Dpf\Services\Identifier\Urn;
use EWW\Dpf\Services\Email\Notifier;
use EWW\Dpf\Helper\ElasticsearchMapper;

/**
* DocumentController
*/
Expand Down Expand Up @@ -152,7 +161,7 @@ public function discardConfirmAction(\EWW\Dpf\Domain\Model\Document $document)
public function discardAction(\EWW\Dpf\Domain\Model\Document $document)
{
// remove document from local index
$elasticsearchRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\ElasticsearchRepository');
$elasticsearchRepository = $this->objectManager->get(ElasticsearchRepository::class);
// send document to index
$elasticsearchRepository->delete($document, "");

Expand Down Expand Up @@ -187,7 +196,7 @@ public function duplicateAction(\EWW\Dpf\Domain\Model\Document $document)

$this->addFlashMessage($message, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);

$newDocument = $this->objectManager->get('\EWW\Dpf\Domain\Model\Document');
$newDocument = $this->objectManager->get(Document::class);

$newDocument->setTitle($document->getTitle());
$newDocument->setAuthors($document->getAuthors());
Expand All @@ -198,7 +207,7 @@ public function duplicateAction(\EWW\Dpf\Domain\Model\Document $document)

$newDocument->setDocumentType($document->getDocumentType());

$processNumberGenerator = $this->objectManager->get("EWW\\Dpf\\Services\\ProcessNumber\\ProcessNumberGenerator");
$processNumberGenerator = $this->objectManager->get(ProcessNumberGenerator::class);
$processNumber = $processNumberGenerator->getProcessNumber();
$newDocument->setProcessNumber($processNumber);

Expand All @@ -208,11 +217,11 @@ public function duplicateAction(\EWW\Dpf\Domain\Model\Document $document)

$this->documentRepository->add($newDocument);

$elasticsearchRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\ElasticsearchRepository');
$elasticsearchRepository = $this->objectManager->get(ElasticsearchRepository::class);

$this->persistenceManager->persistAll();
// send document to index
$elasticsearchMapper = $this->objectManager->get('EWW\Dpf\Helper\ElasticsearchMapper');
$elasticsearchMapper = $this->objectManager->get(ElasticsearchMapper::class);
$json = $elasticsearchMapper->getElasticsearchJson($newDocument);

$elasticsearchRepository->add($newDocument, $json);
Expand Down Expand Up @@ -248,23 +257,23 @@ public function releaseAction(\EWW\Dpf\Domain\Model\Document $document)
$qucosaId = $document->getReservedObjectIdentifier();
}
if (empty($qucosaId)) {
$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);
$qucosaId = $documentTransferManager->getNextDocumentId();
$document->setReservedObjectIdentifier($qucosaId);
}

$mods = new \EWW\Dpf\Helper\Mods($document->getXmlData());
if (!$mods->hasQucosaUrn()) {
$urnService = $this->objectManager->get('EWW\\Dpf\\Services\\Identifier\\Urn');
$urnService = $this->objectManager->get(Urn::class);
$urn = $urnService->getUrn($qucosaId);
$mods->addQucosaUrn($urn);
$document->setXmlData($mods->getModsXml());
}

$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

$objectIdentifier = $document->getObjectIdentifier();
Expand All @@ -276,7 +285,7 @@ public function releaseAction(\EWW\Dpf\Domain\Model\Document $document)
if ($documentTransferManager->ingest($document)) {
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.success';
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::OK;
$notifier = $this->objectManager->get('\EWW\Dpf\Services\Email\Notifier');
$notifier = $this->objectManager->get(Notifier::class);
$notifier->sendIngestNotification($document);
} else {
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.failure';
Expand Down Expand Up @@ -322,8 +331,8 @@ public function restoreConfirmAction(\EWW\Dpf\Domain\Model\Document $document)
public function restoreAction(\EWW\Dpf\Domain\Model\Document $document)
{

$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

if ($documentTransferManager->delete($document, "inactivate")) {
Expand Down Expand Up @@ -359,8 +368,8 @@ public function deleteConfirmAction(\EWW\Dpf\Domain\Model\Document $document)
public function deleteAction(\EWW\Dpf\Domain\Model\Document $document)
{

$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

if ($documentTransferManager->delete($document, "")) {
Expand Down Expand Up @@ -396,8 +405,8 @@ public function activateConfirmAction(\EWW\Dpf\Domain\Model\Document $document)
public function activateAction(\EWW\Dpf\Domain\Model\Document $document)
{

$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

if ($documentTransferManager->delete($document, "revert")) {
Expand Down Expand Up @@ -433,8 +442,8 @@ public function inactivateConfirmAction(\EWW\Dpf\Domain\Model\Document $document
public function inactivateAction(\EWW\Dpf\Domain\Model\Document $document)
{

$documentTransferManager = $this->objectManager->get('\EWW\Dpf\Services\Transfer\DocumentTransferManager');
$remoteRepository = $this->objectManager->get('\EWW\Dpf\Services\Transfer\FedoraRepository');
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class);
$remoteRepository = $this->objectManager->get(FedoraRepository::class);
$documentTransferManager->setRemoteRepository($remoteRepository);

if ($documentTransferManager->delete($document, "inactivate")) {
Expand Down
Loading

0 comments on commit e1e23bc

Please sign in to comment.