mirror of
https://github.com/marcostoll/FF-Factories.git
synced 2025-03-15 10:59:40 +01:00
[DOCS] update readme
This commit is contained in:
parent
d972d2664d
commit
bf88d2b4e8
25
readme.md
25
readme.md
@ -89,7 +89,7 @@ An example:
|
||||
|
||||
use FF\Factories\ClassLocators\NamespaceClassLocator;
|
||||
|
||||
$myLocator = new NamespaceClassLocator('MyProject\Sub1', ''MyProject\Sub2');
|
||||
$myLocator = new NamespaceClassLocator('MyProject\Sub1', 'MyProject\Sub2');
|
||||
|
||||
// This will find MyProject\Sub1\MyClass or MyProject\Sub2\MyClass in this order.
|
||||
// If none of the above exist, $class will be null.
|
||||
@ -99,6 +99,27 @@ An example:
|
||||
// If none of the above exist, $class will be null.
|
||||
$class = $myLocator->locateClass('Foo\MyClass');
|
||||
|
||||
## The Base Namespace Class Locator
|
||||
|
||||
This class locator can be configured with a list of base namespaces and a common suffix ro search for class definitions
|
||||
with a class identifier relative to one of its base namespaces.
|
||||
The base namespaces wil be search in the give order. So the locator will return the first match of an existing class.
|
||||
|
||||
An example:
|
||||
|
||||
use FF\Factories\ClassLocators\BaseNamespaceClassLocator;
|
||||
|
||||
$commonSuffix = 'Some\Suffix';
|
||||
$myLocator = new NamespaceClassLocator($commonSuffix, MyProject\Sub1', 'MyProject\Sub2');
|
||||
|
||||
// This will find MyProject\Sub1\Some\Suffix\MyClass or MyProject\Sub2\Some\Suffix\MyClass in this order.
|
||||
// If none of the above exist, $class will be null.
|
||||
$class = $myLocator->locateClass('MyClass');
|
||||
|
||||
// This will find MyProject\Sub1\Some\Suffix\Foo\MyClass or MyProject\Sub2\Some\Suffix\Foo\MyClass in this order.
|
||||
// If none of the above exist, $class will be null.
|
||||
$class = $myLocator->locateClass('Foo\MyClass');
|
||||
|
||||
## The Namespace Prefixed Class Locator
|
||||
|
||||
Sometimes you want to distribute class definitions of a certain kind (say Event classes) over various packages. To
|
||||
@ -111,7 +132,7 @@ An example:
|
||||
|
||||
// The first argumens ('Events') is the common class namespace prefix.
|
||||
// The following argumentgs are the base namespaces to inspect.
|
||||
$myLocator = new NamespaceClassLocator('Events', MyProject\Sub1', ''MyProject\Sub2');
|
||||
$myLocator = new NamespaceClassLocator('Events', MyProject\Sub1', 'MyProject\Sub2');
|
||||
|
||||
// This will find MyProject\Sub1\Events\MyEvent or MyProject\Sub2\Events\MyEven in this order.
|
||||
// If none of the above exist, $class will be null.
|
||||
|
Loading…
x
Reference in New Issue
Block a user