mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-12-23 06:46:08 +01:00
[BUGFIX] Initialize API manually
This commit is contained in:
parent
9eb9d3c7ec
commit
49b452590a
2 changed files with 13 additions and 5 deletions
|
@ -17,19 +17,23 @@ declare(strict_types=1);
|
|||
|
||||
namespace SkillDisplay\SkilldisplayContent\FormDataProvider;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use SkillDisplay\PHPToolKit\Api\SkillSet;
|
||||
use SkillDisplay\SkilldisplayContent\SettingsFactory;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Inject available skill sets a valuepicker form
|
||||
*/
|
||||
class ValuePickerItemDataProvider implements FormDataProviderInterface
|
||||
{
|
||||
private SkillSet $skillSetApi;
|
||||
protected SiteFinder $siteFinder;
|
||||
|
||||
public function __construct(SkillSet $skillSetApi)
|
||||
public function __construct(SiteFinder $siteFinder = null)
|
||||
{
|
||||
$this->skillSetApi = $skillSetApi;
|
||||
$this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +45,11 @@ class ValuePickerItemDataProvider implements FormDataProviderInterface
|
|||
public function addData(array $result): array
|
||||
{
|
||||
if ($result['tableName'] === 'tt_content' && isset($result['processedTca']['columns']['skilldisplay_skillset'])) {
|
||||
$skillSets = $this->skillSetApi->getAll();
|
||||
$api = new SkillSet(
|
||||
(new SettingsFactory($this->siteFinder))->createFromPageUid($result['parentPageRow']['uid']),
|
||||
GeneralUtility::makeInstance(Client::class)
|
||||
);
|
||||
$skillSets = $api->getAll();
|
||||
foreach ($skillSets as $skillSet) {
|
||||
$result['processedTca']['columns']['skilldisplay_skillset']['config']['valuePicker']['items'][] =
|
||||
[
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.1 || ^8.2",
|
||||
"skilldisplay/phptoolkit": "^2.1",
|
||||
"skilldisplay/phptoolkit": "^2.1.1",
|
||||
"typo3/cms-backend": "^11.5 || ^12.4",
|
||||
"typo3/cms-frontend": "^11.5 || ^12.4"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue