-
Notifications
You must be signed in to change notification settings - Fork 1
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
36 changed files
with
801 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
use App\Core\Assets\AssetOptions; | ||
|
||
interface AssetConstract | ||
{ | ||
public function setDeps($deps): AssetConstract; | ||
|
||
public function setOptions(AssetOptions $options): AssetConstract; | ||
|
||
public function setVersion($version): AssetConstract; | ||
|
||
public function setPriority(int $priority): AssetConstract; | ||
|
||
public function setAssetType(AssetTypeEnum $assetType): AssetConstract; | ||
|
||
public function isValid(): bool; | ||
|
||
public function getId(); | ||
|
||
public function getAssetType(): AssetTypeEnum; | ||
|
||
public function enqueue(); | ||
|
||
public function printHtml(); | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
interface AssetHtmlConstract | ||
{ | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
interface AssetIconConstract | ||
{ | ||
} |
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,80 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
final class AssetTypeEnum | ||
{ | ||
private static $inited = false; | ||
|
||
protected static AssetTypeEnum $CSS; | ||
protected static AssetTypeEnum $JS; | ||
protected static AssetTypeEnum $ICON; | ||
protected static AssetTypeEnum $FONT; | ||
protected static AssetTypeEnum $STYLE; | ||
protected static AssetTypeEnum $SCRIPT; | ||
|
||
protected $type; | ||
|
||
protected function __construct($type) | ||
{ | ||
$this->type = $type; | ||
} | ||
|
||
public static function init() | ||
{ | ||
if (static::$inited === false) { | ||
self::$CSS = new self('css'); | ||
self::$JS = new self('js'); | ||
self::$ICON = new self('icon'); | ||
self::$FONT = new self('font'); | ||
self::$STYLE = new self('style'); | ||
self::$SCRIPT = new self('script'); | ||
|
||
// Make inited flag is true | ||
static::$inited = true; | ||
} | ||
} | ||
|
||
public static function CSS(): AssetTypeEnum | ||
{ | ||
return static::$CSS; | ||
} | ||
|
||
public static function JS(): AssetTypeEnum | ||
{ | ||
return static::$JS; | ||
} | ||
|
||
public static function ICON(): AssetTypeEnum | ||
{ | ||
return static::$ICON; | ||
} | ||
|
||
public static function FONT(): AssetTypeEnum | ||
{ | ||
return static::$FONT; | ||
} | ||
|
||
public static function STYLE(): AssetTypeEnum | ||
{ | ||
return static::$STYLE; | ||
} | ||
|
||
public static function SCRIPT(): AssetTypeEnum | ||
{ | ||
return static::$SCRIPT; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return $this->getType(); | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
use App\Core\Assets\AssetUrl; | ||
|
||
interface ExternalAssetConstract extends AssetConstract | ||
{ | ||
public function setUrl(AssetUrl $url): self; | ||
|
||
public function getUrl(); | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace App\Constracts; | ||
|
||
interface IconTypeConstract | ||
{ | ||
} |
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,75 @@ | ||
<?php | ||
|
||
namespace App\Core; | ||
|
||
use App\Constracts\AssetConstract; | ||
use App\Constracts\AssetTypeEnum; | ||
use App\Core\Assets\AssetOptions; | ||
|
||
abstract class Asset implements AssetConstract | ||
{ | ||
protected $id; | ||
|
||
protected AssetTypeEnum $assetType; | ||
protected AssetOptions $options; | ||
|
||
protected $deps = []; | ||
protected $version = null; | ||
protected $priority = 10; | ||
|
||
public function __construct($id) | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function isValid(): bool | ||
{ | ||
return !empty($this->id); | ||
} | ||
|
||
public function setAssetType(AssetTypeEnum $assetType): AssetConstract | ||
{ | ||
$this->assetType = $assetType; | ||
|
||
return $this; | ||
} | ||
|
||
public function getAssetType(): AssetTypeEnum | ||
{ | ||
return $this->assetType; | ||
} | ||
|
||
public function setDeps($deps): AssetConstract | ||
{ | ||
if (is_array($deps)) { | ||
$this->deps = $deps; | ||
} | ||
return $this; | ||
} | ||
|
||
public function setOptions(AssetOptions $assetOptions): AssetConstract | ||
{ | ||
$this->options = $assetOptions; | ||
|
||
return $this; | ||
} | ||
|
||
public function setPriority(int $priority): AssetConstract | ||
{ | ||
$this->priority = $priority; | ||
|
||
return $this; | ||
} | ||
|
||
public function setVersion($version): AssetConstract | ||
{ | ||
$this->version = $version; | ||
|
||
return $this; | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
} |
Oops, something went wrong.