Zakaria
Zakaria

Reputation: 76

ZF2 : ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0

How can fix it (zend version 2.5) ?

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

I tried :

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);
        }
    }

Upvotes: 1

Views: 5014

Answers (2)

calraiden
calraiden

Reputation: 1818

You need add ~E_USER_DEPRECATED

You can add in the public/index.php

ini_set ( "error_reporting", E_ALL & ~ E_DEPRECATED & ~E_USER_DEPRECATED  & ~ E_STRICT );

or

error_reporting ( E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_STRICT );

User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error().

http://php.net/manual/en/errorfunc.constants.php

Upvotes: 1

Oskar
Oskar

Reputation: 105

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

This Link helped me to inject dependencies right.

Upvotes: 4

Related Questions