Skip to content

Fixed coding standard violations in the Framework\Data namespace #9330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions lib/internal/Magento/Framework/Data/Form/Element/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Data\Form\Element;

use Magento\Framework\Escaper;
Expand Down Expand Up @@ -123,7 +121,15 @@ public function getElementHtml()
'
<script type="text/javascript">
//<![CDATA[
window.tinyMCE_GZ = window.tinyMCE_GZ || {}; window.tinyMCE_GZ.loaded = true;require(["jquery", "mage/translate", "mage/adminhtml/events", "mage/adminhtml/wysiwyg/tiny_mce/setup", "mage/adminhtml/wysiwyg/widget"], function(jQuery){' .
window.tinyMCE_GZ = window.tinyMCE_GZ || {};
window.tinyMCE_GZ.loaded = true;
require([
"jquery",
"mage/translate",
"mage/adminhtml/events",
"mage/adminhtml/wysiwyg/tiny_mce/setup",
"mage/adminhtml/wysiwyg/widget"
], function(jQuery){' .
"\n" .
' (function($) {$.mage.translate.add(' .
\Zend_Json::encode(
Expand Down Expand Up @@ -254,9 +260,9 @@ protected function _getPluginButtonsHtml($visible = true)
$buttonsHtml .= $this->_getButtonHtml(
[
'title' => $this->translate('Insert Widget...'),
'onclick' => "widgetTools.openDialog('" . $this->getConfig(
'widget_window_url'
) . "widget_target_id/" . $this->getHtmlId() . "')",
'onclick' => "widgetTools.openDialog('"
. $this->getConfig('widget_window_url')
. "widget_target_id/" . $this->getHtmlId() . "')",
'class' => 'action-add-widget plugin',
'style' => $visible ? '' : 'display:none',
]
Expand All @@ -268,13 +274,12 @@ protected function _getPluginButtonsHtml($visible = true)
$buttonsHtml .= $this->_getButtonHtml(
[
'title' => $this->translate('Insert Image...'),
'onclick' => "MediabrowserUtility.openDialog('" . $this->getConfig(
'files_browser_window_url'
) . "target_element_id/" . $this->getHtmlId() . "/" . (null !== $this->getConfig(
'store_id'
) ? 'store/' . $this->getConfig(
'store_id'
) . '/' : '') . "')",
'onclick' => "MediabrowserUtility.openDialog('"
. $this->getConfig('files_browser_window_url')
. "target_element_id/" . $this->getHtmlId() . "/"
. (null !== $this->getConfig('store_id') ? 'store/'
. $this->getConfig('store_id') . '/' : '')
. "')",
'class' => 'action-add-image plugin',
'style' => $visible ? '' : 'display:none',
]
Expand Down Expand Up @@ -389,13 +394,11 @@ protected function _wrapIntoContainer($html)
return '<div class="admin__control-wysiwig">' .$html . '</div>';
}

$html = '<div id="editor' . $this->getHtmlId() . '"' . ($this->getConfig(
'no_display'
) ? ' style="display:none;"' : '') . ($this->getConfig(
'container_class'
) ? ' class="admin__control-wysiwig ' . $this->getConfig(
'container_class'
) . '"' : '') . '>' . $html . '</div>';
$html = '<div id="editor' . $this->getHtmlId() . '"'
. ($this->getConfig('no_display') ? ' style="display:none;"' : '')
. ($this->getConfig('container_class') ? ' class="admin__control-wysiwig '
. $this->getConfig('container_class') . '"' : '')
. '>' . $html . '</div>';

return $html;
}
Expand Down
26 changes: 18 additions & 8 deletions lib/internal/Magento/Framework/Data/Form/Element/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Category form input image element
*
Expand Down Expand Up @@ -43,10 +41,18 @@ public function getElementHtml()
$gallery = $this->getValue();

$html = '<table id="gallery" class="gallery" border="0" cellspacing="3" cellpadding="0">';
$html .= '<thead id="gallery_thead" class="gallery"><tr class="gallery"><td class="gallery" valign="middle" align="center">Big Image</td><td class="gallery" valign="middle" align="center">Thumbnail</td><td class="gallery" valign="middle" align="center">Small Thumb</td><td class="gallery" valign="middle" align="center">Sort Order</td><td class="gallery" valign="middle" align="center">Delete</td></tr></thead>';
$html .= '<thead id="gallery_thead" class="gallery">' .
'<tr class="gallery">' .
'<td class="gallery" valign="middle" align="center">Big Image</td>' .
'<td class="gallery" valign="middle" align="center">Thumbnail</td>' .
'<td class="gallery" valign="middle" align="center">Small Thumb</td>' .
'<td class="gallery" valign="middle" align="center">Sort Order</td>' .
'<td class="gallery" valign="middle" align="center">Delete</td>' .
'</tr>'.
'</thead>';
$widgetButton = $this->getForm()->getParent()->getLayout();
$buttonHtml = $widgetButton->createBlock(
\Magento\Backend\Block\Widget\Button::class
\Magento\Backend\Block\Widget\Button::class
)->setData(
['label' => 'Add New Image', 'onclick' => 'addNewImg()', 'class' => 'add']
)->toHtml();
Expand All @@ -60,7 +66,7 @@ public function getElementHtml()
$html .= '<tbody class="gallery">';

$i = 0;
if (!is_null($this->getValue())) {
if ($this->getValue() !== null) {
foreach ($this->getValue() as $image) {
$i++;
$html .= '<tr class="gallery">';
Expand Down Expand Up @@ -102,7 +108,8 @@ public function getElementHtml()
'file'
) . ' ></td>';
}
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;"><input type="input" name="' .
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;">' .
'<input type="input" name="' .
parent::getName() .
'[position][' .
$image->getValueId() .
Expand All @@ -116,7 +123,8 @@ public function getElementHtml()
$this->_getUiId(
'position-' . $image->getValueId()
) . '/></td>';
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;"><input type="checkbox" name="' .
$html .= '<td class="gallery" align="center" style="vertical-align:bottom;">' .
'<input type="checkbox" name="' .
parent::getName() .
'[delete][' .
$image->getValueId() .
Expand All @@ -134,7 +142,9 @@ public function getElementHtml()
}
}
if ($i == 0) {
$html .= '<script type="text/javascript">document.getElementById("gallery_thead").style.visibility="hidden";</script>';
$html .= '<script type="text/javascript">' .
'document.getElementById("gallery_thead").style.visibility="hidden";' .
'</script>';
}

$html .= '</tbody></table>';
Expand Down
44 changes: 18 additions & 26 deletions lib/internal/Magento/Framework/Data/Form/Element/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Form time element
*
Expand Down Expand Up @@ -54,52 +52,46 @@ public function getElementHtml()
{
$this->addClass('select admin__control-select');

$value_hrs = 0;
$value_min = 0;
$value_sec = 0;
$valueHrs = 0;
$valueMin = 0;
$valueSec = 0;

if ($value = $this->getValue()) {
$values = explode(',', $value);
if (is_array($values) && count($values) == 3) {
$value_hrs = $values[0];
$value_min = $values[1];
$value_sec = $values[2];
$valueHrs = $values[0];
$valueMin = $values[1];
$valueSec = $values[2];
}
}

$html = '<input type="hidden" id="' . $this->getHtmlId() . '" ' . $this->_getUiId() . '/>';
$html .= '<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
$this->getHtmlAttributes()
) . $this->_getUiId(
'hour'
) . '>' . "\n";
$html .= '<select name="' . $this->getName() . '" style="width:80px" '
. $this->serialize($this->getHtmlAttributes())
. $this->_getUiId('hour') . '>' . "\n";
for ($i = 0; $i < 24; $i++) {
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
$html .= '<option value="' . $hour . '" ' . ($value_hrs ==
$html .= '<option value="' . $hour . '" ' . ($valueHrs ==
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
}
$html .= '</select>' . "\n";

$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
$this->getHtmlAttributes()
) . $this->_getUiId(
'minute'
) . '>' . "\n";
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" '
. $this->serialize($this->getHtmlAttributes())
. $this->_getUiId('minute') . '>' . "\n";
for ($i = 0; $i < 60; $i++) {
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
$html .= '<option value="' . $hour . '" ' . ($value_min ==
$html .= '<option value="' . $hour . '" ' . ($valueMin ==
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
}
$html .= '</select>' . "\n";

$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" ' . $this->serialize(
$this->getHtmlAttributes()
) . $this->_getUiId(
'second'
) . '>' . "\n";
$html .= ':&nbsp;<select name="' . $this->getName() . '" style="width:80px" '
. $this->serialize($this->getHtmlAttributes())
. $this->_getUiId('second') . '>' . "\n";
for ($i = 0; $i < 60; $i++) {
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
$html .= '<option value="' . $hour . '" ' . ($value_sec ==
$html .= '<option value="' . $hour . '" ' . ($valueSec ==
$i ? 'selected="selected"' : '') . '>' . $hour . '</option>';
}
$html .= '</select>' . "\n";
Expand Down
7 changes: 4 additions & 3 deletions lib/internal/Magento/Framework/Data/FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Data;

/**
Expand Down Expand Up @@ -54,7 +52,10 @@ public function create(array $data = [])
$form = $this->_objectManager->create($this->_instanceName, $data);
if (!$form instanceof \Magento\Framework\Data\Form) {
throw new \Magento\Framework\Exception\LocalizedException(
new \Magento\Framework\Phrase('%1 doesn\'t extend \Magento\Framework\Data\Form', [$this->_instanceName])
new \Magento\Framework\Phrase(
'%1 doesn\'t extend \Magento\Framework\Data\Form',
[$this->_instanceName]
)
);
}
return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Data\Test\Unit\Collection;

/**
Expand Down Expand Up @@ -44,10 +42,18 @@ protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->fetchStrategyMock = $this->getMock(
\Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', false
\Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class,
['fetchAll'],
[],
'',
false
);
$this->entityFactoryMock = $this->getMock(
\Magento\Framework\Data\Collection\EntityFactory::class, ['create'], [], '', false
\Magento\Framework\Data\Collection\EntityFactory::class,
['create'],
[],
'',
false
);
$this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class);
$this->collection = new \Magento\Framework\Data\Test\Unit\Collection\DbCollection(
Expand Down Expand Up @@ -375,7 +381,11 @@ public function testFetchItem()

$adapterMock = $this->getMock(
\Magento\Framework\DB\Adapter\Pdo\Mysql::class,
['select', 'query'], [], '', false);
['select', 'query'],
[],
'',
false
);
$selectMock = $this->getMock(
\Magento\Framework\DB\Select::class,
[],
Expand Down Expand Up @@ -430,9 +440,9 @@ public function testGetSize()
$adapterMock->expects($this->exactly(2))
->method('quoteInto')
->will($this->returnValueMap([
['testField1=?', 'testValue1', null, null, 'testField1=testValue1'],
['testField4=?', 'testValue4', null, null, 'testField4=testValue4'],
]));
['testField1=?', 'testValue1', null, null, 'testField1=testValue1'],
['testField4=?', 'testValue4', null, null, 'testField4=testValue4'],
]));
$selectMock->expects($this->once())
->method('orWhere')
->with('testField1=testValue1');
Expand Down Expand Up @@ -558,7 +568,11 @@ public function testToOptionHash()
$data = [10 => 'test'];
$adapterMock = $this->getMock(
\Magento\Framework\DB\Adapter\Pdo\Mysql::class,
['select', 'query'], [], '', false);
['select', 'query'],
[],
'',
false
);
$selectMock = $this->getMock(
\Magento\Framework\DB\Select::class,
[],
Expand Down
Loading