Skip to content

Commit 95fd385

Browse files
committed
Merge branch 'develop' of https://github.com/bobmulder/cakephp-cakemanager into develop
2 parents 54d6bdc + 81fccc4 commit 95fd385

6 files changed

Lines changed: 210 additions & 31 deletions

File tree

docs/Behaviors/Stateable.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
Stateable-Behavior
2+
==================
3+
4+
With the Stateable-behavior you are able to sort your data in multiple states.
5+
Via this states you are able to save / change them, and get a list via the finders of CakePHP.
6+
7+
Loading
8+
-------
9+
You can load the behavior in your model via:
10+
11+
$this->loadBehavior('CakeManager.Stateable', []);
12+
13+
14+
Configurations
15+
--------------
16+
There are multiple configurations for the behavior. They will be explained.
17+
18+
### Field
19+
20+
The field is the field where the state should be saved. Default set to `state`.
21+
22+
$this->Stateable->config('field', 'custom_field');
23+
24+
### States
25+
26+
This is an array of the available states. The key of the array is the name of the state, the value of the area is the integer of the state.
27+
28+
The default states are:
29+
30+
'states' => [
31+
'concept' => 0,
32+
'active' => 1,
33+
'deleted' => -1,
34+
],
35+
36+
Change the states by:
37+
38+
$this->Stateable->config('states', [
39+
'default' => 2,
40+
]);
41+
42+
This code will expand the known states-array.
43+
44+
> Note: If you define your own states, don't forget to create your own finders!
45+
46+
Writing the data
47+
----------------
48+
49+
### Forms
50+
If you want to add states in a form, you have to add the following in your controller:
51+
52+
// action
53+
$states = $this->Bookmarks->stateList();
54+
55+
$this->set(compact('states'));
56+
57+
The `stateList()`-method flips the states-array of the behavior. So, if you add the following to your view:
58+
59+
echo $this->Form->input('state');
60+
61+
The form will create a drop-down with the available states.
62+
63+
### Method
64+
65+
> Note: A method to change the current state is not available yet.
66+
67+
Getting the data
68+
----------------
69+
The states can be loaded via the [finders](http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#using-finders-to-load-data) of CakePHP.
70+
The Stateable-behavior has the following finders:
71+
72+
### Concept
73+
This finder gets all the concepts (0) of your table:
74+
75+
$query = $articles->find('concept');
76+
77+
### Active
78+
This finder gets all the active rows (1) of your table:
79+
80+
$query = $articles->find('active');
81+
82+
### Deleted
83+
This finder gets all the (soft)deleted rows (-1) of your table:
84+
85+
$query = $articles->find('deleted');
File renamed without changes.

docs/Installation.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Installation
2+
============
3+
4+
Requirements
5+
------------
6+
7+
You need to install a fresh copy of CakePHP 3.x. Read the [Quick Start](http://book.cakephp.org/3.0/en/quickstart.html) for more info.
8+
9+
You also need the [Migrations[(https://github.com/cakephp/migrations) plugin from CakePHP itself. We already required it via the CakeManagers `composer.json`.
10+
11+
Installing CakeManager
12+
----------------------
13+
14+
We asume you already got a new project of CakePHP. You can call the plugin via composer:
15+
16+
"bobmulder/cakephp-cakemanager": "dev-master"
17+
18+
After that we need to load our plugin in our config/bootstrap.php. We also need the Migrations-plugin from CakePHP to load our tables.
19+
20+
Plugin::load('CakeManager', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);
21+
Plugin::load('Migrations');
22+
23+
24+
Adding the component
25+
----------
26+
27+
After loading the plugin we have to load the base-component: `CakeManager.Manager`.
28+
29+
public function initialize() {
30+
31+
// code
32+
33+
$this->loadComponent('CakeManager.Manager');
34+
35+
// code
36+
37+
}
38+
39+
### Configuring the Manager
40+
41+
There are multiple configurations for the manager-component.
42+
See the [Manager Component](Components/Manager.md) for detailed documentation about the Manager-component.
43+
44+
Further reading
45+
-------
46+
47+
You just started with the CakeManager.
48+
49+
Here are some suggestions related to this tutorial:
50+
- CakePHP's [Quick Start](http://book.cakephp.org/3.0/en/quickstart.html) for 3.x.
51+
- Read the [Manager Component](Components/Manager.md) for detailed documentation about the Manager-component.
52+
- Read the [Request Flow](Request-Flow.md) for detailed documentation about callbacks and events via the CakeManager.
53+
- Read the [Configurations](Configurations.md) for detailed documentation about the available configurations of the plugin.

docs/Tutorials-And-Examples/Quick-Start.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,77 @@ We asume you already got a new project of CakePHP. You can call the plugin via c
1313

1414
"bobmulder/cakephp-cakemanager": "dev-master"
1515

16-
After that we need to load our plugin in our `config/bootstrap.php`:
16+
After that we need to load our plugin in our `config/bootstrap.php`. We also need the Migrations-plugin from CakePHP to load our tables.
1717

1818
Plugin::load('CakeManager', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);
19+
Plugin::load('Migrations');
1920

20-
Creating the Schemas
21+
22+
23+
Creating the tables
24+
--------------------
25+
Schema's we know from CakePHP 2.x are not supported anymore. But we got the migrations-plugin from [CakePHP](https://github.com/cakephp/migrations).
26+
27+
Run the following command in your shell:
28+
29+
$ bin/cake migrations migrate -p CakeManager
30+
31+
This command tells the Migrations-plugin to migrate (install) the CakeManager. This will load our tables.
32+
33+
Loading the roles and user
34+
-----------------
35+
We created a shell to load the default roles and adding an administrator. You can access the shell via:
36+
37+
$ bin/cake CakeManager.Init [command] [variables]
38+
39+
### Adding the roles
40+
First we will add the roles:
41+
42+
$ bin/cake CakeManager.Init Roles
43+
44+
This command creates the default roles of the CakeManager:
45+
- Administrators
46+
- Moderators
47+
- Users
48+
- Unregistered
49+
50+
### Adding an user
51+
Now we need a administrator to login. Use the folling to register yourself:
52+
53+
$ bin/cake CakeManager.Init Admin my_email@domain.com mypassword
54+
55+
- The first parameter is your e-mailaddress to login with.
56+
- The second parameter is your (unhashed) password.
57+
58+
> Note: Submit a valid e-mailaddress, otherwise you won't be able to login (the validation requires an e-mailaddress)
59+
60+
> Note: If you get an error, the address already exists
61+
62+
Adding the component
2163
--------------------
2264

23-
After loading our plugin we need the Schema's of CakeManager.
65+
After loading the plugin we have to load the base-component: CakeManager.Manager.
66+
67+
public function initialize() {
68+
69+
// code
70+
71+
$this->loadComponent('CakeManager.Manager');
72+
73+
// code
74+
75+
}
76+
77+
### Configuring the Manager
78+
79+
There are multiple configurations for the manager-component.
80+
See the [Manager Component](../Components/Manager.md) for detailed documentation about the Manager-component.
81+
82+
Loging in
83+
---------
84+
The CakeManager is set, we are now able to login! Go to yourdomain.com/login to login and start happy coding!
85+
Good luck!
2486

25-
> Note: Schema's are not supported yet.
87+
Bob Mulder
2688

89+
The CakeManager-Team

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Branches
2222
Table Of Contents
2323
-----------------
2424

25-
* [Installation](installation.md)
26-
* [Configurations](configurations.md)
25+
* [Installation](Installation.md)
26+
* [Configurations](Configurations.md)
2727

2828
To Do
2929
-----
30-
Write documentation
31-
Adding tests
32-
Many more
30+
- Write documentation
31+
- Adding tests
32+
- Many more

docs/installation.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)