laminas-api-tools/api-tools-admin

Deprecation Warning for ServiceLocatorAwareInterface

weierophinney opened this issue · 4 comments

With deprecation of ServiceLocatorAwareInterface following classes will raise deprecation warnings:

  • ZF\Apigility\Admin\Model\AbstractAutodiscoveryModel
  • ZF\Apigility\Admin\Model\DoctrineAdapterResource

Deprecated: ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. Please update your class ZF\Apigility\Admin\Model\DoctrineAdapterResource to remove the implementation, and start injecting your dependencies via factory instead.


Originally posted by @JueGer at zfcampus/zf-apigility-admin#332

ZF\Apigility\Admin\Model\DoctrineAdapterResource only uses the ServiceManager to get the ModuleManager. It would make sense to replace injection of the ServiceManager with ModuleManager.

  • Remove use of ServiceLocatorAwareInterface (TestCase -> notInstanceOf)
  • Remove setServiceManager and getServiceManager
  • Add setting of ModuleManager (through setter/getter or constructor) (TestCase -> attributeEquals)
  • Inject ModuleManager in Factory

ZF\Apigility\Admin\Model\AbstractAutodiscoveryModel is a bit more tricky since removing ServiceManagerAwareInterface also breaks compatibility in zfcampus/zf-apigility-doctrine.
I would temporary only set the ServiceLocator through the factory and as soon as zfcampus/zf-apigility-doctrine has fixed the issue also remove ServiceLocatorAwareInterface with a new issue.

  • Inject ServiceManager in Factory

Originally posted by @JueGer at zfcampus/zf-apigility-admin#332 (comment)

I had the same deprecation warnings when created new apigility project.
I updated my composer.json file I added the following lines into require:

"php": "^5.6 || ^7.0",
zendframework/zend-mvc": "~2.6.0",

The full composer.json looks like:

{
    "name": "zfcampus/zf-apigility-skeleton",
    "description": "Skeleton Application for Apigility",
    "type": "library",
    "license": "BSD-3-Clause",
    "keywords": [
        "api",
        "apigility",
        "framework",
        "zf2"
    ],
    "homepage": "http://apigility.org/",
    "support": {
        "email": "apigility-users@zend.com",
        "irc": "irc://irc.freenode.net/apigility",
        "source": "https://github.com/zfcampus/zf-apigility-skeleton",
        "issues": "https://github.com/zfcampus/zf-apigility-skeleton/issues"
    },
    "config": {
        "process-timeout": 5000,
        "github-oauth": {
            "github.com": "7e816679eb7e97bae......xxxxxxxxx"
         }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.3-dev",
            "dev-develop": "1.4-dev"
        }
    },
    "require": {
        "php": "^5.6 || ^7.0",
        "zendframework/zendframework": "^2.5.3",
        "zendframework/zend-mvc": "~2.6.0",
        "zfcampus/zf-apigility": "~1.1",
        "zfcampus/zf-apigility-documentation": "^1.0.5",
        "zfcampus/zf-development-mode": "~2.0"
    },
    "require-dev": {
        "zendframework/zftool": "dev-master",
        "zendframework/zend-developer-tools": "dev-master",
        "zfcampus/zf-apigility-admin": "^1.4.1",
        "zfcampus/zf-apigility-admin-ui": "^1.2.3",
        "zfcampus/zf-deploy": "~1.0"
    },
    "suggest": {
        "zfcampus/zf-apigility-doctrine": "zfcampus/zf-apigility-doctrine ~1.0 to create Doctrine-Connected REST services",
        "zfcampus/zf-http-cache": "zfcampus/zf-http-cache ~1.0 to add HTTP caching to your API",
        "zfr/zfr-cors": "zfr/zfr-cors ~1.2 to add CORS support to your API"
    }
}

Please note updating the composer helped to fix the issue "Hydrator Service issue #334"


Originally posted by @haniWeiss at zfcampus/zf-apigility-admin#332 (comment)

This is only a workaround. Not the solution for cb with future versions of zf.


Originally posted by @JueGer at zfcampus/zf-apigility-admin#332 (comment)

@weierophinney @ezimuel I started to do work on zf-apigility-doctrine to remove the ServiceLocatorAwareInterface and was quickly stopped at this project: https://github.com/zfcampus/zf-apigility-admin/blob/master/src/Model/AbstractAutodiscoveryModel.php

I need to know a priority for Apigility:

  • Let the project stay where it is. Don't update for SM3.
  • Update for SM3 and continue in the current ZF2 skeleton paradigm.
  • Create a new initiative to move Apigility into PSR-7 compliance.
  • Something else?

I think the right approach is to make Apigility SM3 compliant and start a new initiative after ZendCon to bring Apigility inline with today's practices.

For zf-apigility-doctrine I've created a work around for the problem of DoctrineModule not supporting zend-hydrator and I'm ready to move the project forward. Without a consensus doing that work could lead to a dead end.


Originally posted by @TomHAnderson at zfcampus/zf-apigility-admin#332 (comment)