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

Class AbstractSource

Full implementation, as abstract class, of the SourceInterface.

Charcoal\Source\AbstractSource implements Charcoal\Source\SourceInterface, Charcoal\Config\ConfigurableInterface, Psr\Log\LoggerAwareInterface uses Charcoal\Config\ConfigurableTrait (not available) Psr\Log\LoggerAwareTrait (not available)

Direct known subclasses

Charcoal\Source\DatabaseSource
Abstract
Namespace: Charcoal\Source
Located at Charcoal/Source/AbstractSource.php
Methods summary
public
# __construct( array|ArrayAccess $dependencies )

Parameters

$dependencies
The class dependencies.
public Charcoal\Source\AbstractSource
# reset( )

Reset everything but the model.

Reset everything but the model.

Returns

Charcoal\Source\AbstractSource
Chainable
public Charcoal\Source\AbstractSource
# setData( array $data )

Initialize the source's properties with an array of data.

Initialize the source's properties with an array of data.

Parameters

$data
The source data.

Returns

Charcoal\Source\AbstractSource
Chainable
public Charcoal\Source\AbstractSource
# setModel( Charcoal\Model\ModelInterface $model )

Set the source's Model.

Set the source's Model.

Parameters

$model
The source's model.

Returns

Charcoal\Source\AbstractSource
Chainable

Implementation of

Charcoal\Source\SourceInterface::setModel()
public Charcoal\Model\ModelInterface
# model( )

Return the source's Model.

Return the source's Model.

Returns

Charcoal\Model\ModelInterface

Throws

Exception
If not model was previously set.

Implementation of

Charcoal\Source\SourceInterface::model()
public boolean
# hasModel( )

Returns

boolean
public ColelectionLoader
# setProperties( array $properties )

Set the properties of the source to fetch.

Set the properties of the source to fetch.

This method accepts an array of property identifiers (property ident, as string) that will, if supported, be fetched from the source.

If no properties are set, it is assumed that all the Model's properties are to be fetched.

Parameters

$properties
The properties.

Returns

ColelectionLoader
Chainable

Implementation of

Charcoal\Source\SourceInterface::setProperties()
public array
# properties( )

Returns

array

Implementation of

Charcoal\Source\SourceInterface::properties()
public CollectionLoader
# addProperty( string $property )

Parameters

$property
Property ident.

Returns

CollectionLoader
Chainable

Throws

InvalidArgumentException
If property is not a string or empty.

Implementation of

Charcoal\Source\SourceInterface::addProperty()
public Collection
# setFilters( array $filters )

Parameters

$filters
The filters to set.

Returns

Collection
Chainable

Implementation of

Charcoal\Source\SourceInterface::setFilters()
public array
# filters( )

Returns

array

Implementation of

Charcoal\Source\SourceInterface::filters()
public CollectionLoader
# addFilter( string|array|Charcoal\Source\Filter $param, mixed $val = null, array $options = null )

Add a collection filter to the loader.

Add a collection filter to the loader.

There are 3 different ways of adding a filter: - as a Filter object, in which case it will be added directly. - addFilter($obj); - as an array of options, which will be used to build the Filter object - addFilter(['property' => 'foo', 'val' => 42, 'operator' => '<=']); - as 3 parameters: property, val and options - addFilter('foo', 42, ['operator' => '<=']);

Parameters

$param
The filter property, or a Filter object / array.
$val
Optional: Only used if the first argument is a string.
$options
Optional: Only used if the first argument is a string.

Returns

CollectionLoader
(Chainable)

Throws

InvalidArgumentException
If property is not a string or empty.

Implementation of

Charcoal\Source\SourceInterface::addFilter()
protected Charcoal\Source\FilterInterface
# createFilter( )

Returns

Charcoal\Source\FilterInterface
public CollectionLoader
# setOrders( array $orders )

Parameters

$orders
The orders to set.

Returns

CollectionLoader
Chainable

Implementation of

Charcoal\Source\SourceInterface::setOrders()
public array
# orders( )

Returns

array

Implementation of

Charcoal\Source\SourceInterface::orders()
public CollectionLoader
# addOrder( string|array|Charcoal\Source\Order $param, string $mode = 'asc', array $orderOptions = null )

Parameters

$param
The order property, or an Order object / array.
$mode
Optional.
$orderOptions
Optional.

Returns

CollectionLoader
Chainable

Throws

