Permalink
Browse files

Remove more <?php blocks.

  • Loading branch information...
markstory committed Nov 20, 2012
1 parent 60ba09d commit f75866c0ac2fff3f5e87fe58845bd57483a58322
Showing with 26 additions and 614 deletions.
  1. +1 −1 en/appendices/cakephp-development-process.rst
  2. +1 −1 en/cakephp-overview/understanding-model-view-controller.rst
  3. +1 −1 en/cakephp-overview/where-to-get-help.rst
  4. +1 −1 en/console-and-shells/acl-shell.rst
  5. +1 −1 en/console-and-shells/code-generation-with-bake.rst
  6. +1 −1 en/console-and-shells/testsuite-shell.rst
  7. +1 −1 en/contributing/tickets.rst
  8. +1 −1 en/controllers/pages-controller.rst
  9. +0 −14 en/core-libraries/events.rst
  10. +1 −2 en/core-libraries/global-constants-and-functions.rst
  11. +0 −9 en/core-libraries/internationalization-and-localization.rst
  12. +0 −13 en/core-libraries/logging.rst
  13. +1 −1 en/core-libraries/toc-behaviors.rst
  14. +1 −1 en/core-libraries/toc-components.rst
  15. +1 −1 en/core-libraries/toc-general-purpose.rst
  16. +1 −1 en/core-libraries/toc-helpers.rst
  17. +1 −1 en/core-libraries/toc-utilities.rst
  18. +0 −18 en/core-utility-libraries/app.rst
  19. +0 −20 en/core-utility-libraries/email.rst
  20. +0 −21 en/core-utility-libraries/hash.rst
  21. +0 −13 en/core-utility-libraries/httpsocket.rst
  22. +1 −1 en/core-utility-libraries/inflector.rst
  23. +0 −13 en/core-utility-libraries/number.rst
  24. +1 −1 en/core-utility-libraries/router.rst
  25. +0 −4 en/core-utility-libraries/sanitize.rst
  26. +0 −6 en/core-utility-libraries/security.rst
  27. +0 −27 en/core-utility-libraries/set.rst
  28. +1 −12 en/core-utility-libraries/string.rst
  29. +0 −14 en/core-utility-libraries/time.rst
  30. +1 −19 en/core-utility-libraries/xml.rst
  31. +0 −19 en/development/configuration.rst
  32. +0 −5 en/development/debugging.rst
  33. +0 −8 en/development/dispatch-filters.rst
  34. +0 −4 en/development/errors.rst
  35. +0 −12 en/development/exceptions.rst
  36. +0 −5 en/development/rest.rst
  37. +0 −47 en/development/routing.rst
  38. +0 −13 en/development/sessions.rst
  39. +0 −39 en/development/testing.rst
  40. +1 −1 en/development/vendor-packages.rst
  41. +0 −1 en/getting-started/cakephp-conventions.rst
  42. +1 −1 en/getting-started/cakephp-folder-structure.rst
  43. +1 −1 en/getting-started/cakephp-structure.rst
  44. +0 −1 en/installation/advanced-installation.rst
  45. +1 −5 en/models/additional-methods-and-properties.rst
  46. +0 −26 en/models/associations-linking-models-together.rst
  47. +0 −17 en/models/behaviors.rst
  48. +1 −6 en/models/callback-methods.rst
  49. +0 −61 en/models/data-validation.rst
  50. +1 −9 en/models/datasources.rst
  51. +1 −3 en/models/deleting-data.rst
  52. +0 −10 en/models/model-attributes.rst
  53. +1 −35 en/models/retrieving-your-data.rst
  54. +0 −29 en/models/saving-your-data.rst
  55. +0 −3 en/models/transactions.rst
  56. +0 −12 en/models/virtual-fields.rst
  57. +0 −13 en/views/helpers.rst
  58. +0 −3 en/views/json-and-xml-views.rst
  59. +0 −2 en/views/media-view.rst
  60. +0 −3 en/views/themes.rst
