I have a class which I am using $this with and since upgrading from 5.6 to 7.1 I cannot get to work. I'm confused as to why? Please see code sample below:
class user_BL extends BLL {
public function getCurrentUserFromSession($userid) {
$userrecord = array();
$query = new query();
$query->addCriteria("userid", $userid , "=");
$userrecords = $this->getDataByQueryObj($query, new user_DAL());
if (isset($userrecords[0])){
$userrecord = $userrecords[0];
$lastlogindetails = $this->getLastLoginDetailsAsArray();
$userrecord['logindatetime'] = astlogindetails['logindatetime'];
}
return $userrecord;
}
}
getLastLoginDetailsAsArray is a function on the BLL base class. The IDE interprets this ok and sees that its available to be used.
Anyhelp with this would be really helpful.
Thanks,
Deano
EDIT: the error I'm getting is Fatal error: Uncaught Error: Using $this when not in object context
Forgot to add that it was a long day yesterday. :)
After digging into the error I've found the call was being made like this:
user_BL::getCurrentUserFromSession();
which seems to be the problem. Calling it like this:
$userbl = new user_BL();
$userbl->getCurrentUserFromSession();
Corrects this.
Thanks for everyones help.
Related
I'm just trying a very simple test
<?php
require 'vendor/autoload.php';
class Blog
{
public function post ()
{
return 'ok';
}
}
$builder = new \Aura\Di\ContainerBuilder();
$blog = $builder->newInstance('Blog');
echo $blog->post();
This results to:
Fatal error: Uncaught Error: Call to undefined method Aura\Di\Container::post()
Am I missing something?
Yes , you are missing to read the docs. You have created builder. Next you need to get the di via new instance. This is what you assigned to blog variable.
Please consider reading getting started http://auraphp.com/packages/3.x/Di/getting-started.html#1-1-1-2
// autoload and rest of code
$builder = new \Aura\Di\ContainerBuilder();
$di = $builder->newInstance();
Now you create instance of object
$blog = $di->newInstance('Blog');
echo $blog->post();
Please read the docs.
I am trying to consume a soap service in php. This is the code I am using
define('APIURL','https://cgorders.com/v2.1/Service.asmx?WSDL');
$client = new SoapClient(APIURL);
$search_query = new StdClass();
$search_query ->CustomerID = CustomerID;
$search_query ->ClientPO = $orderID;
$search_query ->AccessToken = $cgTokem; //AccessToken;
$result = $client->GetOrdersByClientPO($search_query);
//echo "<pre>";print_r($result->GetOrdersByClientPOResult->Orders->OrderID);echo "</pre>";exit;
if(isset($result->GetOrdersByClientPOResult->Orders->OrderID))
{
return($result->GetOrdersByClientPOResult->Orders->OrderID);
}
else
{
return('');
}
I am passing appropriate parameters correctly, did not mention them, for security reasons.
I am getting Call to undefined method soapclient::GetOrdersByClientPO() . Can anybody help?
check available functions by calling $client->::__getFunctions(); and see if GetOrdersByClientPO in the returned list
Soap client was not installed over the server, I was testing. After installation, it worked like a charm.
Thank you.
I wanted to help a friend on his website and he told me to change a link. he use smarty and the website is online
so i change this
<li class="first">Le réseau</li>
to absolute path.
Now, i have this error
Fatal error: Call to undefined function reecrire_url() in /home/deflandrgb/www/includes/smarty/sysplugins/smarty_internal_filter_handler.php on line 60
But I have not changed anything except link.
why I have this error?
Thanks
ps: I handed the old link but I still have the same error
EDIT : i find this function in Site_Smarty.class.php
class Site_Smarty extends Smarty{
public function Site_Smarty(){
parent::__construct();
//$this->caching = true;
//$this->compile_check = true;
$this->template_dir = root.'templates/';
$this->compile_dir = root.'templates_c/';
$this->config_dir = root.'includes/smarty/';
$this->cache_dir = root.'cache/';
//$this->debugging = true;
$this->registerFilter('pre','reecrire_url');
$this->assign('app_name', 'Guest Book');
$this->assign('path', path);
}
}
Seems you missed to define the callback function "reecrire_url"
See docs:
http://www.smarty.net/docs/en/api.register.filter.tpl
I'm getting the following error in magento administration
Fatal error: Class 'Zend_Log' not found in /home/website/public_html/app/code/community/Uni/Fileuploader/Block/Adminhtml/Fileuploader/Edit/Tab/Products.php on line 241
This is a community extension, which has been working fine on my website. The error makes no sense to me, because the line 241 contains just a closing "}" character.
class Uni_Fileuploader_Block_Adminhtml_Fileuploader_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
...
...
...
public function getRowUrl() {
return '#';
}
public function getGridUrl() {
return $this->getUrl('*/*/productgrid', array('_current' => true));
}
protected function getFileuploaderData() {
return Mage::registry('fileuploader_data');
}
protected function _getSelectedProducts() {
$products = $this->getRequest()->getPost('selected_products');
if (is_null($products)) {
$products = explode(',', $this->getFileuploaderData()->getProductIds());
return (sizeof($products) > 0 ? $products : 0);
}
return $products;
}
} // line 241, where error occurs
I can post the rest of the code, if you need it.
I noticed that if I upgrade to PHP 5.4 version the error disappears, but since 5.4 version causes other errors on my website, I have to continue using 5.3.
Any ideas on how to solve this?
The problem could be the name of one of the methods in your custom class.
Take for example the method name is getData() ,
Try searching for generic method names in your script, such as getData, which might be reserved by some of Magento’s core classes. I figure that these methods have predefined functionality, which your module is missing support for, and Zend then tries to write an exception to Zend log.
Reference link: netismine
I got the same error when rewriting a payment method.
public function authorize($payment, $amount)
Solved rewriting exactly the same main method:
public function authorize(Varien_Object $payment, $amount)
Magento 1.9.1.0/PHP 5.5
so... I basically follow the practical symfony book, and encountered following problem.
I have properly (i guess) installed sfGuardPlugin, built the models, sqls etc, created user and tried to log in with the username and password entered.
i got the following error message:
Fatal error: Call to undefined method sfGuardUserPeer::retrieveByUsername() in /***/plugins/sfGuardPlugin/lib/validator/sfGuardValidatorUser.class.php on line 53
it looks quite weird to me, because the problematic part of sfGuardValidatorUser class looks like this:
// user exists?
if ($user = sfGuardUserPeer::retrieveByUsername($username))
{
// password is ok?
if ($user->getIsActive() && $user->checkPassword($password))
{
return array_merge($values, array('user' => $user));
}
}
while sfGuardUserPeer has just the empty class:
class sfGuardUserPeer extends PluginsfGuardUserPeer
{
}
that extends PluginsfGuardUserPeer, so i checked it out too:
class PluginsfGuardUserPeer extends BasesfGuardUserPeer
{
public static function retrieveByUsername($username, $isActive = true)
{
$c = new Criteria();
$c->add(self::USERNAME, $username);
$c->add(self::IS_ACTIVE, $isActive);
return self::doSelectOne($c);
}
}
that's the missing function!
so - what is wrong? why doesn't it work?
i have already tried all the solutions found with google, but none of them work :/
finally found it!
the
symfony propel:build-model
task unnecessarily generated the sfGuard classes in the model directory from the schema file located in the plugin directory, while all the classes were already present in the sfGuard folder.
geez, that shouldn't happen in such a well-developed framework and plugin...
Simply put that
public static function retrieveByUsername($username, $isActive = true)
{
$c = new Criteria();
$c->add(self::USERNAME, $username);
$c->add(self::IS_ACTIVE, $isActive);
return self::doSelectOne($c);
}
Code into your sfGuardUserPeer class, this will sort out the issue, I did the same when I got this error, it worked for me..