Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Oct 15, 2015
1 parent 86f0fbd commit f944c8e
Show file tree
Hide file tree
Showing 37 changed files with 1,479 additions and 1,480 deletions.
Expand Up @@ -19,20 +19,20 @@ protected function _prepareCollection()
$fullPageEnabled = false;
foreach ($collection as $key=>$item)
{
if($item->getStatus()==1 && ($item->getId()=='turpentine_pages' || $item->getId()=='turpentine_esi_blocks'))
if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks'))
{
$turpentineEnabled = true;
}
if($item->getStatus()==1 && $item->getId()=='full_page')
if ($item->getStatus() == 1 && $item->getId() == 'full_page')
{
$fullPageEnabled = true;
}
}
if($turpentineEnabled)
if ($turpentineEnabled)
{
$collection->removeItemByKey('full_page');
}
if($fullPageEnabled)
if ($fullPageEnabled)
{
$collection->removeItemByKey('turpentine_pages');
$collection->removeItemByKey('turpentine_esi_blocks');
Expand Down
130 changes: 65 additions & 65 deletions app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Expand Up @@ -25,13 +25,13 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
* can't use null because that is the default so no way to tell between
* the default and not actually calling it
*/
const NO_SINGLE_RENDER_TYPE = -1;
const NO_SINGLE_RENDER_TYPE = -1;

/**
* Hold the message type to call getHtml with
* @var mixed
*/
protected $_singleRenderType = null;
protected $_singleRenderType = null;

/**
* Sentinel to check if the toHtml method was skipped (getGroupedHtml was
Expand All @@ -41,7 +41,7 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
*
* @var boolean
*/
protected $_directCall = false;
protected $_directCall = false;

/**
* List of session types to load messages from for the "messages" block.
Expand All @@ -65,10 +65,10 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
*
* @var array
*/
protected $_usedStorageTypes = array( 'core/session' );
protected $_usedStorageTypes = array('core/session');

public function _prepareLayout() {
if( $this->_fixMessages() ) {
if ($this->_fixMessages()) {
/* do nothing */
return $this;
} else {
Expand All @@ -82,11 +82,11 @@ public function _prepareLayout() {
* @param Mage_Core_Model_Message_Collection $messages
* @return Mage_Core_Block_Messages
*/
public function setMessages( Mage_Core_Model_Message_Collection $messages ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( $messages->getItems() );
public function setMessages(Mage_Core_Model_Message_Collection $messages) {
if ($this->_fixMessages()) {
$this->_saveMessages($messages->getItems());
} else {
parent::setMessages( $messages );
parent::setMessages($messages);
}
return $this;
}
Expand All @@ -97,11 +97,11 @@ public function setMessages( Mage_Core_Model_Message_Collection $messages ) {
* @param Mage_Core_Model_Message_Collection $messages
* @return Mage_Core_Block_Messages
*/
public function addMessages( Mage_Core_Model_Message_Collection $messages ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( $messages->getItems() );
public function addMessages(Mage_Core_Model_Message_Collection $messages) {
if ($this->_fixMessages()) {
$this->_saveMessages($messages->getItems());
} else {
parent::addMessages( $messages );
parent::addMessages($messages);
}
return $this;
}
Expand All @@ -112,11 +112,11 @@ public function addMessages( Mage_Core_Model_Message_Collection $messages ) {
* @param Mage_Core_Model_Message_Abstract $message
* @return Mage_Core_Block_Messages
*/
public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( array( $message ) );
public function addMessage(Mage_Core_Model_Message_Abstract $message) {
if ($this->_fixMessages()) {
$this->_saveMessages(array($message));
} else {
parent::addMessage( $message );
parent::addMessage($message);
}
return $this;
}
Expand All @@ -125,12 +125,11 @@ public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
* Override this in case some dumb layout decides to use it instead of the
* standard toHtml stuff
*
* @param mixed $type=self::NO_SINGLE_RENDER_TYPE
* @return string
*/
public function getHtml( $type=self::NO_SINGLE_RENDER_TYPE ) {
public function getHtml($type = self::NO_SINGLE_RENDER_TYPE) {
$this->_singleRenderType = $type;
return $this->_handleDirectCall( 'getHtml' )->toHtml();
return $this->_handleDirectCall('getHtml')->toHtml();
}

/**
Expand All @@ -140,7 +139,7 @@ public function getHtml( $type=self::NO_SINGLE_RENDER_TYPE ) {
* @return string
*/
public function getGroupedHtml() {
return $this->_handleDirectCall( 'getGroupedHtml' )->toHtml();
return $this->_handleDirectCall('getGroupedHtml')->toHtml();
}

/**
Expand All @@ -150,37 +149,38 @@ public function getGroupedHtml() {
*
* @param string $type
*/
public function addStorageType( $type ) {
public function addStorageType($type) {
$this->_usedStorageTypes[] = $type;
}

/**
* Load layout options
*
* @return null
* @param string $methodCalled
* @return Nexcessnet_Turpentine_Block_Core_Messages
*/
protected function _handleDirectCall( $methodCalled ) {
protected function _handleDirectCall($methodCalled) {
// this doesn't actually do anything because _real_toHtml() won't be
// called in this request context (unless the flash message isn't
// actually supposed to be ajax/esi'd in)
$this->_directCall = $methodCalled;
if( $this->_fixMessages() ) {
if ($this->_fixMessages()) {
$layout = $this->getLayout();
$layoutUpdate = $layout->getUpdate()->load( 'default' );
if( Mage::app()->useCache( 'layout' ) ) {
$layoutUpdate = $layout->getUpdate()->load('default');
if (Mage::app()->useCache('layout')) {
// this is skipped in the layout update load() if the "layout"
// cache is enabled, which seems to cause the esi layout stuff
// to not load, so we manually do it here
foreach( $layoutUpdate->getHandles() as $handle ) {
$layoutUpdate->merge( $handle );
foreach ($layoutUpdate->getHandles() as $handle) {
$layoutUpdate->merge($handle);
}
}
$layout->generateXml();
$layoutShim = Mage::getSingleton( 'turpentine/shim_mage_core_layout' );
foreach( $layout->getNode()->xpath(
sprintf( '//reference[@name=\'%s\']/action',
$this->getNameInLayout() ) ) as $node ) {
$layoutShim->shim_generateAction( $node );
$layoutShim = Mage::getSingleton('turpentine/shim_mage_core_layout');
foreach ($layout->getNode()->xpath(
sprintf('//reference[@name=\'%s\']/action',
$this->getNameInLayout()) ) as $node) {
$layoutShim->shim_generateAction($node);
}
}
return $this;
Expand All @@ -192,13 +192,13 @@ protected function _handleDirectCall( $methodCalled ) {
* @return string
*/
protected function _toHtml() {
if( $this->_fixMessages() ) {
if( $this->_shouldUseInjection() ) {
if ($this->_fixMessages()) {
if ($this->_shouldUseInjection()) {
$html = $this->renderView();
} else {
$this->_loadMessages();
$this->_loadSavedMessages();
if ( count($this->getMessages()) ) {
if (count($this->getMessages())) {
$html = $this->_real_toHtml();
} else {
// Prevent returning an empty <ul></ul>
Expand All @@ -219,7 +219,7 @@ protected function _toHtml() {
*/
protected function _hasInjectOptions() {
return $this->getEsiOptions() &&
Mage::helper( 'turpentine/esi' )->shouldResponseUseEsi();
Mage::helper('turpentine/esi')->shouldResponseUseEsi();
}

/**
Expand All @@ -241,18 +241,18 @@ protected function _shouldUseInjection() {
* @return boolean
*/
protected function _hasTemplateSet() {
return (bool)$this->getTemplate();
return (bool) $this->getTemplate();
}

/**
* Preserve messages for later display
*
* @return null
*/
protected function _saveMessages( $messages ) {
if( $this->_fixMessages() && !$this->_isEsiRequest() ) {
Mage::getSingleton( 'turpentine/session' )
->saveMessages( $this->getNameInLayout(), $messages );
protected function _saveMessages($messages) {
if ($this->_fixMessages() && ! $this->_isEsiRequest()) {
Mage::getSingleton('turpentine/session')
->saveMessages($this->getNameInLayout(), $messages);
}
}

Expand All @@ -262,14 +262,14 @@ protected function _saveMessages( $messages ) {
* @return null
*/
protected function _loadMessages() {
if( $this->getNameInLayout() == 'messages' ) {
foreach( $this->_messageStorageTypes as $type ) {
$storage = sprintf( '%s/session', $type );
$this->addStorageType( $storage );
$this->_loadMessagesFromStorage( $storage );
if ($this->getNameInLayout() == 'messages') {
foreach ($this->_messageStorageTypes as $type) {
$storage = sprintf('%s/session', $type);
$this->addStorageType($storage);
$this->_loadMessagesFromStorage($storage);
}
} else {
$this->_loadMessagesFromStorage( 'core/session' );
$this->_loadMessagesFromStorage('core/session');
}
}

Expand All @@ -279,9 +279,9 @@ protected function _loadMessages() {
* @return null
*/
protected function _loadSavedMessages() {
$session = Mage::getSingleton( 'turpentine/session' );
foreach( $session->loadMessages( $this->getNameInLayout() ) as $msg ) {
parent::addMessage( $msg );
$session = Mage::getSingleton('turpentine/session');
foreach ($session->loadMessages($this->getNameInLayout()) as $msg) {
parent::addMessage($msg);
}
$this->_clearMessages();
}
Expand All @@ -292,10 +292,10 @@ protected function _loadSavedMessages() {
* @param string $type
* @return null
*/
protected function _loadMessagesFromStorage( $type ) {
foreach( Mage::getSingleton( $type )
->getMessages( true )->getItems() as $msg ) {
parent::addMessage( $msg );
protected function _loadMessagesFromStorage($type) {
foreach (Mage::getSingleton($type)
->getMessages(true)->getItems() as $msg) {
parent::addMessage($msg);
}
}

Expand All @@ -305,8 +305,8 @@ protected function _loadMessagesFromStorage( $type ) {
* @return null
*/
protected function _clearMessages() {
Mage::getSingleton( 'turpentine/session' )
->clearMessages( $this->getNameInLayout() );
Mage::getSingleton('turpentine/session')
->clearMessages($this->getNameInLayout());
}

/**
Expand All @@ -315,8 +315,8 @@ protected function _clearMessages() {
* @return string
*/
protected function _real_toHtml() {
if( !$this->_directCall ) {
switch( $this->getNameInLayout() ) {
if ( ! $this->_directCall) {
switch ($this->getNameInLayout()) {
case 'global_messages':
$this->_directCall = 'getHtml';
break;
Expand All @@ -326,9 +326,9 @@ protected function _real_toHtml() {
break;
}
}
switch( $this->_directCall ) {
switch ($this->_directCall) {
case 'getHtml':
$html = parent::getHtml( $this->_singleRenderType );
$html = parent::getHtml($this->_singleRenderType);
$this->_singleRenderType = self::NO_SINGLE_RENDER_TYPE;
break;
case 'getGroupedHtml':
Expand All @@ -346,7 +346,7 @@ protected function _real_toHtml() {
* @return bool
*/
protected function _fixMessages() {
return Mage::helper( 'turpentine/esi' )->shouldFixFlashMessages();
return Mage::helper('turpentine/esi')->shouldFixFlashMessages();
}

/**
Expand All @@ -358,7 +358,7 @@ protected function _fixMessages() {
* @return boolean
*/
protected function _isEsiRequest() {
return is_a( Mage::app()->getRequest(),
'Nexcessnet_Turpentine_Model_Dummy_Request' );
return is_a(Mage::app()->getRequest(),
'Nexcessnet_Turpentine_Model_Dummy_Request');
}
}
10 changes: 5 additions & 5 deletions app/code/community/Nexcessnet/Turpentine/Block/Management.php
Expand Up @@ -34,7 +34,7 @@ public function __construct() {
* @return string
*/
public function getFlushAllUrl() {
return $this->getUrl( '*/varnish_management/flushAll' );
return $this->getUrl('*/varnish_management/flushAll');
}

/**
Expand All @@ -43,7 +43,7 @@ public function getFlushAllUrl() {
* @return string
*/
public function getFlushPartialUrl() {
return $this->getUrl( '*/varnish_management/flushPartial' );
return $this->getUrl('*/varnish_management/flushPartial');
}

/**
Expand All @@ -52,7 +52,7 @@ public function getFlushPartialUrl() {
* @return string
*/
public function getFlushContentTypeUrl() {
return $this->getUrl( '*/varnish_management/flushContentType' );
return $this->getUrl('*/varnish_management/flushContentType');
}

/**
Expand All @@ -61,7 +61,7 @@ public function getFlushContentTypeUrl() {
* @return string
*/
public function getApplyConfigUrl() {
return $this->getUrl( '*/varnish_management/applyConfig' );
return $this->getUrl('*/varnish_management/applyConfig');
}

/**
Expand All @@ -88,7 +88,7 @@ public function getGetConfigUrl() {
* @param string $type
* @return string
*/
public function getSwitchNavigationUrl( $type ) {
public function getSwitchNavigationUrl($type) {
return $this->getUrl('*/varnish_management/switchNavigation', array('type' => $type));
}
}
Expand Up @@ -24,8 +24,8 @@ class Nexcessnet_Turpentine_Block_Poll_Activepoll extends Mage_Poll_Block_Active
public function setTemplate($template)
{
$this->_template = $template;
$this->setPollTemplate('turpentine/ajax.phtml', 'poll' );
$this->setPollTemplate('turpentine/ajax.phtml', 'results' );
$this->setPollTemplate('turpentine/ajax.phtml', 'poll');
$this->setPollTemplate('turpentine/ajax.phtml', 'results');
return $this;
}
}

0 comments on commit f944c8e

Please sign in to comment.