Skip to content

1215: fix parsing of plugin sort order value #1235

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
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
22 changes: 18 additions & 4 deletions src/com/magento/idea/magento2plugin/stubs/indexes/PluginIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,33 @@ private Set<PluginData> getPluginsForType(final XmlTag typeNode) {

for (final XmlTag pluginTag: typeNode.findSubTags(ModuleDiXml.PLUGIN_TAG_NAME)) {
final String pluginType = pluginTag.getAttributeValue(ModuleDiXml.TYPE_ATTR);
String pluginSortOrder = pluginTag.getAttributeValue(ModuleDiXml.SORT_ORDER_ATTR);
final String pluginSortOrder = pluginTag.getAttributeValue(ModuleDiXml.SORT_ORDER_ATTR);

if (pluginType != null) {
pluginSortOrder = pluginSortOrder == null ? "0" : pluginSortOrder;
final PluginData pluginData = getPluginDataObject(pluginType, Integer.parseInt(pluginSortOrder));
final PluginData pluginData = getPluginDataObject(pluginType, getIntegerOrZeroValue(pluginSortOrder));
results.add(pluginData);
}
}

return results;
}

private PluginData getPluginDataObject(final String pluginType, final Integer sortOrder) {
private Integer getIntegerOrZeroValue(final String sortOrder) {
if (sortOrder == null || sortOrder.isEmpty()) {
return 0;
}

try {
return Integer.parseInt(sortOrder);
} catch (NumberFormatException e) {
return 0;
}
}

private PluginData getPluginDataObject(
final String pluginType,
final Integer sortOrder
) {
return new PluginData(pluginType, sortOrder);
}
};
Expand Down