I would like to override a plugin's event subscriber. Is it possible by just adjusting the priority in the service.xml?
Are there any other ways to disable a subscriber?
I disabled the subscriber by decorating it.
That way I could simply add a new getSubscribedEvents() function, that returns an empty array.
see:
https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/adjusting-service
Subscribers are also normal symfony services, so a simple decorating of the service should work.
Create your own subscriber and add to it's DI declaration the "decorates" attribute with the class name of the original subscriber as value.
Related
I have a .NET Blazor Server app and need to pass an object from one component to another. Both components are pages, meaning that they have #page directives with routes. I know how to use cascading values to pass a parameter between regular Blazor components, but this does not work with page components. I also know how to pass a parameter within an endpoint route. However, instead of a string or int I want to pass an object with multiple properties and am unsure how to best accomplish this.
Is it possible to pass an object as an endpoint route parameter? If not, what is a good way to accomplish this within a Razor components context?
Using dependency injection would likely solve this issue for you.
Example:
Create a class called "ApplicationService"
Create an interface in that class called "IApplicationService"
You could have something like this
public interface IApplicationService
{
public Task MsgBox(string value);
}
In the ApplicationService class inside the "ApplicationService.cs" file, go ahead and implement the interface member above.
You could have something like this:
public async Task MsgBox(string value)
{
await _JSRuntime.InvokeAsync<string>("alert", value);
}
In the program.cs class, you need to now register that "service" we just created.
You could have something like this
builder.Services.AddTransient<IApplicationService, ApplicationService>();
builder.Services.AddScoped<ApplicationService>();
In your _Imports.razor you can inject the class so that the pages have access to it:
#inject ApplicationService MainAppService;
Now in your razor components you should be able to do something like this:
await MainAppService.MsgBox("This is a message box");
This works in my WASM blazor app, hope it sheds some light on the server side of things 🚀
Use a DI service. Create a class to hold your object. Add it as a Scoped Service in Program. Use it in any component (pages are just components with a page attribute) though #inject.
Hi everybody I want to create alert rule in axapta. But some class will run when rules run. I want that class to work with the new rule. How can I do this?
You can create custom event action and call your logic there.
Class representing an action must inherit from the EventAction Class, and it must implement the execute method. For each event rule, the Alerts module creates a list of action class IDs that must be instantiated. The individual execute method that is associated with each respective class ID is called whenever a rule matches an event. The list of actions is customizable. For more information, see
How to: Add Custom Actions for Alerts
I am using SDL Tridion 2011 SP1. I have Components A, B and C. Component C is linked with A & B.
If I publish C, both Component A and B are getting published. But I want only Component A to be published.
Can any one explain how to exclude Component B from publishing?
What you are experiencing is the default behaviour of Tridion. This is by design, to ensure that when you change content in a component, publishing it will update all instances of that content on the website.
As the other answers suggest you can change this behaviour using a Custom Resolver:
using Tridion.ContentManager;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Resolving;
public class UpdateResolvedItems : IResolver
{
public void Resolve(
IdentifiableObject item,
ResolveInstruction instruction,
PublishContext context,
Tridion.Collections.ISet<ResolvedItem> resolvedItems)
{
foreach (ResolvedItem resolvedItem in resolvedItems)
{
// Check resolved items, and remove accordingly
}
}
}
The code example above demonstrates you can get access to a collection called resolvedItems. This is a list of items due to be published, unless you make a change to it.
You can iterate through this list and remove items according to your requirements.
So far I know there is no easy way to do this. When you publish one item Tridion resolves all the related and linked items and publishes them.
You can use event system or a custom resolver to achive want you are asking.
This link might help:
http://nunolinhares.blogspot.com/2011/10/tridion-publisher-and-custom-resolvers.html
If you are publishing from API you can set IncludeComponentLinks property of ResolveInstruction to false, or, as Bappi pointed do this in the event handler
I always have a question about override custom event. I am not sure why or what do to inside override function. I searched google but didn't get too many feedbacks. I appreciate if someone can light me up. Thanks.
EDIT:
My projects seem work fine even though I use my custom event without override. Anyone could explain it? Thanks.
In general, you need to override a function when its use needs to be modified. So for instance, say I have a class called Car. In this class I have a function called go() which starts the car.
Now if i extend this class into another class called PickupTruck, I need to override the Car class' go function so it not only starts the car, but also attaches the Trucks trailer.
So in your case you have to override the clone method of your CustomEvent class because it should return a new CustomEvent instead of a new Event.
From the docs:
When creating your own custom Event
class, you must override the inherited
Event.clone() method in order for it
to duplicate the properties of your
custom class. If you do not set all
the properties that you add in your
event subclass, those properties will
not have the correct values when
listeners handle the redispatched
event.
So, you can have a problem if you don't override clone and redispatch an Event. Also, the problem is not only that the custom properties will not be copied. The clone method will be called on the base class, Event. This will return an Event object, not a CustomEvent. If you have a handler that expects a CustomEvent and receives an Event, an error will be thrown and the code in your handler will not run.
Below is the overriden on complete function for a preloader in Flex.
private function initComplete(e:Event):void
{
//dispatchEvent(new Event(Event.COMPLETE));
cp.status.text="Configuring... Please Wait";
}
What I want to do is when the app has finsihed loading I want to change the preloaders text to "configuring".
Then I want to go and do a bunch of setup stuff in my code.
Once I've done all the setup I wanted how can I get the Preloader to dispatch its Event.complete from else where in my code?
I tried Application.application.preloader but it comes up null.
So I guess my question really is how to access a preloader from anywhere in my application.
Would a better approach be to have all setup classes as members of my preloader class?
One thing that might help is a Model-View-Controller pattern. Are you using a framework for your application like Mate, Swiz, or Cairngorm?
If you were using Mate, for example, you could do something like this:
Create an AppStateManager class with a property (e.g. applicationState)
Create an EventMap with an EventHandler for the FlexEvent.INITIALIZE event. In this handler, set the AppStateManager.applicationState to something like "CONFIGURING"
Your EventMap has an injector that injects the applicationState property into a view. The injector listens for changes to this property and updates the view. In this case it might just be injected into your main view.
In the main view, you have a public bindable property also called applicationState that gets injected by Mate.
In the setter for this property, you can have an if/then or a switch that does different tasks depending on the state. For example, if applicationState == "COMPLETE", then this.preloader.dispatchEvent(Event.COMPLETE) or something like that.
The details are pseudo-sketched out but the idea is to use Flex's bindings to notify view components when changes have been made, and to have shared objects that maintain state. Not sure if that's what you're looking for...
The component LifeCycle does specific stuff in a specific order, and the near final element is to make the component visible.
It sounds to me like you want to defer this setting of visible to true to do other stuff. But, I imaging if you were making use of the component LifeCycle this would be a non-issue.
What sort of app init stuff do you need to do?