Created
November 26, 2013 15:01
-
-
Save bakura10/7659807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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