Skip to content

Commit

Permalink
EZP-23867: Switchable now has methods isSwitchedOn/isSwitchedOff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertrand Dunogier committed Jan 15, 2015
1 parent c12b9d1 commit 29f7f89
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
14 changes: 7 additions & 7 deletions eZ/Bundle/EzPublishLegacyBundle/Cache/PersistenceCachePurger.php
Expand Up @@ -66,7 +66,7 @@ public function __construct( CacheServiceDecorator $cache, LocationHandlerInterf
*/
public function all()
{
if ( $this->getSwitch() === false )
if ( $this->isSwitchedOff() )
return;

$this->cache->clear();
Expand Down Expand Up @@ -108,7 +108,7 @@ public function resetAllCleared()
*/
public function content( $locationIds = null )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return $locationIds;

if ( $locationIds === null )
Expand Down Expand Up @@ -160,7 +160,7 @@ public function content( $locationIds = null )
*/
public function contentType( $id = null )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return;

if ( $id === null )
Expand All @@ -187,7 +187,7 @@ public function contentType( $id = null )
*/
public function contentTypeGroup( $id = null )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return;

if ( $id === null )
Expand Down Expand Up @@ -215,7 +215,7 @@ public function contentTypeGroup( $id = null )
*/
public function section( $id = null )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return;

if ( $id === null )
Expand All @@ -239,7 +239,7 @@ public function section( $id = null )
*/
public function languages( $ids )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return;

$ids = (array)$ids;
Expand All @@ -255,7 +255,7 @@ public function languages( $ids )
*/
public function user( $id = null )
{
if ( $this->allCleared === true || $this->getSwitch() === false )
if ( $this->allCleared === true || $this->isSwitchedOff() )
return;

if ( $id === null )
Expand Down
13 changes: 11 additions & 2 deletions eZ/Bundle/EzPublishLegacyBundle/Cache/Switchable.php
Expand Up @@ -23,11 +23,20 @@ public function switchOff()
}

/**
* Returns the value of the switch
* Checks if the switch is off
* @return bool
*/
public function getSwitch()
public function isSwitchedOn()
{
return $this->isSwitchedOn;
}

/**
* Checks if the switch is off
* @return bool
*/
public function isSwitchedOff()
{
return !$this->isSwitchedOn;
}
}
Expand Up @@ -26,7 +26,7 @@ public function __construct( GatewayCachePurger $gatewayCachePurger )

public function purge( $cacheElements )
{
if ( $this->getSwitch() === false )
if ( $this->isSwitchedOff() )
{
return $cacheElements;
}
Expand All @@ -36,7 +36,7 @@ public function purge( $cacheElements )

public function purgeAll()
{
if ( $this->getSwitch() === false )
if ( $this->isSwitchedOff() )
{
return;
}
Expand Down

0 comments on commit 29f7f89

Please sign in to comment.