Overview

Namespaces

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

Classes

  • Charcoal\Loader\CollectionLoader
  • Charcoal\Loader\FileLoader
  • Charcoal\Model\AbstractMetadata
  • Charcoal\Model\AbstractModel
  • Charcoal\Model\Collection
  • Charcoal\Model\Model
  • Charcoal\Model\ModelMetadata
  • Charcoal\Model\ModelValidator
  • Charcoal\Model\Service\MetadataLoader
  • Charcoal\Model\Service\ModelBuilder
  • Charcoal\Model\Service\ModelLoader
  • Charcoal\Model\Service\ModelLoaderBuilder
  • Charcoal\Model\ServiceProvider\ModelServiceProvider
  • Charcoal\Source\AbstractSource
  • Charcoal\Source\Database\DatabaseFilter
  • Charcoal\Source\Database\DatabaseOrder
  • Charcoal\Source\Database\DatabasePagination
  • Charcoal\Source\DatabaseSource
  • Charcoal\Source\DatabaseSourceConfig
  • Charcoal\Source\Filter
  • Charcoal\Source\Order
  • Charcoal\Source\Pagination
  • Charcoal\Source\SourceConfig
  • Charcoal\Validator\AbstractValidator
  • Charcoal\Validator\ValidatorResult

Interfaces

  • Charcoal\Model\CollectionInterface
  • Charcoal\Model\DescribableInterface
  • Charcoal\Model\MetadataInterface
  • Charcoal\Model\ModelInterface
  • Charcoal\Source\DatabaseSourceInterface
  • Charcoal\Source\FilterInterface
  • Charcoal\Source\OrderInterface
  • Charcoal\Source\PaginationInterface
  • Charcoal\Source\SourceInterface
  • Charcoal\Source\StorableInterface
  • Charcoal\Validator\ValidatableInterface
  • Charcoal\Validator\ValidatorInterface

Traits

  • Charcoal\Model\DescribableTrait
  • Charcoal\Source\StorableTrait
  • Charcoal\Validator\ValidatableTrait
  • Overview
  • Namespace
  • Class
 1: <?php
 2: /**
 3:  * Charcoal Model class file
 4:  * Part of the `charcoal-core` package.
 5:  *
 6:  * @author Mathieu Ducharme <mat@locomotive.ca>
 7:  */
 8: 
 9: namespace Charcoal\Model;
10: 
11: // Local namespace dependencies
12: use \Charcoal\Model\AbstractModel;
13: 
14: /**
15:  * Charcoal Model class
16:  *
17:  * # The Charcoal Model
18:  * <figure>
19:  *   <img src="http:// charcoal.locomotive.ca/doc/assets/images/uml/charcoal.model.svg" alt="The Charcoal Model UML" />
20:  *   <figcaption>The Charcoal Model Class Diagram</figcaption>
21:  * </figure>
22:  *
23:  * # Custom Object Type
24:  * It is possible to attach a custom object type (`$_obj_type`) to a Model. This will allow the
25:  * various loaders (metadata and source data)
26:  *
27:  * # Metadata
28:  * In Charcoal, all models are held in an instance of `\Charcoal\Model\Model`
29:  * and its configuration meta-data structure is defined in a `\Charcoal\Model\Metadata` object.
30:  *
31:  * ## Loading metadata
32:  * To access the metadata, use `$this->metadata()`. To set metadata, use either
33:  *
34:  * # Properties
35:  * The Model Attributes are stored in {@see \Charcoal\Property\PropertyInterface} objects. The properties are defined
36:  * in the Model's `metadata` and can be accessed either with `p($ident)` to retrieve a property or with
37:  * `properties()` to get all properties.
38:  *
39:  * # Data Source
40:  * The Model data (which is stored internally in the class) can be stored in a storage `Source` object.
41:  * There is only one source type currently implemented: `\Charcoal\Source\Database`.
42:  *
43:  * ## Loading from source
44:  * ...
45:  *
46:  * ## Loading into Collection
47:  * ...
48:  *
49:  * # Data validation
50:  * Once an object has had its data filled (from a form, database, or other source), it is possible to check
51:  * wether the data is conform to the object definition, as defined by it's properties and meta-properties.
52:  * This check is done with the `validate()` function.
53:  *
54:  * The `validate()` method always return a boolean (`true` for success and `false` if there was any
55:  * validation error(s)). The validation details are held in a `Validator` object which can then be
56:  * accessed with the `validator()` method.
57:  *
58:  * # Rendering a model
59:  * Every Charcoal Model can be rendered with the help of a `View` and a `ViewController`.
60:  * Or, more precisely, a `\Charcoal\View\ModelView` and a `\Charcoal\View\ModelViewController`.
61:  */
62: class Model extends AbstractModel
63: {
64: }
65: 
API documentation generated by ApiGen