Skip to content

Commit

Permalink
build documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wilson committed Aug 22, 2016
1 parent 59f25fc commit f3f4424
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 60 deletions.
55 changes: 55 additions & 0 deletions docs/compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Composing Your Own Data Manager
If you have your own container objects and want to add Manager functionality to them, you may import traits into your class.
This is also a great way to mix and match exactly which feature you want.

The basic trait you always need to start with is `Michaels\Manager\ManagesItemsTrait`.
There is an accompanying interface.

After that, you may add any of the feature traits you like.
It's important to note, however, that all of these feature traits depend on `ManagesItemsTrait`,
so you must include that one FIRST:

```php
use ManagesItemsTrait, ArrayableTrait, CollectionTrait;
```

None of the traits include a constructor. If you want to have your class be initializable with data:

```php
class MyClass
{
use ManagesItemsTrait;

public function __construct($beginningItems)
{
$this->initManager($beginningItems);
}
}
```
initManager() is used so it doesn't conflict with user-defined init() methods.


## Available Traits
1. [`ManagesItemsTrait`](#getting-started) fulfills `ManagesItemsInterface` and adds most functionality. Look at the interface for full list.
2. [`ArrayableTrait`](arrayable.md) makes the class usable as an array (`$manager['some']['data']`) or in loops and such
3. [`ChainsNestedItemsTrait`](chains.md) allows you to use fluent properties to manage data (`$manager->one()->two()->three = 'three`)
4. [`CollectionTrait`](collections.md) returns collections with all sorts of [array helpers](https://github.com/bocharsky-bw/Arrayzy)
5. [`ManagesIocTrait`](ioc.md) turns Manager into a simple, but complete IoC or Dependency Injection manager
6. [`LoadsFilesTrait`](load-files.md) allows Manager to load data from config files.

```php
/* An example for UberManager */
class MyContainer {
use Michaels\Manager\Traits\ManagesItemsTrait;
use Michaels\Manager\Traits\ChainsNestedItemsTrait;
use Michaels\Manager\Traits\ArrayableTrait;
use Michaels\Manager\Traits\CollectionTrait;
use Michaels\Manager\Traits\LoadsFilesTrait;
use Michaels\Manager\Traits\ManagesIocTrait;

// Your stuff here. And you may override anything you like.
// Remember to add a constructor if you want :)
}
```

You may also use the **tests** under `tests/traits` to test your integrated functionality. You may have to grab these through cloning the repo. composer usually won't include tests in your `require`
58 changes: 1 addition & 57 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Simple data manager for nested data, dot notation access, extendability, and con

## Extras
On top of being a powerful data-manager, there are traits that add features.
Please see [Composing](#composing) for information about mixing and matching features or integrating
Please see [Composing](compose.md) for information about mixing and matching features or integrating
different traits into your project.

* [Arrayable](arrayable.md): Use Manager as an array.
Expand Down Expand Up @@ -139,62 +139,6 @@ You can either [composer your own](#compose) or use one of the build in classes
* **Uber Manager**: Everything in one place. Just for fun, really.


## Composing Features
If you have your own container objects and want to add Manager functionality to them, you may import traits into your class.
This is also a great way to mix and match exactly which feature you want.

The basic trait you always need to start with is `Michaels\Manager\ManagesItemsTrait`.
There is an accompanying interface.

After that, you may add any of the feature traits you like.
It's important to note, however, that all of these feature traits depend on `ManagesItemsTrait`,
so you must include that one FIRST:

```php
use ManagesItemsTrait, ArrayableTrait, CollectionTrait;
```

None of the traits include a constructor. If you want to have your class be initializable with data:

```php
class MyClass
{
use ManagesItemsTrait;

public function __construct($beginningItems)
{
$this->initManager($beginningItems);
}
}
```
initManager() is used so it doesn't conflict with user-defined init() methods.


### Available Traits
1. [`ManagesItemsTrait`](#getting-started) fulfills `ManagesItemsInterface` and adds most functionality. Look at the interface for full list.
2. [`ArrayableTrait`](arrayable.md) makes the class usable as an array (`$manager['some']['data']`) or in loops and such
3. [`ChainsNestedItemsTrait`](chains.md) allows you to use fluent properties to manage data (`$manager->one()->two()->three = 'three`)
4. [`CollectionTrait`](collections.md) returns collections with all sorts of [array helpers](https://github.com/bocharsky-bw/Arrayzy)
5. [`ManagesIocTrait`](ioc.md) turns Manager into a simple, but complete IoC or Dependency Injection manager
6. [`LoadsFilesTrait`](load-files.md) allows Manager to load data from config files.

```php
/* An example for UberManager */
class MyContainer {
use Michaels\Manager\Traits\ManagesItemsTrait;
use Michaels\Manager\Traits\ChainsNestedItemsTrait;
use Michaels\Manager\Traits\ArrayableTrait;
use Michaels\Manager\Traits\CollectionTrait;
use Michaels\Manager\Traits\LoadsFilesTrait;
use Michaels\Manager\Traits\ManagesIocTrait;

// Your stuff here. And you may override anything you like.
// Remember to add a constructor if you want :)
}
```

You may also use the **tests** under `tests/traits` to test your integrated functionality. You may have to grab these through cloning the repo. composer usually won't include tests in your `require`

## Some Advanced Features
By default, Manager stores all the items in an `$items` property.
If you are using the `ManagesItemsTrait` and want to use an internal property besides `$items` to avoid collisions, you have two options:
Expand Down
8 changes: 5 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ site_name: PHP Data Manager

pages:
- Home: index.md
- Composing Traits: index.md#compose
- Composing Traits: compose.md
- Collections: collections.md
- IoC Container: ioc.md
- Config Manager: load-files.md
- Contributing: contributing.md
- License: license.md
- As an Array: arrayable.md
- As Chaniable Object: chains.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md

theme: readthedocs

0 comments on commit f3f4424

Please sign in to comment.