Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto MC-19689
  • Loading branch information
dhorytskyi committed Aug 30, 2019
2 parents 239ef14 + b0e9433 commit c243fc7
Show file tree
Hide file tree
Showing 32 changed files with 820 additions and 326 deletions.
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\Backend\Block\System\Store\Edit\Form;

/**
Expand Down Expand Up @@ -129,6 +132,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'label' => __('Sort Order'),
'value' => $storeModel->getSortOrder(),
'required' => false,
'class' => 'validate-number validate-zero-or-greater',
'disabled' => $storeModel->isReadOnly()
]
);
Expand Down
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\Backend\Block\System\Store\Edit\Form;

/**
Expand Down Expand Up @@ -85,6 +88,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'label' => __('Sort Order'),
'value' => $websiteModel->getSortOrder(),
'required' => false,
'class' => 'validate-number validate-zero-or-greater',
'disabled' => $websiteModel->isReadOnly()
]
);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Minute,Minute
"To use this website you must first enable JavaScript in your browser.","To use this website you must first enable JavaScript in your browser."
"This is only a demo store. You can browse and place orders, but nothing will be processed.","This is only a demo store. You can browse and place orders, but nothing will be processed."
"Report an Issue","Report an Issue"
"Store View:","Store View:"
"Scope:","Scope:"
"Stores Configuration","Stores Configuration"
"Please confirm scope switching. All data that hasn't been saved will be lost.","Please confirm scope switching. All data that hasn't been saved will be lost."
"Additional Cache Management","Additional Cache Management"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?php if ($websites = $block->getWebsites()) : ?>

<div class="store-switcher store-view">
<span class="store-switcher-label"><?= $block->escapeHtml(__('Store View:')) ?></span>
<span class="store-switcher-label"><?= $block->escapeHtml(__('Scope:')) ?></span>
<div class="actions dropdown closable">
<input type="hidden" name="store_switcher" id="store_switcher"
data-role="store-view-id" data-param="<?= $block->escapeHtmlAttr($block->getStoreVarName()) ?>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
<!-- ko if: Array.isArray(option.value) -->
<span data-bind="html: option.value.join('<br>')"></span>
<!-- /ko -->
<!-- ko ifnot: Array.isArray(option.value) -->
<!-- ko if: (!Array.isArray(option.value) && option.option_type == 'file') -->
<span data-bind="html: option.value"></span>
<!-- /ko -->
<!-- ko if: (!Array.isArray(option.value) && option.option_type != 'file') -->
<span data-bind="text: option.value"></span>
<!-- /ko -->
</dd>
Expand Down
45 changes: 41 additions & 4 deletions app/code/Magento/Cron/Console/Command/CronInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Cron\Console\Command;

use Magento\Framework\Crontab\CrontabManagerInterface;
Expand All @@ -19,6 +21,9 @@
*/
class CronInstallCommand extends Command
{
private const COMMAND_OPTION_FORCE = 'force';
private const COMMAND_OPTION_NON_OPTIONAL = 'non-optional';

/**
* @var CrontabManagerInterface
*/
Expand All @@ -44,19 +49,27 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
protected function configure()
{
$this->setName('cron:install')
->setDescription('Generates and installs crontab for current user')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install tasks');
->addOption(self::COMMAND_OPTION_FORCE, 'f', InputOption::VALUE_NONE, 'Force install tasks')
// @codingStandardsIgnoreStart
->addOption(self::COMMAND_OPTION_NON_OPTIONAL, 'd', InputOption::VALUE_NONE, 'Install only the non-optional (default) tasks');
// @codingStandardsIgnoreEnd

parent::configure();
}

/**
* {@inheritdoc}
* Executes "cron:install" command.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null
* @throws LocalizedException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand All @@ -65,8 +78,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
return Cli::RETURN_FAILURE;
}

$tasks = $this->tasksProvider->getTasks();
if ($input->getOption(self::COMMAND_OPTION_NON_OPTIONAL)) {
$tasks = $this->extractNonOptionalTasks($tasks);
}

try {
$this->crontabManager->saveTasks($this->tasksProvider->getTasks());
$this->crontabManager->saveTasks($tasks);
} catch (LocalizedException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return Cli::RETURN_FAILURE;
Expand All @@ -76,4 +94,23 @@ protected function execute(InputInterface $input, OutputInterface $output)

return Cli::RETURN_SUCCESS;
}

/**
* Returns an array of non-optional tasks
*
* @param array $tasks
* @return array
*/
private function extractNonOptionalTasks(array $tasks = []): array
{
$defaultTasks = [];

foreach ($tasks as $taskCode => $taskParams) {
if (!$taskParams['optional']) {
$defaultTasks[$taskCode] = $taskParams;
}
}

return $defaultTasks;
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Cron/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@
<argument name="tasks" xsi:type="array">
<item name="cronMagento" xsi:type="array">
<item name="command" xsi:type="string">{magentoRoot}bin/magento cron:run | grep -v "Ran jobs by schedule" >> {magentoLog}magento.cron.log</item>
<item name="optional" xsi:type="boolean">false</item>
</item>
<item name="cronUpdate" xsi:type="array">
<item name="command" xsi:type="string">{magentoRoot}update/cron.php >> {magentoLog}update.cron.log</item>
<item name="optional" xsi:type="boolean">true</item>
</item>
<item name="cronSetup" xsi:type="array">
<item name="command" xsi:type="string">{magentoRoot}bin/magento setup:cron:run >> {magentoLog}setup.cron.log</item>
<item name="optional" xsi:type="boolean">true</item>
</item>
</argument>
</arguments>
Expand Down
57 changes: 41 additions & 16 deletions app/code/Magento/Customer/Block/Widget/Dob.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,34 @@ public function isRequired()
*/
public function setDate($date)
{
$this->setTime($date ? strtotime($date) : false);
$this->setTime($this->filterTime($date));
$this->setValue($this->applyOutputFilter($date));
return $this;
}

/**
* Sanitizes time
*
* @param mixed $value
* @return bool|int
*/
private function filterTime($value)
{
$time = false;
if ($value) {
if ($value instanceof \DateTimeInterface) {
$time = $value->getTimestamp();
} elseif (is_numeric($value)) {
$time = $value;
} elseif (is_string($value)) {
$time = strtotime($value);
$time = $time === false ? $this->_localeDate->date($value, null, false, false)->getTimestamp() : $time;
}
}

return $time;
}

/**
* Return Data Form Filter or false
*
Expand Down Expand Up @@ -200,21 +223,23 @@ public function getStoreLabel($attributeCode)
*/
public function getFieldHtml()
{
$this->dateElement->setData([
'extra_params' => $this->getHtmlExtraParams(),
'name' => $this->getHtmlId(),
'id' => $this->getHtmlId(),
'class' => $this->getHtmlClass(),
'value' => $this->getValue(),
'date_format' => $this->getDateFormat(),
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => $this->getFirstDay()
]);
$this->dateElement->setData(
[
'extra_params' => $this->getHtmlExtraParams(),
'name' => $this->getHtmlId(),
'id' => $this->getHtmlId(),
'class' => $this->getHtmlClass(),
'value' => $this->getValue(),
'date_format' => $this->getDateFormat(),
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
'years_range' => '-120y:c+nn',
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both',
'first_day' => $this->getFirstDay()
]
);
return $this->dateElement->getHtml();
}

Expand Down
Loading

0 comments on commit c243fc7

Please sign in to comment.