From 925a813ead5a5d4357f7a77665a591edc9b2e2e6 Mon Sep 17 00:00:00 2001 From: Silvan Date: Fri, 29 Dec 2017 21:33:23 +0100 Subject: [PATCH] remove module --- .gitignore | 1 + assets/.gitignore | 2 -- src/Module.php | 52 --------------------------- src/SlickWidget.php | 6 +--- src/controllers/DefaultController.php | 13 ------- src/views/blocks/SlickBlock.php | 2 +- src/views/default/index.php | 17 --------- tests/SlickBlockTest.php | 6 ++-- 8 files changed, 6 insertions(+), 93 deletions(-) delete mode 100644 assets/.gitignore delete mode 100644 src/controllers/DefaultController.php delete mode 100644 src/views/default/index.php diff --git a/.gitignore b/.gitignore index a1fa2a9..b09504d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ +/assets luya /.settings/ /.buildpath diff --git a/assets/.gitignore b/assets/.gitignore deleted file mode 100644 index 6eed8ad..0000000 --- a/assets/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# This empty directory is only needed for needed for running PHP unit test and should always be empty in your VCS. -/*! diff --git a/src/Module.php b/src/Module.php index 8885246..9acb9b4 100644 --- a/src/Module.php +++ b/src/Module.php @@ -37,56 +37,4 @@ public static function t($message, array $params = [], $category = 'slick') return parent::baseT($category, $message, $params); } - /** - * Loading and parsing of json config array. - * - * @param $file - * - * @throws \luya\Exception - * - * @return string - * - * @internal param string $message - * @internal param array $params - */ - private static function jsonLoad($file) - { - if (file_exists(\Yii::$app->getWebroot().'/'.$file)) { - file_get_contents(\Yii::$app->getWebroot().'/'.$file); - - return json_decode($file, true); - } else { - throw new \luya\Exception('Slick.js configs:'.\Yii::$app->getWebroot().'/'.$file.' was not found.'); - } - } - - /** - * Load Slick.js options via LUYA configs as $params. - * - * @return bool|string|array - * - * @internal param array $params - */ - public static function slickConfig() - { - $params = self::getInstance()->params; - - if (array_key_exists('slickConfig', $params) && $params['slickConfig'] === true) { - return self::jsonLoad('slick-config.json'); - } - - if (array_key_exists('slickConfig', $params) && is_string($params['slickConfig'])) { - return self::jsonLoad($params['slickConfig']); - } - - if (array_key_exists('slickConfig', $params) && is_array($params['slickConfig'])) { - return $params['slickConfig']; - } - - if (array_key_exists('slickConfig', $params) && is_bool($params['slickConfig'] === false)) { - return false; - } - - return false; - } } diff --git a/src/SlickWidget.php b/src/SlickWidget.php index 9be3572..5033c14 100644 --- a/src/SlickWidget.php +++ b/src/SlickWidget.php @@ -22,11 +22,7 @@ public function init() SlickAsset::register($this->getView()); ResourcesAsset::register($this->getView()); - if (Module::slickConfig() !== false) { - $this->slickConfig = Module::slickConfig(); - } else { - $this->slickConfig = $this->slickConfigWidget; - } + $this->slickConfig = $this->slickConfigWidget; $this->view->registerJs( "var slickSlider = $('.slick-slider').slick({" diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php deleted file mode 100644 index 6e0e1a4..0000000 --- a/src/controllers/DefaultController.php +++ /dev/null @@ -1,13 +0,0 @@ -render('index'); - } -} diff --git a/src/views/blocks/SlickBlock.php b/src/views/blocks/SlickBlock.php index dbdff46..6f7da46 100644 --- a/src/views/blocks/SlickBlock.php +++ b/src/views/blocks/SlickBlock.php @@ -9,7 +9,7 @@ 'images' => $images, 'slickConfigWidget' => [ 'infinite' => 'true', - 'slidesToShow' => '2', + 'slidesToShow' => '1', 'slidesToScroll' => '1', 'autoplay' => 'true', 'autoplaySpeed' => '5000', diff --git a/src/views/default/index.php b/src/views/default/index.php deleted file mode 100644 index 6de91c0..0000000 --- a/src/views/default/index.php +++ /dev/null @@ -1,17 +0,0 @@ - - - [], - 'slickConfigWidget' => [ - 'infinite' => 'true', - 'slidesToShow' => '1', - 'slidesToScroll' => '1', - 'autoplay' => 'true', - 'autoplaySpeed' => '5000', - ], -]) -?> \ No newline at end of file diff --git a/tests/SlickBlockTest.php b/tests/SlickBlockTest.php index 24b0b26..0c541f6 100644 --- a/tests/SlickBlockTest.php +++ b/tests/SlickBlockTest.php @@ -16,7 +16,7 @@ public function testEmpty() public function files_are_equal($a, $b) { - // Check if filesize is different + // Check if file size is different if(filesize($a) !== filesize($b)) return false; @@ -44,8 +44,8 @@ public function testWidgetView() { $is = ['view' => fopen(dirname(__FILE__, 2) . '/src/views/SlickSlider.php', 'rb')]; - $should = [ 'view' => fopen(dirname(__FILE__) . '/data/views/SlickSlider.php', 'rb')]; - $this->assertSameSize($is,$should); + $should = ['view' => fopen(dirname(__FILE__) . '/data/views/SlickSlider.php', 'rb')]; + $this->assertSameSize($is, $should); }