Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
faonni committed Dec 25, 2016
1 parent 7c22d4c commit fce7801
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 80 deletions.
37 changes: 0 additions & 37 deletions Cron/Upgrade.php

This file was deleted.

57 changes: 57 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Faonni
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade module to newer
* versions in the future.
*
* @package Faonni_Browser
* @copyright Copyright (c) 2016 Karliuka Vitalii(karliuka.vitalii@gmail.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Faonni\Browser\Helper;

use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Helper\AbstractHelper;

/**
* Faonni Browser Data helper
*/
class Data extends AbstractHelper
{
/**
* Browser processor code config path
*/
const XML_BROWSER_PROCESSOR = 'web/browser_capabilities/processor';

/**
* Retrieve browser processor code
*
* @return string
*/
public function getProcessor()
{
return $this->_getConfig(self::XML_BROWSER_PROCESSOR);
}

/**
* Retrieve store configuration data
*
* @param string $path
* @return string|null
*/
protected function _getConfig($path)
{
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE);
}
}
15 changes: 13 additions & 2 deletions Model/Plugin/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Magento\Framework\HTTP\Header;
use Magento\Framework\View\Element\Context;
use Faonni\Browser\Model\Processor\ProcessorFactory;
use Faonni\Browser\Helper\Data as BrowserHelper;

/**
* Plugin for \Magento\Customer\Model\Visitor
Expand Down Expand Up @@ -59,13 +60,21 @@ class Visitor
*
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
protected $_objectManager;

/**
* Helper instance
*
* @var \Faonni\Browser\Helper\Data
*/
protected $_helper;

/**
* @param \Magento\Framework\Session\SessionManagerInterface $session
* @param \Faonni\Browser\Model\Processor\ProcessorFactory $processorFactory
* @param \Magento\Framework\HTTP\Header $httpHeader
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param \Faonni\Browser\Helper\Data $helper
* @param \Magento\Framework\View\Element\Context $context
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
Expand All @@ -75,12 +84,14 @@ public function __construct(
ProcessorFactory $processorFactory,
Header $httpHeader,
ObjectManagerInterface $objectManager,
BrowserHelper $helper,
Context $context
) {
$this->_session = $session;
$this->_processorFactory = $processorFactory;
$this->_httpHeader = $httpHeader;
$this->_objectManager = $objectManager;
$this->_helper = $helper;
$this->_eventManager = $context->getEventManager();
}

Expand Down Expand Up @@ -113,7 +124,7 @@ public function aroundInitByRequest($subject, $proceed, $observer)
if ($info->getId()) {
$browserInfo = $info->getBrowser();
} else {
$processor = $this->_processorFactory->create('browscap_php');
$processor = $this->_processorFactory->create($this->_helper->getProcessor());
$browserInfo = $processor->getBrowser($userAgent);
$info->addData($browserInfo);
$info->save();
Expand Down
11 changes: 2 additions & 9 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,9 @@
<system>
<section id="web">
<group id="browser_capabilities">
<field id="enabled" translate="label" type="select" sortOrder="750" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Enable Advanced Mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="processor" translate="label" type="select" sortOrder="760" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Processor of detection</label>
<source_model>Faonni\Browser\Model\Config\Source\Processor</source_model>
<depends>
<field id="enabled">1</field>
</depends>
<label>Advanced Mode Processor</label>
<source_model>Faonni\Browser\Model\Config\Source\Processor</source_model>
</field>
</group>
</section>
Expand Down
1 change: 0 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<default>
<web>
<browser_capabilities>
<enabled>1</enabled>
<processor>browscap_php</processor>
</browser_capabilities>
</web>
Expand Down
31 changes: 0 additions & 31 deletions etc/crontab.xml

This file was deleted.

0 comments on commit fce7801

Please sign in to comment.