InvalidArgumentException
If the param argument is invalid.

Implementation of

Charcoal\Source\SourceInterface::addOrder()
protected Charcoal\Source\OrderInterface
# createOrder( )

Returns

Charcoal\Source\OrderInterface
public CollectionLoader
# setPagination( mixed $param )

Parameters

$param
The pagination object or array.

Returns

CollectionLoader
Chainable

Throws

InvalidArgumentException
If the argument is not an object or array.

Implementation of

Charcoal\Source\SourceInterface::setPagination()
public Charcoal\Source\Pagination
# pagination( )

Get the pagination object.

Get the pagination object.

If the pagination wasn't set previously, a new (default / blank) Pagination object will be created. (Always return a PaginationInterface object)

Returns

Charcoal\Source\Pagination

Implementation of

Charcoal\Source\SourceInterface::pagination()
protected Charcoal\Source\PaginationInterface
# createPagination( )

Returns

Charcoal\Source\PaginationInterface
public CollectionLoader
# setPage( integer $page )

Parameters

$page
The page number.

Returns

CollectionLoader
Chainable

Throws

InvalidArgumentException
If the page argument is not numeric.

Implementation of

Charcoal\Source\SourceInterface::setPage()
public integer
# page( )

Returns

integer

Implementation of

Charcoal\Source\SourceInterface::page()
public CollectionLoader
# setNumPerPage( integer $num )

Parameters

$num
The number of items to retrieve per page.

Returns

CollectionLoader
Chainable

Throws

InvalidArgumentException
If the num per page argument is not numeric.

Implementation of

Charcoal\Source\SourceInterface::setNumPerPage()
public integer
# numPerPage( )

Returns

integer

Implementation of

Charcoal\Source\SourceInterface::numPerPage()
public Charcoal\Source\SourceConfig
# createConfig( array $data = null )

ConfigurableTrait > createConfig()

ConfigurableTrait > createConfig()

Parameters

$data
Optional.

Returns

Charcoal\Source\SourceConfig
abstract public Charcoal\Source\StorableInterface
# loadItem( mixed $ident, Charcoal\Source\StorableInterface $item = null )

Parameters

$ident
The ID of the item to load.
$item
Optional item to load into.

Returns

Charcoal\Source\StorableInterface

Implementation of

Charcoal\Source\SourceInterface::loadItem()
abstract public array
# loadItems( Charcoal\Source\StorableInterface $item = null )

Parameters

$item
The model to load items from.

Returns

array

Implementation of

Charcoal\Source\SourceInterface::loadItems()
abstract public mixed
# saveItem( Charcoal\Source\StorableInterface $item )

Save an item (create a new row) in storage.

Save an item (create a new row) in storage.

Parameters

$item
The object to save.

Returns

mixed
The created item ID, or false in case of an error.

Implementation of

Charcoal\Source\SourceInterface::saveItem()
abstract public boolean
# updateItem( Charcoal\Source\StorableInterface $item, array $properties = null )

Update an item in storage.

Update an item in storage.

Parameters

$item
The object to update.
$properties
The list of properties to update, if not all.

Returns

boolean
Success / Failure

Implementation of

Charcoal\Source\SourceInterface::updateItem()
abstract public boolean
# deleteItem( Charcoal\Source\StorableInterface $item = null )

Delete an item from storage

Delete an item from storage

Parameters

$item
Optional item to delete. If none, the current model object will be used..

Returns

boolean
Success / Failure

Implementation of

Charcoal\Source\SourceInterface::deleteItem()
protected string
# getter( string $key, string $case = 'camel' )

Allow an object to define how the key getter are called.

Allow an object to define how the key getter are called.

Parameters

$key
The key to get the getter from.
$case
Optional. The type of case to return. camel, pascal or snake.

Returns

string
The getter method name, for a given key.
protected string
# setter( string $key, string $case = 'camel' )

Allow an object to define how the key setter are called.

Allow an object to define how the key setter are called.

Parameters

$key
The key to get the setter from.
$case
Optional. The type of case to return. camel, pascal or snake.

Returns

string
The setter method name, for a given key.
Properties summary
protected array $filters

Array of Filter objects

Array of Filter objects

# []
protected array $orders

Array of Order object

Array of Order object

# []
protected Charcoal\Source\Pagination|null $pagination

The Pagination object

The Pagination object

# null
API documentation generated by ApiGen