Inherit a class present in plugin to the app controller in cakephp - cakephp

I want to Inherit a controller present in plugin of cakephp in my app/xyz_controller class.Is it possible.Can somebody help me.

If you need to use some class functionality you can import it but inheriting a class in a controller is not a good practice, as PHP doesn't support multiple inheritance you'll lose all functionality Controller class provides.

Related

ApplicationModule definition class code is blank in ADF

When i select Generate Application Module class and click OK, The AMImpl.java class is generated without any code. what might be the reason for this?
It's because all the code is in the base class.
What do you expect to be in the class?
When you define to create the class, you can choose what will be created (all based on the time you create the class).
Then all methods you write will end up in this class and can be exposed to the client.
Use is described here.
Per the docs:
The base classes of the ADF Business Components framework may be
extended to incorporate custom code with all types of components in
the framework and to extend the ADF Business Components framework
behavior.
When used without customization, your business component is completely defined by its XML document and it will be fully functional
without custom Java code or even a Java class file for the component.
If you have no need to extend the built-in functionality of a
component in ADF Business Components, and no need to write any custom
code to handle its built-in events, you can use the component in this
XML-only fashion. However, when you do extend base classes of the ADF
Business Components framework, you can still work with XML documents
in JDeveloper.
Once you have created framework extension classes, any new business component you create can be based on your customized
framework class instead of the base one. And, you can always update
the definitions of existing components to use the new framework
extension class as well.
Best practice is to create your own set of custom framework extension classes so you have hook points for creating common code for your custom ADF BC EOs and VOs

Laravel : Should I extend my User class to 'Authenticatable'?

Im building an app with AngularJS and Laravel. I'm currently working on a login page.
By default in Laravel, the 'out of the box' class User extends 'Authenticatable' but I would like to know if I can rather simply extend it to 'Model', because I actually want to rule my authentication access through AngularJS routing and not via Laravel. I don't know if this makes sense.. and if this would even work (I dont wanna break the logic behind Laravel). Could anyone help me on that?
The Authenticatable refers to Illuminate\Foundation\Auth\User which in turn includes some Traits and implements some contracts, depending on whether you're going to use Laravel's Auth system it seems like you can omit extending this class without any problems.

How do I override the models and controllers in a plugin in CakePHP?

How can I override a CakePHP plugin from application? I see that overriding of a view is very simple (http://book.cakephp.org/2.0/en/plugins.html#overriding-plugin-views-from-inside-your-application), but how can I override a controller or a model?
You can override and extend plugin views modeld and controllers. There is a good example of doing this in the below link.
https://github.com/CakeDC/users#how-to-extend-the-plugin
Basically this is the summary... In your model you need to declare it like so.
App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {
}
No you cannot override any plugin class files in your app like you can do for view files. Just make a copy of the plugin and modify required class files.

CakePHP: Overrride Controller method with plugin

I'm new to this framework and looking to extend/override a Controller method with a plugin. If this is the wrong way to do this please let me know. I just want the solution to be modular in that there is no tampering with the extended controller. This is what I'd like..
MyController extends AppController{
function index(){}
}
I have a plugin
MyPlugin extends MyController{
function index(){}
}
I want when MyController->index() gets called it runs MyPlugin->index(). Any help would be appreciated.
What you're asking for is some kind of "reverse-inheritance", which is not supported in PHP (one might consider Aspects in Java or ObjectiveC's categories).
As far as I understand, you have the following situation:
"3rd Party App's Controller class" extends "CakePHP's Controller class"
You get both classes from external upstreams and want to modify the 3rd Party App's Controller without sacrificing either upstream. This is not possible by language, and as far as I can tell CakePHP offers no framework solution.
You might be able to achieve your goal by modifieng the routing, i.e. redirect requests to MyController to your custom MyPlugin controller and call MyController's action from there.

CakePHP Calling a Plugins Model in the App's Controller

I am building a plugin and have certain methods in the Model of the Plugin.
From the Controller of the App lets say Users Controller i wanna call a Model from the Plugin.
How do i access the Plugins Model ?
$this->loadModel('PluginName.ModelName');
whats the big deal?

Resources