How to get NodeType information from a controller - neoscms

How could I get NodeType information from within a controller? E.g., for checking access rights?

I'm not sure if that's what you are asking for:
You can get access of a nodes property within a controller (e.g. for an extension) like this:
$myOwnProperty = $this->request->getInternalArgument('__myOwnProperty');
"myOwnProperty" has to be defined for a nodetype in Configuration\Settings.yaml
The internal argument gets two underscores before the property name.

Related

Get full, namespaced, Swift type name [duplicate]

Is there any way to get a Swift type name as a string with its namespace (or framework name)?
For example, if Foo.framework has a class named Bar, I would like to get a string something like "Foo.Bar".
The followings just return the class name "Bar".
let barName1 = String(Bar.self) // returns "Bar"
let barName2 = "\(Bar.self)" // returns "Bar"
let barName3 = "\(Bar().dynamicType)" // returns "Bar"
I would like to also get the framework name "Foo" as a namespace.
Use String(reflecting:):
struct Bar { }
let barName = String(reflecting: Bar.self)
print(barName) // <Module>.Bar
From the Xcode 7 Release Notes:
Type names and enum cases now print and convert to String without
qualification by default. debugPrint or String(reflecting:) can still
be used to get fully qualified names.
String(reflecting:) works right now, but could change in the future. So if you only need the fully-qualified name temporarily, you should be fine. However, if the name is something you're going to rely on over a longer period of time (spanning multiple releases of Swift) you shouldn't use it.
The Swift community is trying to come to a consensus on a longer-term method for getting the information from a type.
From Joe Groff:
In 4.2, String(reflecting:) still shows a fully qualified name for local types, but the local type context is anonymized and printed in a way that's intended to be clear is non-stable, since no matter what reflection support we add in the future, it'd be a bad idea to incidentally rely on the presence or identity of local types in dynamic code.
https://forums.swift.org/t/getting-the-more-fully-qualified-name-of-a-type/14375/9

Can powershell call subclasses from external C# dll

