init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Stemcell\ProductImport\Plugin;
|
||||
|
||||
use Magento\Framework\View\Element\Html\Calendar;
|
||||
use Magento\Framework\Locale\Bundle\DataBundle;
|
||||
|
||||
class FixCalendarIcuData
|
||||
{
|
||||
/**
|
||||
* Fix ICU data issues in calendar component
|
||||
*
|
||||
* @param Calendar $subject
|
||||
* @param \Closure $proceed
|
||||
* @return string
|
||||
*/
|
||||
public function aroundToHtml(Calendar $subject, \Closure $proceed)
|
||||
{
|
||||
try {
|
||||
$result = $proceed();
|
||||
if (empty($result)) {
|
||||
throw new \Exception('Empty result from calendar component');
|
||||
}
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
// If there's an error with ICU data, return a basic calendar implementation
|
||||
$days = [
|
||||
'wide' => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
'abbreviated' => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
||||
];
|
||||
|
||||
$months = [
|
||||
'wide' => ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
'abbreviated' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
];
|
||||
|
||||
$subject->assign('days', [
|
||||
'wide' => json_encode($days['wide']),
|
||||
'abbreviated' => json_encode($days['abbreviated'])
|
||||
]);
|
||||
|
||||
$subject->assign('months', [
|
||||
'wide' => json_encode($months['wide']),
|
||||
'abbreviated' => json_encode($months['abbreviated'])
|
||||
]);
|
||||
|
||||
$subject->assign('am', json_encode('AM'));
|
||||
$subject->assign('pm', json_encode('PM'));
|
||||
$subject->assign('firstDay', 0);
|
||||
$subject->assign('weekendDays', json_encode('0,6'));
|
||||
$subject->assign('defaultFormat', json_encode('MM/dd/yyyy'));
|
||||
$subject->assign('toolTipFormat', json_encode('MMMM d, yyyy'));
|
||||
|
||||
$enUS = new \stdClass();
|
||||
$enUS->m = new \stdClass();
|
||||
$enUS->m->wide = $months['wide'];
|
||||
$enUS->m->abbr = $months['abbreviated'];
|
||||
$subject->assign('enUS', json_encode($enUS));
|
||||
|
||||
return $subject->fetchView($subject->getTemplateFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user