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

A repository for managing CRUD operations on a model, displayed in a view. More...

Public Member Functions

 __construct (Controller $ctrl, string $model)
 
 all (string $condition='', $included=false, array $parameters=[], bool $useCache=false, string $viewVar='all')
 Load all instances in a view variable named all.
 
 byId ($keyValues, $included=true, bool $useCache=false, string $viewVar='byId')
 Load one instance by id in a view variable named byId.
 
 one (string $condition='', $included=true, array $parameters=[], bool $useCache=false, string $viewVar='one')
 Load one instance in a view variable named one.
 
 insert (object $instance, $insertMany=false, string $viewVar='inserted')
 Insert a new instance $instance into the database and add the instance in a view variable (inserted).
 
 update (object $instance, $insertMany=false, string $viewVar='updated')
 Update an instance $instance in the database and add the instance in a view variable (updated).
 
 save (object $instance, $insertMany=false, string $viewVar='saved')
 Save (insert or update) an instance $instance in the database and add the instance in a view variable (saved).
 
 remove (object $instance, string $viewVar='removed')
 Remove an instance $instance from the database and add the instance in a view variable.
 

Private Member Functions

 setViewVarsAndReturn (string $viewVar, $instance, $r)
 

Private Attributes

string $model
 
View $view
 

Detailed Description

A repository for managing CRUD operations on a model, displayed in a view.

Ubiquity\orm\repositories$ViewRepository This class is part of Ubiquity

Author
jc
Version
1.0.0

Definition at line 18 of file ViewRepository.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Controller  $ctrl,
string  $model 
)

Definition at line 28 of file ViewRepository.php.

Member Function Documentation

◆ all()

all ( string  $condition = '',
  $included = false,
array  $parameters = [ ],
bool  $useCache = false,
string  $viewVar = 'all' 
)

Load all instances in a view variable named all.

Parameters
string$condition
array | boolean$included
array$parameters
bool$useCache
string$viewVar
Returns
array

Definition at line 43 of file ViewRepository.php.

◆ byId()

byId (   $keyValues,
  $included = true,
bool  $useCache = false,
string  $viewVar = 'byId' 
)

Load one instance by id in a view variable named byId.

Parameters
$keyValues
bool | array$included
bool$useCache
string$viewVar
Returns
?object

Definition at line 57 of file ViewRepository.php.

◆ insert()

insert ( object  $instance,
  $insertMany = false,
string  $viewVar = 'inserted' 
)

Insert a new instance $instance into the database and add the instance in a view variable (inserted).

A status variable added to the view shows whether the operation was successful.

Parameters
object$instance
bool$insertMany
string$viewVar
Returns
bool
Exceptions

Exception

Definition at line 88 of file ViewRepository.php.

◆ one()

one ( string  $condition = '',
  $included = true,
array  $parameters = [ ],
bool  $useCache = false,
string  $viewVar = 'one' 
)

Load one instance in a view variable named one.

Parameters
string$condition
bool | array$included
array$parameters
bool$useCache
string$viewVar
Returns
?object
Exceptions

Ubiquity\exceptions\DAOException

Definition at line 73 of file ViewRepository.php.

◆ remove()

remove ( object  $instance,
string  $viewVar = 'removed' 
)

Remove an instance $instance from the database and add the instance in a view variable.

Parameters
object$instance
string$viewVar
Returns
int|null

Definition at line 128 of file ViewRepository.php.

◆ save()

save ( object  $instance,
  $insertMany = false,
string  $viewVar = 'saved' 
)

Save (insert or update) an instance $instance in the database and add the instance in a view variable (saved).

A status variable added to the view shows whether the operation was successful.

Parameters
object$instance
bool$insertMany
string$viewVar
Returns
bool|int

Definition at line 116 of file ViewRepository.php.

◆ setViewVarsAndReturn()

setViewVarsAndReturn ( string  $viewVar,
  $instance,
  $r 
)
private

Definition at line 22 of file ViewRepository.php.

◆ update()

update ( object  $instance,
  $insertMany = false,
string  $viewVar = 'updated' 
)

Update an instance $instance in the database and add the instance in a view variable (updated).

A status variable added to the view shows whether the operation was successful.

Parameters
object$instance
bool$insertMany
string$viewVar
Returns
bool

Definition at line 102 of file ViewRepository.php.

Field Documentation

◆ $model

string $model
private

Definition at line 19 of file ViewRepository.php.

◆ $view

View $view
private

Definition at line 20 of file ViewRepository.php.


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