TYPO3 CMS  TYPO3_7-6
Typo3DependencyViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
24 
31 {
38  public function render(Extension $extension)
39  {
40  return static::renderStatic(
41  [
42  'extension' => $extension,
43  ],
45  $this->renderingContext
46  );
47  }
48 
57  {
58  $extension = $arguments['extension'];
60  foreach ($extension->getDependencies() as $dependency) {
61  if ($dependency->getIdentifier() === 'typo3') {
62  $lowestVersion = $dependency->getLowestVersion();
63  $highestVersion = $dependency->getHighestVersion();
64  $cssClass = self::isVersionSuitable($lowestVersion, $highestVersion) ? 'success' : 'default';
65  return
66  '<span class="label label-' . $cssClass . '">'
67  . htmlspecialchars($lowestVersion) . ' - ' . htmlspecialchars($highestVersion)
68  . '</span>';
69  }
70  }
71  return '';
72  }
73 
81  protected static function isVersionSuitable($lowestVersion, $highestVersion)
82  {
84  $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($lowestVersion);
85  $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($highestVersion);
86  return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion);
87  }
88 }
static isIntegerInRange($value, $minimum, $maximum)
static renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)