From 2b15e4306d2bc2c92ff972f7f87ce7fbbe760698 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 4 Oct 2024 17:23:45 +0100 Subject: [PATCH] remove supplement_data --- src/Tags/Dictionary/Dictionary.php | 3 +-- tests/Tags/DictionaryTagTest.php | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Tags/Dictionary/Dictionary.php b/src/Tags/Dictionary/Dictionary.php index 887805871d..b91e594b7b 100644 --- a/src/Tags/Dictionary/Dictionary.php +++ b/src/Tags/Dictionary/Dictionary.php @@ -39,14 +39,13 @@ public function index() } $search = $this->params->pull('search'); - $supplement = $this->params->pull('supplement_data'); if (! $dictionary = Dictionaries::find($handle, $this->params->all())) { throw new DictionaryNotFoundException($handle); } $options = collect($dictionary->options($search)) - ->map(fn ($label, $value) => new DictionaryItem($supplement ? $dictionary->get($value)->extra() : ['label' => $label, 'value' => $value])) + ->map(fn ($label, $value) => new DictionaryItem(array_merge(['label' => $label, 'value' => $value], $dictionary->get($value)->extra()))) ->values(); $query = (new ItemQueryBuilder)->withItems(new DataCollection($options)); diff --git a/tests/Tags/DictionaryTagTest.php b/tests/Tags/DictionaryTagTest.php index aa2898c098..f717da2792 100644 --- a/tests/Tags/DictionaryTagTest.php +++ b/tests/Tags/DictionaryTagTest.php @@ -45,15 +45,11 @@ public function it_can_search() } #[Test] - public function it_can_supplement_data() + public function it_pulls_extra_data_data() { - $template = '{{ dictionary:countries search="Alg" supplement_data="true" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}'; + $template = '{{ dictionary:countries search="Alg" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}'; $this->assertEquals('Africa - DZ', $this->tag($template)); - - $template = '{{ dictionary:countries search="Alg" supplement_data="false" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}'; - - $this->assertEquals(' - ', $this->tag($template)); } #[Test] @@ -71,7 +67,7 @@ public function it_can_paginate() #[Test] public function it_can_be_filtered_using_conditions() { - $template = '{{ dictionary:countries supplement_data="true" iso3:is="AUS" }}{{ name }}{{ /dictionary:countries }}'; + $template = '{{ dictionary:countries iso3:is="AUS" }}{{ name }}{{ /dictionary:countries }}'; $this->assertEquals('Australia', $this->tag($template)); } @@ -81,7 +77,7 @@ public function it_can_be_filtered_using_a_query_scope() { app('statamic.scopes')[TestScope::handle()] = TestScope::class; - $template = '{{ dictionary:countries supplement_data="true" query_scope="test_scope" }}{{ name }}{{ /dictionary:countries }}'; + $template = '{{ dictionary:countries query_scope="test_scope" }}{{ name }}{{ /dictionary:countries }}'; $this->assertEquals('Australia', $this->tag($template)); }