How to add missing getters and setters to existing entity (#Shopware 6, #b2bsellers, #b2bsellers-suite) - shopware6

I am tasked to make the B2Bsellers plugin work for our use case.
I need to access data from EmployeePermissionTranslationEntity. The plugin has not defined a getter for the field i need to access.
I can see that the data exists though debugging, but the getter is not defined. How can I extend this entity and manually add the getter though my own plugin?

The \Shopware\Core\Framework\DataAbstractionLayer\Entity class defines a magic getter method https://github.com/shopware/platform/blob/v6.4.15.2/src/Core/Framework/DataAbstractionLayer/Entity.php#L44
so you should have access to it with $employeePermissionTranslationEntity->propertyName

Could you maybe tell me which data you want to get from EmployeePermissionTranslationEntity
Currently you only can get the name.
This is the only available translation for EmployeePermission

Related

Is it possible to extend private Dart classes?

I am trying to expand upon the functionality of the Dismissible widget, which is a StatefulWidget, with its state being a private class.
Since I need to change the functionality inside of _DismissibleState, is it possible to somehow extend from it?
If not, is there an alternative or recommended way how to extend upon Flutter standard classes, apart from copying the whole source?
You can only extend a class that you can refer to. If _DismissibleState is declared in a different library, then you cannot refer to it, and so you can't extend it.
There is no workaround. That's what it means to be private.
You also cannot extend Dismissible to return a different state because its interface contains _DismissibleState createState(). There is no way you can return a state which satisfies that interface restriction, and you also cannot override it with a different return type unless that type also implements _DismissibleState, which was the original unsolvable problem.
I had to copy and paste the entire original file into a new one to make a simple change just in one line in a private class.

Use data in plugin outside the SCIPsolve call

I would like to share data between a plugin and my main function (this is, use it outside the call to the SCIPsolve function). For example, a branching rule sets a certain int variable to 1 and then, after the optimization is done I can go and check wether the variable was changes or not.
I thought I could accomplish this by using the plugin data (e.g. SCIP_BranchruleData) but it can't be accessed from outside the plugin's source file.
How can I do it?
I will appreciate any help.
Rodolfo
An easy solution is to add a getter function to the branchrule which you implement in branch_xyc.c and prototype in branch_xyz.h. Then your code needs to include the header file and you can access the fields in the branchdata.
See also the documentation of branch_allfullstrong.cpp where an external function is defined and you can see how to get the branchdata and branchrule when passing just a SCIP pointer.

Is it possible to use one static variable in property that is accessible by both the getter and setter

Not taking performance into account, it can be handy to use a static variable inside the getter for a readonly property since:
It allows you to save information between get calls
The information is only accessible by the property
The problem is that it does not seem to be accessible by the property's setter. Is this correct, or am I missing something?
No, because that does not make sense. You could expose a static value via a read only property, sure. By the very definition of "Static" you cannot assign anything to it, which is the only purpose of the Set method of a property.
Edit: To clarify, you could do something else with the inbound 'value' of Set... but then you aren't really setting the member variable the property exposes anymore, which sounds like you just need a Public Class Sub that does whatever your weird Set would do.

How to fire our aspects conditionally in PostSharp 2.0

We are in the progress of introducing PostSharp in one of our projects. It's been working great so far! There is one thing though that we haven't managed to solve: how to fire an advice conditionally.
Details:
- we have an attribute StopWatchAttribute which makes it possible to record the time needed to run methods
- this attribute accepts an enumeration "LoggingLevel" which is set in the config file with values like 0, 1, 2 etc
- this parameter is read in a base class called BaseService during runtime: new BaseService().CurrentLoggingSettings
- we tried to set up the attribute constructor like StopWatchAttribute(new BaseService().CurrentLoggingLevel) but we get a compile error: an attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.
--> summary: we would like the advice to be called conditionally and the condition depends on the parameter in the constructor of the attribute.
Is this possible to do?
Thanks for your help,
Andras
You cannot give variables to attributes, PostSharp or not. Since you're already reading the values from the config, just set your aspect to do the same on the Initialize() method. Override it in the aspect class and then save the value to a local field. You can use that field throughout the aspect. This compiles the value into the aspect essentially hard coding it.
Or, you can pull the value from the config from your advice method (OnMethodStart, etc) so that you can change it in the config at runtime. This is a more 'flexible' way to do it as it doesn't hard code anything.
Remember, your variables are being set at Runtime. PostSharp is a post-compile framework which means it does it's work long before your variables are even known to JIT.

Intercepting Method Access on the Host Program of IronPython

Greetings,
Most of the information I see around concerning the construction of Proxies for objects assume that there exists a Type somewhere which defines the members to be proxied. My problem is: I can't have any such type.
To make the problem simpler, what I have is a dictionary that maps strings to objects. I also have getters and setters to deal with this dictionary.
My goal then is to provide transparent access inside IronPython to this getters and setters as if they were real properties of a class. For example, the following code in a python script:
x.result = x.input * x.percentage;
...would actually represent something like in the host language:
x.SetProperty("result", x.GetProperty("input") * x.GetProperty("percentage"));
Also, 'x' here is given by the host program. Any ideas? Please remember that I cannot afford the creation of a typed stub... Ideally, I would be happy if somehow I could intercept every call to an attribute/method of a specific object in the script language onto the host program.
This post might be useful.