diff --git a/src/Tag/Gtag.php b/src/Tag/Gtag.php index 0405a88..8c0480b 100644 --- a/src/Tag/Gtag.php +++ b/src/Tag/Gtag.php @@ -13,7 +13,10 @@ public function __construct(string $template, array $parameters = []) { parent::__construct($template); - $this->setName('setono_tag_bag_gtag'); + $this + ->setName('setono_tag_bag_gtag') + ->setSection(TagInterface::SECTION_HEAD) + ; $this->parameters = $parameters; } diff --git a/src/Tag/GtagConfig.php b/src/Tag/GtagConfig.php index e429f88..ad02486 100644 --- a/src/Tag/GtagConfig.php +++ b/src/Tag/GtagConfig.php @@ -13,7 +13,12 @@ public function __construct(string $target, array $parameters = []) { parent::__construct('@SetonoTagBagGtag/config', $parameters); - $this->setName('setono_tag_bag_gtag_config'); + $this + ->setName('setono_tag_bag_gtag_config') + ->setPriority(GtagLibrary::PRIORITY - 10) + ->setUnique(true) + ; + $this->target = $target; } diff --git a/src/Tag/GtagEvent.php b/src/Tag/GtagEvent.php index 7707ad2..50a3686 100644 --- a/src/Tag/GtagEvent.php +++ b/src/Tag/GtagEvent.php @@ -15,7 +15,10 @@ public function __construct(string $event, array $parameters = []) { parent::__construct('@SetonoTagBagGtag/event', $parameters); - $this->setName('setono_tag_bag_gtag_event'); + $this + ->setName('setono_tag_bag_gtag_event') + ->setPriority(GtagLibrary::PRIORITY - 20) + ; $this->event = $event; } diff --git a/src/Tag/GtagLibrary.php b/src/Tag/GtagLibrary.php index c2b2531..e0c7901 100644 --- a/src/Tag/GtagLibrary.php +++ b/src/Tag/GtagLibrary.php @@ -8,6 +8,8 @@ class GtagLibrary extends PhpTemplatesTag { public const NAME = 'setono_tag_bag_gtag_library'; + public const PRIORITY = 100; + public function __construct(string $id) { parent::__construct('@SetonoTagBagGtag/library', [ @@ -17,7 +19,7 @@ public function __construct(string $id) $this->setName(self::NAME) ->setUnique(true) ->setSection(TagInterface::SECTION_HEAD) - ->setPriority(128) + ->setPriority(self::PRIORITY) ; } } diff --git a/src/Tag/GtagSet.php b/src/Tag/GtagSet.php index 53a4ee7..070e734 100644 --- a/src/Tag/GtagSet.php +++ b/src/Tag/GtagSet.php @@ -10,6 +10,9 @@ public function __construct(array $parameters) { parent::__construct('@SetonoTagBagGtag/set', $parameters); - $this->setName('setono_tag_bag_gtag_set'); + $this + ->setName('setono_tag_bag_gtag_set') + ->setPriority(GtagLibrary::PRIORITY - 20) + ; } } diff --git a/tests/Tag/GtagConfigTest.php b/tests/Tag/GtagConfigTest.php index 3b8a9c3..e60a9ef 100644 --- a/tests/Tag/GtagConfigTest.php +++ b/tests/Tag/GtagConfigTest.php @@ -30,8 +30,8 @@ public function it_has_default_values(): void $tag = new GtagConfig('target'); $this->assertSame('@SetonoTagBagGtag/config', $tag->getTemplate()); - $this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection()); - $this->assertSame(0, $tag->getPriority()); + $this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection()); + $this->assertSame(90, $tag->getPriority()); $this->assertIsArray($tag->getDependencies()); $this->assertCount(0, $tag->getDependencies()); $this->assertIsArray($tag->getContext()); diff --git a/tests/Tag/GtagEventTest.php b/tests/Tag/GtagEventTest.php index 56af0e5..d96200a 100644 --- a/tests/Tag/GtagEventTest.php +++ b/tests/Tag/GtagEventTest.php @@ -44,8 +44,8 @@ public function it_has_default_values(): void $tag = new GtagEvent('event'); $this->assertSame('@SetonoTagBagGtag/event', $tag->getTemplate()); - $this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection()); - $this->assertSame(0, $tag->getPriority()); + $this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection()); + $this->assertSame(80, $tag->getPriority()); $this->assertIsArray($tag->getDependencies()); $this->assertCount(0, $tag->getDependencies()); $this->assertIsArray($tag->getContext()); diff --git a/tests/Tag/GtagLibraryTest.php b/tests/Tag/GtagLibraryTest.php index 4a73b48..bdb7fed 100644 --- a/tests/Tag/GtagLibraryTest.php +++ b/tests/Tag/GtagLibraryTest.php @@ -32,7 +32,7 @@ public function it_has_default_values(): void $this->assertSame('@SetonoTagBagGtag/library', $tag->getTemplate()); $this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection()); - $this->assertSame(128, $tag->getPriority()); + $this->assertSame(100, $tag->getPriority()); } /** diff --git a/tests/Tag/GtagSetTest.php b/tests/Tag/GtagSetTest.php index 828503c..7d95356 100644 --- a/tests/Tag/GtagSetTest.php +++ b/tests/Tag/GtagSetTest.php @@ -29,8 +29,8 @@ public function it_has_default_values(): void $tag = new GtagSet(['param1' => 'value1']); $this->assertSame('@SetonoTagBagGtag/set', $tag->getTemplate()); - $this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection()); - $this->assertSame(0, $tag->getPriority()); + $this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection()); + $this->assertSame(80, $tag->getPriority()); $this->assertIsArray($tag->getDependencies()); $this->assertCount(0, $tag->getDependencies()); $this->assertIsArray($tag->getContext());