PHP/Laravel can not resolve parent Class - php-7

Using php 7, Laravel 5.5. All models are in default app/ folder, Prototype is in app/ folder too. Nothing was moved
What is most frustrating - this worked all right for controllers (everything is in their default folders)
My Prototype Class:
class Prototype extends Model
{
//other code
}
My child Class:
class Tree extends Prototype
{
//other code
}
Exception:
include(/var/www/html/app/Prototypephp): failed to open stream: No such file or directory
I need help to fix this issue. Thanks!

After a few hrs of working over this issue solved it by moving Prototype Class to other namespace (and folder). Did the same to PrototypeController for code readability.

Related

How to bundle a plugin which requires multiple files in order to work

I'm facing an issue when I try to bundle Aurelia-hammer with the CLI.
The app still keeps pulling hammer-swipe.js, hammer-tap.js,... from the node_modules folder.
When I inspect the plugin's AMD structure, these are defined as global resources:
function configure(frameworkConfig) {
frameworkConfig.globalResources('./hammer-swipe');
frameworkConfig.globalResources('./hammer-tap');
frameworkConfig.globalResources('./hammer-press');
frameworkConfig.globalResources('./hammer-hold');}
Is there any way to bundle these with the CLI? I tried adding these files to the "resources" element in aurelia.json without success.
the plugin author should export those classes: (HammerPressCustomAttribute...) so they could be traced properly. But you can dummy-import theme yourself as a workaround:
import { HammerPressCustomAttribute } from 'aurelia-hammer/hammer-press';
import { HammerSwipeCustomAttribute } from 'aurelia-hammer/hammer-swipe';
import { HammerTapeCustomAttribute } from 'aurelia-hammer/hammer-tap';
normally you have to do this as well:
import { HammerHoldCustomAttribute } from 'aurelia-hammer/hammer-hold';
but the class exported from hammer-hold.js is named HammerPressCustomAttribute (oops looks like copy-paste issue) so just reference the file even with a non existent class.
import { HammerHoldCustomAttribute } from 'aurelia-hammer/hammer-hold';
this should fix your problem (I hope). It's best to open an issue in the plugin repo and ask the author to export those classes (and rename the duplicate one).

How and where to instantiate a custom class that extends the WP_REST_Controller

