Skip to content

Commit 00a5334

Browse files
committed
First cut at object inheritance documentation
1 parent b875585 commit 00a5334

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

en/developers.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Developers
55

66
developers/working-with-git
77
developers/understanding-cakephp
8+
developers/object-inheritance
89
developers/callbacks
910
developers/view-blocks
1011
developers/plugins
1112
developers/core-plugins
1213
developers/shells
1314
developers/events
14-
developers/tips
15+
developers/tips

en/developers/object-inheritance.rst

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Object Inheritance
2+
##################
3+
4+
Croogo follows established standards for how to integrate custom functionality into a `CakePHP <http://cakephp.org/>`_ application. To those already familiar with the object inheritance of CakePHP, learning where the Croogo classes fit in should feel quite natural. And since Croogo is implemented almost entirely as a set of `CakePHP Plugins <http://book.cakephp.org/2.0/en/plugins.html>`_, it is important to include those in the explanation.
5+
6+
All requests to a Croogo app come in the form of /plugin/controller/action along with any additional parameters that might be necessary. This url gets parsed, the specific plugin and controller is located and its action is dispatched. For example, /menus/links/index will locate the Menus plugin, load the LinksController class found there and dispatch the index action. Each controller layer exists to contain increasing levels of custom functionality that carries out the activities once dispatched. The following inheritance list of the controllers in the Menus plugin display their ancestry.
7+
8+
* `Controller` *(/myapp/Vendor/cakephp/cakephp/lib/Cake/Controller/)*
9+
* `CroogoAppController` *(/myapp/Vendor/croogo/croogo/Croogo/Controller/)*
10+
* `AppController` *(/myapp/Controller/)*
11+
* `MenusAppController` *(/myapp/Vendor/croogo/croogo/Menus/Controller/)*
12+
* `LinksController` *(/myapp/Vendor/croogo/croogo/Menus/Controller/)*
13+
* `MenusController` *(/myapp/Vendor/croogo/croogo/Menus/Controller/)*
14+
15+
Controller
16+
""""""""""
17+
18+
At the root of the list is the CakePHP Controller which provides the base functionality of dispatching requests and interacting with Models, Views, Components and many other utility classes. *All* controllers within a Croogo application inherit this class. You will never modify this file unless your intention is to submit your changes back to the CakePHP repository (or you are simply changing things to better understand how Cake works). But you should certainly never release non-standard CakePHP code for production use.
19+
20+
CroogoAppController
21+
"""""""""""""""""""
22+
23+
This controller extends CakePHP's Controller and performs much of the activity required to make Croogo what it is. This includes User auth, Theme setup, Settings load, custom Event callbacks, View fallbacks, and more. Similar to the CakePHP code, you will not modify this file unless your intention is to submit your changes back to the Croogo repository.
24+
25+
AppController
26+
"""""""""""""
27+
28+
This controller extends the CroogoAppController and performs any actions that are applicable to *all* the controllers used in your entire application. This includes any controllers located in the /myapp/Controller/ directory, as well as any standard or custom plugins enabled in your app. This file can be modified without limits as needed for your application. As is typical in OOP, when subclassing, function overrides will usually contain a call to the parent function to include whatever activities are required at the higher level. This guideline can certainly be ignored when those activities are exactly what you are trying to change.
29+
30+
MenusAppController
31+
""""""""""""""""""
32+
33+
Similar in function to the AppController, the MenusAppController is different only in its scope of applicability. Instead of being inherited by all controllers within the entire app, it is inherited by only the controllers within the Menus plugin.
34+
35+
.. NOTE:: Functionally, although not syntactically, code contained within a <plugin>AppController, and code contained within a <plugin>Component are equivalent. It is all used to keep your code `DRY <http://book.cakephp.org/2.0/en/appendices/glossary.html>`_. Typically, you should put your logical code within the Component, and only place code within the AppController when necessary to hook in at a specific point within the dispatching flow. This is especially true if the logic you write might be useful *outside* the plugin since it is very easy to include a Component from one plugin into another.
36+
37+
LinksController and MenusController
38+
"""""""""""""""""""""""""""""""""""
39+
40+
Finally, the LinksController and MenusController both extend the MenusAppController and contain the functions specific to managing the hyperlinks and the menus within Croogo. Since Menus is a core Croogo plugin, its code should not be modified for production use, but understanding the structure will help immensely when creating your own custom :doc:`plugin<plugins>`.

themes/docs/static/theme.css

+2
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ tt { font-family: inherit; }
8383
#footer .separator { margin-left: 10px; }
8484

8585
.strike { text-decoration: line-through; }
86+
87+
.note { background: #f8f8f8; border: 1px solid #e5e5e5; font-style: normal; padding: 1px 3px; }

0 commit comments

Comments
 (0)