1<?php namespace ILIAS\GlobalScreen\Identification;
2
3use ILIAS\GlobalScreen\Identification\Map\IdentificationMap;
4use ILIAS\GlobalScreen\Identification\Serializer\SerializerInterface;
5use ILIAS\GlobalScreen\Provider\Provider;
6
7/**
8 * Class PluginIdentificationProvider
9 *
10 * @see    IdentificationProviderInterface
11 * @author Fabian Schmid <fs@studer-raimann.ch>
12 */
13class PluginIdentificationProvider extends AbstractIdentificationProvider implements IdentificationProviderInterface
14{
15
16    /**
17     * @var string
18     */
19    protected $plugin_id = "";
20
21
22    /**
23     * PluginIdentificationProvider constructor.
24     *
25     * @param Provider            $provider
26     * @param string              $plugin_id
27     * @param SerializerInterface $serializer
28     * @param IdentificationMap   $map
29     */
30    public function __construct(Provider $provider, string $plugin_id, SerializerInterface $serializer, IdentificationMap $map)
31    {
32        parent::__construct($provider, $serializer, $map);
33        $this->plugin_id = $plugin_id;
34    }
35
36
37    /**
38     * @inheritdoc
39     */
40    public function identifier(string $identifier_string) : IdentificationInterface
41    {
42        if (isset(self::$instances[$identifier_string])) {
43            return self::$instances[$identifier_string];
44        }
45
46        $identification = new PluginIdentification($this->plugin_id, $identifier_string, $this->class_name, $this->serializer, $this->provider->getProviderNameForPresentation());
47        $this->map->addToMap($identification);
48
49        return self::$instances[$identifier_string] = $identification;
50    }
51}
52