Skip to content

Commit e91c64a

Browse files
1139: Code refactoring
1 parent 68d951c commit e91c64a

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

resources/fileTemplates/internal/Magento Module Observer File.php.ft

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ namespace ${NAMESPACE};
66
use Magento\Framework\Event\ObserverInterface;
77
use Magento\Framework\Event\Observer;
88

9+
/**
10+
* Observes the `${EVENT_NAME}` event.
11+
*/
912
class ${CLASS_NAME} implements ObserverInterface
1013
{
1114
/**
1215
* Observer for ${EVENT_NAME}.
1316
*
1417
* @param Observer $observer
18+
*
1519
* @return void
1620
*/
1721
public function execute(Observer $observer)

src/com/magento/idea/magento2plugin/actions/context/php/NewObserverAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ protected boolean isVisible(
5252
final PsiDirectory targetDirectory,
5353
final PsiFile targetFile
5454
) {
55-
if (!moduleData.getType().equals(ComponentType.module)) {
55+
if (!moduleData.getType().equals(ComponentType.module)
56+
|| !moduleData.getModuleDir().equals(targetDirectory.getParentDirectory())) {
5657
return false;
5758
}
5859

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewObserverDialog.form

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
</constraints>
88
<properties>
99
<opaque value="true"/>
10-
<preferredSize width="720" height="280"/>
10+
<preferredSize width="420" height="280"/>
1111
<requestFocusEnabled value="true"/>
1212
</properties>
1313
<border type="none"/>
1414
<children>
1515
<grid id="9ad5" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1616
<margin top="0" left="0" bottom="0" right="0"/>
1717
<constraints>
18-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
18+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
1919
</constraints>
2020
<properties/>
2121
<border type="none"/>
@@ -102,7 +102,9 @@
102102
</component>
103103
<component id="12752" class="com.magento.idea.magento2plugin.ui.FilteredComboBox" binding="eventName" custom-create="true">
104104
<constraints>
105-
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
105+
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
106+
<preferred-size width="150" height="-1"/>
107+
</grid>
106108
</constraints>
107109
<properties/>
108110
</component>
@@ -116,7 +118,9 @@
116118
</component>
117119
<component id="ec3f4" class="javax.swing.JComboBox" binding="observerArea" custom-create="true">
118120
<constraints>
119-
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
121+
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
122+
<preferred-size width="150" height="-1"/>
123+
</grid>
120124
</constraints>
121125
<properties/>
122126
</component>
@@ -146,9 +150,7 @@
146150
</component>
147151
<component id="662ad" class="javax.swing.JLabel" binding="classNameLabel">
148152
<constraints>
149-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
150-
<preferred-size width="113" height="16"/>
151-
</grid>
153+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
152154
</constraints>
153155
<properties>
154156
<text value="Class Name"/>

testData/actions/generation/generator/ModuleObserverGenerator/generateModuleObserverFile/TestClassObserver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
use Magento\Framework\Event\ObserverInterface;
66
use Magento\Framework\Event\Observer;
77

8+
/**
9+
* Observes the `test_event_name` event.
10+
*/
811
class TestClassObserver implements ObserverInterface
912
{
1013
/**
1114
* Observer for test_event_name.
1215
*
1316
* @param Observer $observer
17+
*
1418
* @return void
1519
*/
1620
public function execute(Observer $observer)

tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleObserverGeneratorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.magento.idea.magento2plugin.magento.files.ModuleObserverFile;
1111

1212
public final class ModuleObserverGeneratorTest extends BaseGeneratorTestCase {
13+
1314
private static final String CLASS_NAME = "TestClassObserver";
1415

1516
/**

0 commit comments

Comments
 (0)