@@ -53,4 +53,4 @@ on irc.freenode.net.
.. meta::
:title lang=en: CakePHP Development Process
- :keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
+ :keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
@@ -107,4 +107,4 @@ To get started on your first CakePHP application,
.. meta::
:title lang=en: Understanding Model-View-Controller
- :keywords lang=en: model view controller,model layer,formatted result,model objects,music documents,business logic,text representation,first glance,retrieving data,software design,html page,videos music,new friends,interaction,cakephp,interface,photo,presentation,mvc,photos
+ :keywords lang=en: model view controller,model layer,formatted result,model objects,music documents,business logic,text representation,first glance,retrieving data,software design,html page,videos music,new friends,interaction,cakephp,interface,photo,presentation,mvc,photos
@@ -96,4 +96,4 @@ and solved questions as well.
.. meta::
:title lang=en: Where to Get Help
:description lang=en: Where to get help with CakePHP: The official CakePHP website, The Cookbook, The Bakery, The API, in the test cases, the IRC channel, The CakePHP Google Group or CakePHP Questions.
- :keywords lang=en: cakephp,cakephp help,help with cakephp,where to get help,cakephp irc,cakephp questions,cakephp api,cakephp test cases,open source projects,channel irc,code reference,irc channel,developer tools,test case,bakery
+ :keywords lang=en: cakephp,cakephp help,help with cakephp,where to get help,cakephp irc,cakephp questions,cakephp api,cakephp test cases,open source projects,channel irc,code reference,irc channel,developer tools,test case,bakery
@@ -79,4 +79,4 @@ allows you to return only a portion of the requested tree::
.. meta::
:title lang=en: ACL Shell
- :keywords lang=en: record style,style reference,acl,database tables,group id,notations,alias,privilege,node,privileges,shell,databases
+ :keywords lang=en: record style,style reference,acl,database tables,group id,notations,alias,privilege,node,privileges,shell,databases
@@ -230,4 +230,4 @@ and add the files there.
.. meta::
:title lang=en: Code Generation with Bake
- :keywords lang=en: command line interface,functional application,atabase,database configuration,bash script,basic ingredients,roject,odel,path path,code generation,scaffolding,windows users,configuration file,few minutes,config,iew,shell,models,running,mysql
+ :keywords lang=en: command line interface,functional application,atabase,database configuration,bash script,basic ingredients,roject,odel,path path,code generation,scaffolding,windows users,configuration file,few minutes,config,iew,shell,models,running,mysql
@@ -14,4 +14,4 @@ For more information on basic usage of the test shell see
.. meta::
:title lang=en: Test Shell
- :keywords lang=en: cakephp testing,test shell,testsuite,command line
+ :keywords lang=en: cakephp testing,test shell,testsuite,command line
@@ -51,4 +51,4 @@ CakePHP team will take the following actions:
.. meta::
:title lang=en: Tickets
- :keywords lang=en: bug reporting system,code snippet,reporting security,private mailing,release announcement,google,ticket system,core team,security issue,bug tracker,irc channel,test cases,support questions,bug report,security issues,bug reports,exploits,lighthouse,vulnerability,repository
+ :keywords lang=en: bug reporting system,code snippet,reporting security,private mailing,release announcement,google,ticket system,core team,security issue,bug tracker,irc channel,test cases,support questions,bug report,security issues,bug reports,exploits,lighthouse,vulnerability,repository
@@ -25,4 +25,4 @@ created in your ``app/Controller/`` folder. You can also copy the file from
.. meta::
:title lang=en: The Pages Controller
- :keywords lang=en: pages controller,default controller,lib,cakephp,ships,php,file folder
+ :keywords lang=en: pages controller,default controller,lib,cakephp,ships,php,file folder
@@ -55,7 +55,6 @@ Dispatching events
So back to our example, we would have an `Order` model that will manage the buying logic,
and probably a `place` method to save the order details and do any other logic::
- <?php
// Cart/Model/Order.php
class Order extends AppModel {
@@ -77,7 +76,6 @@ about sending emails, and may not even have the inventory data to decrement the
item from it, and definitely tracking usage statistics is not the best place to
do it. So we need another solution, let's rewrite that using the event manager::
- <?php
// Cart/Model/Order.php
App::uses('CakeEvent', 'Event');
class Order extends AppModel {
@@ -106,7 +104,6 @@ and to dispatch events you use :php:meth:`CakeEventManager::dispatch()` which
receives an instance of the :php:class:`CakeEvent` class. Let's dissect now the
process of dispatching an event::
- <?php
new CakeEvent('Model.Order.afterPlace', $this, array(
'order' => $order
));
@@ -145,7 +142,6 @@ For simplicity's sake, let's imagine we know in the plugin what the callbacks
are available in the controller, and say this controller is responsible for
attaching them. The possible code would look like this::
- <?php
// Listeners configured somewhere else, maybe a config file:
Configure::write('Order.afterPlace', array(
'email-sending' => 'EmailSender::sendBuyEmail',
@@ -199,7 +195,6 @@ statistics. It would be natural to pass an instance of this class as a callback,
instead of implementing a custom static function or converting any other workaround
to trigger methods in this class. A listener is created as follows::
- <?php
App::uses('CakeEventListener', 'Event');
class UserStatistic implements CakeEventListener {
@@ -246,7 +241,6 @@ executed with a `FIFO` policy, the first listener method to be attached is calle
first and so on. You set priorities using the `attach` method for callbacks, and
declaring it in the `implementedEvents` function for event listeners::
- <?php
// Setting priority for a callback
$callback = array($this, 'doSomething');
$this->getEventManager()->attach($callback, 'Model.Order.afterPlace', array('priority' => 2));
@@ -278,7 +272,6 @@ In order to toggle this option you have to add the `passParams` option to the
third argument of the `attach` method, or declare it in the `implementedEvents`
returned array similar to what you do with priorities::
- <?php
// Setting priority for a callback
$callback = array($this, 'doSomething');
$this->getEventManager()->attach($callback, 'Model.Order.afterPlace', array('passParams' => true));
@@ -300,7 +293,6 @@ In the above code the `doSomething` function and `updateBuyStatistic` method wil
receive `$orderData` instead of the `$event` object. This is so, because in our
previous example we trigger the `Model.Order.afterPlace` event with some data::
- <?php
$this->getEventManager()->dispatch(new CakeEvent('Model.Order.afterPlace', $this, array(
'order' => $order
)));
@@ -322,7 +314,6 @@ the code detects it cannot proceed any further.
In order to stop events you can either return `false` in your callbacks or call
the `stopPropagation` method on the event object::
- <?php
public function doSomething($event) {
// ...
return false; // stops the event
@@ -342,7 +333,6 @@ we had a `beforePlace` stopping the event would have a valid meaning.
To check if an event was stopped, you call the `isStopped()` method in the event object::
- <?php
public function place($order) {
$event = new CakeEvent('Model.Order.beforePlace', $this, array('order' => $order));
$this->getEventManager()->dispatch($event);
@@ -370,7 +360,6 @@ the $order data.
Event results can be altered either using the event object result property
directly or returning the value in the callback itself::
- <?php
// A listener callback
public function doSomething($event) {
// ...
@@ -410,7 +399,6 @@ If for any reason you want to remove any callback from the event manager just ca
the :php:meth:`CakeEventManager::detach()` method using as arguments the first two
params you used for attaching it::
- <?php
// Attaching a function
$this->getEventManager()->attach(array($this, 'doSomething'), 'My.event');
@@ -459,7 +447,6 @@ the local callbacks will get called in the respective priority order.
Accessing the global event manager is as easy as calling a static function,
the following example will attach a global event to the `beforePlace` event::
- <?php
// In any configuration file or piece of code that executes before the event
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach($aCallback, 'Model.Order.beforePlace');
@@ -476,7 +463,6 @@ to prevent some bugs. Remember that extreme flexibility implies extreme complexi
Consider this callback that wants to listen for all Model beforeFinds but in
reality, it cannot do its logic if the model is the Cart::
- <?php
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach('myCallback', 'Model.beforeFind');
@@ -28,7 +28,6 @@ such as debugging and translating content.
``sprintf()``. You can supply additional arguments to replace
placeholders in your string::
- <?php
__('You have %s unread messages', $number);
.. note::
@@ -308,4 +307,4 @@ Timing Definition Constants
.. meta::
:title lang=en: Global Constants and Functions
- :keywords lang=en: internationalization and localization,global constants,example config,array php,convenience functions,core libraries,component classes,optional number,global functions,string string,core classes,format strings,unread messages,placeholders,useful functions,sprintf,arrays,parameters,existence,translations
+ :keywords lang=en: internationalization and localization,global constants,example config,array php,convenience functions,core libraries,component classes,optional number,global functions,string string,core classes,format strings,unread messages,placeholders,useful functions,sprintf,arrays,parameters,existence,translations
@@ -82,7 +82,6 @@ Remember that po files are useful for short messages, if you find
you want to translate long paragraphs, or even whole pages - you
should consider implementing a different solution. e.g.::
- <?php
// App Controller Code.
public function beforeFilter() {
$locale = Configure::read('Config.language');
@@ -94,7 +93,6 @@ should consider implementing a different solution. e.g.::
or::
- <?php
// View code
echo $this->element(Configure::read('Config.language') . '/tos');
@@ -107,7 +105,6 @@ follow a few conventions.
Instead of __() and __n() you will have to use __d() and __dn(). The D means
domain. So if you have a plugin called 'DebugKit' you would have to do this::
- <?php
__d('debug_kit', 'My example text');
Using the underscored syntax is important, if you don't use it CakePHP won't
@@ -133,7 +130,6 @@ Localization in CakePHP
To change or set the language for your application, all you need to
do is the following::
- <?php
Configure::write('Config.language', 'fre');
This tells Cake which locale to use (if you use a regional locale, such as
@@ -146,13 +142,11 @@ in fact anytime at all before you want a message in a different language. To
set the language for the current user, you can store the setting in the Session
object, like this::
- <?php
$this->Session->write('Config.language', 'fre');
At the beginning of each request in your controller's ``beforeFilter`` you
should configure ``Configure`` as well::
- <?php
class AppController extends Controller {
public function beforeFilter() {
Configure::write('Config.language', $this->Session->read('Config.language'));
@@ -198,7 +192,6 @@ CakePHP will automatically extract the validation error when you are using the
:doc:`i18n console task </console-and-shells>`. By default, the default domain is used.
This can be overwritten by setting the ``$validationDomain`` property in your model::
- <?php
class User extends AppModel {
public $validationDomain = 'validation_errors';
@@ -207,7 +200,6 @@ This can be overwritten by setting the ``$validationDomain`` property in your mo
Additional parameters defined in the validation rule are passed to the translation
function. This allows you to create dynamic validation messages::
- <?php
class User extends AppModel {
public $validationDomain = 'validation';
@@ -224,7 +216,6 @@ function. This allows you to create dynamic validation messages::
Which will do the following internal call::
- <?php
__d('validation', 'Username should be between %d and %d characters', array(2, 10));
.. meta::
@@ -32,7 +32,6 @@ configured ``CakeLog`` will attempt to load Configuring log streams
is done by calling ``CakeLog::config()``. Configuring our
DataBaseLogger would look like::
- <?php
// for app/Lib
CakeLog::config('otherFile', array(
'engine' => 'DatabaseLogger',
@@ -51,7 +50,6 @@ When configuring a log stream the ``engine`` parameter is used to
locate and load the log handler. All of the other configuration
properties are passed to the log stream's constructor as an array.::
- <?php
App::uses('CakeLogInterface', 'Log');
class DatabaseLogger implements CakeLogInterface {
@@ -113,7 +111,6 @@ message is stored in. If a type is not supplied, LOG\_ERROR is used
which writes to the error log. The default log location is
``app/tmp/logs/$type.log``::
- <?php
// Executing this inside a CakePHP class
$this->log("Something didn't work!");
@@ -124,7 +121,6 @@ You can specify a custom log name using the first parameter. The
default built-in FileLog class will treat this log name as the file
you wish to write logs to::
- <?php
// called statically
CakeLog::write('activity', 'A special message for activity logging');
@@ -138,7 +134,6 @@ You can configure additional/alternate FileLog locations using
:php:meth:`CakeLog::config()`. FileLog accepts a ``path`` which allows for
custom paths to be used::
- <?php
CakeLog::config('custom_path', array(
'engine' => 'FileLog',
'path' => '/path/to/custom/place/'
@@ -152,14 +147,12 @@ Writing to logs
Writing to the log files can be done in 2 different ways. The first
is to use the static :php:meth:`CakeLog::write()` method::
- <?php
CakeLog::write('debug', 'Something did not work');
The second is to use the log() shortcut function available on any
class that extends ``Object``. Calling log() will internally call
CakeLog::write()::
- <?php
// Executing this inside a CakePHP class:
$this->log("Something did not work!", 'debug');
@@ -188,7 +181,6 @@ the log messages will be directed to those loggers. If a log message is written
to an unknown scope, loggers that handle that level of message will log the
message. For example::
- <?php
// configure tmp/logs/shops.log to receive all types (log levels), but only
// those with `orders` and `payments` scope
CakeLog::config('shops', array(
@@ -260,14 +252,12 @@ CakeLog API
To append the additional levels 'user0' and 'user1' to the default
log levels use::
- <?php
CakeLog::levels(array('user0', 'user1'));
// or
CakeLog::levels(array('user0', 'user1'), true);
Calling ``CakeLog::levels()`` will result in::
- <?php
array(
0 => 'emergency',
1 => 'alert',
@@ -279,12 +269,10 @@ CakeLog API
To set/replace an existing configuration, pass an array with the second
argument set to false::
- <?php
CakeLog::levels(array('user0', 'user1'), false);
Calling ``CakeLog::levels()`` will result in::
- <?php
array(
0 => 'user0',
1 => 'user1',
@@ -296,7 +284,6 @@ CakeLog API
Resets log levels to their original values::
- <?php
array(
'emergency' => LOG_EMERG,
'alert' => LOG_ALERT,
@@ -7,4 +7,4 @@ Behaviors
behaviors/acl
behaviors/containable
behaviors/translate
- behaviors/tree
+ behaviors/tree
@@ -11,4 +11,4 @@ Components
components/request-handling
components/pagination
components/security-component
- components/sessions
+ components/sessions
@@ -7,4 +7,4 @@ General Purpose
global-constants-and-functions
../core-utility-libraries/app
events
- collections
+ collections
@@ -13,4 +13,4 @@ Helpers
helpers/rss
helpers/session
helpers/text
- helpers/time
+ helpers/time
@@ -19,4 +19,4 @@ Utilities
../core-utility-libraries/hash
../core-utility-libraries/set
../core-utility-libraries/string
- ../core-utility-libraries/xml
+ ../core-utility-libraries/xml
Oops, something went wrong.

0 comments on commit f75866c

Please sign in to comment.