Skip to content

Commit

Permalink
Adding some validation
Browse files Browse the repository at this point in the history
  • Loading branch information
snake14 committed Nov 3, 2023
1 parent ddf6ddf commit 0101e7f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Model/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Piwik\Plugins\TagManager\Input\IdSite;
use Piwik\Plugins\TagManager\Input\Name;
use Piwik\Plugins\TagManager\Model\Container\ContainerIdGenerator;
use Piwik\Validators\NumberRange;


class Container extends BaseModel
Expand Down Expand Up @@ -143,7 +144,7 @@ public function getContainerInstallInstructions($idSite, $idContainer, $environm
}
}

private function validateContainer($idSite, $name, $description)
private function validateContainer($idSite, $name, $description, $ignoreGtmDataLayer)
{
$site = new IdSite($idSite);
$site->check();
Expand All @@ -153,11 +154,14 @@ private function validateContainer($idSite, $name, $description)

$description = new Description($description);
$description->check();

$numberRange = new NumberRange(0, 1);
$numberRange->validate($ignoreGtmDataLayer);
}

public function addContainer($idSite, $context, $name, $description, $ignoreGtmDataLayer)
{
$this->validateContainer($idSite, $name, $description);
$this->validateContainer($idSite, $name, $description, $ignoreGtmDataLayer);
$this->contextProvider->checkIsValidContext($context);

$createdDate = $this->getCurrentDateTime();
Expand All @@ -175,7 +179,7 @@ public function addContainer($idSite, $context, $name, $description, $ignoreGtmD

public function updateContainer($idSite, $idContainer, $name, $description, $ignoreGtmDataLayer)
{
$this->validateContainer($idSite, $name, $description);
$this->validateContainer($idSite, $name, $description, $ignoreGtmDataLayer);

$columns = array(
'name' => $name,
Expand Down

0 comments on commit 0101e7f

Please sign in to comment.