Problems with Yii2 creation Rules - yii2

I have a Yii2 with Yii2 admin, user andAdminLTE installed. My problem is I don't know how to create rules, actually I don't know how to define the Class Name. Where "Classes" should be defined? How can I see which Classes do I have or add Classes?
Thanks a lot,

The class that you'll enter should be the child class of yii\rbac\Rule. So, in order to make a rule you need to provide the namespace of this child class. Suppose, if the name of the child class is TestRule and the namespace of this class is app\test. Then you must write the class name as app\test\TestRule.
And your TestRule class must look like
namespace app\test;
class TestRule extends yii\rbac\Rule{
...
}

Related

PowerMockIgnore all package except one class

Is there any way to annotate #PowerMockIgnore to ignore the whole package except just one class inside this package?
I was hoping to do something like for example:
#PowerMockIgnore({ "foo.bar.ignore*\DoNotIgnoreClass"})
Use the #PrepareForTest annotation:
e.g.
#PrepareForTest(DoNotIgnoreClass.class)
or for multiple classes:
#PrepareForTest({DoNotIgnoreClass.class, Another.class})

In AS3, how do I run code when a when the movie starts?

I'm making a level editor for my game, and would like to be able to access a list of all the classes included in my game. I have a static function in my Main class:
public static function register(c:Class, category:String):void {
if (classRegister[category] == null) {
classRegister[category] = new Array();
}
classRegister[category].push(c);
}
Then, in each class I want registered, I put a static initializer:
{
Main.register(prototype.constructor, "motion");
}
However, the static initializers only get called when the class first gets used. Is there a way for a class to force itself to be used right when the game starts? I'm aware that I could explicitly list all the registered classes in the Main file, but that's suboptimal in that the Main file would have to be edited whenever a new class is added that wants registration.
Thanks,
Varga
List all the class definition in the ApplicationDomain, and filter them based on a naming convention or a type (an interface?).
To achieve this, you can use ApplicationDomain.getQualifiedDefinitionNames() (docs), but only if you target FlashPlayer 11.3+.
As a side note, you MUST reference this class somewhere, as a class field so the compiler knows it must include this class in the SWF. You can also put the classes you want to reference inside a SWC library and use -compiler.include-libraries as compiler setting (in that case I wonder if your static initializers gets called?).

Is it possible to access a class outside package from other package?

I have a class like this
package test{
class Test{}
}
class TestInnerClass{}
I can access the TestInnerClass from Test class but I need to access the TestInnerClass(as class, not its instance) from other class as well. And I don't really want to make TestInnerClass an independent class as all it contains are a few variables.
Is there any way to access the class from outside Test class?
[edit]
More specifically, I need the access for the following code to work.
registerClassAlias("TestInnerClass",TestInnerClass);
If you have a class that would not otherwise be accessed except internally by a public class you may define it as internal.
Internal classes are visible to references inside the current package.
In your example, TestInnerClass is only visible to Test.
Otherwise, to access the class or register class alias it must be defined public in its own .as file.
Packages help to order and classify code in hierarchy. Often, I'll keep Value Object or Data Transfer Objects within their own package, such as:
com.jasonsturges.model.vo
This helps to group smaller model classes together.
If you wanted to make a class visible outside of it's containing package your class would be defined as so:
// SampleCode.as file
package samples{
public class SampleCode {}
}
// CodeFormatter.as file
package samples{
class CodeFormatter {}
}
The SampleCode class is visible whilst the CodeFormatter class is not.
Hope I've answered your question

Create setter for a style property

I want to make a setter for the fontSize property of my WrappedLabel class because I need to do some additional stuff when someone changes it.
So when someone uses my class like this:
<comp:WrappedLabel fontSize="10"/>
I want to know.
I tried to override setStyle but looks like it doesn't get called when fontSize is initialized in mxml.
That's actually easier to accomplish then you might think, but it involves metadata. All you need to do is add a Style metadata declaration to your class definition, like so:
[Style(name="fontSize", type="Number", inherit="no")]
public class WrappedLabel {
...
}
If you want more information on the parameters of the metadata, read the docs.

Document class silently fails

I have this weird issue while compiling my .fla file : it won't use the Document class. Here is the document class. (note that the parent class EditorPlugin extends Sprite).
package com.myproject.plugins.editor {
import flash.display.MovieClip;
import com.myproject.editor.EditorPlugin;
import com.myproject.editor.tools.EpisodeEditorTool;
import com.myproject.editor.tools.NewTabTool;
import com.myproject.editor.tools.ToolManager;
public class EpisodeEditorPlugin extends EditorPlugin{
public function EpisodeEditorPlugin(){
trace("creating", this);
AddAuth(ToolManager.EDIT_EPISODE_AUTH, ToolManager.EDIT_EPISODE_AUTH, EpisodeEditorTool, ToolManager.EDIT_EPISODE_LABEL);
}
}
}
The weird part is that in the line below, if I use NewTabTool instead of EpisodeEditorTool, the code works just fine, but with EpisodeEditorTool, the Class is not instanciated. There are no warnings or compiling errors, but i don't get the trace. I loaded the resulting .swf, it is not of type EpisodeEditorPlugin, but rather a simple MovieClip (via getQualifiedClassName() and is EpisodeEditorPlugin).
The EpisodeEditorTool and NewTabTool are quite similar even though of different use, but very huge, here are their declarations :
public class EpisodeEditorTool extends JPanel implements ITool{
and
public class NewTabTool extends JPanel implements ITool{
I should add that both class contain no error (at least according to Flash) and have been compiled in other .flas before. the only problem I can see is that EpisodeEditorTool is even more huge(r?) than other ITools.
Does anyone have any idea of how a document class could fail to be applied? And fail silently at that?
Thanks!
The only thing I can really think of is that you're not specifying the name of the Document class correctly inside the Flash IDE. Inside the Properties panel there's a box where you enter the name of your Document class, which you must presumably have used if the Document class works when you rename the class to NewTabTool. I guess you put NewTabTool into that box, then changed the actual class' name, and forgot to change the reference in the Properties panel. I've forgotten that little bit when changing the name of my Document class before, I hope your solution is as simple as that!
debu