Skip to content

Commit

Permalink
Merge pull request #11 from Becklyn/fix-track-js-embed-to-use-deploym…
Browse files Browse the repository at this point in the history
…ent-tier

fix TrackJSEmbed to use deployment tier
  • Loading branch information
Kai Eichinger authored Nov 4, 2019
2 parents 6c16814 + ba30b8e commit 4c287f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/Config/HostingConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Becklyn\Hosting\Config;


use Becklyn\Hosting\Git\GitIntegration;
use Becklyn\Hosting\Project\ProjectVersion;


Expand All @@ -23,7 +22,7 @@ class HostingConfig

/**
* @param array $config
* @param GitIntegration $gitIntegration
* @param ProjectVersion $projectVersion
*/
public function __construct (array $config, ProjectVersion $projectVersion)
{
Expand All @@ -41,6 +40,15 @@ public function getDeploymentTier () : string
}


/**
* @return bool
*/
public function isInDevelopmentTier () : bool
{
return "development" === $this->config["tier"];
}


/**
* @return string|null
*/
Expand Down
6 changes: 5 additions & 1 deletion src/DependencyInjection/BecklynHostingConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public function getConfigTreeBuilder ()
->children()
->scalarNode("tier")
->isRequired()
->info("The deployment environment (or tier) where this app is installed. E.g. 'staging' or 'production'.")
->info("The deployment environment (or tier) where this app is installed. E.g. 'development', 'staging' or 'production'.")
->validate()
->ifNotInArray(["development", "staging", "production"])
->thenInvalid("Invalid hosting tier %s")
->end()
->end()
->scalarNode("project_name")
->isRequired()
Expand Down
2 changes: 1 addition & 1 deletion src/TrackJS/TrackJSEmbed.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getEmbedHtml () : string
$trackJsToken = $this->hostingConfig->getTrackJsToken();

// only embed if token is set, in production and not in debug
if (null === $trackJsToken || $this->isDebug || "prod" !== $this->environment)
if (null === $trackJsToken || $this->isDebug || $this->hostingConfig->isInDevelopmentTier())
{
return "";
}
Expand Down

0 comments on commit 4c287f4

Please sign in to comment.