Project

General

Profile

Bug #94714 » SomeFormWizard.php

Bare update wizard for testing - Pierrick Caillon, 2021-08-04 17:37

 
<?php
declare(strict_types=1);

namespace Vendor\Extension\Updates;

use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

/**
* SomeFormWizard
*/
class SomeFormWizard implements UpgradeWizardInterface, RepeatableInterface
{

/**
* @inheritDoc
*/
public function getIdentifier(): string
{
return 'extension_someform';
}

/**
* @inheritDoc
*/
public function getTitle(): string
{
return 'Upgrade forms';
}

/**
* @inheritDoc
*/
public function getDescription(): string
{
return 'Do something on forms.';
}

/**
* @inheritDoc
*/
public function executeUpdate(): bool
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$persistenceManager = $objectManager->get(FormPersistenceManager::class);
foreach ($persistenceManager->listForms() as $form) {
// Do something
}
return true;
}

/**
* @inheritDoc
*/
public function updateNecessary(): bool
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$persistenceManager = $objectManager->get(FormPersistenceManager::class);
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
foreach ($persistenceManager->listForms() as $form) {
// Do some test to return true
return true;
}
return false;
}

/**
* @inheritDoc
*/
public function getPrerequisites(): array
{
return [];
}
}
(3-3/3)