Sylius plugin - how to use listeners and classes properly inside package - plugins

Good day,
I got my own package that I've installed into Sylius based on Sylius plugin-skeleton. The main class in /src folder of that plugin is called, but I need to work with other classes from /src folder. For example I got /src/Menu/RewriteMenu.php that I need to trigger method via services.yaml and I need to do this inside package - not to configure listener inside Sylius project. How can I achieve it? Thank you very much for response.

You can have a src/Resources/config/services.yaml file with your services declarations there.
You then need to import the configurations from the root configuration files. For example, to import your plugin's services, you can do this:
# config/packages/_sylius.yaml
imports:
...
- { resource: "#YourPluginName/Resources/config/services.yaml" }
In cases like this one, you can take a look at other Sylius plugins source code to see how they achieve things. But as a rule of thumb, anything that you customize in a root level basis, can be also done in a plugin moving the non-php stuff inside the src/Resources folder: configs (like services, serialization, validation, etc), templates, translations, assets, etc.

Related

How can I import plugin projects from my workspace without specifying them?

I am developing an scripting environment for EMF and need to import the model plugin so that my script is able to use classes generated by the model, but in order to do that I need to explicitly add the plugin to my imports.
Can I do that automatically? Like adding all workspace plugins to my imports at runtime?
You can use DynamicImport-Package: * attribute in the bundle manifest to make all exported packages visible.
Note that packages imported via DynamicImport-Package are resolved every time a class from the package is needed. Consider selective dynamic import DynamicImport-Package: *;dynamic=mymodel or buddy policy as better alternatives.

included hook not working for addon projects that depend on other addons

I have the following structure whereby I have common code used in a number of projects that itself contains other third party ember addons. I add these third party addons to the dependencies hash in package.json so they flow down to consumers. Therefore I don't have to install them in every consumer manually which would cause a maintenance headache when updating a single dependency.
common-code-addon
- third-party-ember-addon
myapp
- common-code-addon
The problem is that the included hook in index.js which might import bower dependencies such ass .css and .js code does not work from myapp. What is the recommended way to allow them to flow down properly?

Foundation 5 Production Environment Files

I've created a new foundation project using the foundation new myproject --libsass method.
Its just a simple static index.html (for the purpose of this question).
I've deployed it to a live server now, and I am wondering about the best way to structure this. I have omitted the node_modules & scss directories, and i'm left with the following:
bower_components/
css/
js/
index.html
bowerrc
bower.json
Gruntfile.js
humans.txt
package.json
README.md
bower_components is needed in its current form, unless I shuffle some files around, which is what I intend to do, but I'm checking if there is a better way of doing this, and that I haven't missed some magic terminal command to deploy to production.
As msturdy suggested in the comments, grunt is the way to go here. There are a lot of plugins out there, see a list on the official page.
If you want to have grunt "compile" your project into one specific folder which you can then for example push to a deployment server, you should do several things in grunt:
compile your scss
minify your javascript, that is making the files smaller, see jscompress for a demo of what it is. All your js-files from /bower_components which you include in your project should be in a vendor.js which is loaded first, and then a second js-file should contain your custom js from /js
save everything into a deployment folder.
(optional) automatically deploy to a server.
Take a look at these grunt tutorials for setting up your gruntfile.js, you'll want to have two tasks, one for just quickly compiling your scss, one for the whole deployment process:
grunt is not weird and hard
official tutorial
sitepoint tutorial
They show you how to do certain things and definitely how to write the gruntfile. Plugins you might want to use apart from your current libsass plugin are uglify and any plugin that lets you deploy your code via git, ftp or anything else. You can download all these plugins via npm by adding them to your package.json and doing npm install, refer to their websites for exact usage instruction.

Class loading when extending an Eclipse plugin with a fragment project does not work

I am trying to extend a third-party Eclipse plug-in by using a fragment project. The major reason is that the third party plug-in contains classes having the default (package) modifier and I need to extend them.
Thus, my extensions class must be located in exactly the same package. I create a fragment project containing the same package and put my class into it. Everything works fine when I am using a runtime workspace.
However, if I try to deploy my fragment (e.g., deploying it into the dropins folder of my Eclipse distribution), I am not able to execute the code. Extensions and stuff like that work fine (e.g., I use extensions for a new Run Configuration. However, if I try to instantiate this run configuration I get an error message that the third-party root plug-in was unable to load the class to display my configuration tab group.
Any experience with this kind of problems?
Sorry, but that does not work. Unless the host bundle has been crafted specially for it, you cannot override a class in the host from a fragment. The reason is that resources - including classes - are retrieved from the host before any fragment.
See org.eclipse.osgi.baseadaptor.loader.ClasspathManager for the implementation..
Actually, this is the extension code I am using:
<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
class="com.android.ide.eclipse.adt.internal.launch.jouleunit.AndroidJouleUnitTabGroup"
id="com.android.ide.eclipse.adt.jouleunit.AndroidJouleUnitLaunchConfigTabGroup"
type="com.android.ide.eclipse.adt.jouleunit.launchConfigurationType">
</launchConfigurationTabGroup>
Of course, there are further extensions definig the launch configuration type etc. but this is the one leading to the class which Eclipse can not find.
Actually I found the problem now for myself. The problem was a wrong configured build properties file which excluded the Java byte code from my fragment JAR. Very itchy, as the classes were in the JAR but in a wrong subdirectory.

My first GWT Module

I created a module to share code across a couple of projects.
I created a GWT project: Framework. I then created a module com.framework.Framework within the project. The Framework project contains both client code, in the com.framework.client packages, and server code in the com.framework.server packages.
I try to consume this by
- Adding the project to the Java Build Path
- Adding to the module's definition
When I run the consuming project, I get NoClassDefFoundErrors for Framework classes I use in the module's server code.
What am I missing?
If I jar up the Framework project's WEB-INF\classes contents and put it into the consuming project's WEB-INF\lib folder, as well as add it to the Build Path it seems to work, but I don't see a way to keep the framework classes up to date in the consuming project(s).
Please make sure that you create gwt.xml file via menu New->Module, and in this gwt.xml file, you must declare your entry point class.