Skip to content

Commit

Permalink
Merge pull request #6 from btn114/master
Browse files Browse the repository at this point in the history
fix di:compile, add link in slide
  • Loading branch information
haitv282 authored Mar 28, 2017
2 parents 7d35221 + 8d56053 commit 1ff0894
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 86 deletions.
3 changes: 0 additions & 3 deletions Controller/Adminhtml/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ abstract class Banner extends \Magento\Backend\App\Action
*
* @var \Magento\Backend\Model\View\Result\RedirectFactory
*/
protected $resultRedirectFactory;

/**
* constructor
Expand All @@ -49,13 +48,11 @@ abstract class Banner extends \Magento\Backend\App\Action
public function __construct(
\Mageplaza\BetterSlider\Model\BannerFactory $bannerFactory,
\Magento\Framework\Registry $coreRegistry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->bannerFactory = $bannerFactory;
$this->coreRegistry = $coreRegistry;
$this->resultRedirectFactory = $resultRedirectFactory;
parent::__construct($context);
}

Expand Down
14 changes: 3 additions & 11 deletions Controller/Adminhtml/Banner/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

class Edit extends \Mageplaza\BetterSlider\Controller\Adminhtml\Banner
{
/**
* Backend session
*
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;

/**
* Page factory
Expand Down Expand Up @@ -50,19 +44,16 @@ class Edit extends \Mageplaza\BetterSlider\Controller\Adminhtml\Banner
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Magento\Backend\Model\Session $backendSession,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Mageplaza\BetterSlider\Model\BannerFactory $bannerFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->backendSession = $backendSession;
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
parent::__construct($bannerFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($bannerFactory, $registry, $context);
}

/**
Expand All @@ -80,6 +71,7 @@ protected function _isAllowed()
*/
public function execute()
{

$id = $this->getRequest()->getParam('banner_id');
/** @var \Mageplaza\BetterSlider\Model\Banner $banner */
$banner = $this->initBanner();
Expand All @@ -104,7 +96,7 @@ public function execute()
}
$title = $banner->getId() ? $banner->getName() : __('New Banner');
$resultPage->getConfig()->getTitle()->prepend($title);
$data = $this->backendSession->getData('mageplaza_betterslider_banner_data', true);
$data = $this->_session->getData('mageplaza_betterslider_banner_data', true);
if (!empty($data)) {
$banner->setData($data);
}
Expand Down
16 changes: 2 additions & 14 deletions Controller/Adminhtml/Banner/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ class Save extends \Mageplaza\BetterSlider\Controller\Adminhtml\Banner
*/
protected $imageModel;

