Skip to content

Commit a4b0469

Browse files
committed
[~TASK] Fixed FireGento CS violations: Private class vars to protected and leading underscore
1 parent e1b4c60 commit a4b0469

4 files changed

Lines changed: 40 additions & 42 deletions

File tree

src/app/code/community/FireGento/AdminMonitoring/Model/History/Data.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FireGento_AdminMonitoring_Model_History_Data
3030
/**
3131
* @var Mage_Core_Model_Abstract
3232
*/
33-
private $savedModel;
33+
protected $_savedModel;
3434

3535
/**
3636
* Init the saved model
@@ -39,7 +39,7 @@ class FireGento_AdminMonitoring_Model_History_Data
3939
*/
4040
public function __construct(Mage_Core_Model_Abstract $savedModel)
4141
{
42-
$this->savedModel = $savedModel;
42+
$this->_savedModel = $savedModel;
4343
}
4444

4545
/**
@@ -60,10 +60,10 @@ public function getSerializedContent()
6060
public function getContent()
6161
{
6262
// have to re-load the model as based on database datatypes the format of values changes
63-
$className = get_class($this->savedModel);
63+
$className = get_class($this->_savedModel);
6464
$model = new $className;
65-
$model->setStoreId($this->savedModel->getStoreId());
66-
$model->load($this->savedModel->getId());
65+
$model->setStoreId($this->_savedModel->getStoreId());
66+
$model->load($this->_savedModel->getId());
6767

6868
return $this->filterObligatoryFields($model->getData());
6969
}
@@ -91,7 +91,7 @@ protected function filterObligatoryFields($data)
9191
*/
9292
public function getOrigContent()
9393
{
94-
$data = $this->savedModel->getOrigData();
94+
$data = $this->_savedModel->getOrigData();
9595
return $this->filterObligatoryFields($data);
9696
}
9797

@@ -102,7 +102,7 @@ public function getOrigContent()
102102
*/
103103
public function getObjectType()
104104
{
105-
return get_class($this->savedModel);
105+
return get_class($this->_savedModel);
106106
}
107107

108108
/**
@@ -112,6 +112,6 @@ public function getObjectType()
112112
*/
113113
public function getObjectId()
114114
{
115-
return $this->savedModel->getId();
115+
return $this->_savedModel->getId();
116116
}
117117
}

src/app/code/community/FireGento/AdminMonitoring/Model/History/Diff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FireGento_AdminMonitoring_Model_History_Diff
3030
/**
3131
* @var FireGento_AdminMonitoring_Model_History_Data
3232
*/
33-
private $dataModel;
33+
protected $_dataModel;
3434

3535
/**
3636
* Init the data model
@@ -39,29 +39,29 @@ class FireGento_AdminMonitoring_Model_History_Diff
3939
*/
4040
public function __construct(FireGento_AdminMonitoring_Model_History_Data $dataModel)
4141
{
42-
$this->dataModel = $dataModel;
42+
$this->_dataModel = $dataModel;
4343
}
4444

4545
/**
4646
* Check if the data has changed.
4747
*
48-
* @return bool
48+
* @return bool Result
4949
*/
5050
public function hasChanged()
5151
{
52-
return ($this->dataModel->getContent() != $this->dataModel->getOrigContent());
52+
return ($this->_dataModel->getContent() != $this->_dataModel->getOrigContent());
5353
}
5454

