1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @category Zookal_Mock |
5
|
|
|
* @package Model |
6
|
|
|
* @author Cyrill Schumacher | {firstName}@{lastName}.fm | @SchumacherFM |
7
|
|
|
* @copyright Copyright (c) Zookal Pty Ltd |
8
|
|
|
* @license OSL - Open Software Licence 3.0 | http://opensource.org/licenses/osl-3.0.php |
9
|
|
|
*/ |
10
|
|
|
class Zookal_Mock_Model_Mocks_Mage_Payment extends Zookal_Mock_Model_Mocks_Abstract |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Mage_Core_Model_Store |
14
|
|
|
*/ |
15
|
|
|
protected $_store = null; |
16
|
|
|
|
17
|
|
|
public function __construct($helper = null, $store = null) |
18
|
|
|
{ |
19
|
|
|
parent::__construct($helper); |
20
|
|
|
if (false === empty($store) && $store instanceof Mage_Core_Model_Store) { |
|
|
|
|
21
|
|
|
$this->_store = $store; |
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return Mage_Core_Model_Store |
27
|
|
|
*/ |
28
|
|
|
public function getStore() |
29
|
|
|
{ |
30
|
|
|
if (null === $this->_store) { |
31
|
|
|
$this->_store = Mage::app()->getStore(); |
32
|
|
|
} |
33
|
|
|
return $this->_store; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @see Mage_Payment_Helper_Data |
38
|
|
|
* Retrieve block type for display method information |
39
|
|
|
* Only frontend layout generation checks if a block is an instance of Mage_Core_Block_Abstract |
40
|
|
|
* therefore we need to separate. |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getInfoBlockType() |
45
|
|
|
{ |
46
|
|
|
return 'zookal_mock/payment_' . ($this->_isAdmin() ? 'backend' : 'frontend'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @see Mage_Payment_Helper_Data |
51
|
|
|
* |
52
|
|
|
* Retreive payment method form html |
53
|
|
|
* |
54
|
|
|
* @return Zookal_Mock_Block_Payment_Backend |
55
|
|
|
*/ |
56
|
|
|
public function getMethodFormBlock() |
57
|
|
|
{ |
58
|
|
|
return new Zookal_Mock_Block_Payment_Backend(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @see http://stackoverflow.com/questions/9693020/magento-request-frontend-or-backend thanks alan :-) |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
|
|
protected function _isAdmin() |
66
|
|
|
{ |
67
|
|
|
return ($this->getStore()->isAdmin() || Mage::getDesign()->getArea() === 'adminhtml'); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.