Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
TransformersManager Class Reference

Transform objects after loading. More...

Static Public Member Functions

static start ()
 Load all transformers.
 
static startProd (?string $op='transform')
 Start the manager for production.
 
static registerClass (string $transformer, string $classname)
 Register a new transformer class.
 
static registerClassAndSave (string $transformer, string $classname)
 Register and save in cache a new Transformer.
 
static registerClasses (array $transformersAndClasses)
 Register an associative array of transformers based on ['name'=>'transformerClass'].
 
static registerClassesAndSave (array $transformersAndClasses)
 Register and save an associative array of transformers based on ['name'=>'transformerClass'].
 
static getTransformerClass (string $transformer)
 Return the class from a transformer name.
 
static transform (object $instance, string $member, ?string $transform='transform')
 Transform a member of an instance.
 
static applyTransformer (object $instance, string $member, $value, ?string $transform='transform')
 Apply a transformer using a member transformer(s) on a value.
 
static transformInstance (object $instance, $transform='transform')
 Transform all the members of a model instance.
 
static transformInstances (array $instances, $transform='transform')
 Transform all the members of a model instances.
 
static store ()
 Store the loaded transformers in cache.
 

Data Fields

const TRANSFORMER_TYPES = ['reverse' => TransformerInterface::class, 'transform' => TransformerInterface::class, 'toView' => TransformerViewInterface::class, 'toForm' => TransformerFormInterface::class]
 

Static Private Attributes

static $transformers = ['md5' => Md5::class, 'datetime' => DateTime::class, 'upper' => UpperCase::class, 'firstUpper' => FirstUpperCase::class, 'lower' => LowerCase::class, 'password' => Password::class, 'hpassword' => HidePassword::class, 'boolean' => Boolean::class]
 
static $key = 'contents/transformers'
 

Detailed Description

Transform objects after loading.

Ubiquity\contents\transformation\transformers$TransformersManager This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.0.5

Definition at line 27 of file TransformersManager.php.

Member Function Documentation

◆ applyTransformer()

static applyTransformer ( object  $instance,
string  $member,
  $value,
?string  $transform = 'transform' 
)
static

Apply a transformer using a member transformer(s) on a value.

Parameters
object$instance
string$member
mixed$value
?string$transform
Returns
mixed

Definition at line 147 of file TransformersManager.php.

◆ getTransformerClass()

static getTransformerClass ( string  $transformer)
static

Return the class from a transformer name.

Parameters
string$transformer
Returns
?string

Definition at line 115 of file TransformersManager.php.

◆ registerClass()

static registerClass ( string  $transformer,
string  $classname 
)
static

Register a new transformer class.

Do not used at runtime !

Parameters
string$transformer
string$classname

Definition at line 66 of file TransformersManager.php.

◆ registerClassAndSave()

static registerClassAndSave ( string  $transformer,
string  $classname 
)
static

Register and save in cache a new Transformer.

Do not used at runtime !

Parameters
string$transformer
string$classname

Definition at line 77 of file TransformersManager.php.

◆ registerClasses()

static registerClasses ( array  $transformersAndClasses)
static

Register an associative array of transformers based on ['name'=>'transformerClass'].

Do not used at runtime !

Parameters
array$transformersAndClasses

Definition at line 89 of file TransformersManager.php.

◆ registerClassesAndSave()

static registerClassesAndSave ( array  $transformersAndClasses)
static

Register and save an associative array of transformers based on ['name'=>'transformerClass'].

Do not used at runtime !

Parameters
array$transformersAndClasses

Definition at line 101 of file TransformersManager.php.

◆ start()

static start ( )
static

Load all transformers.

Do not use at runtime !

Definition at line 40 of file TransformersManager.php.

◆ startProd()

static startProd ( ?string  $op = 'transform')
static

Start the manager for production.

Parameters
?string$op

Definition at line 54 of file TransformersManager.php.

◆ store()

static store ( )
static

Store the loaded transformers in cache.

Definition at line 213 of file TransformersManager.php.

◆ transform()

static transform ( object  $instance,
string  $member,
?string  $transform = 'transform' 
)
static

Transform a member of an instance.

Parameters
object$instance
string$member
?string$transform
Returns
?mixed

Definition at line 130 of file TransformersManager.php.

◆ transformInstance()

static transformInstance ( object  $instance,
  $transform = 'transform' 
)
static

Transform all the members of a model instance.

Parameters
object$instance
string$transform

Definition at line 163 of file TransformersManager.php.

◆ transformInstances()

static transformInstances ( array  $instances,
  $transform = 'transform' 
)
static

Transform all the members of a model instances.

Parameters
array$instances
string$transform

Definition at line 186 of file TransformersManager.php.

Field Documentation

◆ $key

$key = 'contents/transformers'
staticprivate

Definition at line 34 of file TransformersManager.php.

◆ $transformers

$transformers = ['md5' => Md5::class, 'datetime' => DateTime::class, 'upper' => UpperCase::class, 'firstUpper' => FirstUpperCase::class, 'lower' => LowerCase::class, 'password' => Password::class, 'hpassword' => HidePassword::class, 'boolean' => Boolean::class]
staticprivate

Definition at line 33 of file TransformersManager.php.

◆ TRANSFORMER_TYPES

const TRANSFORMER_TYPES = ['reverse' => TransformerInterface::class, 'transform' => TransformerInterface::class, 'toView' => TransformerViewInterface::class, 'toForm' => TransformerFormInterface::class]

Definition at line 28 of file TransformersManager.php.


The documentation for this class was generated from the following file: