Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

validate.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.83 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\install\console\command\update\config;
015   
016  use phpbb\install\helper\iohandler\factory;
017  use phpbb\install\updater_configuration;
018  use phpbb\language\language;
019  use Symfony\Component\Config\Definition\Exception\Exception;
020  use Symfony\Component\Config\Definition\Processor;
021  use Symfony\Component\Console\Input\InputArgument;
022  use Symfony\Component\Console\Input\InputInterface;
023  use Symfony\Component\Console\Output\OutputInterface;
024  use Symfony\Component\Console\Style\SymfonyStyle;
025  use Symfony\Component\Yaml\Exception\ParseException;
026  use Symfony\Component\Yaml\Yaml;
027   
028  class validate extends \phpbb\console\command\command
029  {
030      /**
031       * @var factory
032       */
033      protected $iohandler_factory;
034   
035      /**
036       * @var language
037       */
038      protected $language;
039   
040      /**
041       * Constructor
042       *
043       * @param language $language
044       * @param factory $factory
045       */
046      public function __construct(language $language, factory $factory)
047      {
048          $this->iohandler_factory = $factory;
049          $this->language = $language;
050   
051          parent::__construct(new \phpbb\user($language, 'datetime'));
052      }
053   
054      /**
055       *
056       * {@inheritdoc}
057       */
058      protected function configure()
059      {
060          $this
061              ->setName('update:config:validate')
062              ->addArgument(
063                  'config-file',
064                  InputArgument::REQUIRED,
065                  $this->language->lang('CLI_CONFIG_FILE'))
066              ->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG'))
067          ;
068      }
069   
070      /**
071       * Validate the configuration file
072       *
073       * @param InputInterface  $input  An InputInterface instance
074       * @param OutputInterface $output An OutputInterface instance
075       *
076       * @return null
077       */
078      protected function execute(InputInterface $input, OutputInterface $output)
079      {
080          $this->iohandler_factory->set_environment('cli');
081   
082          /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
083          $iohandler = $this->iohandler_factory->get();
084          $style = new SymfonyStyle($input, $output);
085          $iohandler->set_style($style, $output);
086   
087          $config_file = $input->getArgument('config-file');
088   
089          if (!is_file($config_file))
090          {
091              $iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
092   
093              return 1;
094          }
095   
096          try
097          {
098              $config = Yaml::parse(file_get_contents($config_file), true, false);
099          }
100          catch (ParseException $e)
101          {
102              $iohandler->add_error_message('INVALID_YAML_FILE');
103   
104              return 1;
105          }
106   
107          $processor = new Processor();
108          $configuration = new updater_configuration();
109   
110          try
111          {
112              $processor->processConfiguration($configuration, $config);
113          }
114          catch (Exception $e)
115          {
116              $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
117   
118              return 1;
119          }
120   
121          $iohandler->add_success_message('CONFIGURATION_VALID');
122          return 0;
123      }
124  }
125