PHP Class Bravo3\Orm\Services\EntityLocator

Afficher le fichier Open project: bravo3/orm Class Usage Examples

Protected Properties

Свойство Type Description
$entity_manager EntityManager
$normaliser callable

Méthodes publiques

Méthode Description
__construct ( EntityManager $entity_manager = null )
getEntityManager ( ) : EntityManager | null Get the entity manager currently used for validation
getNormaliser ( ) : callable Get class normaliser
locateEntities ( string $dir, string $namespace, string $regex = '/^.+\.php$/i' ) : string[] Gather all entities in a given directory
setEntityManager ( EntityManager $entity_manager = null ) Set the entity manager, if null no entity validation will occur
setNormaliser ( callable $normaliser ) Set class normaliser

Method Details

__construct() public méthode

public __construct ( EntityManager $entity_manager = null )
$entity_manager EntityManager

getEntityManager() public méthode

Get the entity manager currently used for validation
public getEntityManager ( ) : EntityManager | null
Résultat EntityManager | null

getNormaliser() public méthode

By default this will return a callback that will simply strip the file extension from the input. If you have a more complex filename structure you can account for it using the #setNormaliser() function (see docblock). However be aware that you're probably not PSR compliant if you need to do this.
public getNormaliser ( ) : callable
Résultat callable

locateEntities() public méthode

Assumes PSR-0/4 compliant entity class names, and an appropriate auto-loader is installed.
public locateEntities ( string $dir, string $namespace, string $regex = '/^.+\.php$/i' ) : string[]
$dir string Directory to scan
$namespace string PSR base namespace for the directory
$regex string Filter for file matching
Résultat string[]

setEntityManager() public méthode

Set the entity manager, if null no entity validation will occur
public setEntityManager ( EntityManager $entity_manager = null )
$entity_manager EntityManager

setNormaliser() public méthode

This must be a callback that takes 1 argument and will return a string. Its purpose is to convert file names into class names, for example, "MyEntity.php" should return "MyEntity". It will only ever operate on the final segment of a namespace.
public setNormaliser ( callable $normaliser )
$normaliser callable

Property Details

$entity_manager protected_oe property

protected EntityManager,Bravo3\Orm\Services $entity_manager
Résultat EntityManager

$normaliser protected_oe property

protected callable $normaliser
Résultat callable