‪TYPO3CMS  ‪main
AbstractPlatform.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 
24 
29 {
33  protected ‪$messageQueue;
34 
38  protected const ‪SCHEMA_NAME_MAX_LENGTH = 64;
39 
40  public function ‪__construct()
41  {
42  $this->messageQueue = new ‪FlashMessageQueue('install-database-check-platform');
43  }
44 
45  public function ‪getMessageQueue(): ‪FlashMessageQueue
46  {
48  }
49 
53  public function ‪getStatus(): ‪FlashMessageQueue
54  {
56  }
57 
61  public static function ‪isValidDatabaseName(string $databaseName): bool
62  {
63  return strlen($databaseName) <= static::SCHEMA_NAME_MAX_LENGTH && preg_match('/^[a-zA-Z0-9\$_]*$/', $databaseName);
64  }
65 
66  protected function ‪checkDatabaseName(‪Connection $connection): void
67  {
68  if (static::isValidDatabaseName((string)$connection->getDatabase())) {
69  return;
70  }
71 
72  $this->messageQueue->enqueue(
73  new ‪FlashMessage(
74  'The given database name must not be longer than ' . static::SCHEMA_NAME_MAX_LENGTH . ' characters'
75  . ' and consist solely of basic latin letters (a-z), digits (0-9), dollar signs ($)'
76  . ' and underscores (_).',
77  'Database name not valid',
78  ContextualFeedbackSeverity::ERROR
79  )
80  );
81  }
82 }
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\SCHEMA_NAME_MAX_LENGTH
‪const SCHEMA_NAME_MAX_LENGTH
Definition: AbstractPlatform.php:37
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\checkDatabaseName
‪checkDatabaseName(Connection $connection)
Definition: AbstractPlatform.php:65
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform
Definition: AbstractPlatform.php:29
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\getStatus
‪getStatus()
Definition: AbstractPlatform.php:52
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform
Definition: AbstractPlatform.php:18
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\isValidDatabaseName
‪static isValidDatabaseName(string $databaseName)
Definition: AbstractPlatform.php:60
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\getMessageQueue
‪getMessageQueue()
Definition: AbstractPlatform.php:44
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\PlatformCheckInterface
Definition: PlatformCheckInterface.php:27
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\$messageQueue
‪FlashMessageQueue $messageQueue
Definition: AbstractPlatform.php:32
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\__construct
‪__construct()
Definition: AbstractPlatform.php:39
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:29