Skip to content

Commit

Permalink
Merge pull request #11 from magento/2.3-develop
Browse files Browse the repository at this point in the history
2.3-Develop update
  • Loading branch information
speedy008 authored Nov 30, 2018
2 parents 22daf66 + 733f2fc commit edc9a5c
Show file tree
Hide file tree
Showing 156 changed files with 2,327 additions and 2,183 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ atlassian*
/.php_cs
/.php_cs.cache
/grunt-config.json
/dev/tools/grunt/configs/local-themes.js
/pub/media/*.*
!/pub/media/.htaccess
/pub/media/attribute/*
Expand Down
10 changes: 9 additions & 1 deletion app/code/Magento/Backend/Block/Page/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
}

/**
* @return void
* @inheritdoc
*/
protected function _construct()
{
Expand All @@ -57,4 +57,12 @@ public function getMagentoVersion()
{
return $this->productMetadata->getVersion();
}

/**
* @inheritdoc
*/
protected function getCacheLifetime()
{
return 3600 * 24 * 10;
}
}
34 changes: 31 additions & 3 deletions app/code/Magento/Backend/Block/System/Store/Delete/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,35 @@
*/
namespace Magento\Backend\Block\System\Store\Delete;

use Magento\Backup\Helper\Data as BackupHelper;
use Magento\Framework\App\ObjectManager;

/**
* Adminhtml cms block edit form
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Form extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
* @var BackupHelper
*/
private $backup;

/**
* @inheritDoc
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
array $data = [],
?BackupHelper $backup = null
) {
parent::__construct($context, $registry, $formFactory, $data);
$this->backup = $backup ?? ObjectManager::getInstance()->get(BackupHelper::class);
}

/**
* Init form
*
Expand All @@ -25,7 +47,7 @@ protected function _construct()
}

/**
* {@inheritdoc}
* @inheritDoc
*/
protected function _prepareForm()
{
Expand All @@ -45,15 +67,21 @@ protected function _prepareForm()

$fieldset->addField('item_id', 'hidden', ['name' => 'item_id', 'value' => $dataObject->getId()]);

$backupOptions = ['0' => __('No')];
$backupSelected = '0';
if ($this->backup->isEnabled()) {
$backupOptions['1'] = __('Yes');
$backupSelected = '1';
}
$fieldset->addField(
'create_backup',
'select',
[
'label' => __('Create DB Backup'),
'title' => __('Create DB Backup'),
'name' => 'create_backup',
'options' => ['1' => __('Yes'), '0' => __('No')],
'value' => '1'
'options' => $backupOptions,
'value' => $backupSelected
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Store controller
*
* @author Magento Core Team <core@magentocommerce.com>
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
abstract class Store extends Action
{
Expand Down Expand Up @@ -86,6 +87,8 @@ protected function createPage()
* Backup database
*
* @return bool
*
* @deprecated Backup module is to be removed.
*/
protected function _backupDatabase()
{
Expand Down
25 changes: 24 additions & 1 deletion app/code/Magento/Backup/Controller/Adminhtml/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

use Magento\Backend\App\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Backup\Helper\Data as Helper;
use Magento\Framework\App\ObjectManager;

/**
* Backup admin controller
*
* @author Magento Core Team <core@magentocommerce.com>
* @api
* @since 100.0.2
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
abstract class Index extends Action implements HttpGetActionInterface
{
Expand Down Expand Up @@ -51,27 +54,47 @@ abstract class Index extends Action implements HttpGetActionInterface
*/
protected $maintenanceMode;

/**
* @var Helper
*/
private $helper;

/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\Backup\Factory $backupFactory
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
* @param \Magento\Backup\Model\BackupFactory $backupModelFactory
* @param \Magento\Framework\App\MaintenanceMode $maintenanceMode
* @param Helper|null $helper
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\Backup\Factory $backupFactory,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
\Magento\Backup\Model\BackupFactory $backupModelFactory,
\Magento\Framework\App\MaintenanceMode $maintenanceMode
\Magento\Framework\App\MaintenanceMode $maintenanceMode,
?Helper $helper = null
) {
$this->_coreRegistry = $coreRegistry;
$this->_backupFactory = $backupFactory;
$this->_fileFactory = $fileFactory;
$this->_backupModelFactory = $backupModelFactory;
$this->maintenanceMode = $maintenanceMode;
$this->helper = $helper ?? ObjectManager::getInstance()->get(Helper::class);
parent::__construct($context);
}

/**
* @inheritDoc
*/
public function dispatch(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->helper->isEnabled()) {
return $this->_redirect('*/*/disabled');
}

return parent::dispatch($request);
}
}
48 changes: 48 additions & 0 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Disabled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Backup\Controller\Adminhtml\Index;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;

/**
* Inform that backup is disabled.
*/
class Disabled extends Action implements HttpGetActionInterface
{
/**
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_Backend::backup';

/**
* @var PageFactory
*/
private $pageFactory;

/**
* @param Context $context
* @param PageFactory $pageFactory
*/
public function __construct(Context $context, PageFactory $pageFactory)
{
parent::__construct($context);
$this->pageFactory = $pageFactory;
}

/**
* @inheritDoc
*/
public function execute()
{
return $this->pageFactory->create();
}
}
7 changes: 7 additions & 0 deletions app/code/Magento/Backup/Cron/SystemBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Store\Model\ScopeInterface;

/**
* Performs scheduled backup.
*/
class SystemBackup
{
const XML_PATH_BACKUP_ENABLED = 'system/backup/enabled';
Expand Down Expand Up @@ -101,6 +104,10 @@ public function __construct(
*/
public function execute()
{
if (!$this->_backupData->isEnabled()) {
return $this;
}

if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
return $this;
}
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Backup/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Backup\Helper;

use Magento\Framework\App\Filesystem\DirectoryList;
Expand Down Expand Up @@ -285,4 +288,14 @@ public function extractDataFromFilename($filename)

return $result;
}

/**
* Is backup functionality enabled.
*
* @return bool
*/
public function isEnabled(): bool
{
return $this->scopeConfig->isSetFlag('system/backup/functionality_enabled');
}
}
Loading

0 comments on commit edc9a5c

Please sign in to comment.