like in topic, I have two static method in view helper but when I try to call in controller action by
Zend_View_Helper_SomeHelper::firstStaticMethod();
I got error:
Warning: include_once(Zend/View/Helper/SomeHelper.php): failed to open stream: No such file or directory in /library/Zend/Loader.php on line 134 Warning: include_once(): Failed opening 'Zend/View/Helper/SomeHelper.php' for inclusion (include_path='/application/../library:/library:.:/usr/share/pear:/usr/share/php') in /library/Zend/Loader.php on line 134 Fatal error: Class 'Zend_View_Helper_SomeHelper' not found in /application/modules/default/controllers/Controller.php on line 174
Helper code:
class Zend_View_Helper_SomeHelper extends Zend_View_Helper_Abstract {
//....//
public static function firstStaticMethod(){
//some code hear
}
public static function secoundStaticMethod(){
//some code hear
}
}
I need to use this method in helpers and action.
any ideas?
Can you try this
$viewHelperObj = $this->view->getHelper('SomeHelper');
$viewHelperObj->secoundStaticMethod();
Related
I'm trying to debug a library which uses haxe.macro.TypeTools::findField. I've created a simple code for that:
package;
using haxe.macro.TypeTools;
class Main
{
public function new()
{
var test = findField(Child, "hello");
trace(test);
}
}
class Base
{
private function hello()
{
}
}
class Child extends Base
{
public function new() {}
}
However I'm getting error Unknown identifier : findField. Is this because it can only be used in build macro context?
This is what I'm trying to emulate.
First of all, function findField() is not from the haxe.macro.TypeTools.
It is a helper function from edge.core.macro.Macros.
To use it without a class path, import it's class with a wildcard import edge.core.macro.Macros.*
Secondly, findField() should be used in a build macro context only, since it expects Array<Field>, which is obtained by haxe.macro.Context.getBuildFields().
When I call init() I get an error saying the class "Facebook" has not been declared. Every tutorial online has similar code and supposedly works so I'm guessing its a setting somewhere I haven't set because it does look like its getting imported.
My Code:
import flash.display.MovieClip;
import com.facebook.graph.Facebook;
import com.facebook.graph.net.*;
import com.facebook.graph.data.*;
public class A_CLASS extends MovieClip {
protected var _appID:String = "164534125383085";
function A_CLASS():void {
Facebook.init(_appID, logIn);
}
function logIn(session:Object, fail:Object):void {
console.text = "Did Init()";
}
}
My Output:
ReferenceError: Error #1065: Variable com.facebook.graph::Facebook is not defined.
at ALPHA_CLASS()[C:\Users\DelphPC\Desktop\FlashProjects\A\A_CLASS.as:11]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
ReferenceError: Error #1065: Variable com.facebook.graph::Facebook is not defined.
that means your program cannot see the reference class please check your Build Path SWC or ANE and build your project then retry
How can I implement mysqli in an extended class?
I am uploading an image and storing it in a MySQL database, but I get this error:
Notice: Undefined variable: mysqli in ...ecc/ecc/ on line 33
Fatal error: Call to a member function query() on a non-object in ...ecc/ecc/ on line 33
Here is my test code:
<?php
interface ICheckImage {
public function checkImage();
public function sendImage();
}
abstract class ACheckImage implements ICheckImage {
public $image;
private $mysqli;
public function _construct(){
$this->image = $_POST['image'];
$this->mysqli = new mysqli('localhost','test','test','test');
}
}
class Check extends ACheckImage {
public function checkImage() {
if($this->image > 102400) {
echo "File troppo grande";
}
}
public function sendImage() {
//This is the line 33 give me the error
if ($mysqli->query("INSERT INTO images (image) VALUES ('$this->image')")) {
echo "Upload avvenuto  ";
} else {
echo "Errore  " . $mysqli->error;
}
}
}
$form = new Check();
$form->checkImage();
$form->sendImage();
?>
There are some errors in your code.
The $mysqli member is private inside the abstract class. It will not be inherited by the Check class, so it does not exist there. Make it protected.
Access to the members of a class always needs $this-> in front, specifically $this->mysqli in this instance.
The constructor function must be named __construct with two underscores in front.
The image check looks wrong. $_POST['image'] does contain something that you expect to store in the database, but you also compare it with an integer value and seem to echo an error message if it is bigger. While the data handling will work, e.g. you can compare a string from POST data with an integer, it looks like you want something else.
I have this code
class PagamentoController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$model_pagamenti = new Model_Pagamento();
$this->_helper->layout->setLayout('/crudabstract/index.phtml');
$this->view->render('/crudabstract/index.phtml');
}
...
and when i run /pagamento/index
i get this error
An error occurred
Application error
Exception information:
Message: script 'pagamento/index.phtml' not found in path (C:/www/www/abc/application/views\scripts/)
Stack trace:
why won't it work ? it's not supposed to be looking for "pagamento/index.phtml", but for "/crudabstract/index.phtml"
thanks
found out how in my own code
$this->_helper->viewRenderer('crudabstract/'.$this->_request->getActionName(), null, true);
the error message states that there is no view script defined for the index action. when you define a controller, zend framework will automatically look for a corresponding view file which is not being found in your case. so create a corresponding view file in
application/views/script/pagamento/index.phtml
and it should work.
Iam writing an application using Zend Framework 1.10.2.
I created few model classes and a controller to process them.
When Iam executing my application and accessing the admin controller. Iam seeing this error.
Fatal error: Class 'Application_Model_DbTable_Users' not found in C:\xampp\htdocs\bidpopo\application\controllers\AdminController.php on line 16
The error clearly shows its an autoloading error.
Hence I wrote this code in the bootstrap file.
protected function initAutoload()
{
$modeLoader = new Zend_Application_Module_AutoLoader(array
('namespace'=>'','basePath'=>APPLICATION_PATH ));
//echo(APPLICATION_PATH);
return $modeLoader;
}
Still the error remains :( . Can anyone suggest me what Iam missing out here?
This is the location of the Model Users class.
C:\xampp\htdocs\bidpopo\application\models\DbTable\Users.php
This is its code.
class Application_Model_DbTable_Users extends Zend_Db_Table_Abstract
{
//put your code here
protected $_name='users';
public function getUser($id)
{
$id = (int)$id;
$row = $this->fetchrow('id='.$id);
if(!$row)
{throw new Exception("Could not find row id - $id");}
return $row->toArray();
}
public function addUser($userDetailArray)
{
$this->insert($userDetailsArray);
}
public function updateUser($id,$userDetailArray)
{
$this->update($userDetailArray,'id='.(int)$id);
}
public function deleteUser($id)
{
$this->delete('id='. (int)$id);
}
}
This is the Admin Controller's code
class AdminController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->title= "All Users";
$this->view->headTitle($this->view->title);
$users = new Application_Model_DbTable_Users();
$this->view->users = $users->fetchAll();
}
public function addUserAction()
{
// action body
}
public function editUserAction()
{
// action body
}
public function deleteUserAction()
{
// action body
}
You application classes don't follow the proper naming convention for the namespace you've set. The Zend_Application_Module_AutoLoader is a little different than the normal autoloader in that it doesn't simply change the '_' in the class name with '/'. It looks at the second part of the class name and then checks a folder for the existence of the class based on that.
You need to change the line:
$modeLoader = new Zend_Application_Module_AutoLoader(array(
'namespace'=>'Application',
'basePath'=>APPLICATION_PATH
));
This means it will autoload all module classes prefixed with 'Application_'. When it the second part of the class is 'Model_' it will look in "{$basePath}/models" for the class. The '_' in the rest of the class name will be replaced with '/'. So the file path of the file will be "{$basePath}/models/DbTable/Users.php".
Read more here.