मैं एक प्रणाली Zend फ्रेमवर्क 2 का उपयोग कर विकसित कर रहा हूँ में कारखाने द्वारा बंद की जगह और चाबी config_cache_enabled
application.config.php
में बंद एक त्रुटि प्राप्त कर दें:Zend फ्रेमवर्क 2 - Module.php
Fatal error: Call to undefined method set_state Closure::__()in /home/user/www/myProject.com/data/cache/module-config-cache.app_config.php online 185.
बेहतर सर्च कर रहे हैं मैंने पाया यह नहीं था Module.php
में बंद करने का उपयोग करने की अनुशंसा की गई क्योंकि यह कॉन्फ़िगरेशन कैश में इस त्रुटि के कारण हुआ था, इसके बारे में सोचकर मैंने कुछ पोस्ट पढ़ीं जो कारखाने द्वारा बंद करने की प्रतिलिपि बनाने की सिफारिश करती हैं।
यही मैंने किया है, मैंने एक कारखाना बनाया है और डीजी को टेबलगेटवे में Module.php
में फैक्ट्री द्वारा प्रतिस्थापित किया है और पूरी तरह से काम किया है, मेरा सवाल यह है कि मुझे नहीं पता कि यह ठीक है या नहीं।
क्या कोई मुझे बता सकता है कि समस्या को हल करने का यह सही तरीका है या नहीं?
application.config.php
- से पहले:
'Admin\Model\PedidosTable' => function($sm) {
$tableGateway = $sm->get('PedidosTableGateway');
$table = new PedidosTable($tableGateway);
return $table;
},
'PedidosTableGateway' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Pedidos());
return new TableGateway('pedidos', $dbAdapter, null, $resultSetPrototype);
},
application.config.php - के बाद:
'factories' => array(
'PedidosTable' => 'Admin\Service\PedidosTableFactory',
),
'aliases' => array(
'Admin\Model\PedidosTable' => 'PedidosTable',
),
TableFactory:
namespace Admin\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Admin\Model\Pedidos;
use Admin\Model\PedidosTable;
class PedidosTableFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Pedidos());
$tableGateway = new TableGateway('pedidos', $dbAdapter, null, $resultSetPrototype);
$table = new PedidosTable($tableGateway);
return $table;
}
}
यह एप्रोच सही है, हां। हालांकि, मैं आपको जादू विधि __invoke usung करने के लिए स्विच करने की सलाह देते हैं। मैं बाद में एक स्पष्टीकरण के साथ एक कोड नमूना पोस्ट करूंगा। – Stanimir
हाँ यह ठीक है ... – tasmaniski