I have a plugin that I created and I want to use the WP rest api controller pattern in order to extend the api.
<?php
/**
* Plugin Name: myplugin
* Plugin URI: h...
* Description: A simple plugin ...
* Version: 0.1
* Author: Kamran ...
* Author ....
* License: GPL2
function myplugin_register_endpoints(){
require_once 'server/controllers/my_ctrl.php';
$items=new items();
$items->register_routes();
}
add_action('rest_api_init','myplugin_register_endpoints');
.
.
I created a class a folder called server/controllers and inside it my_ctrl.php file with a class that extends WP_REST_Controller that looks like this
// server/controllers/my_ctrl.php
class items extends WP_REST_Controller {
/**
* Register the routes for the objects of the controller.
*/
public function register_routes() {
.....
}
}
However I am receiving the following error in sublime xdebuge call stack:
[Fatal error] Class 'myplugin\WP_REST_Controller' not found
I am not sure how to solve this issue, where to put the files for my custom controller, where to create the instance of the custom class etc?
Stumbled upon this and thought I'd provide my solution in case someone else encounters this.
The idea is to postpone the instantiation of the class extending WP_REST_Controller by not instantiating it until the actual rest_api_init hook is called.
Code example:
add_action( 'rest_api_init', function () {
require_once(plugin_dir_path(__FILE__) . '/VideoImageApi.php');
VideoImageApi::instance()->register_routes();
});
Note the require_once from within the callback.
I have manged to solve the issue,
I checked the wp-content\plugins folder and I couldn't find the \rest-api folder and although I found the folder inside \wp-includes\rest-api it seems that this folder that integrates the "wp rest api" into core doesn't include all the classes that the api can expose (it includes only 3 php files), So it didn't include \wp-content\plugins\rest-api\lib\endpoints\class-wp-rest-controller.php . I installed the "wp rest api" plugin and it was added to wp-content\plugins and now I don't have the error anymore. (It was strange because I don't know when it was deleted from my project)
Thank you Dan your comments really helped me to recheck everything and scan the folders included in my wordpress and realize that the plugin is missing and that the folder \wp-includes\rest-api doesnt contain all the needed classes.

Override and use front controller features in a prestashop module [1.6.x.x]

I would like to edit and add features to the prestashop Store Locator page.
Prestashop's documentation isn't really clear, and i would like to know if it's possible to implement a Controller in a custom module.
I would like to create a module which is able to extends StoreFrontController and it's features without starting from scratch.
Is it possible ? Have you some documentation for me ?
A beginner,
Best.
As you have many requirements, you will have to go with an override of class StoresController.php.
Your module folder should look like this:
/mymodule
/mymodule.php
/config.xml
/override
/controllers
/front
StoresController.php
/views
/templates
/front
stores.tpl
In StoresController.php you will have to override initContent():
<?php
class StoresController extends StoresControllerCore
{
/**
* Assign template vars related to page content
* #see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
// here add any smarty variables you want
$this->setTemplate(_PS_MODULE_DIR_.'mymodule/views/templates/front/stores.tpl');
}
}
Now you can add as many variables as you want in this controller and customized its template in your own module.
We you create an override in a module, it will be only parsed once at installation. If your module is already installed you will have to uninstall it and install it again. Then your override file will be copied to the root /override folder.
Any change made in your module override will not be reflected to the root override folder. So you will have to uninstall and install your module each time you want to make a change.
So I advise you to make all your changes directly in the root override folder, and when you're done copy this file back into your module folder. And if you don't want to uninstall your module and install it again to declare this file, you can put it directly in the root override folder and delete the file /cache/class_index.php so that Prestashop knows that an overrides has been added.
If you have any questions :)
You can start by overriding front controller like
`"/modules/mymodule/override/controllers/front/StoresController.php" and in this fine add class "class StoresControllerCore extends FrontController {
public function initContent()
{
parent::initContent();
//here do whatever you like
}
}"
though you must know coding to proceed further.

Shared base controller between modules

I am setting up a multi-module application, so far I have it setup like this example http://docs.phalconphp.com/en/latest/reference/applications.html.
But I was wandering if its possible to have shared base controller that both the backend and frontend controllers extend from. This is so I can have a single ACL in the base controller. How would I set that up?
According to the docs I can create a controllerbase anywhere and then just require this file directly in the bootstrap file or cause to be loaded using any autoloader. So I created a folder called apps/shared/controllers/ControllerBase.php and required this file directly in the bootstrap file but this does not work.
If I try to load a controller like so:
class AdminController extends ControllerBase
{
public function indexAction()
{
echo "<h1>Hello admin!</h1>";
}
}
I get an error ...Backend\Controllers\ControllerBase' not found in......
So how do I cause to be loaded using any autoloader as per the docs? Do I need to register it as its own namespace or something?
You not using the full namespace path for your base controller so the autoloader attempts to find it under in the same namespace of the child class.
Try something like this:
namespace MyApp\Backend\Controllers;
use MyApp\Shared\Controllers\ControllerBase;
class AdminController extends ControllerBase
{
public function indexAction()
{
echo "<h1>Hello admin!</h1>";
}
}
This answer consider that you have applied the PSR-0 and PSR-4 properly.

The hierarchy of the type AddEntryAction is inconsistent (Jface)

i have the following class in eclipse
class AddEntryAction extends Action {
public AddEntryAction() {
super("Add Entry");
setToolTipText("Add Entry");
}
public void run() {
WizardDialog dlg = new WizardDialog(MainClass.mainWindow.getShell(),
new AddEntryWizard());
dlg.open();
}
}
and Action class extends AbstractAction which intern extends EventManager class. Both these parent classes are part of the eclipse SWT/jface libraries... I get the following error on the above class declaration
The project was not built since its
build path is incomplete. Cannot find
the class file for
org.eclipse.core.commands.common.EventManager.
Fix the build path then try building
this
project DisplayExample Unknown Java
Problem
The type
org.eclipse.core.commands.common.EventManager
cannot be resolved. It is indirectly
referenced from required .class
files MainClass.java /DisplayExample/src line
94 Java Problem
AddEntryAction is declared within the same source file MainClass.java. Actually, this is an example from Java2s.com ... I have the libraries/jars because i can see the compiles classes of all these clases
The error "The project was not built since ... org.eclipse.core.commands.common.EventManager cannot be resolved..." with swt/jface dependencies can be caused by missing reference sources or binaries containing org.eclipse.core packages in addition to org.eclipse.swt and org.eclipse.jface packages.
E.g. build path in my case included:
swt.jar
org.eclipse.jface_3.4.2.M20090107-0800.jar
Following jar was missing and caused above error:
org.eclipse.core.commands_3.4.0.I20080509-2000.jar