-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/* | ||
* This file is inspired from the Symfony WebpackEncoreBundle package. | ||
*/ | ||
|
||
namespace Pentatrion\ViteBundle\Event; | ||
|
||
/** | ||
* Dispatched each time a script or link tag is rendered. | ||
*/ | ||
final class RenderAssetTagEvent | ||
{ | ||
public const TYPE_SCRIPT = 'script'; | ||
public const TYPE_LINK = 'link'; | ||
public const TYPE_PRELOAD = 'preload'; | ||
|
||
private string $type; | ||
private array $attributes; | ||
private bool $isBuild; | ||
|
||
public function __construct(string $type, array $attributes, bool $isBuild) | ||
{ | ||
$this->type = $type; | ||
$this->attributes = $attributes; | ||
$this->isBuild = $isBuild; | ||
} | ||
|
||
public function isScriptTag(): bool | ||
{ | ||
return self::TYPE_SCRIPT === $this->type; | ||
} | ||
|
||
public function isLinkTag(): bool | ||
{ | ||
return self::TYPE_LINK === $this->type; | ||
} | ||
|
||
public function isPreloadTag(): bool | ||
{ | ||
return self::TYPE_PRELOAD === $this->type; | ||
} | ||
|
||
public function getAttributes(): array | ||
{ | ||
return $this->attributes; | ||
} | ||
|
||
public function isBuild(): bool | ||
{ | ||
return $this->isBuild; | ||
} | ||
|
||
/** | ||
* @param string $name The attribute name | ||
* @param string|bool $value Value can be "true" to have an attribute without a value (e.g. "defer") | ||
*/ | ||
public function setAttribute(string $name, $value): void | ||
{ | ||
$this->attributes[$name] = $value; | ||
} | ||
|
||
public function removeAttribute(string $name): void | ||
{ | ||
unset($this->attributes[$name]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters