Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created November 26, 2013 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakura10/7659807 to your computer and use it in GitHub Desktop.
Save bakura10/7659807 to your computer and use it in GitHub Desktop.
<?php
/**
* If for instance a plugin manager has the following config:
*
* [
* 'invokables' => [
* 'formDateSelect' => 'Zend\Form\Element\DateSelect'
* ]
* ]
*
* It's actually stored as "formdateselect". This is a super light normalization
*/
public function setInvokableClass($name, $invokableClass, $shared = null)
{
$normalizedName = strtolower($name);
$this->normalized[$normalizedName] = $name;
$this->invokableClasses[$normalizedName] = (string) $invokableClass;
}
/**
* If user asks "formdateselect" or "formDateSelect", it will still work:
*/
public function get(ServiceRequest $request)
{
$name = (string) $request;
$name = $this->normalized[strtolower($name)];
// Continue as usual
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment