Issues (3936)

Classes/Tasks/EmbargoTask.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace EWW\Dpf\Tasks;
4
5
use EWW\Dpf\Domain\Workflow\DocumentWorkflow;
6
use EWW\Dpf\Services\Email\Notifier;
7
use TYPO3\CMS\Core\Utility\GeneralUtility;
8
use TYPO3\CMS\Extbase\Object\ObjectManager;
9
use EWW\Dpf\Domain\Repository\DocumentRepository;
10
11
12
class EmbargoTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
0 ignored issues
show
The type TYPO3\CMS\Scheduler\Task\AbstractTask was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
15
    public function execute() {
16
17
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
18
        $documentRepository = $objectManager->get(DocumentRepository::class);
19
        $embargoDocuments = $documentRepository->crossClientEmbargoFindAll();
20
21
        $currentDate = new \DateTime('now');
22
23
        foreach ($embargoDocuments as $document) {
24
            if ($currentDate > $document->getEmbargoDate()) {
25
26
                if ($document->getRemoteState() == DocumentWorkflow::REMOTE_STATE_ACTIVE OR
27
                    $document->getRemoteState() == DocumentWorkflow::REMOTE_STATE_DELETED OR
28
                    $document->getRemoteState() == DocumentWorkflow::REMOTE_STATE_INACTIVE OR
29
                    $document->getLocalState() == DocumentWorkflow::LOCAL_STATE_IN_PROGRESS OR
30
                    $document->getLocalState() == DocumentWorkflow::LOCAL_STATE_POSTPONED OR
31
                    $document->getLocalState() == DocumentWorkflow::LOCAL_STATE_DISCARDED) {
32
                    // send message
33
                    $notifier = $objectManager->get(Notifier::class);
34
                    $notifier->sendEmbargoNotification($document);
35
                }
36
            }
37
        }
38
39
        return TRUE;
40
    }
41
42
}