aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/libraries/classes/Di
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-09 10:55:03 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-09 13:09:38 +0100
commit04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa (patch)
tree5c691241355c943a3c68ddb06b8cf8c60aa11319 /srcs/phpmyadmin/libraries/classes/Di
parent7e0d85db834d6351ed85d01e5126ac31dc510b86 (diff)
downloadft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.gz
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.bz2
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.zip
phpmyadmin working
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Di')
-rw-r--r--srcs/phpmyadmin/libraries/classes/Di/Migration.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Di/Migration.php b/srcs/phpmyadmin/libraries/classes/Di/Migration.php
new file mode 100644
index 0000000..2990610
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Di/Migration.php
@@ -0,0 +1,71 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Migration from home-made DI to Symfony DI
+ *
+ * @package PhpMyAdmin\Di
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Di;
+
+use InvalidArgumentException;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+ * Migration from home-made DI to Symfony DI
+ *
+ * @package PhpMyAdmin\Di
+ */
+class Migration
+{
+ /** @var self */
+ protected static $instance;
+
+ /** @var ContainerBuilder */
+ protected $containerBuilder;
+
+ /**
+ * Get instance of this class
+ *
+ * @param ContainerBuilder|null $containerBuilder ContainerBuilder object that should be used to store the data
+ *
+ * @return Migration
+ */
+ public static function getInstance(?ContainerBuilder $containerBuilder = null): self
+ {
+ if (null !== self::$instance) {
+ return self::$instance;
+ }
+
+ if (null === $containerBuilder) {
+ throw new InvalidArgumentException('Container builder should be sent for ' . self::class . ' creation');
+ }
+
+ return self::$instance = new self($containerBuilder);
+ }
+
+ /**
+ * Migration constructor.
+ *
+ * @param ContainerBuilder $containerBuilder ContainerBuilder object that should be used to store the data
+ */
+ protected function __construct(ContainerBuilder $containerBuilder)
+ {
+ $this->containerBuilder = $containerBuilder;
+ }
+
+ /**
+ * Get the instance of the service
+ *
+ * @param string $key Key of data to store
+ * @param mixed $value Data to store
+ *
+ * @return void
+ */
+ public function setGlobal(string $key, $value)
+ {
+ $GLOBALS[$key] = $value;
+ $this->containerBuilder->setParameter($key, $value);
+ }
+}