Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions app/code/community/Inviqa/SymfonyContainer/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ class Inviqa_SymfonyContainer_Model_Observer

public function onCacheRefresh(Varien_Event_Observer $event)
{
if (ConfigurationBuilder::MODEL_ALIAS === $event->getType()) {
$containerFilePath = $this->containerCachePath();
$metaFilePath = $this->containerCacheMetaPath();

if (file_exists($containerFilePath)) {
unlink($containerFilePath);
}

if (file_exists($metaFilePath)) {
unlink($metaFilePath);
}
if ($event->getType() === ConfigurationBuilder::MODEL_ALIAS) {
$this->clearCache();
}
}

public function onCacheFlush()
{
$this->clearCache();
}

public function onPreDispatch(Varien_Event_Observer $event)
{
$controller = $event->getControllerAction();
Expand All @@ -34,6 +31,20 @@ public function onPreDispatch(Varien_Event_Observer $event)
])->setupDependencies($controller);
}

private function clearCache()
{
$containerFilePath = $this->containerCachePath();
$metaFilePath = $this->containerCacheMetaPath();

if (file_exists($containerFilePath)) {
unlink($containerFilePath);
}

if (file_exists($metaFilePath)) {
unlink($metaFilePath);
}
}

private function containerCachePath()
{
return Mage::getBaseDir('cache') . DIRECTORY_SEPARATOR . ConfigurationBuilder::CACHED_CONTAINER;
Expand Down
20 changes: 19 additions & 1 deletion app/code/community/Inviqa/SymfonyContainer/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
</inviqa_symfonyContainer>
</observers>
</adminhtml_cache_refresh_type>
<adminhtml_cache_flush_all>
<observers>
<inviqa_symfonyContainer>
<class>Inviqa_SymfonyContainer_Model_Observer</class>
<type>singleton</type>
<method>onCacheFlush</method>
</inviqa_symfonyContainer>
</observers>
</adminhtml_cache_flush_all>
<adminhtml_cache_flush_system>
<observers>
<inviqa_symfonyContainer>
<class>Inviqa_SymfonyContainer_Model_Observer</class>
<type>singleton</type>
<method>onCacheFlush</method>
</inviqa_symfonyContainer>
</observers>
</adminhtml_cache_flush_system>
<controller_action_predispatch>
<observers>
<inviqa_symfonyContainer>
Expand All @@ -43,4 +61,4 @@
</cache>
</global>

</config>
</config>