Overview

Namespaces

  • Charcoal
    • Loader
    • Model
      • Service
      • ServiceProvider
    • Source
      • Database
    • Validator

Classes

  • AbstractSource
  • DatabaseSource
  • DatabaseSourceConfig
  • Filter
  • Order
  • Pagination
  • SourceConfig

Interfaces

  • DatabaseSourceInterface
  • FilterInterface
  • OrderInterface
  • PaginationInterface
  • SourceInterface
  • StorableInterface

Traits

  • StorableTrait
  • Overview
  • Namespace
  • Class

Trait StorableTrait

Full implementation, as trait, of the StorableInterface

Direct Known Users

Charcoal\Model\AbstractModel

Indirect Known Users

Charcoal\Model\Model
Namespace: Charcoal\Source
Located at Charcoal/Source/StorableTrait.php
Methods summary
public Charcoal\Source\StorableInterface
# setId( mixed $id )

Set the object's ID. The actual property set depends on key()

Set the object's ID. The actual property set depends on key()

Parameters

$id
The object id (identifier / primary key value).

Returns

Charcoal\Source\StorableInterface
Chainable

Throws

InvalidArgumentException
If the argument is not scalar.
public mixed
# id( )

Get the object's (unique) ID. The actualy property get depends on key()

Get the object's (unique) ID. The actualy property get depends on key()

Returns

mixed

Throws

Exception
If the set key is invalid.
public Charcoal\Source\StorableInterface
# setKey( string $key )

Set the key property.

Set the key property.

Parameters

$key
The object key, or identifier "name".

Returns

Charcoal\Source\StorableInterface
Chainable

Throws

InvalidArgumentException
If the argument is not scalar.
public string
# key( )

Get the key property.

Get the key property.

Returns

string
protected Charcoal\Source\StorableInterface
# setSourceFactory( Charcoal\Factory\FactoryInterface $factory )

Parameters

$factory
The source factory, which is useful to create source.

Returns

Charcoal\Source\StorableInterface
Chainable
protected Charcoal\Factory\FactoryInterface
# sourceFactory( )

Returns

Charcoal\Factory\FactoryInterface

Throws

Exception
If the source factory was not previously set.
public Charcoal\Source\StorableInterface
# setSource( Charcoal\Source\SourceInterface $source )

Set the object's source.

Set the object's source.

Parameters

$source
The storable object's source.

Returns

Charcoal\Source\StorableInterface
Chainable
public Charcoal\Source\SourceInterface
# source( )

Get the object's source.

Get the object's source.

Returns

Charcoal\Source\SourceInterface
abstract protected Charcoal\Source\SourceInterface
# createSource( )

Create the model's source, with the Source Factory.

Create the model's source, with the Source Factory.

Returns

Charcoal\Source\SourceInterface
public Charcoal\Source\StorableInterface
# load( mixed $id = null )

Load an object from the database from its ID.

Load an object from the database from its ID.

Parameters

$id
The identifier to load.

Returns

Charcoal\Source\StorableInterface
Chainable
public Charcoal\Source\StorableInterface
# loadFrom( string $key = null, mixed $value = null )

Load an object from the database from its key $key.

Load an object from the database from its key $key.

Parameters

$key
Key pointing a column's name.
$value
Value of said column.

Returns

Charcoal\Source\StorableInterface
Chainable.
public Charcoal\Source\StorableInterface
# loadFromQuery( string $query, array $binds = [] )

Load an object from the database from a custom SQL query.

Load an object from the database from a custom SQL query.

Parameters

$query
The SQL query.
$binds
Optional. The SQL query parameters.

Returns

Charcoal\Source\StorableInterface
Chainable.
public boolean
# save( )

Save an object current state to storage

Save an object current state to storage

Returns

boolean
public boolean
# update( array $properties = null )

Update the object in storage to the current object state.

Update the object in storage to the current object state.

Parameters

$properties
If set, only update the properties specified in this array.

Returns

boolean
public boolean
# delete( )

Delete an object from storage.

Delete an object from storage.

Returns

boolean
protected boolean
# preSave( )

Returns

boolean
protected boolean
# postSave( )

Returns

boolean
protected boolean
# preUpdate( array $keys = null )

Parameters

$keys
Optional. The list of keys to update.

Returns

boolean
protected boolean
# postUpdate( array $keys = null )

Parameters

$keys
Optional. The list of keys to update.

Returns

boolean
protected boolean
# preDelete( )

Returns

boolean
protected boolean
# postDelete( )

Returns

boolean
Properties summary
protected mixed $id

$id The object (unique) identifier

$id The object (unique) identifier

#
protected string $key

$key The object key

$key The object key

# 'id'
protected Charcoal\Factory\FactoryInterface $sourceFactory

$sourceFactory

$sourceFactory

#
API documentation generated by ApiGen