generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
c700ac9
commit b3de72a
Showing
18 changed files
with
470 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Using assets | ||
|
||
Assets are files that are not processed by Webpack. They are copied directly to the output folder. This includes images, fonts, and any other files that you want to use in your project. | ||
|
||
To use an asset, you need to import it from JavaScript or CSS. | ||
|
||
```php | ||
file: ./resources/views/layout/main.php | ||
|
||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Yii\Assets\SweetAlert2Dev; | ||
|
||
/** | ||
* @var \Yiisoft\Assets\AssetManager $assetManager | ||
*/ | ||
|
||
// Register the asset bundle with a asset manager component. | ||
$assetManager->register(SweetAlert2Dev::class); | ||
|
||
// Set parameters for the registered asset bundle a view component. | ||
$this->addCssFiles($assetManager->getCssFiles()); | ||
$this->addCssStrings($assetManager->getCssStrings()); | ||
$this->addJsFiles($assetManager->getJsFiles()); | ||
$this->addJsStrings($assetManager->getJsStrings()); | ||
$this->addJsVars($assetManager->getJsVars()); | ||
``` | ||
|
||
## Registering the Asset Bundle via container configuration | ||
|
||
Alternatively, you can register the asset bundle through the container configuration. | ||
|
||
```php | ||
file: ./config/params.php | ||
|
||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Yii\Assets\SweetAlert2Cdn; | ||
|
||
return [ | ||
'yiisoft/assets' => [ | ||
'assetManager' => [ | ||
'register' => [ | ||
SweetAlert2Cdn::class, | ||
], | ||
], | ||
], | ||
]; | ||
``` | ||
|
||
## Using npm packages | ||
|
||
You can install [npm](https://www.npmjs.com/) packages [fxpio/foxy](https://github.com/fxpio/foxy), | ||
and they will be available in the `node_modules` directory. |
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,35 @@ | ||
# Testing | ||
|
||
## Checking dependencies | ||
|
||
This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`. | ||
|
||
To run the checker, execute the following command: | ||
|
||
```shell | ||
composer run check-dependencies | ||
``` | ||
|
||
## Mutation testing | ||
|
||
Mutation testing is checked with [Infection](https://infection.github.io/). To run it: | ||
|
||
```shell | ||
composer run mutation | ||
``` | ||
|
||
## Static analysis | ||
|
||
The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis: | ||
|
||
```shell | ||
composer run psalm | ||
``` | ||
|
||
## Unit tests | ||
|
||
The code is tested with [PHPUnit](https://phpunit.de/). To run tests: | ||
|
||
``` | ||
composer run test | ||
``` |
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,8 @@ | ||
{ | ||
"name": "sweetalert2-asset", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"sweetalert2": "^11.7.5" | ||
}, | ||
"license": "mit" | ||
} |
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 |
---|---|---|
@@ -1,30 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<phpunit | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache"> | ||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
<ini name="error_reporting" value="-1"/> | ||
</php> | ||
|
||
<coverage> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="SweetAlert2"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory>./src</directory> | ||
</include> | ||
<exclude> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</coverage> | ||
|
||
<testsuites> | ||
<testsuite name="Template"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</source> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yii\Assets; | ||
|
||
use Yiisoft\Assets\AssetBundle; | ||
|
||
/** | ||
* CDN asset bundle for the sweet alert2. | ||
*/ | ||
final class SweetAlert2Cdn extends AssetBundle | ||
{ | ||
public bool $cdn = true; | ||
public array $css = ['https://cdn.jsdelivr.net/npm/sweetalert2@11.7.5/dist/sweetalert2.min.css']; | ||
public array $js = ['https://cdn.jsdelivr.net/npm/sweetalert2@11.7.5/dist/sweetalert2.all.min.js']; | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yii\Assets; | ||
|
||
use Yiisoft\Assets\AssetBundle; | ||
use Yiisoft\Files\PathMatcher\PathMatcher; | ||
|
||
/** | ||
* Development asset bundle for the sweet alert2. | ||
*/ | ||
final class SweetAlert2Dev extends AssetBundle | ||
{ | ||
public string|null $basePath = '@assets'; | ||
public string|null $baseUrl = '@assetsUrl'; | ||
public string|null $sourcePath = '@npm/sweetalert2/dist'; | ||
public array $css = ['sweetalert2.css']; | ||
public array $js = ['sweetalert2.js']; | ||
|
||
public function __construct() | ||
{ | ||
$pathMatcher = new PathMatcher(); | ||
|
||
$this->publishOptions = [ | ||
'filter' => $pathMatcher->only('**sweetalert2.css', '**sweetalert2.js'), | ||
]; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yii\Assets; | ||
|
||
use Yiisoft\Assets\AssetBundle; | ||
use Yiisoft\Files\PathMatcher\PathMatcher; | ||
|
||
/** | ||
* Production asset bundle for the sweet alert2. | ||
*/ | ||
final class SweetAlert2Prod extends AssetBundle | ||
{ | ||
public string|null $basePath = '@assets'; | ||
public string|null $baseUrl = '@assetsUrl'; | ||
public string|null $sourcePath = '@npm/sweetalert2/dist'; | ||
public array $css = ['sweetalert2.min.css']; | ||
public array $js = ['sweetalert2.min.js']; | ||
|
||
public function __construct() | ||
{ | ||
$pathMatcher = new PathMatcher(); | ||
|
||
$this->publishOptions = [ | ||
'filter' => $pathMatcher->only('**sweetalert2.min.css', '**sweetalert2.min.js'), | ||
]; | ||
} | ||
} |
Oops, something went wrong.