Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.DataModelData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.DataModelFile;
import com.magento.idea.magento2plugin.magento.files.DataModelInterfaceFile;
Expand Down Expand Up @@ -60,29 +58,20 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();

phpClassTypesBuilder
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("NAME", data.getName())
.appendProperty("PROPERTIES", data.getProperties())
.appendProperty("HASINTERFACE", Boolean.toString(data.hasInterface()))
typesBuilder
.append("NAMESPACE", file.getNamespace(), false)
.append("NAME", data.getName(), false)
.append("PROPERTIES", data.getProperties(), false)
.append("HASINTERFACE", Boolean.toString(data.hasInterface()), false)
.append("EXTENDS", DataModelFile.DATA_OBJECT);

if (data.hasInterface()) {
phpClassTypesBuilder.append(
typesBuilder.append(
"IMPLEMENTS",
new DataModelInterfaceFile(
data.getModuleName(),
data.getInterfaceName()
).getClassFqn());
}

phpClassTypesBuilder.mergeProperties(attributes);

attributes.setProperty(
"USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.DeleteEntityByIdCommandData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.ModelFile;
import com.magento.idea.magento2plugin.magento.files.ResourceModelFile;
Expand Down Expand Up @@ -63,29 +61,24 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
final ModelFile modelFile = new ModelFile(data.getModuleName(), data.getModelName());
final String modelType = modelFile.getClassFqn();
final String modelFactoryType = modelType.concat("Factory");
final ResourceModelFile resourceFile =
new ResourceModelFile(data.getModuleName(), data.getResourceModelName());

phpClassTypesBuilder
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("CLASS_NAME", DeleteEntityByIdCommandFile.CLASS_NAME)
.appendProperty("ENTITY_ID", data.getEntityId())
typesBuilder
.append("ENTITY_NAME", data.getEntityName(), false)
.append("NAMESPACE", file.getNamespace(), false)
.append("CLASS_NAME", DeleteEntityByIdCommandFile.CLASS_NAME, false)
.append("ENTITY_ID", data.getEntityId(), false)
.append("Exception", "Exception")
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType())
.append("NO_SUCH_ENTITY_EXCEPTION",
ExceptionType.NO_SUCH_ENTITY_EXCEPTION.getType())
.append("LOGGER", FrameworkLibraryType.LOGGER.getType())
.append("MODEL", modelType)
.append("MODEL_FACTORY", modelFactoryType)
.append("RESOURCE", resourceFile.getClassFqn())
.mergeProperties(attributes);

attributes.setProperty("USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
.append("RESOURCE", resourceFile.getClassFqn());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.DeleteEntityControllerFileData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.actions.DeleteActionFile;
import com.magento.idea.magento2plugin.magento.files.commands.DeleteEntityByIdCommandFile;
Expand Down Expand Up @@ -64,14 +62,12 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();

phpClassTypesBuilder
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("CLASS_NAME", DeleteActionFile.CLASS_NAME)
.appendProperty("ADMIN_RESOURCE", data.getAcl())
.appendProperty("ENTITY_ID", data.getEntityId())
typesBuilder
.append("NAMESPACE", file.getNamespace(), false)
.append("ENTITY_NAME", data.getEntityName(), false)
.append("CLASS_NAME", DeleteActionFile.CLASS_NAME, false)
.append("ADMIN_RESOURCE", data.getAcl(), false)
.append("ENTITY_ID", data.getEntityId(), false)
.append("DELETE_COMMAND",
new DeleteEntityByIdCommandFile(
data.getModuleName(),
Expand All @@ -86,10 +82,6 @@ protected void fillAttributes(final @NotNull Properties attributes) {
.append("IMPLEMENTS_GET", HttpMethod.GET.getInterfaceFqn())
.append("NO_SUCH_ENTITY_EXCEPTION",
ExceptionType.NO_SUCH_ENTITY_EXCEPTION.getType())
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType())
.mergeProperties(attributes);

attributes.setProperty("USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.EditEntityActionData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.actions.EditActionFile;
import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
Expand Down Expand Up @@ -62,22 +60,16 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();

phpClassTypesBuilder
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("CLASS_NAME", file.getClassName())
.appendProperty("ADMIN_RESOURCE", data.getAcl())
.appendProperty("MENU_IDENTIFIER", data.getMenu())
typesBuilder
.append("NAMESPACE", file.getNamespace(), false)
.append("ENTITY_NAME", data.getEntityName(), false)
.append("CLASS_NAME", file.getClassName(), false)
.append("ADMIN_RESOURCE", data.getAcl(), false)
.append("MENU_IDENTIFIER", data.getMenu(), false)
.append("EXTENDS", BackendModuleType.EXTENDS.getType())
.append("IMPLEMENTS", HttpMethod.GET.getInterfaceFqn())
.append("RESULT_INTERFACE", FrameworkLibraryType.RESULT_INTERFACE.getType())
.append("RESULT_FACTORY", FrameworkLibraryType.RESULT_FACTORY.getType())
.append("RESULT_PAGE", BackendModuleType.RESULT_PAGE.getType())
.mergeProperties(attributes);

attributes.setProperty("USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
.append("RESULT_PAGE", BackendModuleType.RESULT_PAGE.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.EntityDataMapperData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.DataModelFile;
import com.magento.idea.magento2plugin.magento.files.DataModelInterfaceFile;
Expand Down Expand Up @@ -63,8 +61,6 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();

final ModelFile modelFile = new ModelFile(data.getModuleName(), data.getModelName());
final DataModelFile dtoFile = new DataModelFile(data.getDtoName(), data.getModuleName());
final DataModelInterfaceFile dtoInterfaceFile =
Expand All @@ -77,20 +73,14 @@ protected void fillAttributes(final @NotNull Properties attributes) {
dtoType = dtoFile.getClassFqn();
}

phpClassTypesBuilder
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("CLASS_NAME", file.getClassName())
typesBuilder
.append("NAMESPACE", file.getNamespace(), false)
.append("ENTITY_NAME", data.getEntityName(), false)
.append("CLASS_NAME", file.getClassName(), false)
.append("DATA_OBJECT", FrameworkLibraryType.DATA_OBJECT.getType())
.append("DTO_TYPE", dtoType)
.append("MAGENTO_MODEL_TYPE", modelFile.getClassFqn())
.append("DTO_FACTORY", dtoType.concat("Factory"))
.append("ABSTRACT_COLLECTION", FrameworkLibraryType.ABSTRACT_COLLECTION.getType())
.mergeProperties(attributes);

attributes.setProperty(
"USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses())
);
.append("ABSTRACT_COLLECTION", FrameworkLibraryType.ABSTRACT_COLLECTION.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.FormGenericButtonBlockData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.FormGenericButtonBlockFile;
import com.magento.idea.magento2plugin.magento.packages.code.FrameworkLibraryType;
Expand Down Expand Up @@ -63,22 +61,17 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
final String entityIdGetter = "get" + Arrays.stream(data.getEntityId().split("_"))
.map(s -> s.substring(0, 1).toUpperCase(Locale.getDefault()) + s.substring(1))
.collect(Collectors.joining());

phpClassTypesBuilder
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("CLASS_NAME", FormGenericButtonBlockFile.CLASS_NAME)
.appendProperty("ENTITY_ID", data.getEntityId())
.appendProperty("ENTITY_ID_GETTER", entityIdGetter)
typesBuilder
.append("NAMESPACE", file.getNamespace(), false)
.append("ENTITY_NAME", data.getEntityName(), false)
.append("CLASS_NAME", FormGenericButtonBlockFile.CLASS_NAME, false)
.append("ENTITY_ID", data.getEntityId(), false)
.append("ENTITY_ID_GETTER", entityIdGetter, false)
.append("CONTEXT", FormGenericButtonBlockFile.CONTEXT)
.append("URL", FrameworkLibraryType.URL.getType())
.mergeProperties(attributes);

attributes.setProperty("USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
.append("URL", FrameworkLibraryType.URL.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.GetListQueryModelData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.CollectionModelFile;
import com.magento.idea.magento2plugin.magento.files.EntityDataMapperFile;
Expand Down Expand Up @@ -63,7 +61,6 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
final CollectionModelFile collectionModelFile =
new CollectionModelFile(
data.getModuleName(),
Expand All @@ -73,10 +70,10 @@ protected void fillAttributes(final @NotNull Properties attributes) {
final NamespaceBuilder collectionNamespace =
collectionModelFile.getNamespaceBuilder();

phpClassTypesBuilder
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("CLASS_NAME", GetListQueryFile.CLASS_NAME)
typesBuilder
.append("ENTITY_NAME", data.getEntityName(), false)
.append("NAMESPACE", file.getNamespace(), false)
.append("CLASS_NAME", GetListQueryFile.CLASS_NAME, false)
.append(
"ENTITY_COLLECTION_TYPE",
collectionNamespace.getClassFqn()
Expand Down Expand Up @@ -111,12 +108,6 @@ protected void fillAttributes(final @NotNull Properties attributes) {
.append(
"SEARCH_RESULT_FACTORY_TYPE",
FrameworkLibraryType.SEARCH_RESULT.getFactory()
)
.mergeProperties(attributes);

attributes.setProperty(
"USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses())
);
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.actions.generation.data.GridActionColumnData;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
import com.magento.idea.magento2plugin.magento.files.GridActionColumnFile;
import com.magento.idea.magento2plugin.magento.packages.code.FrameworkLibraryType;
Expand Down Expand Up @@ -60,22 +58,16 @@ protected AbstractPhpFile initFile() {
*/
@Override
protected void fillAttributes(final @NotNull Properties attributes) {
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();

phpClassTypesBuilder
.appendProperty("ENTITY_NAME", data.getEntityName())
.appendProperty("ENTITY_ID", data.getEntityIdColumn())
.appendProperty("NAMESPACE", file.getNamespace())
.appendProperty("CLASS_NAME", file.getClassName())
.appendProperty("EDIT_URL_PATH", data.getEditUrlPath())
.appendProperty("DELETE_URL_PATH", data.getDeleteUrlPath())
typesBuilder
.append("ENTITY_NAME", data.getEntityName(), false)
.append("ENTITY_ID", data.getEntityIdColumn(), false)
.append("NAMESPACE", file.getNamespace(), false)
.append("CLASS_NAME", file.getClassName(), false)
.append("EDIT_URL_PATH", data.getEditUrlPath(), false)
.append("DELETE_URL_PATH", data.getDeleteUrlPath(), false)
.append("PARENT_CLASS", GridActionColumnFile.PARENT_CLASS)
.append("URL", FrameworkLibraryType.URL.getType())
.append("CONTEXT", GridActionColumnFile.CONTEXT)
.append("UI_COMPONENT_FACTORY", GridActionColumnFile.UI_COMPONENT_FACTORY)
.mergeProperties(attributes);

attributes.setProperty("USES",
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
.append("UI_COMPONENT_FACTORY", GridActionColumnFile.UI_COMPONENT_FACTORY);
}
}
Loading