【发布时间】:2018-01-19 17:31:44
【问题描述】:
我很困惑如何在 ZF2 中创建对象的新实例。 我的课程名为 Clientela,我想在另一个页面中创建此类的新实例,但尝试执行此操作时出错。
我的班级是:
<?php
namespace Magento\Framework\Model\ResourceModel\Clientela;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\ResourceModel\AbstractResource;
class Clientela{
private $id;
private $nome;
private $email;
public function __construct(){
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getNome(){
return $this->nome;
}
public function setNome($nome){
$this->nome = $nome;
}
public function getEmail(){
return $this->email;
}
public function setEmail($email){
$this->email = $email;
}
}
?>
我正在尝试在另一个页面中初始化 .php
use Magento\Framework\Model\ResourceModel\Clientela as Cli;
$cli = new Cli();
但它不起作用。 错误:
Fatal error: Class 'Magento\Framework\Model\ResourceModel\Clientela' not found in /var/www/html/vendor/magento/module-contact/view/frontend/templates/form.phtml on line 20
我该怎么做?
【问题讨论】:
-
您是否尝试在您的视图中创建
Cli的实例? -
是的,只是为了理解。
-
试试
use Magento\Framework\Model\ResourceModel\Clientela\Clientela as Cli;。在 ZF 中创建对象实例的方式与 PHP 没有什么不同。 -
我必须映射这个类吗?它仍然无法正常工作。
标签: php zend-framework zend-framework2 magento2