Runs a kernel target

@param KernelHandleWebInterface $target
511841
public function handle(KernelHandleInterface $target, Request $request) {
		$event = new KernelHandleEvent($target);

		$this->dispatcher->dispatch(KernelHandleEvent::PRE_RUN, $event);
		$response = $target->run($request);
		$this->dispatcher->dispatch(KernelHandleEvent::POST_RUN, $event);

		return $response;
	}
1161159
public function setRenderer(int $target, RendererInterface $renderer): Dumper
    {
        if (!isset($this->targets[$target])) {
            throw new DumperException(sprintf("Undefined dump target %d", $target));
        }

        $this->targets[$target] = $renderer;

        return $this;
    }
302530
public function getTargetClass($target): int
    {
        if (!in_array($target, $this->classes, true)) {
            throw new InvalidArgumentException(
                sprintf('Target with value "%s" is not part of the accepted classes', $target)
            );
        }

        return array_search($target, $this->classes, true);
    }
377657
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setOutput($output);

        $this->resetCodeBuffer();

        $this->setAutoExit(false);
        $this->setCatchExceptions(false);

        $this->readline->readHistory();

        $this->output->writeln($this->getHeader());
        $this->writeVersionInfo();
        $this->writeStartupMessage();

        try {
            $this->beforeRun();
            $this->loop->run($this);
            $this->afterRun();
        } catch (ThrowUpException $e) {
            throw $e->getPrevious();
        } catch (BreakException $e) {
            // The ProcessForker throws a BreakException to finish the main thread.
            return;
        }
    }
1345451
public function setUp(KernelInterface $kernel)
    {
        $this->application = new Application($kernel);
        $this->application->setAutoExit(false);

        $this
            ->executeCommand('doctrine:database:drop', [
                '--force' => true,
            ])
            ->executeCommand('doctrine:database:create')
            ->executeCommand('doctrine:schema:create');
    }
1046547
protected static function makeWriter($target): WriterInterface
    {
        if (is_array($target) || $target instanceof \ArrayAccess) {
            return new ArrayWriter();
        }

        if (is_object($target)) {
            return new ObjectWriter();
        }

        throw new InvalidTargetException(
            sprintf('Cannot find suitable writer for target type "%s"', gettype($target))
        );
    }
1244545
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->registerCommands();

        if ($this->registrationErrors) {
            $this->renderRegistrationErrors($input, $output);
        }

        $this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));

        return parent::doRun($input, $output);
    }
680426
public function setTarget($target)
    {
        //Add to route group if any
        if (!$target instanceof \Closure) {
            $groupNamespace = implode('\\', Router::$groupsProps['namespace']);
            $target = $groupNamespace ? "$groupNamespace\\$target" : $target;
        }

        if (!$target instanceof Closure &&
                !preg_match(Router::TARGET_REGEX, $target)) {
            throw new Exception("Invalid target string $target");
        }
        $this->target = $target;

        return $this;
    }
172935
public function addTarget(Target $target, string $name = null)
    {
        if ($name === null) {
            $this->_targets[] = $target;
        } else {
            $this->_targets[$name] = $target;
        }
    }
628773
public function update(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $initial,
			\Composer\Package\PackageInterface $target) {
				
		$this->moveBackResources($initial);
		
		parent::update($repo, $initial, $target);
		
		$this->removeResources($target);
		$this->installResources($target);
	}
675724
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $container = $this->getContainer();

        $kernel = $container->get('kernel');

        /** @var array $bundles */
        $bundles = $container->getParameter('kernel.bundles');

        $domains = ['messages'];

        foreach ($bundles as $key => $class) {
            $application = new Application($kernel);

            $application->setAutoExit(false);

            /* @noinspection NotOptimalRegularExpressionsInspection */
            if (preg_match('/Compo.*/', $key) && 0 === preg_match('/^CompoSonata.*/', $key)) {
                $resources = $kernel->locateResource('@' . $key . '/Resources');

                $bundle_dir = \dirname($kernel->locateResource('@' . $key . '/Resources')) . '/';

                $output_dir = $resources . '/translations';

                if (!file_exists($output_dir) && !mkdir($output_dir) && !is_dir($output_dir)) {
                    throw new \RuntimeException(sprintf('Directory "%s" was not created', $output_dir));
                }

                $arguments = [
                    'command' => 'translation:extract',
                    'locales' => ['ru'],
                    '--enable-extractor' => ['compo_admin'],
                    '--config' => 'app',
                    '--bundle' => $key,
                    '--output-dir' => $output_dir,
                    '--output-format' => 'yml',
                    '--default-output-format' => 'yml',
                    '--dir' => [$bundle_dir],

                    '--keep',
                    '--domain' => [$key],
                    '--ignore-domain' => $domains,
                ];

                $domains[] = $key;

                $greetInput = new ArrayInput($arguments);

                $greetInput->setInteractive(false);

                $application->run($greetInput, $output);
            }
        }

        return 0;
    }
685777
private function symlink($source, $target)
	{
		if (file_exists($target))
		{
			if (is_dir($target))
			{
				$this->_deleteDir($target);
			}
			else
			{
				unlink($target);
			}
		}

		try
		{
			$this->taskFileSystemStack()
				->symlink($source, $target)
				->run();
		}
		catch (Exception $e)
		{
			$this->say('Error symlinking: ' . $e->message());
		}
	}
