Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

New LazyControllerFactory #165

Commits on Jun 23, 2016

  1. New LazyControllerFactory

    Inspired by http://circlical.com/blog/2016/3/9/preparing-for-zend-f,
    this abstract factory/factory can be used to create controller
    instances for controllers defining constructor dependencies, using
    the following rules:
    
    - A parameter named `$config` typehinted as an array will receive the
      application "config" service (i.e., the merged configuration).
    - Parameters type-hinted against array, but not named `$config` will
      be injected with an empty array.
    - Scalar parameters will be resolved as null values.
    - If a service cannot be found for a given typehint, the factory will
      raise an exception detailing this.
    - Some services provided by Zend Framework components do not have
      entries based on their class name (for historical reasons); the
      factory contains a map of these class/interface names to the
      corresponding service name to allow them to resolve.
    
    `$options` passed to the factory are ignored in all cases, as we cannot
    make assumptions about which argument(s) they might replace.
    
    As it implements zend-servicemanager's v3 AbstractFactoryInterface, it
    may be used as either an abstract factory, or by mapping controller
    class names to the factory.
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    8e2e226 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    df3000d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4ba6e25 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    33c8cc9 View commit details
    Browse the repository at this point in the history
  5. Remove test for non-string $requestedName

    cannot happen with version 3 servicemanager.
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    e4a813c View commit details
    Browse the repository at this point in the history
  6. Made $aliases protected (not private)

    - Allows extending in order to add more aliases.
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    dd34bad View commit details
    Browse the repository at this point in the history
  7. Use splat operator

    - Updated instantiation to use splat operator instead of reflection
    - switch from array_key_exists to isset
    
    Both per @snapshotpl
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    bc75c3d View commit details
    Browse the repository at this point in the history
  8. Refactor: extract method

    Extracted parameter resolution to a new method, and modified factory to
    use array_map with that method to create the list of parameters for
    instantiating the controller.
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    7d30314 View commit details
    Browse the repository at this point in the history
  9. Refactor array_map

    `resolveParameter()` now accepts the container and requested name, and
    returns a callback for resolving a parameter to a value, closing over
    the two provided values. This simplifies the array_map call, making it
    more readable.
    weierophinney committed Jun 23, 2016
    Configuration menu
    Copy the full SHA
    00ba958 View commit details
    Browse the repository at this point in the history