‪TYPO3CMS  10.4
ExtensionComposerStatusController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
32 
39 {
44 
49 
53  protected ‪$nodeFactory;
54 
58  protected ‪$listUtility;
59 
63  protected ‪$returnUrl = '';
64 
65  public function ‪__construct(
70  ) {
71  $this->composerDeficitDetector = ‪$composerDeficitDetector;
72  $this->composerManifestProposalGenerator = ‪$composerManifestProposalGenerator;
73  $this->nodeFactory = ‪$nodeFactory;
74  $this->listUtility = ‪$listUtility;
75  }
76 
77  protected function ‪initializeAction(): void
78  {
79  parent::initializeAction();
80  if ($this->request->hasArgument('returnUrl')) {
81  $this->returnUrl = GeneralUtility::sanitizeLocalUrl(
82  (string)$this->request->getArgument('returnUrl')
83  );
84  }
85  }
86 
87  protected function ‪initializeView(ViewInterface ‪$view): void
88  {
89  parent::initializeView(‪$view);
91  }
92 
93  public function ‪listAction(): void
94  {
95  $extensions = [];
96  $basePackagePath = ‪Environment::getExtensionsPath() . '/';
97  $detailLinkReturnUrl = $this->uriBuilder->reset()->uriFor('list', array_filter(['returnUrl' => $this->returnUrl]));
98  foreach ($this->composerDeficitDetector->getExtensionsWithComposerDeficit() as $extensionKey => $deficit) {
99  $extensions[$extensionKey] = [
100  'deficit' => $deficit,
101  'packagePath' => $basePackagePath . $extensionKey . '/',
102  'icon' => $this->‪getExtensionIcon($basePackagePath . $extensionKey . '/'),
103  'detailLink' => $this->uriBuilder->reset()->uriFor('detail', [
104  'extensionKey' => $extensionKey,
105  'returnUrl' => $detailLinkReturnUrl
106  ])
107  ];
108  }
109  ksort($extensions);
110  $this->view->assign('extensions', $this->listUtility->enrichExtensionsWithEmConfInformation($extensions));
111  $this->‪generateMenu();
112  }
113 
114  public function ‪detailAction(string $extensionKey): void
115  {
116  if ($extensionKey === '') {
117  $this->‪redirect('list');
118  }
119 
120  $deficit = $this->composerDeficitDetector->checkExtensionComposerDeficit($extensionKey);
121  $this->view->assignMultiple([
122  'extensionKey' => $extensionKey,
123  'deficit' => $deficit
124  ]);
125 
127  $this->view->assign('composerManifestMarkup', $this->‪getComposerManifestMarkup($extensionKey));
128  }
129  }
130 
131  protected function ‪getComposerManifestMarkup(string $extensionKey): string
132  {
133  $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
134  $composerManifest = $this->composerManifestProposalGenerator->getComposerManifestProposal($extensionKey);
135  if ($composerManifest === '') {
136  return '';
137  }
138  $rows = ‪MathUtility::forceIntegerInRange(count(explode(LF, $composerManifest)), 1, PHP_INT_MAX);
139  $fakeFieldTca = [
140  'renderType' => 't3editor',
141  'tableName' => $extensionKey,
142  'fieldName' => 'composer.json',
143  'effectivePid' => 0,
144  'parameterArray' => [
145  'itemFormElName' => 'composerManifest-' . $extensionKey,
146  'itemFormElValue' => $composerManifest,
147  'fieldChangeFunc' => [],
148  'fieldConf' => [
149  'config' => [
150  'rows' => ++$rows,
151  'codeMirrorFirstLineNumber' => 1,
152  ]
153  ]
154  ]
155  ];
156  $resultArray = $this->nodeFactory->create($fakeFieldTca)->render();
157  $formResultCompiler->mergeResult($resultArray);
158  $formResultCompiler->addCssFiles();
159  $formResultCompiler->printNeededJSFunctions();
160  return $resultArray['html'];
161  }
162 
163  protected function ‪registerDocHeaderButtons(): void
164  {
165  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
166  if ($this->returnUrl !== '') {
167  $buttonBar->addButton(
168  $buttonBar
169  ->makeLinkButton()
170  ->setHref($this->returnUrl)
171  ->setClasses('typo3-goBack')
172  ->setTitle($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
173  ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', ‪Icon::SIZE_SMALL))
174  );
175  }
176  }
177 
178  protected function ‪getExtensionIcon(string $extensionPath): string
179  {
180  $icon = ‪ExtensionManagementUtility::getExtensionIcon($extensionPath);
181  return $icon ? ‪PathUtility::getAbsoluteWebPath($extensionPath . $icon) : '';
182  }
183 
184  protected function ‪getLanguageService()
185  {
186  return ‪$GLOBALS['LANG'];
187  }
188 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\initializeAction
‪initializeAction()
Definition: ExtensionComposerStatusController.php:72
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\initializeView
‪initializeView(ViewInterface $view)
Definition: ExtensionComposerStatusController.php:82
‪TYPO3\CMS\Extensionmanager\Service\ComposerManifestProposalGenerator
Definition: ComposerManifestProposalGenerator.php:30
‪TYPO3\CMS\Core\Package\ComposerDeficitDetector\EXTENSION_COMPOSER_MANIFEST_VALID
‪const EXTENSION_COMPOSER_MANIFEST_VALID
Definition: ComposerDeficitDetector.php:30
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\getExtensionIcon
‪getExtensionIcon(string $extensionPath)
Definition: ExtensionComposerStatusController.php:173
‪TYPO3\CMS\Backend\Form\FormResultCompiler
Definition: FormResultCompiler.php:30
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController
Definition: AbstractModuleController.php:27
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Package\ComposerDeficitDetector
Definition: ComposerDeficitDetector.php:29
‪TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange
‪static int forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\getLanguageService
‪getLanguageService()
Definition: ExtensionComposerStatusController.php:179
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\generateMenu
‪generateMenu()
Definition: AbstractModuleController.php:60
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\$listUtility
‪ListUtility $listUtility
Definition: ExtensionComposerStatusController.php:54
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\$returnUrl
‪string $returnUrl
Definition: ExtensionComposerStatusController.php:58
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\$composerManifestProposalGenerator
‪ComposerDeficitDetector $composerManifestProposalGenerator
Definition: ExtensionComposerStatusController.php:46
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\__construct
‪__construct(ComposerDeficitDetector $composerDeficitDetector, ComposerManifestProposalGenerator $composerManifestProposalGenerator, NodeFactory $nodeFactory, ListUtility $listUtility)
Definition: ExtensionComposerStatusController.php:60
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:16
‪TYPO3\CMS\Extensionmanager\Utility\ListUtility
Definition: ListUtility.php:41
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController
Definition: ExtensionComposerStatusController.php:39
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\redirect
‪redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
Definition: ActionController.php:852
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\listAction
‪listAction()
Definition: ExtensionComposerStatusController.php:88
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\getComposerManifestMarkup
‪getComposerManifestMarkup(string $extensionKey)
Definition: ExtensionComposerStatusController.php:126
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\$nodeFactory
‪NodeFactory $nodeFactory
Definition: ExtensionComposerStatusController.php:50
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\detailAction
‪detailAction(string $extensionKey)
Definition: ExtensionComposerStatusController.php:109
‪TYPO3\CMS\Extbase\Mvc\View\ViewInterface
Definition: ViewInterface.php:24
‪TYPO3\CMS\Backend\Form\NodeFactory
Definition: NodeFactory.php:37
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\getExtensionIcon
‪static string getExtensionIcon($extensionPath, $returnFullPath=false)
Definition: ExtensionManagementUtility.php:1518
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:43
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$view
‪BackendTemplateView $view
Definition: AbstractModuleController.php:32
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\registerDocHeaderButtons
‪registerDocHeaderButtons()
Definition: ExtensionComposerStatusController.php:158
‪TYPO3\CMS\Extensionmanager\Controller\ExtensionComposerStatusController\$composerDeficitDetector
‪ComposerDeficitDetector $composerDeficitDetector
Definition: ExtensionComposerStatusController.php:42
‪TYPO3\CMS\Core\Core\Environment\getExtensionsPath
‪static string getExtensionsPath()
Definition: Environment.php:271