ZF2:ServiceLocatorAwareInterface 已弃用,将在 3.0 版中删除 [英] ZF2 : ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0

查看:25
本文介绍了ZF2:ServiceLocatorAwareInterface 已弃用,将在 3.0 版中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修复它(zend 2.5 版)?

How can fix it (zend version 2.5) ?

ServiceLocatorAwareInterface 已弃用,将在 3.0 版中与 ServiceLocatorAwareInitializer 一起删除.请更新您的班级 Teacher\Controller\TeacherController 以删除实现,并开始通过工厂注入您的依赖项

ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. Please update your class Teacher\Controller\TeacherController to remove the implementation, and start injecting your dependencies via factory instead

我试过了:

class TeacherControllerFactory implements FactoryInterface
    {
        public function __invoke(ContainerInterface $container, $name, array $options = null)
        {
            return new TeacherController(
                $container->getServiceLocator()->get(TeacherService::class)
            );
        }

        /**
         * Create and return TeacherController instance
         *
         * For use with zend-servicemanager v2; proxies to __invoke().
         *
         * @param ServiceLocatorInterface $container
         * @return TeacherController
         */
        public function createService(ServiceLocatorInterface $container)
        {
            return $this($container, TeacherController::class);
        }
    }

推荐答案

看看 这里.补丁已经合并了.这是补丁链接.

Have a look here. The patch is already merged. Here is the link to the patch.

此链接帮助我注入依赖项没错.

This Link helped me to inject dependencies right.

这篇关于ZF2:ServiceLocatorAwareInterface 已弃用,将在 3.0 版中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