@@ -61,6 +61,11 @@ class Renderer implements RendererInterface
6161 */
6262 protected $ curatorenClientTest ;
6363
64+ /**
65+ * @var bool
66+ */
67+ protected $ useClientIds ;
68+
6469 /**
6570 * @var array
6671 */
@@ -82,7 +87,7 @@ class Renderer implements RendererInterface
8287 * @param $googleTagManagerId
8388 * @param ProjectServiceInterface $projectService
8489 */
85- public function __construct (WidgetPluginManager $ widgetPluginManager , $ googleTagManagerId , EntityRepository $ projectRepository , SearchClientInterface $ searchClient , SearchClientInterface $ searchClientTest , CuratorenClient $ curatorenClient , CuratorenClient $ curatorenClientTest )
90+ public function __construct (WidgetPluginManager $ widgetPluginManager , $ googleTagManagerId , EntityRepository $ projectRepository , SearchClientInterface $ searchClient , SearchClientInterface $ searchClientTest , CuratorenClient $ curatorenClient , CuratorenClient $ curatorenClientTest, bool $ useClientIds )
8691 {
8792 $ this ->widgetPluginManager = $ widgetPluginManager ;
8893 $ this ->googleTagManagerId = $ googleTagManagerId ;
@@ -91,6 +96,7 @@ public function __construct(WidgetPluginManager $widgetPluginManager, $googleTag
9196 $ this ->searchClientTest = $ searchClientTest ;
9297 $ this ->curatorenClient = $ curatorenClient ;
9398 $ this ->curatorenClientTest = $ curatorenClientTest ;
99+ $ this ->useClientIds = $ useClientIds ;
94100 }
95101
96102 public function addSettings (array $ settings )
@@ -105,16 +111,22 @@ public function setProject(ProjectInterface $project)
105111 // If a project is not live yet. We should use the test api + test key.
106112 if ($ project ->getStatus () !== ProjectInterface::PROJECT_STATUS_ACTIVE ) {
107113 $ apiKey = $ project ->getTestApiKeySapi3 ();
114+ $ clientId = $ project ->getTestClientId ();
108115 $ config = $ this ->searchClientTest ->getClient ()->getConfig ();
109116 $ curatorenConfig = $ this ->curatorenClientTest ->getClient ()->getConfig ();
110117 } else {
111118 $ config = $ this ->searchClient ->getClient ()->getConfig ();
112119 $ apiKey = $ project ->getLiveApiKeySapi3 ();
120+ $ clientId = $ project ->getLiveClientId ();
113121 $ curatorenConfig = $ this ->curatorenClient ->getClient ()->getConfig ();
114122 }
115123
116124 $ headers = $ config ['headers ' ] ?? [];
117- $ headers ['X-Api-Key ' ] = $ apiKey ;
125+ if ($ this ->useClientIds ) {
126+ $ headers ['X-Client-Id ' ] = $ clientId ;
127+ } else {
128+ $ headers ['X-Api-Key ' ] = $ apiKey ;
129+ }
118130 $ config ['headers ' ] = $ headers ;
119131
120132 $ this ->searchClient ->setClient (new \GuzzleHttp \Client ($ config ));
0 commit comments