Skip to content

Commit

Permalink
Fixes Fatal Error: Call to a member function toArray() on array for i…
Browse files Browse the repository at this point in the history
…dempotent invoke FlashMessenger
  • Loading branch information
samsonasik committed Jan 9, 2017
1 parent 692fe05 commit 741e746
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function onBootstrap(MvcEvent $e)
}

/**
* Used to re-fill flashMessenger data after it shown and gone.
* Used to re-fill flashMessenger data as it shown and gone.
*
* @param EventInterface
*/
Expand All @@ -65,15 +65,16 @@ public function flashMessengerHandler(EventInterface $e)
if ($controller->getPluginManager()->has('flashMessenger')) {
$flash = $controller->plugin('flashMessenger');
$container = $flash->getContainer();
$flashToolbarContainer = new Container('SanSessionToolbarFlashMessenger');

foreach ($container->getArrayCopy() as $key => $row) {
if ($row instanceof SplQueue) {
$valuesMessage = [];
foreach ($row->toArray() as $rowArray) {
$flash->setNamespace($key)->addMessage($rowArray);
$valuesMessage[] = $rowArray;
foreach ($row->toArray() as $keyArray => $rowArray) {
if ($keyArray === 0) {
$flashToolbarContainer->$key = new SplQueue();
}
$flashToolbarContainer->$key->push($rowArray);
}
$container->offsetSet($key, $valuesMessage);
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions test/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ public function testOnBootstrap($hasMessages)

$flashMessenger->getContainer()->willReturn($container)
->shouldBeCalled();
$flashMessenger->setNamespace($namespace)
->willReturn($flashMessenger)
->shouldBeCalled();
$flashMessenger->addMessage($message)
->willReturn($flashMessenger)
->shouldBeCalled();
}
$abstractActionController->plugin('flashMessenger')
->willReturn($flashMessenger)
Expand Down
15 changes: 11 additions & 4 deletions view/zend-developer-tools/toolbar/session-data-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
foreach ($sessionData as $containerName => $session) { ?>
<span class="zdt-toolbar-info san-session-toolbar-info-containerName-<?php echo $containerName; ?>">
<br>
<span class="zdt-detail-label" style="text-transform: none;"><a><?php echo $containerName; ?></a></span>
<a href="#" data-container="<?php echo $containerName; ?>" class="clearSessionOfContainer"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wIcEAIBFqROeQAAAjlJREFUOMuNkltIk2Ecxn/v9s1DbivxtEzyUFPBogy6UbuKDMkiAymquwUVSBdBXgSRdBVdViQFEkQGIV4VRhGSVqid1XDp5jZtLu0zT/t2+vzmulFYubT35v/y/p//w/s8z1/Pf5yXj+rRuodS6qqordyM51ilTnv+NQaAWG/45imJSZ9m3X/k4Ei2JXdq3P3t1aHLPSdW+rr1CC60alTX1bxQlZ+9C7JHkSd/2OP70lrDN46nEpgLVVgy0gqEKbPAKys0t3iux2PW/EHj4xClu0psQXmEWdlL72fnub4AkXVNO733LI4eyqdH61vftFjnu5vMsVu2LV2JsPpEjwO+jxQaLz0QmI+WVWQmZ5dbMFuC7+4+lNv+xib0wNu//aJ9QDvgdaXT2ZZL8c4xcgqdrxNhV8Xoel92Zau1/losOk1U9eEe9dH5JJ9n7UbrU2eLc02CoS5zzbayhg4BRLUJlFk3CD+xJT19nR+qDjfwNqEEx6ci5nyu/PyS8x2wkbAyiD5JR1QLoakzSClGpCRTHvhXSdABBKZdxaV7Gh0LM/ZYcN6BlBwjHDQidAssRlTAQMivhBN5oAPYXc3IhOt+h0HKEgKZYEAQCdhRw3MYNpSjRvQMDse+AynLyYk/CDLShSitkk/2f+m+rUbNTHnHEcLD0pIFZX6MgD958eo9XIARSAOSVkjiTUwFTICpvTnPVlBUss//y7spIydrx5hbvlN7ZrgJ0AAViCzf+Zcsw3IVcWlJiVb/N1zt3GxYq9vSAAAAAElFTkSuQmCC">Clear Session of <?php echo $containerName; ?> Container</a>
<?php if ($containerName !== 'FlashMessenger') { ?>
<span class="zdt-detail-label" style="text-transform: none;"><a><?php echo ($containerName === 'SanSessionToolbarFlashMessenger') ? $this->flashMessenger()->getContainer()->getName() : $containerName; ?></a></span>
<a href="#" data-container="<?php echo $containerName; ?>" class="clearSessionOfContainer"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wIcEAIBFqROeQAAAjlJREFUOMuNkltIk2Ecxn/v9s1DbivxtEzyUFPBogy6UbuKDMkiAymquwUVSBdBXgSRdBVdViQFEkQGIV4VRhGSVqid1XDp5jZtLu0zT/t2+vzmulFYubT35v/y/p//w/s8z1/Pf5yXj+rRuodS6qqordyM51ilTnv+NQaAWG/45imJSZ9m3X/k4Ei2JXdq3P3t1aHLPSdW+rr1CC60alTX1bxQlZ+9C7JHkSd/2OP70lrDN46nEpgLVVgy0gqEKbPAKys0t3iux2PW/EHj4xClu0psQXmEWdlL72fnub4AkXVNO733LI4eyqdH61vftFjnu5vMsVu2LV2JsPpEjwO+jxQaLz0QmI+WVWQmZ5dbMFuC7+4+lNv+xib0wNu//aJ9QDvgdaXT2ZZL8c4xcgqdrxNhV8Xoel92Zau1/losOk1U9eEe9dH5JJ9n7UbrU2eLc02CoS5zzbayhg4BRLUJlFk3CD+xJT19nR+qDjfwNqEEx6ci5nyu/PyS8x2wkbAyiD5JR1QLoakzSClGpCRTHvhXSdABBKZdxaV7Gh0LM/ZYcN6BlBwjHDQidAssRlTAQMivhBN5oAPYXc3IhOt+h0HKEgKZYEAQCdhRw3MYNpSjRvQMDse+AynLyYk/CDLShSitkk/2f+m+rUbNTHnHEcLD0pIFZX6MgD958eo9XIARSAOSVkjiTUwFTICpvTnPVlBUss//y7spIydrx5hbvlN7ZrgJ0AAViCzf+Zcsw3IVcWlJiVb/N1zt3GxYq9vSAAAAAElFTkSuQmCC">Clear Session of <?php echo ($containerName === 'SanSessionToolbarFlashMessenger') ? $this->flashMessenger()->getContainer()->getName() : $containerName; ?> Container</a>
<?php if ($containerName !== 'SanSessionToolbarFlashMessenger') { ?>
&nbsp;|&nbsp;<a href="#" class="addNewSessionData" data-container="<?php echo $containerName; ?>"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wMbCTUKojG+MwAAAepJREFUOMuNkr1PU2EUxn/v/aLeUtq0sZVgagwxrSEkbmzi6mIkOEPixB/AaBgwJi5OjYOLQcJoAsaPOKghMSEODiqiYiBRUWpt/WhL2wu93sPQNgLtNZzl5Jw873POed5H4RMiEgcGgCCwBqwrpeoHcYYfwbfCUu7LzzuICOFgmkjX6CRw49AEpeoG+fJbNM3EcSsEQufNTjhfAg9wPUFD8MQD1Rln+GsArgdaM/uF0RTsOuC0mn89z1lavYbrKZQSavUqITsSFpHUnreaUuq9WngwE4j0r9U+fr/bmg1Kw9J70JXR6hAKJLGteLOCZOwsp/suKcMKOamt+jblHdmngPBn36r5SuFfoRQuNo+f306r/hF6Fm7OF1c27zd0UorqTp5scbl5oSAIR7tPED5yEpHGoIHeCwymL9rG+jylRyNzzyyje7s14HhsOJqMGkPZ0jKgCJo2p6yJlVerDzdaN3x+N9dFmRpj04k2ZV++fnru3psJySymJLOYkpkXw5L9sTl5EDc2ncCYncq1EVSdX5YV0rFMDQDL1Kk5W21fPjuV8/eBoStMveEeS9f+74O2Deq/GewdJWwfQ1M6sWCKSiHf0Ysdm0OXCcRjXEn3nYnWPcdd/vShqIRbTzJ85bAxvkfc8asJX9wugxWw9upyQDoAAAAASUVORK5CYII="> Add New Session Data</a>
<?php } ?>
</span>
Expand Down Expand Up @@ -36,7 +36,7 @@
<?php if (is_scalar($rowsession)) { ?>
<a href="#" class="editSessionByKey" data-container="<?php echo $containerName; ?>" data-keySession="<?php echo $keysession; ?>"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wIcEQ45k9HT3AAAAZtJREFUOMtjYKAHYGdnJ18zGxsbAwMDA8PE2bsL1u+4cNHAMsyAZM3d07ZXHD718P+R0w//r99x+a+eeYgRTA0TPs2/fv1iaOjZWKGhptT+4dN3hvcfvzOwsLAyJSQmr4OpY8GmmZmZmeHXr18MlW3rKpQU5do/fPoOl2NiYmY4deLofhifEZvmv3//MuTXrixXVpLvYPj/H6GZmYVh/+71q9YuaYtmYGD4g2EATHNm+dJyKSmpDpj4//8Qm48f3rJy6+quGJhmrC5IL11aLiQi2sHECNH45+8/hj9/GRgun921cveGPhTNDAwMDMzInPa0evsfYupLOFiZGNjZWBgYmRgZGBiYGS6c2olVM0Yghov8nHSP+wXDZUF1BnZmRobffxgYDu3buHLXhl6smlGicV96ugM7D5+eHtc3BivW1wwMLGwMJ49sWbl2SRtOzSguUBQWnsjIwsLAzMjEwPzw4qtDRxa2rNi+Zjo+zXBgaGJi3xAT8/9UWdnLAlfXPAYGBg6S0ruxsfF0OQUF0jUyMDAwHDx4kKKcCgCbuZBiqF2uRAAAAABJRU5ErkJggg==" alt="Edit Session" title="Edit Session"></a>
<?php } else { echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } ?>
<?php if ($containerName !== 'FlashMessenger') { ?>
<?php if ($containerName !== 'SanSessionToolbarFlashMessenger') { ?>
<a href="#" class="removeSessionByKey" data-row-class="removeSessionByKey-<?php echo $keysession?>" data-container="<?php echo $containerName; ?>" data-keySession="<?php echo $keysession; ?>">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACRklEQVR42mNkoBAwUtWAhYyMpjLWlutenziVGvHnzw5kuaVMTB6StlZznh89ERj9589pDAPmMDCYyirL7rJMTRU4t27tj4enLgbFMzBsB8nNY2DwVDLWWWcUHsFxfN68D89u3HNLZGA4jWLAUnaWx/ZpCTJM/9gZGLg5GM7u3fFj79mrwSA5F0OttUZObhwMP34zMEoIMexraXsS/fOvLIoBkxkYPOTVZderGFtw/P31n4GRj5th79kTPxn//2dwMjJn///lOwMLNzvD3Yvnfjy6cD0wi4FhB0YY9AGdKqciuU5BWYPj77c/DP8EeMAKmD5/Z+CQl2S4ffLYjyc3HgblQ72GNRY6gIbIK4mtUxCT5vjz/R/Df2ZmBgYOBoZHT+//eP7wfVApkmasBjQDDVCUE1on9+UHx69338BibEJcDI94OX88fPg2qBqfAbVAzaryousMP3/n+PvuC8MPYV6wAva3nxmYhXkYzvNy/7j74GVQIzYvVHCye2pKiqxz/PiZg+HtJ4ZfokIMdTwcPxkYGf83AQ1ke/2OgUFEgGE/P/+Pt/+Zg4ru3duOYkCjqsyTDG5+aa4LVxl+iYkw1PHx/Lhz50HwX6Cchori2sZPnznYXr1h+Gakx7DhP/OT9PPnUaOxhIXZVFVKclegsJDAjC9ffpy6fS94CwPDNpCcF9Br1qpK61J5eTjWv3n34cGTZ27t//6dxgiDYj4ucy5x4XVP7z9LmffnL0pgZbCyenqamc65eP5CQN23b5hJmSqZiRwAABaj2REhYuqwAAAAAElFTkSuQmCC" alt="Remove Session"
title="Remove Session" /></a>&nbsp;
Expand Down Expand Up @@ -67,6 +67,13 @@
</span>
<?php } ?>

<?php
if ($containerName === 'SanSessionToolbarFlashMessenger') {
$container = new Zend\Session\Container($containerName);
$container->offsetUnset($keysession);
}
?>

<?php }
}
} else { ?>
Expand Down

0 comments on commit 741e746

Please sign in to comment.