5555
/**
5656
* Generate an object diff of the original content and the actual content.
5757
*
5858
* @return array Diff Array
5959
*/
60-
private function getObjectDiff ()
60+
private function getObjectDiff()
6161
{
62-
$dataOld = $this->dataModel->getOrigContent();
62+
$dataOld = $this->_dataModel->getOrigContent();
6363
if (is_array($dataOld)) {
64-
$dataNew = $this->dataModel->getContent();
64+
$dataNew = $this->_dataModel->getContent();
6565
$dataDiff = array();
6666
foreach ($dataOld as $key => $oldValue) {
6767
// compare objects serialized
@@ -81,7 +81,7 @@ private function getObjectDiff ()
8181
/**
8282
* Retrieve the serialized diff for the current data model.
8383
*
84-
* @return string
84+
* @return string Serialized Diff
8585
*/
8686
public function getSerializedDiff()
8787
{

src/app/code/community/FireGento/AdminMonitoring/Model/Observer/Model/Abstract.php

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ abstract class FireGento_AdminMonitoring_Model_Observer_Model_Abstract
3030
/**
3131
* @var Mage_Core_Model_Abstract
3232
*/
33-
protected $savedModel;
33+
protected $_savedModel;
3434

3535
/**
3636
* @var FireGento_AdminMonitoring_Model_History_Diff
3737
*/
38-
private $diffModel;
38+
protected $_diffModel;
3939

4040
/**
4141
* @var FireGento_AdminMonitoring_Model_History_Data
4242
*/
43-
private $dataModel;
43+
protected $_dataModel;
4444

4545
/**
4646
* Abstract method for retrieving the history action.
@@ -66,7 +66,7 @@ public function modelAfter(Varien_Event_Observer $observer)
6666
*/
6767
protected function hasChanged()
6868
{
69-
return $this->diffModel->hasChanged();
69+
return $this->_diffModel->hasChanged();
7070
}
7171

7272
/**
@@ -76,15 +76,13 @@ protected function hasChanged()
7676
*/
7777
protected function storeByObserver(Varien_Event_Observer $observer)
7878
{
79-
/**
80-
* @var $savedModel Mage_Core_Model_Abstract
81-
*/
79+
/* @var $savedModel Mage_Core_Model_Abstract */
8280
$savedModel = $observer->getObject();
83-
$this->savedModel = $savedModel;
81+
$this->_savedModel = $savedModel;
8482

8583
if (!$this->isExcludedClass($savedModel)) {
86-
$this->dataModel = Mage::getModel('firegento_adminmonitoring/history_data', $savedModel);
87-
$this->diffModel = Mage::getModel('firegento_adminmonitoring/history_diff', $this->dataModel);
84+
$this->_dataModel = Mage::getModel('firegento_adminmonitoring/history_data', $savedModel);
85+
$this->_diffModel = Mage::getModel('firegento_adminmonitoring/history_diff', $this->_dataModel);
8886

8987
if ($this->hasChanged()) {
9088
$this->createHistoryForModelAction();
@@ -97,16 +95,15 @@ protected function storeByObserver(Varien_Event_Observer $observer)
9795
*/
9896
private function createHistoryForModelAction()
9997
{
100-
Mage::dispatchEvent(
101-
'firegento_adminmonitoring_log',
102-
array(
103-
'object_id' => $this->dataModel->getObjectId(),
104-
'object_type' => $this->dataModel->getObjectType(),
105-
'content' => $this->dataModel->getSerializedContent(),
106-
'content_diff' => $this->diffModel->getSerializedDiff(),
107-
'action' => $this->getAction(),
108-
)
98+
$eventData = array(
99+
'object_id' => $this->_dataModel->getObjectId(),
100+
'object_type' => $this->_dataModel->getObjectType(),
101+
'content' => $this->_dataModel->getSerializedContent(),
102+
'content_diff' => $this->_diffModel->getSerializedDiff(),
103+
'action' => $this->getAction(),
109104
);
105+
106+
Mage::dispatchEvent('firegento_adminmonitoring_log', $eventData);
110107
}
111108

112109
/**
@@ -116,7 +113,7 @@ private function createHistoryForModelAction()
116113
*/
117114
private function isExcludedClass()
118115
{
119-
$savedModel = $this->savedModel;
116+
$savedModel = $this->_savedModel;
120117

121118
$objectTypeExcludes = array_keys(Mage::getStoreConfig('firegento_adminmonitoring_config/exclude/object_types'));
122119
$objectTypeExcludesFiltered = array_filter(

src/app/code/community/FireGento/AdminMonitoring/Model/Observer/Model/Save.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class FireGento_AdminMonitoring_Model_Observer_Model_Save
3131
/**
3232
* @var string Object Hash
3333
*/
34-
private $currentHash;
34+
protected $_currentHash;
3535

3636
/**
3737
* @var array
3838
*/
39-
private $beforeIds = array();
39+
protected $_beforeIds = array();
4040

4141
/**
4242
* Handle the model_save_after event.
@@ -56,7 +56,7 @@ public function modelAfter(Varien_Event_Observer $observer)
5656
*/
5757
private function setCurrentHash(Mage_Core_Model_Abstract $model)
5858
{
59-
$this->currentHash = $this->getObjectHash($model);
59+
$this->_currentHash = $this->getObjectHash($model);
6060
}
6161

6262
/**
@@ -110,7 +110,7 @@ public function modelBefore(Varien_Event_Observer $observer)
110110
*/
111111
private function storeBeforeId($id)
112112
{
113-
$this->beforeIds[$this->currentHash] = $id;
113+
$this->_beforeIds[$this->_currentHash] = $id;
114114
}
115115

116116
/**
@@ -136,7 +136,7 @@ protected function getAction()
136136
*/
137137
private function hadIdAtBefore()
138138
{
139-
return (isset($this->beforeIds[$this->currentHash]) && $this->beforeIds[$this->currentHash]);
139+
return (isset($this->_beforeIds[$this->_currentHash]) && $this->_beforeIds[$this->_currentHash]);
140140
}
141141

142142
/**
@@ -146,7 +146,8 @@ private function hadIdAtBefore()
146146
*/
147147
private function hasOrigData()
148148
{
149-
$data = $this->savedModel->getOrigData();
149+
$data = $this->_savedModel->getOrigData();
150+
150151
// unset website_ids as this is even on new entities set for catalog_product models
151152
unset($data['website_ids']);
152153
return (bool) $data;

0 commit comments

Comments
 (0)