842104
public function setTarget($target)
    {
        if (Format::isIdentifier($target)) {
            $this->target = $target;
        } else {
            $msg = "'${target}' is not a valid QTI identifier.";
            throw new InvalidArgumentException($msg);
        }
    }
678146
private static function enforceValidTarget($target)
    {
        if (!is_string($target)) {
            throw new \InvalidArgumentException('Parameter $type must be a string.');
        }
        if (!isset(self::$map[ $target ])) {
            throw new \InvalidArgumentException("Type {$target} is invalid.");
        }
    }
1287827
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $force = false;
        if ($input->getOption('force')) {
            $force = true;
        }

        if ($force) {
            $output->writeln('Run in <comment>force</comment> mode');
        } else {
            $output->writeln('Run in <comment>dry run</comment> mode');
        }

        $targetArg = rtrim($input->getArgument('target'), '/\\');

        if (!is_dir($targetArg)) {
            throw new \InvalidArgumentException(
                sprintf('The target directory "%s" does not exist.', $input->getArgument('target'))
            );
        }

        if (!function_exists('symlink') && $input->getOption('symlink')) {
            throw new \InvalidArgumentException(
                'The symlink() function is not available on your system.' .
                'You need to install the assets without the --symlink option.'
            );
        }

        $kernel = $this->getContainer()->get('kernel');
        $kernelRootDir = $kernel->getRootDir();
        $rootDir = $this->getContainer()->getParameter('joomla.root_dir');

        // install normal roots
        $this->filesystem = $this->getContainer()->get('filesystem');
        $this->input = $input;
        $this->output = $output;

        $process = new Process('git --version');
        $process->run();
        if ($process->getExitCode() !== 0) {
            $output->writeln('<error>Failed to execute git --version</error>');

            return;
        } else {
            $output->writeln(sprintf('Found <comment>%s</comment>', trim($process->getOutput())));
        }

        if (!$this->filesystem->exists($rootDir . DIRECTORY_SEPARATOR . '.git')) {
            $output->writeln('<error>' . $rootDir . DIRECTORY_SEPARATOR . '.git' . '. Could only work with git vendors</error>');

            return;
        }

        $process = new Process('git status -z', $rootDir);
        $process->run();

        if ($process->getExitCode() !== 0) {
            $output->writeln('<error>Failed to execute git status -z</error>');

            return;
        }

        $unknownFiles = array_keys($this->parseStatusOutput($process->getOutput()));

        $knownFiles = [];

        foreach ($this->getContainer()->getParameter('joomla.installations') as $resources) {
            foreach ($resources as $resource) {
                $knownFiles[] = $resource['target'];
            }
        }

        foreach ($unknownFiles as $k => $unknownFile) {
            foreach (['tmp'] as $ignore) {
                if (preg_match('#^' . preg_quote($ignore . DIRECTORY_SEPARATOR, '#') . '#', $unknownFile)) {
                    $this->output->writeln(sprintf('Ignore <comment>%s</comment>', $unknownFile));
                    continue 2;
                }
            }
            foreach ($knownFiles as $knownFile) {
                $part = substr($unknownFile, 0, strlen($knownFile));
                if ($knownFile === $part) {
                    $this->output->writeln(
                        sprintf('<fg=green>Asset <comment>%s</comment> already known</fg=green>', $unknownFile)
                    );
                    unset($unknownFiles[$k]);
                }
            }
        }

        $config = [];

        foreach ($unknownFiles as $unknownFile) {
            $resourcePath = 'Resources' . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . $unknownFile;
            $targetDir = $kernelRootDir . DIRECTORY_SEPARATOR . $resourcePath;

            $originDir = $targetArg . DIRECTORY_SEPARATOR . $unknownFile;

            $this->output->writeln(
                sprintf('Installing files for <comment>%s</comment> into <comment>%s</comment>', $originDir, $targetDir)
            );
            if ($force) {
                if (is_dir($originDir)) {
                    $this->filesystem->mkdir($targetDir, 0777);
                    $this->filesystem->mirror(
                        $originDir,
                        $targetDir,
                        Finder::create()->ignoreDotFiles(false)->in($originDir)
                    );
                } else {
                    $this->filesystem->mkdir(dirname($targetDir), 0777);
                    $this->filesystem->copy($originDir, $targetDir);
                }
            }

            $config[] = [
                'resource' => $resourcePath,
                'target'   => $unknownFile
            ];
        }

        if (empty($config)) {
            $this->output->writeln("<fg=green>Everything fine!</fg=green>");

            return;
        }

        $config = Yaml::dump(
            [
                'xtain_joomla' => [
                    'install' => [
                        'app' => $config
                    ]
                ]
            ],
            4
        );

        $this->output->writeln("Add this to config.yml:\n\n" . $config);
    }
464239
protected function createLink($source, $target)
    {
        $success = $this->filesystem->relativeSymlink($source, $target);
        if (!$success) {
            throw new RuntimeException("Could not create symlink at $target");
        }
    }
306864
private function checkTextTarget($source, $target): void
    {
        $text_array = $this->text_array;
        if (!(\array_key_exists($source, $text_array))) {
            throw new TencentAIException(90701);
        }
        if (!(\in_array($target, $text_array[$source], true))) {
            throw new TencentAIException(90702);
        }
    }