An Exception was Raised while Creating "Panel Authentication Adapter"; no instance returned

Asked

Viewed 118 times

0

Talks blz, face to with an error fd.. in zf2.. (it is just a system for study, I know that the framework is outdated) , the business is as follows. I am with 2 modules, 'Panel', 'Admin' and each of the modules is connected to different banks. admin module is working normally, but the error panel module in Doctrine entitymanager is working. I actually have 3 errors.

Error 1 -

An Exception was Raised while Creating "Panel Authentication Adapter"; no instance returned

Error 2 -

n Exception was Raised while Creating "Doctrine.entitymanager.orm_maxfoodapp"; no instance returned

Error 3 -

Options with name "orm_maxfoodapp" could not be found in "Doctrine.entitymanager".

Give me a light guys.. I’ve done everything and I can’t fix it.

local Orm.

<?php

return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => array(
                    'host' => '127.0.0.1',
                    'port' => '3306',
                    'user' => 'root',
                    'password' => 'root',
                    'dbname' => 'maxfood',
                    'driver' => 'pdo_mysql',
                    'driverOptions' => array(
                        1002 => "SET NAMES 'UTF8'"
                    )
                )
            ),

            //////////////////////////////     config-connections -------->
            'orm_maxfoodapp' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => array(
                    'host' => 'localhost',
                    'port' => '3306',
                    'user' => 'root',
                    'password' => 'root',
                    'dbname' => 'maxfood_application',
                    'driver' => 'pdo_mysql',
                    'driverOptions' => array(
                        1002 => "SET NAMES 'UTF8'"
                    )
                )
            ),
            'configuration' => array(
                //////////////////////////////     config-extra-configuration -------->
                'orm_maxfoodapp' => array(
                    'metadata_cache' => 'array',
                    'query_cache' => 'array',
                    'result_cache' => 'array',
                    'hydration_cache' => 'array',
                    'driver' => 'orm_maxfoodapp',
                    'generate_proxies' => true,
                    'proxy_dir' => 'data/DoctrineORMModule4/Proxy',
                    'proxy_namespace' => 'DoctrineORMModule4\Proxy',
                    'filters' => array()
                ),
            ),
            'entitymanager' => array(
                //////////////////////////////     config-extra-entitymanager -------->
                'orm_maxfoodapp' => array(
                    'connection' => 'orm_maxfoodapp',
                    'configuration' => 'orm_maxfoodapp'
                ),
            ),
            'eventmanager' => array(
                //////////////////////////////     config-extra-eventmanager -------->
                'orm_maxfoodapp' => array(),
            ),
        )
    )
);

Adpter -

<?php
/**
 * Created by PhpStorm.
 * User: m2corp
 * Date: 29/01/19
 * Time: 09:35
 */

namespace Panel\Authentication;

use Doctrine\ORM\EntityManager;
use Zend\Authentication\Adapter\AdapterInterface;
use Zend\Authentication\Result;
use Panel\Entity\Persons;

class Adapter implements AdapterInterface
{

    protected $em;
    protected $username;
    protected $password;

    protected $entity = "Panel\Entity\Persons";

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    /**
     * @return mixed
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * @param mixed $username
     */
    public function setUsername($username)
    {
        $this->username = $username;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * @param mixed $password
     */
    public function setPassword($password)
    {
        $this->password = $password;
        return $this;
    }



    public function authenticate()
    {
        $repository = $this->em->getRepository($this->entity);
        $user = $repository->username($this->getUsername(),$this->getPassword());

        if($user) {
            return new Result(Result::SUCCESS, array('user' => $user), array('OK'));
        } else {
            return new Result(Result::FAILURE_CREDENTIAL_INVALID, null, array());
        }

    }

}

Module -

 /**
  * Zend Framework (http://framework.zend.com/)
  *
  * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
  * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  * @license   http://framework.zend.com/license/new-bsd New BSD License
  */

namespace Panel;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Panel\Authentication\Adapter as AuthAdapter;
use Zend\Authentication\Storage\Session as SessionStorage;
use Zend\Authentication\AuthenticationService;

class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);
    }

    public function getServiceConfig() {

        return array(
            'factories' => array(
                'Panel\Form\Access' => function($sm) {
                    return new Form\Access("access");
                },

                ///////////////////////////////////////////    Serviços   ->
                'Panel\Service\Persons' => function($em) {
                    return new Service\Address($em->get('doctrine.entitymanager.orm_maxfoodapp'));
                },
                'Panel\Authentication\Adapter' => function($service) {
                    return new AuthAdapter($service->get('doctrine.entitymanager.orm_maxfoodapp'));
                },
            ),
        );
    }

    public function getViewHelperConfig() {
        return array(
            'factories' => array(
                'flashMessage' => function($sm) {

                    $flashmessenger = $sm->getServiceLocator()
                        ->get('ControllerPluginManager')
                        ->get('flashmessenger');

                    $message   = new \Admin\View\Helper\FlashMessages( ) ;
                    $message->setFlashMessenger( $flashmessenger );

                    return $message ;
                },
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
}
  • Says Nando, it would be interesting that you format your question better so that the codes don’t get cut in half and we can read it better as a whole. Another tip I give you is to improve the title of your question to facilitate future research, so there is not much help.

  • Speak David, thank you very much, I used only the stack for research, never posted anything, newbie is fucking haha. but vlw by touch, I’ll fix them and take more care next time.. vlww

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.