Skip to content
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

Additional Code Source directiories selection #2504

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
36 changes: 36 additions & 0 deletions .github/workflows/asset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will build a package using Gradle and then save it to Assets

name: Build Asset

on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: gradle
- name: Gradle wrapper
run: gradle wrapper
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build Plugin
run: ./gradlew buildPlugin

- name: Upload Plugin to Release Assets
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/distributions/PhpStorm Magento 2 Plugin-${{ github.event.release.tag_name }}.zip
asset_name: PhpStorm Magento 2 Plugin-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).

## 2025.0.1
## 2025.1.0

### Added

- Possibility to add additional code source directories using content root feature [#2504](https://github.com/magento/magento2-phpstorm-plugin/pull/2504)

### Fixed

78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,53 +7,53 @@
<!-- Plugin description -->
# PhpStorm Magento 2 Plugin

<table align="center">
<caption>
This is a PhpStorm IDE plugin for a better Magento 2 development workflow.
<table align="center" style="border-collapse: collapse; width: 100%; text-align: center;">
<caption style="font-size: 1.2em; margin-bottom: 10px;">
<strong>PhpStorm IDE Plugin</strong> for a better Magento 2 development workflow.
</caption>
<thead>
<tr>
<td colspan="3" align="center">
Version 2025.0.0 - Contributors
<tr style="background-color: #f4f4f4;">
<td colspan="3" style="padding: 10px; font-size: 1.2em;">
<strong>Version 2025.0.0 - Contributors</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/YevhenZvieriev">
<img src="https://avatars.githubusercontent.com/u/43544955?v=4" width="100px;" alt="Contributor 1"/>
<br/>
<sub><b>Yevhen Zvieriev</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/SilinMykola">
<img src="https://avatars.githubusercontent.com/u/15772032?v=4" width="100px;" alt="Contributor 2"/>
<br/>
<sub><b>Mykola Silin</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/VitaliyBoyko">
<img src="https://avatars.githubusercontent.com/u/20116393?v=4" width="100px;" alt="Contributor 3"/>
<br/>
<sub><b>Vitalii Boiko</b></sub>
</a>
</td>
</tr>
</tbody>
<tfoot>
<tbody>
<tr>
<td colspan="3" align="center">
<h3>Support the Project</h3>
<td align="center" style="padding: 15px;">
<a href="https://github.com/YevhenZvieriev" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/43544955?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Yevhen Zvieriev"/>
<br/>
<sub style="font-size: 1em;"><b>Yevhen Zvieriev</b></sub>
</a>
</td>
<td align="center" style="padding: 15px;">
<a href="https://github.com/SilinMykola" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/15772032?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Mykola Silin"/>
<br/>
<sub style="font-size: 1em;"><b>Mykola Silin</b></sub>
</a>
</td>
<td align="center" style="padding: 15px;">
<a href="https://github.com/VitaliyBoyko" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/20116393?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Vitalii Boiko"/>
<br/>
<sub style="font-size: 1em;"><b>Vitalii Boiko</b></sub>
</a>
</td>
</tr>
</tbody>
<tfoot>
<tr style="background-color: #f9f9f9;">
<td colspan="3" style="padding: 20px;">
<h3 style="margin: 10px 0;">Support the Project</h3>
<p>If you find this plugin helpful and want to support its development, consider buying the contributors a coffee:</p>
<a href="https://buymeacoffee.com/vitalii_b">
<img src="https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Donate-orange.svg" alt="Buy Me a Coffee">
<a href="https://buymeacoffee.com/vitalii_b" style="text-decoration: none;">
<img src="https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Donate-orange.svg" alt="Buy Me a Coffee" style="margin: 10px 0;">
</a>
<p>Thank you to our sponsors—your support means everything:</p>
<p>Lucas van Staden</p>
<p>Ivan Chepurnyi</p>
<p style="margin: 10px 0;">Thank you to our sponsors—your support means everything:</p>
<p><strong>Lucas van Staden</strong></p>
<p><strong>Ivan Chepurnyi</strong></p>
</td>
</tr>
</tfoot>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pluginGroup = com.magento.idea.magento2plugin
pluginName = Magento PhpStorm
pluginRepositoryUrl = https://github.com/magento/magento2-phpstorm-plugin
pluginVersion = 2025.0.1
pluginSinceBuild = 233
pluginVersion = 2025.1.0
pluginSinceBuild = 243.3
pluginUntilBuild = 258.*
platformType = PS
platformVersion = 2024.3
Original file line number Diff line number Diff line change
@@ -18,4 +18,5 @@ public class MagentoIcons {
public static final Icon PLUGIN_ICON_MEDIUM =
IconLoader.getIcon("/icons/pluginIcon64x64.svg", MagentoIcons.class);
public static final Icon GRAPHQL = IconLoader.getIcon("/icons/graphql.svg", MagentoIcons.class);
public static final Icon MARK_AS = IconLoader.getIcon("/icons/mark-as.svg", MagentoIcons.class);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.actions.content.root;

import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.actions.MarkRootActionBase;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
import org.jetbrains.annotations.NotNull;
import java.net.MalformedURLException;
import java.net.URL;

public class MarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
private Project project;

public MarkDirectoryAsMagentoContentRot() {
super();
final Presentation presentation = this.getTemplatePresentation();
presentation.setIcon(MagentoIcons.MARK_AS);
}

@Override
protected void modifyRoots(final VirtualFile virtualFile, ContentEntry contentEntry) {
if (project != null) {
final Settings settings = Settings.getInstance(project);
Settings.getInstance(project).addMagentoFolder(virtualFile.getUrl());
if (settings.getMagentoFolders() != null) {
settings.getMagentoFolders().removeIf(folder -> {
final VirtualFile file;
try {
file = VfsUtil.findFileByURL(new URL(folder));
} catch (MalformedURLException e) {
return false;
}
return file == null || !file.exists();
});
}

ProjectView.getInstance(project).refresh();
}
}

@Override
public void update(@NotNull final AnActionEvent event) {
final DataContext context = event.getDataContext();
final PsiElement targetElement = LangDataKeys.PSI_ELEMENT.getData(context);
final Module module = event.getData(PlatformCoreDataKeys.MODULE);
if (module != null) {
project = module.getProject();
}

if (targetElement instanceof PsiDirectory) {
final Settings settings = Settings.getInstance(project);
final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
final String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
event.getPresentation().setEnabledAndVisible(false);
return;
}
if (!settings.containsMagentoFolder(directoryUrl)) {
event.getPresentation().setEnabledAndVisible(true);
return;
}
}

event.getPresentation().setEnabledAndVisible(false);
}

@Override
protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.actions.content.root;

import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.actions.MarkRootActionBase;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.MagentoPathUrlUtil;
import org.jetbrains.annotations.NotNull;
import java.net.MalformedURLException;
import java.net.URL;

public class UnmarkDirectoryAsMagentoContentRot extends MarkRootActionBase {
private Project project;

public UnmarkDirectoryAsMagentoContentRot() {
super();
}

@Override
protected void modifyRoots(VirtualFile virtualFile, ContentEntry contentEntry) {
if (project != null) {
Settings settings = Settings.getInstance(project);
Settings.getInstance(project).removeMagentoFolder(virtualFile.getUrl());
if (settings.getMagentoFolders() != null) {
settings.getMagentoFolders().removeIf(folder -> {
VirtualFile file = null;
try {
file = VfsUtil.findFileByURL(new URL(folder));
} catch (MalformedURLException e) {
return false;
}
return file == null || !file.exists();
});
}

ProjectView.getInstance(project).refresh();
}
}

@Override
public void update(@NotNull AnActionEvent event) {
final DataContext context = event.getDataContext();
final PsiElement targetElement = LangDataKeys.PSI_ELEMENT.getData(context);
Module module = event.getData(PlatformCoreDataKeys.MODULE);
if (module != null) {
project = module.getProject();
}

if (targetElement instanceof PsiDirectory) {
Settings settings = Settings.getInstance(project);
String magentoPathUrl = MagentoPathUrlUtil.execute(project);
String directoryUrl = ((PsiDirectory) targetElement).getVirtualFile().getUrl();
if (magentoPathUrl != null && magentoPathUrl.equals(directoryUrl)) {
event.getPresentation().setEnabledAndVisible(false);
return;
}

if (settings.containsMagentoFolder(directoryUrl)) {
event.getPresentation().setEnabledAndVisible(true);
return;
}
}

event.getPresentation().setEnabledAndVisible(false);
}

@Override
protected boolean isEnabled(@NotNull RootsSelection rootsSelection, @NotNull Module module) {
return false;
}
}
Loading
Loading