Skip to content

Commit

Permalink
support removing version on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidgh83 committed Jun 13, 2024
1 parent 6b1a4b9 commit d3c5bd9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Publiux/laravelcdn/Cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function emptyBucket()
* @param string $name The name to append to the upload folder.
* @return $this The current instance of the Cdn class.
*/
public function version(string $name)
public function version(?string $name)
{
$this->helper->setVersion($name);

Expand Down
7 changes: 7 additions & 0 deletions src/Publiux/laravelcdn/CdnFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,11 @@ private function generateUrl($path, $prepend = '')
// call the provider specific url generator
return $this->provider->urlGenerator($clean_path);
}

public function version(?string $name)
{
$this->helper->setVersion($name);

return $this;
}
}
4 changes: 2 additions & 2 deletions src/Publiux/laravelcdn/CdnHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ public function cleanPath($path)
*
* @return $this The current instance for method chaining.
*/
public function setVersion(string $version): self
public function setVersion(?string $version): self
{
$this->configurations->set('cdn.providers.aws.s3.cloudfront.cdn_version', trim($version, ' \/'));
$this->configurations->set('cdn.providers.aws.s3.cloudfront.cdn_version', !is_null($version) ? trim($version, ' \/') : null);

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Publiux/laravelcdn/Contracts/CdnHelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public function startsWith($haystack, $needle);

public function cleanPath($path);

public function setVersion(string $version): CdnHelperInterface;
public function setVersion(?string $name): CdnHelperInterface;
}
2 changes: 1 addition & 1 deletion src/Publiux/laravelcdn/Contracts/CdnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public function push();

public function emptyBucket();

public function version(string $name);
public function version(?string $name);
}

0 comments on commit d3c5bd9

Please sign in to comment.