/**
* Backend session
*
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;

/**
* JS helper
*
Expand All @@ -50,29 +43,24 @@ class Save extends \Mageplaza\BetterSlider\Controller\Adminhtml\Banner
*
* @param \Mageplaza\BetterSlider\Model\Upload $uploadModel
* @param \Mageplaza\BetterSlider\Model\Banner\Image $imageModel
* @param \Magento\Backend\Model\Session $backendSession
* @param \Magento\Backend\Helper\Js $jsHelper
* @param \Mageplaza\BetterSlider\Model\BannerFactory $bannerFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Mageplaza\BetterSlider\Model\Upload $uploadModel,
\Mageplaza\BetterSlider\Model\Banner\Image $imageModel,
\Magento\Backend\Model\Session $backendSession,
\Magento\Backend\Helper\Js $jsHelper,
\Mageplaza\BetterSlider\Model\BannerFactory $bannerFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->uploadModel = $uploadModel;
$this->imageModel = $imageModel;
$this->backendSession = $backendSession;
$this->jsHelper = $jsHelper;
parent::__construct($bannerFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($bannerFactory, $registry, $context);
}

/**
Expand Down Expand Up @@ -106,7 +94,7 @@ public function execute()
try {
$banner->save();
$this->messageManager->addSuccess(__('The Banner has been saved.'));
$this->backendSession->setMageplazaBetterSliderBannerData(false);
$this->_session->setMageplazaBetterSliderBannerData(false);
if ($this->getRequest()->getParam('back')) {
$resultRedirect->setPath(
'mageplaza_betterslider/*/edit',
Expand Down
4 changes: 1 addition & 3 deletions Controller/Adminhtml/Banner/Sliders.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ class Sliders extends \Mageplaza\BetterSlider\Controller\Adminhtml\Banner
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
* @param \Mageplaza\BetterSlider\Model\BannerFactory $sliderFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
\Mageplaza\BetterSlider\Model\BannerFactory $sliderFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->resultLayoutFactory = $resultLayoutFactory;
parent::__construct($sliderFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($sliderFactory, $registry, $context);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions Controller/Adminhtml/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,22 @@ abstract class Slider extends \Magento\Backend\App\Action
*
* @var \Magento\Backend\Model\View\Result\RedirectFactory
*/
protected $resultRedirectFactory;

/**
* constructor
*
* @param \Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory,
\Magento\Framework\Registry $coreRegistry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->sliderFactory = $sliderFactory;
$this->coreRegistry = $coreRegistry;
$this->resultRedirectFactory = $resultRedirectFactory;
parent::__construct($context);
}

Expand Down
4 changes: 1 addition & 3 deletions Controller/Adminhtml/Slider/Banners.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ class Banners extends \Mageplaza\BetterSlider\Controller\Adminhtml\Slider
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
* @param \Mageplaza\BetterSlider\Model\SliderFactory $bannerFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
\Mageplaza\BetterSlider\Model\SliderFactory $bannerFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->resultLayoutFactory = $resultLayoutFactory;
parent::__construct($bannerFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($bannerFactory, $registry, $context);
}

/**
Expand Down
15 changes: 2 additions & 13 deletions Controller/Adminhtml/Slider/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

class Edit extends \Mageplaza\BetterSlider\Controller\Adminhtml\Slider
{
/**
* Backend session
*
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;

/**
* Page factory
Expand All @@ -41,28 +35,23 @@ class Edit extends \Mageplaza\BetterSlider\Controller\Adminhtml\Slider
/**
* constructor
*
* @param \Magento\Backend\Model\Session $backendSession
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Magento\Backend\Model\Session $backendSession,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->backendSession = $backendSession;
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
parent::__construct($sliderFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($sliderFactory, $registry, $context);
}

/**
Expand Down Expand Up @@ -104,7 +93,7 @@ public function execute()
}
$title = $slider->getId() ? $slider->getName() : __('New Slider');
$resultPage->getConfig()->getTitle()->prepend($title);
$data = $this->backendSession->getData('mageplaza_betterslider_slider_data', true);
$data = $this->_session->getData('mageplaza_betterslider_slider_data', true);
if (!empty($data)) {
$slider->setData($data);
}
Expand Down
15 changes: 2 additions & 13 deletions Controller/Adminhtml/Slider/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

class Save extends \Mageplaza\BetterSlider\Controller\Adminhtml\Slider
{
/**
* Backend session
*
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;

/**
* JS helper
Expand All @@ -34,25 +28,20 @@ class Save extends \Mageplaza\BetterSlider\Controller\Adminhtml\Slider
/**
* constructor
*
* @param \Magento\Backend\Model\Session $backendSession
* @param \Magento\Backend\Helper\Js $jsHelper
* @param \Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Magento\Backend\Model\Session $backendSession,
\Magento\Backend\Helper\Js $jsHelper,
\Mageplaza\BetterSlider\Model\SliderFactory $sliderFactory,
\Magento\Framework\Registry $registry,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
$this->backendSession = $backendSession;
$this->jsHelper = $jsHelper;
parent::__construct($sliderFactory, $registry, $resultRedirectFactory, $context);
parent::__construct($sliderFactory, $registry, $context);
}

/**
Expand Down Expand Up @@ -81,7 +70,7 @@ public function execute()
try {
$slider->save();
$this->messageManager->addSuccess(__('The Slider has been saved.'));
$this->backendSession->setMageplazaBetterSliderSliderData(false);
$this->_session->setMageplazaBetterSliderSliderData(false);
if ($this->getRequest()->getParam('back')) {
$resultRedirect->setPath(
'mageplaza_betterslider/*/edit',
Expand Down
4 changes: 2 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
namespace Mageplaza\BetterSlider\Helper;

use Mageplaza\Core\Helper\AbstractData;
use Mageplaza\Core\Helper\AbstractData as CoreHelper;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractData
class Data extends CoreHelper
{

}
5 changes: 1 addition & 4 deletions Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Image extends AbstractHelper
protected $storeManager;

protected $subDir = 'mageplaza/betterslider/banner/image';
protected $urlBuilder;
/**
* @var \Magento\Framework\Filesystem
*/
Expand All @@ -33,13 +32,11 @@ class Image extends AbstractHelper
public function __construct(
Context $context,
BannerFactory $bannerFactory,
UrlInterface $urlBuilder,
Filesystem $fileSystem,
StoreManagerInterface $storeManager

)
{
$this->urlBuilder = $urlBuilder;
$this->fileSystem = $fileSystem;
$this->bannerFactory = $bannerFactory;
$this->storeManager = $storeManager;
Expand All @@ -48,7 +45,7 @@ public function __construct(

public function getBaseUrl()
{
return $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $this->subDir . '/image/';
return $this->_urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $this->subDir . '/image/';
}


Expand Down
30 changes: 15 additions & 15 deletions view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// var config = {
// map: {
// '*': {
// 'owlcarousel': 'Mageplaza_BetterSlider/js/owl.carousel',
// },
// },
// paths: {
// 'owlcarousel': 'Mageplaza_BetterSlider/js/owl.carousel',
// },
// shim: {
// 'owlcarousel': {
// deps: ['jquery']
// }
// }
// };
var config = {
// map: {
// '*': {
// 'owlcarousel': 'Mageplaza_BetterSlider/js/owl.carousel',
// },
// },
// paths: {
// 'owlcarousel': 'Mageplaza_BetterSlider/js/owl.carousel',
// },
// shim: {
// 'owlcarousel': {
// deps: ['jquery']
// }
// }
};
3 changes: 2 additions & 1 deletion view/frontend/templates/slider.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $autoHeight = $block->getAutoHeight() ? 'true' : 'false';
<div>
<div class="mp-owl-carousel owl-carousel">
<?php foreach ($block->getSliders() as $slider): ?>
<div class="item"><img src="<?php echo $slider->getBannerUrl(); ?>" alt="img"></div>
<?php $url = $slider->getUrl() ? $slider->getUrl() : '#'?>
<div class="item"><a href="<?php echo $url ; ?>"><img src="<?php echo $slider->getBannerUrl(); ?>" alt="img"></a></div>
<?php endforeach; ?>
</div>
</div>
Expand Down

0 comments on commit 1ff0894

Please sign in to comment.