The method creates an object and I call the method from another object
In the router, in the way, in the included file is the controller code. into the model, and in my opinion I need access to controller properties and methods. In the router, in another method, I want to return the controller object to the model and view. What Now ??
If I understand the question correctly, you are a little confused about MVC. The router class is the inner class of the cake and should never ever be absolutely never changed. And those "never" are not even copied, they are actually printed.
Second, the model classes don't even know anything called a controller. The controller uses models, not the other way around. If your model needs something from the controller, pass it as a parameter. Anything behind this is just bad design.
Also, calling controller actions from a view is possible, but strongly discouraged. The controller is the one that prepares all the data for the view, so the view doesn't need to access the controller (there are exceptions to this, outside the scope of this question).
I recommend you read a little about MVC , cake a typical request, and at least go through a basic blogging tutorial .
a source to share
Edit: In light of the tag change, this answer is no longer relevant. I left it to save comments ...
Original answer:
Like this?:
public MyObject CreateObject()
{
return new MyObject() { FirstProperty = "Hello World" };
}
public Main()
{
MyObject n = CreateObject();
Console.WriteLine(n.FirstProperty);
}
Or that?:
class Program
{
MyObject _myObject;
public void CreateObject()
{
_myObject = new MyObject() { FirstProperty = "Hello World" };
}
public Main()
{
Console.WriteLine(_myObject.FirstProperty);
}
}
In either of these two cases, you can access the properties of your object. If that's not what you meant, I don't know exactly how to answer your question, and you need to clarify.
a source to share