I have some simple code from:
https://www.codeguru.com/csharp/csharp/cs_misc/dllsandexecutables/article.php/c4239/Creating-and-Using-C-DLLs.htm
which generates a dll to do some simple math. I wanted to add a subclass
namespace MathFunctions
{
public class Add : MultiClass
{
public static int MultiplyAndAdd(int a, int b, int c)
{
return (a * b) + c;
}
}
}
Then call it from powershell.
Running powershell against the master classes returns data back without an issue
Import-module("C:\temp\MathFunctions.dll")
[MathFunctions.MultiClass]::Multiply(10, 2)
returns 20 as expected, but I can't figure the format to access the subclass. I've tried variations on:
[MathFunctions.MultiClass.Add]::MultiplyAndAdd(10, 2, 3)
[MathFunctions.MultiClass+Add]::MultiplyAndAdd(10, 2, 3)
[MathFunctions.MultiClass]:Add:MultiplyAndAdd(10, 2, 3)
[MathFunctions.MultiClass]::Add.MultiplyAndAdd(10, 2, 3)
but I always get variations on
Unable to find type [MathFunctions.MultiClass.Add]
I've also looked for the method in powershell via:
[MathFunctions.MultiClass] | get-member -MemberType method
but my subclass isn't listed.
I know I'm accessing it incorrectly. I can't figure out how to access the subclass from powershell.
I'm fairly sure subclasses can be accessed, as the closest example is:
PowerShell IComparable with subclasses
but I don't see how he aliased it.
Thanks
Thank you bluuf who pointed me in the right direction.
I ended up using dotPeek to take the dll apart (now it was public [blush]).
Code is as above and the powershell method is just the subclass name:
[MathFunctions.Add]::MultiplyAndAdd(5,2,3)
which gave an answer - not an error
To explain the confusion in more detail:
You mistakenly thought that class-inheritance relationships must be reflected in a given class' full (namespace-qualified) type name, so you thought that because class Add derives from class MultiClass, MultiClass too must be reflected in the full type name.
In reality, a class' derivation is irrelevant with respect to its full name; all that matter is the namespace in which it is placed.
In other words: to form the full type name for any type (class), use <EnclosingNamespace>.<TypeName>[1], which in your case means:
MathFunctions.Add
Using that as a PowerShell type literal - [MathFunctions.Add] - allows you to access the static MultiplyAndAdd() method via ::, the static-member access operator, as shown in your own answer.
Also, remember that tab-completion can be helpful here, because it works with type names too; in your case, typing [Add<tab> will expand to [MathFunctions.Add, yielding the full type name.
(If multiple available (public) type names start with Add, you may to have to press the tab key repeatedly to cycle through the matches.)
[1] A variation is required to access a nested class, i.e., a class embedded in another class:
<EnclosingNamespace>.<EnclosingTypeName>+<NestedTypeName>, e.g., if your Add class had a nested class named Inner: MathFunctions.Add+Inner

Passing complex object as parameter to sub-stack

I want to pass the output of a custom resource, which is an array of objects, as parameter to a sub-stack. An example of what I want to pass as parameter to the child stack is :
[
{"Role":"Role1","IdentifierType":"Prefix","Identifiers":"Bucket1"}
{"Role":"Role2","IdentifierType":"Prefix","Identifiers":"Bucket2"}
]
How do I pass this to the sub-stack? I tried declaring the parameter in the child stack as String, and later as CommaDelimitedList. Both the times, the stack gave an error: "Value of property Parameters must be an object with String (or simple type) properties"
As I know until now, there is not way to pass complex objects as a result of of stack execution. Like the message say, the outputs need to be string or single types (integer and boolean in case of cloudformation).
Without more information is hard to help you with alternatives, but let's assume that your Custom Resource is based on lambda. And let's assume that you have control about the code of your Custom Resource. If this is the case you can:
Send the resource identification of your custom resource as a parameter for your nested stack;
Inside nested stack, invoke the lambda function again with the resourceId as a parameter;
Change the lambda code to check for a new parameter for the resourceId (inside the ResourceParameters, not inside the Common Resource Id sent by CloudFormation).
If the parameter is not empty (or not a defined value passed on the first invocation) respond with the old values (you must have a way to keep this values in some place or check then in runtime.);
Change the lambda code to do not take action in the update/deletion is case of invocation by the nested stack (with the resourceId parameter).
Again, is hard to think in alternatives without more info about your specific problem. But use this response as a food for thought.

Passing Data between Interface Controllers on Xcode 8.0 Swift 3.0

I want to pass a string between two Interface Controllers. On InterfaceController1 I want to create a variable like:
var level:String = ("easy")
and then be able to access that variable on InterfaceController2.
I would prefer not to use global variables as I am aware that they are not recommended.
There is one answer on StackOverFlow but it was created when Swift 1 was out and I can't find any up to date anwser.
Thanks
You have several options to achieve this.
Use pushController(withName:,context:) and set level as the context input argument, then in InterfaceController2's awake(withContext:) use that variable.
Use singletons (declare the variable as static) if you need to access the variable of InterfaceController2 from several classes or if you don't directly navigate to InterfaceController2.
If you only need to set up that variable from InterfaceController1 and you directly present InterfaceController2 from InterfaceController1, option 1 is the preferred method.

get values of multiple checkboxes in extbase/fluid TYPO3

How to get values of multiple checkboxes checked in frontend template with fluid and use these values in action extbase?
Declare the argument in your controller action and give it a type array or an array-compatible type which can be constructed by the PropertyMapper.
Name all fields the same as this argument.
Post the data and use the argument in the controller action.
This is the correct way of receiving an array as value of a controller argument. Accessing it directly from the request is not recommended, unless you also declared the argument on the controller action. Not doing so will bypass important argument processing.
save them in a form and retrieve the POST data trough:
$this->request->getArgument('variable')