Skip to content

Commit

Permalink
Merge pull request #88 from magento-tango/MAGETWO-32571
Browse files Browse the repository at this point in the history
[Tango] S46 Controller Refactoring, Exceptions, Bug Fixes
  • Loading branch information
Dooffy committed Feb 12, 2015
2 parents bc18e4c + dfa392b commit b32bd91
Show file tree
Hide file tree
Showing 349 changed files with 3,543 additions and 1,379 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getUnreadMessages()
/**
* Retrieve popup title
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getPopupTitle()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function isDisplayed()
/**
* Retrieve message text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getText()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function _shouldBeDisplayed()
/**
* Retrieve message text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getText()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function _shouldBeDisplayed()
/**
* Retrieve message text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getText()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function isDisplayed()
/**
* Retrieve message text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getText()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/System/Account/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _construct()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getHeaderText()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/System/Store/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function _construct()
/**
* Get edit form container header text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getHeaderText()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/System/Variable/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getFormHtml()
/**
* Return translated header text depending on creating/editing action
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getHeaderText()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function _getShowEmptyStoresLabelFlag()
* Render row store views
*
* @param \Magento\Framework\Object $row
* @return string
* @return \Magento\Framework\Phrase|string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
Expand Down Expand Up @@ -135,7 +135,7 @@ public function render(\Magento\Framework\Object $row)
* Render row store views for export
*
* @param \Magento\Framework\Object $row
* @return string
* @return \Magento\Framework\Phrase|string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function renderExport(\Magento\Framework\Object $row)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Controller\Adminhtml\Dashboard;

class RefreshStatistics extends \Magento\Reports\Controller\Adminhtml\Report\Statistics
{
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
* @param array $reportTypes
* @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
array $reportTypes,
\Psr\Log\LoggerInterface $logger
) {
parent::__construct($context, $dateFilter, $resultRedirectFactory, $reportTypes);
$this->logger = $logger;
}

/**
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
try {
$collectionsNames = array_values($this->reportTypes);
foreach ($collectionsNames as $collectionName) {
$this->_objectManager->create($collectionName)->aggregate();
}
$this->messageManager->addSuccess(__('We updated lifetime statistic.'));
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t refresh lifetime statistics.'));
$this->logger->critical($e);
}
return $this->resultRedirectFactory->create()->setPath('*/*');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function execute()
$itemId = $this->getRequest()->getParam('item_id', null);
if (!($model = $this->_objectManager->create('Magento\Store\Model\Store')->load($itemId))) {
$this->messageManager->addError(__('Unable to proceed. Please, try again.'));
$this->_redirect('adminhtml/*/');
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
return $redirectResult->setPath('adminhtml/*/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(StoreManagerInterface $storeManager)
* Translate element attribute
*
* @param string $code
* @return string
* @return \Magento\Framework\Phrase|string
*/
protected function _getTranslatedAttribute($code)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected function _getStaticOptions(array $options)
* Translate a label
*
* @param string $label an option label that should be translated
* @return string the translated version of the input label
* @return \Magento\Framework\Phrase
*/
private function _translateLabel($label)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
</block>
</referenceContainer>
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
<block class="Magento\Backend\Block\Dashboard" name="dashboard">
<block class="Magento\Backend\Block\Template" name="refresh_statistics" template="Magento_Backend::dashboard/totalbar/refreshstatistics.phtml"/>
</block>
</referenceContainer>
</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ window.changeDiagramsPeriod = function(periodObj) {
<div class="dashboard-store-stats">
<?php echo $block->getChildHtml('grids') ?>
<div id="grid_tab_content" class="dashboard-store-stats-content"></div>
<?php echo $block->getChildHtml('refresh_statistics') ?>
</div>
</div>
<div class="dashboard-secondary">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<form action="<?php echo $block->getUrl('*/*/refreshStatistics'); ?>" method="post">
<input name="form_key" type="hidden" value="<?php echo $block->getFormKey(); ?>" />
<button type="submit" style="float:right; margin: 15px" title="Refresh data">
<?php echo __('Refresh data') ?>
</button>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ public function getProduct()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Bundle Items');
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public function isSalable($product)
* @param \Magento\Framework\Object $buyRequest
* @param \Magento\Catalog\Model\Product $product
* @param string $processMode
* @return array|string
* @return \Magento\Framework\Phrase|array|string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
Expand Down Expand Up @@ -852,7 +852,7 @@ private function multiToFlatArray(array $array)
/**
* Retrieve message for specify option(s)
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getSpecifyOptionMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function getTabsHtml()
}

/**
* @return string
* @return \Magento\Framework\Phrase|string
*/
public function getHeader()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region
/**
* Retrieve header text
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getHeaderText()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getSetFormHtml()
/**
* Retrieve Block Header Text
*
* @return string
* @return \Magento\Framework\Phrase
*/
protected function _getHeader()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _prepareLayout()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
protected function _getHeader()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getNewButtonHtml()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
protected function _getHeader()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ protected function _getAdditionalElementHtml($element)
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Attributes');
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public function getDefaultConfigValue($field)
/**
* Tab settings
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Advanced Inventory');
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function getStoreCollection(Group $group)
/**
* Tab settings
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Websites');
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct(
/**
* Get label
*
* @return string
* @return \Magento\Framework\Phrase
*/
public function getLabel()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Block/Adminhtml/Rss/Grid/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getLink()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getLabel()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Block/Category/Rss/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function isRssAllowed()
}

/**
* @return string
* @return \Magento\Framework\Phrase
*/
public function getLabel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function getAttributes()
*
* @param Product $product
* @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
* @return string
* @return \Magento\Framework\Phrase|string
*/
public function getProductAttributeValue($product, $attribute)
{
Expand Down
Loading

0 comments on commit b32bd91

Please sign in to comment.