mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
run adapters test on laravel
This commit is contained in:
+11
-8
@@ -14,20 +14,23 @@
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"ext-json": "*",
|
||||
"illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0",
|
||||
"symfony/config": "^2.7|^3.0|^4.0|^5.0",
|
||||
"symfony/dependency-injection": "^2.7|^3.0|^4.0|^5.0",
|
||||
"symfony/http-kernel": "^2.7|^3.0|^4.0|^5.0",
|
||||
"symfony/yaml": "^2.7|^3.0|^4.0|^5.0",
|
||||
"twig/twig": "^1.34|^2.0|^3.0"
|
||||
"illuminate/support": "5.0.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.*",
|
||||
"orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0"
|
||||
"orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/Prime/helpers.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "5.4.0"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
|
||||
@@ -33,7 +33,7 @@ final class FlasherServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory',
|
||||
'flasher',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher.php')), 'config');
|
||||
|
||||
@@ -42,13 +42,13 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishAssets(FlasherServiceProvider $provider)
|
||||
{
|
||||
$provider->publishes(array(__DIR__.'/../../Resources/public' => public_path('vendor/php-flasher/flasher/assets/js')), 'public');
|
||||
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/public') => public_path(flasher_path('vendor/php-flasher/flasher/assets/js'))), 'public');
|
||||
}
|
||||
|
||||
public function publishTranslations(FlasherServiceProvider $provider)
|
||||
{
|
||||
$provider->loadTranslationsFrom(__DIR__.'/../../Resources/lang', 'flasher');
|
||||
$provider->publishes(array(__DIR__.'/../../Resources/lang' => resource_path('lang/vendor/flasher')));
|
||||
$provider->loadTranslationsFrom(flasher_path(__DIR__.'/../../Resources/lang'), 'flasher');
|
||||
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/lang') => resource_path(flasher_path('lang/vendor/flasher'))));
|
||||
}
|
||||
|
||||
public function registerServices()
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Laravel\Config\Config;
|
||||
use Flasher\Laravel\FlasherServiceProvider;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Flasher\Laravel\Config\Config;
|
||||
use Illuminate\View\Compilers\BladeCompiler;
|
||||
|
||||
final class Laravel4 extends Laravel
|
||||
{
|
||||
@@ -16,13 +17,17 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-laravel', 'flasher', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-laravel', 'flasher', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function publishAssets(FlasherServiceProvider $provider)
|
||||
{
|
||||
}
|
||||
|
||||
public function publishTranslations(FlasherServiceProvider $provider)
|
||||
{
|
||||
}
|
||||
|
||||
public function registerServices()
|
||||
{
|
||||
$this->app->singleton('flasher.config', function (Application $app) {
|
||||
@@ -34,10 +39,31 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function registerBladeDirectives()
|
||||
{
|
||||
Blade::extend(function ($view, $compiler) {
|
||||
$pattern = $compiler->createPlainMatcher('flasher_render(.*)');
|
||||
$startsWith = function($haystack, $needle) {
|
||||
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
|
||||
};
|
||||
|
||||
return preg_replace($pattern, "$1<?php echo app('flasher.renderer')->render($2, 'html'); ?>", $view);
|
||||
$endsWith = function($haystack, $needle) {
|
||||
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||
};
|
||||
|
||||
Blade::extend(function ($view, BladeCompiler $compiler) use ($startsWith, $endsWith) {
|
||||
$pattern = $compiler->createPlainMatcher('flasher_render(.*)');
|
||||
$matches = array();
|
||||
|
||||
preg_match($pattern, $view, $matches);
|
||||
|
||||
$value = $matches[2];
|
||||
|
||||
if (!empty($value) && $startsWith($value, "(") && $endsWith($value, ")")) {
|
||||
$value = substr($value, 1, -1);
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
$value = "array()";
|
||||
}
|
||||
|
||||
return str_replace("%criteria%", $value, $matches[1] . "<?php echo app('flasher.renderer')->render(%criteria%, 'html'); ?>");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Laravel\FlasherServiceProvider;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\View\Compilers\BladeCompiler;
|
||||
|
||||
final class Laravel50 extends Laravel
|
||||
{
|
||||
@@ -12,12 +14,39 @@ final class Laravel50 extends Laravel
|
||||
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '5.0');
|
||||
}
|
||||
|
||||
public function publishTranslations(FlasherServiceProvider $provider)
|
||||
{
|
||||
$provider->loadTranslationsFrom(flasher_path(__DIR__.'/../../Resources/lang'), 'flasher');
|
||||
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/lang') => base_path(flasher_path('resources/lang/vendor/flasher'))));
|
||||
}
|
||||
|
||||
public function registerBladeDirectives()
|
||||
{
|
||||
Blade::extend(function ($view, $compiler) {
|
||||
$pattern = $compiler->createPlainMatcher('flasher_render(.*)');
|
||||
$startsWith = function($haystack, $needle) {
|
||||
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
|
||||
};
|
||||
|
||||
return preg_replace($pattern, "$1<?php echo app('flasher.renderer')->render($2, 'html'); ?>", $view);
|
||||
$endsWith = function($haystack, $needle) {
|
||||
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||
};
|
||||
|
||||
Blade::extend(function ($view, BladeCompiler $compiler) use ($startsWith, $endsWith) {
|
||||
$pattern = $compiler->createPlainMatcher('flasher_render(.*)');
|
||||
$matches = array();
|
||||
|
||||
preg_match($pattern, $view, $matches);
|
||||
|
||||
$value = $matches[2];
|
||||
|
||||
if (!empty($value) && $startsWith($value, "(") && $endsWith($value, ")")) {
|
||||
$value = substr($value, 1, -1);
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
$value = "array()";
|
||||
}
|
||||
|
||||
return str_replace("%criteria%", $value, $matches[1] . "<?php echo app('flasher.renderer')->render(%criteria%, 'html'); ?>");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher');
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ final class FlasherServiceProviderTest extends TestCase
|
||||
/** @var BladeCompiler $blade */
|
||||
$blade = $this->app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
|
||||
|
||||
$this->assertEquals("<?php echo app('flasher.renderer')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render'));
|
||||
$this->assertEquals("<?php echo app('flasher.renderer')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render()'));
|
||||
$this->assertEquals("<?php echo app('flasher.renderer')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render(array())'));
|
||||
$this->assertEquals("<?php echo app('flasher.renderer')->render(array(\"priority\" => array(\"min\" => 4, \"max\" => 5)), 'html'); ?>", $blade->compileString('@flasher_render(array("priority" => array("min" => 4, "max" => 5)))'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ final class FlasherNotyServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory.noty',
|
||||
'flasher.renderer.noty',
|
||||
'flasher.noty',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherNotyServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher_noty.php')), 'config');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherNotyServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-noty-laravel', 'flasher_noty', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-noty-laravel', 'flasher_noty', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function mergeConfigFromNoty()
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherNotyServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher_noty');
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ class FlasherNotyfServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory.notyf',
|
||||
'flasher.renderer.notyf',
|
||||
'flasher.notyf',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher_notyf.php')), 'config');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-notyf-laravel', 'flasher_notyf', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-notyf-laravel', 'flasher_notyf', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function mergeConfigFromNotyf()
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher_notyf');
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ final class FlasherPnotifyServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory.pnotify',
|
||||
'flasher.renderer.pnotify',
|
||||
'flasher.pnotify',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherPnotifyServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher_pnotify.php')), 'config');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherPnotifyServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-pnotify-laravel', 'notify_pnotify', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-pnotify-laravel', 'flasher_pnotify', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function mergeConfigFromPnotify()
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherPnotifyServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher_pnotify');
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
"psr-4": {
|
||||
"Flasher\\Prime\\": ""
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
],
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('flasher_path')) {
|
||||
/**
|
||||
* normalize paths for linux and windows
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function flasher_path($path = '')
|
||||
{
|
||||
return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,7 @@ final class FlasherSweetAlertServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory.sweet_alert',
|
||||
'flasher.renderer.sweet_alert',
|
||||
'flasher.sweet_alert',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher_sweet_alert.php')), 'config');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-sweet_alert-laravel', 'flasher_sweet_alert', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-sweet_alert-laravel', 'flasher_sweet_alert', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function mergeConfigFromSweetAlert()
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher_sweet_alert');
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ final class FlasherToastrServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory.toastr',
|
||||
'flasher.renderer.toastr',
|
||||
'flasher.toastr',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function publishConfig(FlasherToastrServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('flasher_toastr.php')), 'config');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Laravel4 extends Laravel
|
||||
|
||||
public function publishConfig(FlasherToastrServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-toastr-laravel', 'flasher_toastr', __DIR__.'/../../Resources');
|
||||
$provider->package('php-flasher/flasher-toastr-laravel', 'flasher_toastr', flasher_path(__DIR__.'/../../Resources'));
|
||||
}
|
||||
|
||||
public function mergeConfigFromToastr()
|
||||
|
||||
@@ -14,7 +14,7 @@ final class Lumen extends Laravel
|
||||
|
||||
public function publishConfig(FlasherToastrServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw;
|
||||
$source = realpath($raw = flasher_path(__DIR__.'/../../Resources/config/config.php')) ?: $raw;
|
||||
|
||||
$this->app->configure('flasher_toastr');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user