Skip to content
Browse files

Merge pull request #429 from cakephp/no-php

Remove the need for <?php everywhere
  • Loading branch information...
2 parents 4ce5264 + 55608d1 commit 8340dc0f397f0552430851647829735b61b8bcb8 @lorenzo lorenzo committed
Showing with 444 additions and 1,310 deletions.
  1. +7 −1 config/all.py
  2. +0 −26 en/appendices/2-0-migration-guide.rst
  3. +0 −2 en/appendices/2-1-migration-guide.rst
  4. +0 −3 en/appendices/2-2-migration-guide.rst
  5. +1 −1 en/appendices/cakephp-development-process.rst
  6. +0 −2 en/appendices/glossary.rst
  7. +5 −26 en/appendices/migrating-from-cakephp-1-2-to-1-3.rst
  8. +15 −60 en/appendices/new-features-in-cakephp-1-3.rst
  9. +6 −24 en/appendices/new-features-in-cakephp-2-0.rst
  10. +5 −12 en/appendices/new-features-in-cakephp-2-1.rst
  11. +1 −2 en/appendices/phpunit-migration-hints.rst
  12. +1 −1 en/cakephp-overview.rst
  13. +1 −1 en/cakephp-overview/understanding-model-view-controller.rst
  14. +1 −1 en/cakephp-overview/where-to-get-help.rst
  15. +0 −30 en/console-and-shells.rst
  16. +1 −1 en/console-and-shells/acl-shell.rst
  17. +1 −1 en/console-and-shells/code-generation-with-bake.rst
  18. +0 −2 en/console-and-shells/schema-management-and-migrations.rst
  19. +1 −1 en/console-and-shells/testsuite-shell.rst
  20. +1 −1 en/contributing.rst
  21. +0 −18 en/contributing/cakephp-coding-conventions.rst
  22. +1 −1 en/contributing/tickets.rst
  23. +0 −30 en/controllers.rst
  24. +0 −10 en/controllers/components.rst
  25. +1 −1 en/controllers/pages-controller.rst
  26. +3 −32 en/controllers/request-response.rst
  27. +1 −6 en/controllers/scaffolding.rst
  28. +1 −10 en/core-libraries/behaviors/acl.rst
  29. +1 −15 en/core-libraries/behaviors/containable.rst
  30. +0 −11 en/core-libraries/behaviors/translate.rst
  31. +0 −19 en/core-libraries/behaviors/tree.rst
  32. +0 −9 en/core-libraries/caching.rst
  33. +0 −12 en/core-libraries/collections.rst
  34. +0 −9 en/core-libraries/components/access-control-lists.rst
  35. +0 −25 en/core-libraries/components/authentication.rst
  36. +0 −8 en/core-libraries/components/cookie.rst
  37. +1 −1 en/core-libraries/components/email.rst
  38. +0 −20 en/core-libraries/components/pagination.rst
  39. +0 −7 en/core-libraries/components/request-handling.rst
  40. +1 −8 en/core-libraries/components/security-component.rst
  41. +1 −14 en/core-libraries/components/sessions.rst
  42. +0 −14 en/core-libraries/events.rst
  43. +1 −2 en/core-libraries/global-constants-and-functions.rst
  44. +4 −6 en/core-libraries/helpers/cache.rst
  45. +162 −142 en/core-libraries/helpers/form.rst
  46. +128 −81 en/core-libraries/helpers/html.rst
  47. +14 −37 en/core-libraries/helpers/js.rst
  48. +1 −1 en/core-libraries/helpers/number.rst
  49. +51 −44 en/core-libraries/helpers/paginator.rst
  50. +0 −7 en/core-libraries/helpers/rss.rst
  51. +6 −7 en/core-libraries/helpers/session.rst
  52. +0 −1 en/core-libraries/helpers/text.rst
  53. +1 −2 en/core-libraries/helpers/time.rst
  54. +0 −9 en/core-libraries/internationalization-and-localization.rst
  55. +0 −13 en/core-libraries/logging.rst
  56. +1 −1 en/core-libraries/toc-behaviors.rst
  57. +1 −1 en/core-libraries/toc-components.rst
  58. +1 −1 en/core-libraries/toc-general-purpose.rst
  59. +1 −1 en/core-libraries/toc-helpers.rst
  60. +1 −1 en/core-libraries/toc-utilities.rst
  61. +0 −18 en/core-utility-libraries/app.rst
  62. +0 −20 en/core-utility-libraries/email.rst
  63. +0 −21 en/core-utility-libraries/hash.rst
  64. +0 −13 en/core-utility-libraries/httpsocket.rst
  65. +1 −1 en/core-utility-libraries/inflector.rst
  66. +0 −13 en/core-utility-libraries/number.rst
  67. +1 −1 en/core-utility-libraries/router.rst
  68. +0 −4 en/core-utility-libraries/sanitize.rst
  69. +0 −6 en/core-utility-libraries/security.rst
  70. +0 −27 en/core-utility-libraries/set.rst
  71. +1 −12 en/core-utility-libraries/string.rst
  72. +0 −14 en/core-utility-libraries/time.rst
  73. +1 −19 en/core-utility-libraries/xml.rst
  74. +1 −1 en/deployment.rst
  75. +0 −19 en/development/configuration.rst
  76. +0 −5 en/development/debugging.rst
  77. +0 −8 en/development/dispatch-filters.rst
  78. +0 −4 en/development/errors.rst
  79. +0 −12 en/development/exceptions.rst
  80. +0 −5 en/development/rest.rst
  81. +0 −47 en/development/routing.rst
  82. +0 −13 en/development/sessions.rst
  83. +0 −39 en/development/testing.rst
  84. +1 −1 en/development/vendor-packages.rst
  85. +0 −1 en/getting-started/cakephp-conventions.rst
  86. +1 −1 en/getting-started/cakephp-folder-structure.rst
  87. +1 −1 en/getting-started/cakephp-structure.rst
  88. +0 −1 en/installation.rst
  89. +0 −1 en/installation/advanced-installation.rst
  90. +0 −3 en/models.rst
  91. +1 −5 en/models/additional-methods-and-properties.rst
  92. +0 −26 en/models/associations-linking-models-together.rst
  93. +0 −17 en/models/behaviors.rst
  94. +1 −6 en/models/callback-methods.rst
  95. +0 −61 en/models/data-validation.rst
  96. +1 −7 en/models/data-validation/validating-data-from-the-controller.rst
  97. +1 −9 en/models/datasources.rst
  98. +1 −3 en/models/deleting-data.rst
  99. +0 −10 en/models/model-attributes.rst
Sorry, we could not display the entire diff because it was too big.
View
8 config/all.py
@@ -71,7 +71,7 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
-highlight_language = 'php'
+highlight_language = 'phpinline'
# -- Options for HTML output ---------------------------------------------------
@@ -281,3 +281,9 @@
# Languages available.
languages = ['en', 'pt', 'es', 'ja', 'ru', 'fr']
+
+# Hack to render the php source code without the <?php tag
+from sphinx.highlighting import lexers
+from pygments.lexers.web import PhpLexer
+
+lexers['phpinline'] = PhpLexer(startinline=True)
View
26 en/appendices/2-0-migration-guide.rst
@@ -111,7 +111,6 @@ Internationalization / Localization
If you want to echo the result of the translation, use::
- <?php
echo __('My Message');
This change includes all shortcut translation methods::
@@ -128,7 +127,6 @@ Alongside this, if you pass additional parameters, the translation will call
`sprintf <http://php.net/manual/en/function.sprintf.php>`_ with these
parameters before returning. For example::
- <?php
// Will return something like "Called: MyClass:myMethod"
echo __('Called: %s:%s', $className, $methodName);
@@ -215,7 +213,6 @@ Components
Component is now the required base class for all components. You should update
your components and their constructors, as both have changed::
- <?php
class PrgComponent extends Component {
function __construct(ComponentCollection $collection, $settings = array()) {
parent::__construct($collection, $settings);
@@ -245,7 +242,6 @@ All the deprecated callbacks in Component have not been transferred to
ComponentCollection. Instead you should use the `trigger()` method to interact
with callbacks. If you need to trigger a callback you could do so by calling::
- <?php
$this->Components->trigger('someCallback', array(&$this));
Changes in disabling components
@@ -429,7 +425,6 @@ Although there has been a huge refactoring in how the classes are loaded, in ver
few occasions you will need to change your application code to respect the way you were
used to doing it. The biggest change is the introduction of a new method::
- <?php
App::uses('AuthComponent', 'Controller/Component');
We decided the function name should emulate PHP 5.3's ``use`` keyword, just as a way
@@ -443,7 +438,6 @@ is used for the first time it will be located.
Some examples on using :php:meth:`App::uses()` when migrating from
:php:meth:`App::import()`::
- <?php
App::import('Controller', 'Pages');
// becomes
App::uses('PagesController', 'Controller');
@@ -468,7 +462,6 @@ All classes that were loaded in the past using ``App::import('Core', $class);``
will need to be loaded using ``App::uses()`` referring to the correct package.
See the api to locate the classes in their new folders. Some examples::
- <?php
App::import('Core', 'CakeRoute');
// becomes
App::uses('CakeRoute', 'Routing/Route');
@@ -494,7 +487,6 @@ App::build() and core paths
Examples::
- <?php
App::build(array('controllers' => array('/full/path/to/controllers')));
//becomes
App::build(array('Controller' => array('/full/path/to/Controller')));
@@ -526,7 +518,6 @@ Cache
::
- <?php
Cache::config('something');
Cache::write('key', $value);
@@ -557,14 +548,12 @@ Router
``index`` action is given a short route. If you wish to continue using short
routes, you can add a route like::
- <?php
Router::connect('/users/:action', array('controller' => 'users', 'plugin' => 'users'));
To your routes file for each plugin you need short routes on.
Your app/Config/routes.php file needs to be updated adding this line at the bottom of the file::
- <?php
require CAKE . 'Config' . DS . 'routes.php';
This is needed in order to generate the default routes for your application. If you do not wish to have such routes,
@@ -663,7 +652,6 @@ In order to accommodate View being removed from the ClassRegistry, the signature
of Helper::__construct() was changed. You should update any subclasses to use
the following::
- <?php
function __construct(View $View, $settings = array())
When overriding the constructor you should always call `parent::__construct` as
@@ -803,13 +791,11 @@ this, just change ``$_minimizedAttributeFormat`` in your AppHelper to ``%s``.
To use with Html/Form helpers and others, you can write::
- <?php
$this->Form->checkbox('field', array('checked' => true, 'value' => 'some_value'));
Other facility is that minimized attributes can be passed as item and not as
key. For example::
- <?php
$this->Form->checkbox('field', array('checked', 'value' => 'some_value'));
Note that ``checked`` have a numeric key.
@@ -938,7 +924,6 @@ afterRender it is the view file being rendered. For beforeLayout and afterLayout
it is the layout file being rendered. Your helpers function signatures should
look like::
- <?php
function beforeRender($viewFile) {
}
@@ -1030,20 +1015,17 @@ Models
Model relationships are now lazy loaded. You can run into a situation where
assigning a value to a nonexistent model property will throw errors::
- <?php
$Post->inexistentProperty[] = 'value';
will throw the error "Notice: Indirect modification of overloaded property
$inexistentProperty has no effect". Assigning an initial value to the property
solves the issue::
- <?php
$Post->nonexistentProperty = array();
$Post->nonexistentProperty[] = 'value';
Or just declare the property in the model class::
- <?php
class Post {
public $nonexistentProperty = array();
}
@@ -1087,12 +1069,10 @@ List of Changes
* API for DboSource::execute has changed, it will now take an array of query
values as second parameter::
- <?php
public function execute($sql, $params = array(), $options = array())
became::
- <?php
public function execute($sql, $options = array(), $params = array())
third parameter is meant to receive options for logging, currently it only
@@ -1102,7 +1082,6 @@ List of Changes
* DboSource::fetchAll() now accepts an array as second parameter, to pass values
to be bound to the query, third parameter was dropped. Example::
- <?php
$db->fetchAll('SELECT * from users where username = ? AND password = ?', array('jhon', '12345'));
$db->fetchAll('SELECT * from users where username = :username AND password = :password', array('username' => 'jhon', 'password' => '12345'));
@@ -1145,7 +1124,6 @@ AclBehavior and TreeBehavior
- No longer supports strings as configuration. Example::
- <?php
public $actsAs = array(
'Acl' => 'Controlled',
'Tree' => 'nested'
@@ -1153,7 +1131,6 @@ AclBehavior and TreeBehavior
became::
- <?php
public $actsAs = array(
'Acl' => array('type' => 'Controlled'),
'Tree' => array('type' => 'nested')
@@ -1167,14 +1144,12 @@ Plugins no longer magically append their plugin prefix to components, helpers
and models used within them. You must be explicit with the components, models,
and helpers you wish to use. In the past::
- <?php
public $components = array('Session', 'Comments');
Would look in the controller's plugin before checking app/core components. It
will now only look in the app/core components. If you wish to use objects from a
plugin you must put the plugin name::
- <?php
public $components = array('Session', 'Comment.Comments');
This was done to reduce hard to debug issues caused by magic misfiring. It also
@@ -1272,7 +1247,6 @@ the key "driver" is not accepted anymore, only "datasource", in order to make it
more consistent. Also, as the datasources have been moved to packages you will
need to pass the package they are located in. Example::
- <?php
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
View
2 en/appendices/2-1-migration-guide.rst
@@ -12,7 +12,6 @@ removed from the CakePHP core. If you do not already have these classes, you
can use the following while upgrading::
// app/View/Helper/AppHelper.php
- <?php
App::uses('Helper', 'View');
class AppHelper extends Helper {
}
@@ -262,7 +261,6 @@ View
instead.
- ``$scripts_for_layout`` is deprecated. Use the following instead::
- <?php
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
View
3 en/appendices/2-2-migration-guide.rst
@@ -13,7 +13,6 @@ When upgrading to CakePHP 2.2 its important to add a few new configuration
values to ``app/Config/bootstrap.php``. Adding these will ensure consistent
behavior with 2.1.x::
- <?php
// Enable the Dispatcher filters for plugin assets, and
// CacheHelper.
Configure::write('Dispatcher.filters', array(
@@ -36,7 +35,6 @@ behavior with 2.1.x::
You will also need to modify ``app/Config/core.php``. Change the value of
:php:const:`LOG_ERROR` to :php:const:`LOG_ERR`::
- <?php
define('LOG_ERROR', LOG_ERR);
When using ``Model::validateAssociated()`` or ``Model::saveAssociated()`` and
@@ -274,7 +272,6 @@ It is now possible to tag or label cache keys under groups. This makes it
simpler to mass-delete cache entries associated to the same label. Groups are
declared at configuration time when creating the cache engine::
- <?php
Cache::config(array(
'engine' => 'Redis',
...
View
2 en/appendices/cakephp-development-process.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
View
2 en/appendices/glossary.rst
@@ -12,7 +12,6 @@ Glossary
html attributes
An array of key => values that are composed into html attributes. For example::
- <?php
// Given
array('class' => 'my-class', '_target' => 'blank')
@@ -22,7 +21,6 @@ Glossary
If an option can be minimized or accepts it's name as the value, then ``true``
can be used::
- <?php
// Given
array('checked' => true)
View
31 en/appendices/migrating-from-cakephp-1-2-to-1-3.rst
@@ -46,7 +46,6 @@ There is a new way to add those paths. As of 1.3 RC1 the
::
- <?php
App::build(array(
'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
'models' => array('/full/path/to/models/', '/next/full/path/to/models/'),
@@ -74,11 +73,8 @@ configs are created **before** bootstrap.php is loaded.
``inflections.php`` has been removed, it was an unnecessary file
hit, and the related features have been refactored into a method to
increase their flexibility. You now use ``Inflector::rules()`` to
-load custom inflections.
+load custom inflections::
-::
-
- <?php
Inflector::rules('singular', array(
'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),
'uninflected' => array('singulars'),
@@ -223,11 +219,8 @@ automatically included without you asking for them. SessionHelper
and SessionComponent now act like every other component and must be
declared like any other helper/component. You should update
``AppController::$components`` and ``AppController::$helpers`` to
-include these classes to retain existing behavior.
-
-::
+include these classes to retain existing behavior::
- <?php
var $components = array('Session', 'Auth', ...);
var $helpers = array('Session', 'Html', 'Form' ...);
@@ -281,11 +274,8 @@ behavior with other prefix style routes in that it was treated
differently. Instead you should use ``Routing.prefixes``. Prefix
routes in 1.3 do not require additional routes to be declared
manually. All prefix routes will be generated automatically. To
-update simply change your core.php.
-
-::
+update simply change your core.php::
- <?php
//from:
Configure::write('Routing.admin', 'admin');
@@ -295,11 +285,8 @@ update simply change your core.php.
See the New features guide for more information on using prefix
routes. A small change has also been done to routing params. Routed
params should now only consist of alphanumeric chars, - and \_ or
-``/[A-Z0-9-_+]+/``.
+``/[A-Z0-9-_+]+/``::
-::
-
- <?php
Router::connect('/:$%@#param/:action/*', array(...)); // BAD
Router::connect('/:can/:anybody/:see/:m-3/*', array(...)); //Acceptable
@@ -308,11 +295,8 @@ increase performance and reduce code clutter. The side effect of
this is two seldom used features were removed, as they were
problematic and buggy even with the existing code base. First path
segments using full regular expressions was removed. You can no
-longer create routes like
-
-::
+longer create routes like::
- <?php
Router::connect('/([0-9]+)-p-(.*)/', array('controller' => 'products', 'action' => 'show'));
These routes complicated route compilation and impossible to
@@ -321,9 +305,6 @@ you use route parameters with capture patterns. Next mid-route
greedy star support has been removed. It was previously possible to
use a greedy star in the middle of a route.
-::
-
- <?php
Router::connect(
'/pages/*/:event',
array('controller' => 'pages', 'action' => 'display'),
@@ -343,7 +324,6 @@ $this->redirect() calls to reflect this change.
::
- <?php
// old format:
$url = array('controller' => 'posts', 'action' => 'view', 'id' => $id);
// use cases:
@@ -500,7 +480,6 @@ automatically outputs SQL logs. If you want to output SQL logs in
::
- <?php
echo $this->element('sql_dump');
You can place this element anywhere in your layout or view. The
View
75 en/appendices/new-features-in-cakephp-1-3.rst
@@ -16,7 +16,6 @@ as a collection of string names.
::
- <?php
$this->Security->requirePost(array('edit', 'update'));
**Component settings**
@@ -27,7 +26,6 @@ settings for components when you declare the component.
::
- <?php
var $components = array(
'Cookie' => array(
'name' => 'MyCookie'
@@ -83,7 +81,6 @@ available to all helpers. Assuming ``Asset.timestamp == force``
::
- <?php
$path = 'css/cake.generic.css'
$stamped = $this->Html->assetTimestamp($path);
@@ -100,11 +97,8 @@ highlight() now accepts an array of words to highlight.
**NumberHelper**
A new method ``addFormat()`` has been added. This method allows you
-to set currency parameter sets, so you don't have to retype them.
+to set currency parameter sets, so you don't have to retype them::
-::
-
- <?php
$this->Number->addFormat('NOK', array('before' => 'Kr. '));
$formatted = $this->Number->currency(1000, 'NOK');
@@ -133,11 +127,8 @@ directory. If you had a cache engine named ``MyCustomCacheEngine``
it would be placed in either ``app/libs/cache/my_custom_cache.php``
as an app/libs. Or in ``$plugin/libs/cache/my_custom_cache.php`` as
part of a plugin. Cache configs from plugins need to use the plugin
-dot syntax.
-
-::
+dot syntax::
- <?php
Cache::config('custom', array(
'engine' => 'CachePack.MyCustomCache',
...
@@ -179,11 +170,8 @@ You can use plugin datasources by setting the datasource key with
the plugin name. For example if you had a WebservicePack plugin
with a LastFm datasource
(plugin/webservice\_pack/models/datasources/last\_fm.php), you
-could do:
+could do::
-::
-
- <?php
var $lastFm = array(
'datasource' => 'WebservicePack.LastFm'
...
@@ -242,11 +230,8 @@ your schema files.
**Using tableParameters in schema files**
You use ``tableParameters`` just as you would any other key in a
-schema file. Much like ``indexes``:
-
-::
+schema file. Much like ``indexes``::
- <?php
var $comments => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0),
@@ -322,20 +307,14 @@ admin routing did in 1.2. They use the same syntax and
persist/behave in the same way. Assuming you have
``Configure::write('Routing.prefixes', array('admin', 'member'));``
in your core.php you will be able to do the following from a
-non-prefixed url:
-
-::
+non-prefixed url::
- <?php
$this->Html->link('Go', array('controller' => 'posts', 'action' => 'index', 'member' => true));
$this->Html->link('Go', array('controller' => 'posts', 'action' => 'index', 'admin' => true));
Likewise, if you are in a prefixed url and want to go to a
-non-prefixed url, do the following:
+non-prefixed url, do the following::
-::
-
- <?php
$this->Html->link('Go', array('controller' => 'posts', 'action' => 'index', 'member' => false));
$this->Html->link('Go', array('controller' => 'posts', 'action' => 'index', 'admin' => false));
@@ -374,11 +353,8 @@ inflection (except slug method).
Set has a new method ``Set::apply()``, which allows you to apply
`callbacks <http://ca2.php.net/callback>`_ to the results of
-``Set::extract`` and do so in either a map or reduce fashion.
-
-::
+``Set::extract`` and do so in either a map or reduce fashion::
- <?php
Set::apply('/Movie/rating', $data, 'array_sum');
Would return the sum of all Movie ratings in ``$data``.
@@ -412,18 +388,12 @@ been added. This directory can also be part of plugins, located at
party libraries that do not come from 3rd parties or external
vendors. This allows you to separate your organization's internal
libraries from vendor libraries. ``App::import()`` has also been
-updated to import from libs directories.
+updated to import from libs directories::
-::
-
- <?php
App::import('Lib', 'ImageManipulation'); //imports app/libs/image_manipulation.php
-You can also import libs files from plugins
-
-::
+You can also import libs files from plugins::
- <?php
App::import('Lib', 'Geocoding.Geocode'); //imports app/plugins/geocoding/libs/geocode.php
The remainder of lib importing syntax is identical to vendor files.
@@ -452,11 +422,8 @@ For example, if you have access to a machine running debian or
ubuntu you can find a french locale file at:
/usr/share/i18n/locales/fr\_FR. Copy the part corresponding to
LC\_TIME into app/locale/fr\_fr/LC\_TIME file. You can then access
-the time preferences for French language this way:
+the time preferences for French language this way::
-::
-
- <?php
Configure::write('Config.language','fr-fr'); // set the current language
$monthNames = __c('mon',LC_TIME,true); // returns an array with the month names in French
$dateFormat = __c('d_fmt',LC_TIME,true); // return the preferred dates format for France
@@ -481,11 +448,8 @@ error404, then you will need to do it manually.
**Scaffolding**
With the addition of ``Routing.prefixes`` scaffolding has been
-updated to allow the scaffolding of any one prefix.
-
-::
+updated to allow the scaffolding of any one prefix::
- <?php
Configure::write('Routing.prefixes', array('admin', 'member'));
class PostsController extends AppController {
@@ -504,11 +468,8 @@ not afford the flexibility needed for all cases, an alternate path
was taken. In 1.3, ``phone()`` and ``postal()`` will pass off any
country prefix it does not know how to handle to another class with
the appropriate name. For example if you lived in the Netherlands
-you would create a class like
-
-::
+you would create a class like::
- <?php
class NlValidation {
function phone($check) {
...
@@ -520,11 +481,8 @@ you would create a class like
This file could be placed anywhere in your application, but must be
imported before attempting to use it. In your model validation you
-could use your NlValidation class by doing the following.
+could use your NlValidation class by doing the following::
-::
-
- <?php
var $validate = array(
'phone_no' => array('rule' => array('phone', null, 'nl')),
'postal_code' => array('rule' => array('postal', null, 'nl'))
@@ -543,11 +501,8 @@ off to another validator has been added.
Validation of IP Addresses has been extended to allow strict
validation of a specific IP Version. It will also make use of PHP
-native validation mechanisms if available.
-
-::
+native validation mechanisms if available::
- <?php
Validation::ip($someAddress); // Validates both IPv4 and IPv6
Validation::ip($someAddress, 'IPv4'); // Validates IPv4 Addresses only
Validation::ip($someAddress, 'IPv6'); // Validates IPv6 Addresses only
@@ -561,4 +516,4 @@ only. It does not ensure uniqueness of the given uuid.
.. meta::
:title lang=en: New features in CakePHP 1.3
- :keywords lang=en: component settings,array name,array controller,private methods,necessary components,core components,share names,collisions,func,message id,new features,clutter,consistency,messageid,email,htmlmessage,variables,doc
+ :keywords lang=en: component settings,array name,array controller,private methods,necessary components,core components,share names,collisions,func,message id,new features,clutter,consistency,messageid,email,htmlmessage,variables,doc
View
30 en/appendices/new-features-in-cakephp-2-0.rst
@@ -45,7 +45,6 @@ HtmlHelper
Example of how to set configuration file on controller::
- <?php
public $helpers = array(
'Html' => array(
'configFile' => array('config_file', 'php') // Option one: an array with filename and reader name
@@ -100,7 +99,6 @@ modify them beyond adding the query string and fragment elements. For example
this could be used to create routes to handle subdomains, or enabling https/http
flags. An example of a route class that supports subdomains would be::
- <?php
class SubdomainRoute extends CakeRoute {
public function match($params) {
@@ -119,7 +117,6 @@ subdomains.
::
- <?php
echo $this->Html->link(
'Other domain',
array('subdomain' => 'test', 'controller' => 'posts', 'action' => 'add')
@@ -193,11 +190,8 @@ Automatic parsing of Accept headers
If a client sends a single Accept mime type that matches one of the extensions
enabled in :php:class`Router`, :php:class:`RequestHandler` will treat it the
same an extension. This expands CakePHP's support for REST style endpoints. To
-use this feature start off by enabling extensions in ``app/Config/routes.php``
+use this feature start off by enabling extensions in ``app/Config/routes.php``::
-::
-
- <?php
Router::parseExtensions('json', 'xml');
Once you have created layouts and views for your extensions, you will be able to
@@ -241,11 +235,8 @@ Pagination
Pagination now provides a default maxLimit for pagination at 100.
-This limit can be overridden with the paginate variable on Controller.
+This limit can be overridden with the paginate variable on Controller::
-::
-
- <?php
$this->paginate = array('maxLimit' => 1000);
This default is provided to prevent user URL manipulation causing excessive
@@ -259,22 +250,16 @@ You can now alias helpers, components and behaviors to use your class instead of
a different one. This means that you can very easily make a ``MyHtml`` helper
and not need to replace every instance of ``$this->Html`` in your views. To do
this, pass the 'className' key along with your class, like you would with
-models.
-
-::
+models::
- <?php
public $helpers = array(
'Html' => array(
'className' => 'MyHtml'
)
);
-Similarly, you can alias components for use in your controllers.
-
-::
+Similarly, you can alias components for use in your controllers::
- <?php
public $components = array(
'Email' => array(
'className' => 'QueueEmailer'
@@ -282,11 +267,8 @@ Similarly, you can alias components for use in your controllers.
);
Calls to the Email component would call the QueueEmailer component instead.
-Finally, you can alias behaviors as well.
-
-::
+Finally, you can alias behaviors as well::
- <?php
public $actsAs = array(
'Containable' => array(
'className' => 'SuperContainable'
@@ -309,4 +291,4 @@ removing connections at runtime.
.. meta::
:title lang=en: New Features in CakePHP 2.0
- :keywords lang=en: time reductions,doctypes,model construction,key value,option one,database connection,content view,configuration file,constructor,great time,array,new features,bootstrap process,elements,new models
+ :keywords lang=en: time reductions,doctypes,model construction,key value,option one,database connection,content view,configuration file,constructor,great time,array,new features,bootstrap process,elements,new models
View
17 en/appendices/new-features-in-cakephp-2-1.rst
@@ -8,7 +8,6 @@ Model::saveAll(), Model::saveAssociated(), Model::validateAssociated()
----------------------------------------------------------------------
``Model::saveAll()`` and friends now support passing the `fieldList` for multiple models. Example::
- <?php
$this->SomeModel->saveAll($data, array(
'fieldList' => array(
'SomeModel' => array('field_1'),
@@ -18,7 +17,6 @@ Model::saveAll(), Model::saveAssociated(), Model::validateAssociated()
``Model::saveAll()`` and friends now can save unlimited levels deep. Example::
- <?php
$data = array(
'Article' => array('title' => 'My first article'),
'Comment' => array(
@@ -71,7 +69,6 @@ In 2.1, the use of ``ThemeView`` is deprecated in favor of using the ``View`` cl
All custom pathing code has been moved into the ``View`` class, meaning that it is now possible for classes extending the ``View`` class to automatically support themes. Whereas before we might set the ``$viewClass`` Controller property to ``Theme``, it is now possible to enable themes by simply setting the ``$theme`` property. Example::
- <?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
@@ -89,7 +86,6 @@ Previously, it was necessary to create a JSON layout (``APP/View/Layouts/json/de
The :php:class:`JsonView` is used like any other view class, by defining it on the controller. Example::
- <?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
@@ -98,7 +94,6 @@ The :php:class:`JsonView` is used like any other view class, by defining it on t
Once you have setup the controller, you need to identify what content should be serialized as JSON, by setting the view variable ``_serialize``. Example::
- <?php
$this->set(compact('users', 'posts', 'tags'));
$this->set('_serialize', array('users', 'posts'));
@@ -112,7 +107,6 @@ Further customization of the output can be achieved by extending the :php:class:
The following example wraps the result with ``{results: ... }``::
- <?php
App::uses('JsonView', 'View');
class ResultsJsonView extends JsonView {
public function render($view = null, $layout = null) {
@@ -127,13 +121,15 @@ The following example wraps the result with ``{results: ... }``::
XmlView
-------
-Much like the :php:class:`JsonView`, the :php:class:`XmlView` requires you to set the ``_serialize`` view variable in order to indicate what information should be serialized into XML for output.
+Much like the :php:class:`JsonView`, the :php:class:`XmlView` requires you to
+set the ``_serialize`` view variable in order to indicate what information
+should be serialized into XML for output::
- <?php
$this->set(compact('users', 'posts', 'tags'));
$this->set('_serialize', array('users', 'posts'));
-The above example would result in only the ``users`` and ``posts`` variables being serialized for the XML output, like so::
+The above example would result in only the ``users`` and ``posts`` variables
+being serialized for the XML output, like so::
<response><users>...</users><posts>...</posts></response>
@@ -156,7 +152,6 @@ response is already cached in the client and will send a `304 Not Modified`
status code before rendering the view. Skipping the view rendering process saves
CPU cycles and memory.::
- <?php
class ArticlesController extends AppController {
public $components = array('RequestHandler');
@@ -180,7 +175,6 @@ and :php:class:`CakeNumber` classes respectively.
To use the new utility classes::
- <?php
class AppController extends Controller {
public function log($msg) {
@@ -193,7 +187,6 @@ You can override the default class to use by creating a new class in your
``APP/Utility`` folder, e.g.: ``Utility/MyAwesomeStringClass.php``, and specify
it in ``engine`` key::
- <?php
// Utility/MyAwesomeStringClass.php
class MyAwesomeStringClass extends String {
// my truncate is better than yours
View
3 en/appendices/phpunit-migration-hints.rst
@@ -172,7 +172,6 @@ suites as composable entities in the runner. You can place group tests inside
the cases directory and use ``PHPUnit_Framework_TestSuite`` as a base class. An
example Testsuite would look like::
- <?php
class AllJavascriptHelpersTest extends PHPUnit_Framework_TestSuite {
/**
@@ -198,4 +197,4 @@ recommended that you use the methods PHPUnit offers.
.. meta::
:title lang=en: PHPUnit Migration Hints
- :keywords lang=en: free transition,vendor directory,static methods,teardown,test cases,pear,dependencies,test case,replacements,phpunit,migration,simpletest,cakephp,discover channel
+ :keywords lang=en: free transition,vendor directory,static methods,teardown,test cases,pear,dependencies,test case,replacements,phpunit,migration,simpletest,cakephp,discover channel
View
2 en/cakephp-overview.rst
@@ -21,4 +21,4 @@ used in context.
.. meta::
:title lang=en: CakePHP Overview
- :keywords lang=en: web application framework,model view controller,object oriented programming,piece of cake,cookbook,functionality,xml,cakephp
+ :keywords lang=en: web application framework,model view controller,object oriented programming,piece of cake,cookbook,functionality,xml,cakephp
View
2 en/cakephp-overview/understanding-model-view-controller.rst
@@ -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
View
2 en/cakephp-overview/where-to-get-help.rst
@@ -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
View
30 en/console-and-shells.rst
@@ -137,7 +137,6 @@ we'll create a simple Hello world shell. In your applications
``Console/Command`` directory create ``HelloShell.php``. Put the following
code inside it::
- <?php
class HelloShell extends AppShell {
public function main() {
$this->out('Hello world.');
@@ -169,7 +168,6 @@ by creating ``app/Console/Command/AppShell.php``. If you don't have one, CakePH
built-in one. Since our main method wasn't very interesting lets add another command
that does something::
- <?php
class HelloShell extends AppShell {
public function main() {
$this->out('Hello world.');
@@ -201,7 +199,6 @@ array of models you want to have access to in your shell. The defined models
are loaded in as properties attached to your shell, just like a controller gets
models attached to it::
- <?php
class UserShell extends AppShell {
public $uses = array('User');
@@ -222,7 +219,6 @@ to compose functionality into re-usable classes that can be shared across many s
Tasks allow you to extract commands into classes. For example the ``bake`` is made
almost entirely of tasks. You define a shell's tasks by using the ``$tasks`` property::
- <?php
class UserShell extends AppShell {
public $tasks = array('Template');
}
@@ -235,7 +231,6 @@ their classes. So if we were to create a new 'FileGenerator' task, you would cre
Each task must at least implement an ``execute()`` method. The ShellDispatcher,
will call this method when the task is invoked. A task class looks like::
- <?php
class FileGeneratorTask extends Shell {
public $uses = array('User');
public function execute() {
@@ -246,7 +241,6 @@ will call this method when the task is invoked. A task class looks like::
A shell can also access it's tasks as properties, which makes tasks great for
making re-usable chunks of functionality similar to :doc:`/controllers/components`::
- <?php
// found in Console/Command/SeaShell.php
class SeaShell extends AppShell {
public $tasks = array('Sound'); // found in Console/Command/Task/SoundTask.php
@@ -273,12 +267,10 @@ Loading tasks on the fly with TaskCollection
You can load tasks on the fly using the Task collection object. You can load tasks that
were not declared in $tasks this way::
- <?php
$Project = $this->Tasks->load('Project');
Would load and return a ProjectTask instance. You can load tasks from plugins using::
- <?php
$ProgressBar = $this->Tasks->load('ProgressBar.ProgressBar');
.. _invoking-other-shells-from-your-shell:
@@ -292,7 +284,6 @@ There are still many cases where you will want to invoke one shell from another
`argv` for the sub shell. You can provide arguments and options either
as var args or as a string::
- <?php
// As a string
$this->dispatchShell('schema create Blog --plugin Blog');
@@ -321,7 +312,6 @@ they are interested in by setting the correct flag when calling the shell.
You can mark output as follows::
- <?php
// would appear at all levels.
$this->out('Quiet message', 1, Shell::QUIET);
@@ -353,7 +343,6 @@ are several built in styles, and you can create more. The built in ones are
You can create additional styles using `$this->stdout->styles()`. To declare a
new output style you could do::
- <?php
$this->stdout->styles('flashy', array('text' => 'magenta', 'blink' => true));
This would then allow you to use a ``<flashy>`` tag in your shell output, and if ansi
@@ -387,7 +376,6 @@ Turning off colouring
Although colouring is pretty awesome, there may be times when you want to turn it off,
or force it on::
- <?php
$this->output->outputAs(ConsoleOutput::RAW);
The above will put the output object into raw output mode. In raw output mode,
@@ -426,7 +414,6 @@ have different option parsers for subcommands and tasks.
The ConsoleOptionParser implements a fluent interface and includes
methods for easily setting multiple options/arguments at once.::
- <?php
public function getOptionParser() {
$parser = parent::getOptionParser();
//configure parser
@@ -439,7 +426,6 @@ Configuring an option parser with the fluent interface
All of the methods that configure an option parser can be chained,
allowing you to define an entire option parser in one series of method calls::
- <?php
function getOptionParser() {
$parser = parent::getOptionParser();
$parser->addArgument('type', array(
@@ -472,7 +458,6 @@ displays above the argument and option information. By passing in
either an array or a string, you can set the value of the description.
Calling with no arguments will return the current value::
- <?php
// Set multiple lines at once
$parser->description(array('line one', 'line two'));
@@ -486,7 +471,6 @@ is displayed after the argument and option information. By passing in
either an array or a string, you can set the value of the epilog.
Calling with no arguments will return the current value::
- <?php
// Set multiple lines at once
$parser->epilog(array('line one', 'line two'));
@@ -504,7 +488,6 @@ arguments as well as make them required. You can add arguments
one at a time with ``$parser->addArgument();`` or multiple at once
with ``$parser->addArguments();``::
- <?php
$parser->addArgument('model', array('help' => 'The model to bake'));
You can use the following options when creating an argument:
@@ -527,7 +510,6 @@ handle that in your shell.
If you have an array with multiple arguments you can use ``$parser->addArguments()``
to add multiple arguments at once.::
- <?php
$parser->addArguments(array(
'node' => array('help' => 'The node to create', 'required' => true),
'parent' => array('help' => 'The parent node', 'required' => true)
@@ -544,7 +526,6 @@ indicate that an argument must be present when a shell is called.
Additionally you can use ``choices`` to force an argument to
be from a list of valid choices::
- <?php
$parser->addArgument('type', array(
'help' => 'The type of node to interact with.',
'required' => true,
@@ -566,7 +547,6 @@ with both verbose and short aliases, supplying defaults
and creating boolean switches. Options are created with either
``$parser->addOption()`` or ``$parser->addOptions()``.::
- <?php
$parser->addOption('connection', array(
'short' => 'c',
'help' => 'connection',
@@ -579,7 +559,6 @@ when invoking the shell. You can also create boolean switches, these switches do
consume values, and their presence just enables them in the
parsed parameters.::
- <?php
$parser->addOption('no-commit', array('boolean' => true));
With this option, when calling a shell like ``cake myshell --no-commit something``
@@ -604,7 +583,6 @@ define the behavior of the option:
If you have an array with multiple options you can use ``$parser->addOptions()``
to add multiple options at once.::
- <?php
$parser->addOptions(array(
'node' => array('short' => 'n', 'help' => 'The node to create'),
'parent' => array('short' => 'p', 'help' => 'The parent node')
@@ -620,7 +598,6 @@ Options can be provided with a set of choices much like positional arguments
can be. When an option has defined choices, those are the only valid choices
for an option. All other values will raise an ``InvalidArgumentException``::
- <?php
$parser->addOption('accept', array(
'help' => 'What version to accept.',
'choices' => array('working', 'theirs', 'mine')
@@ -634,7 +611,6 @@ some flag options. Like options with defaults, boolean options always include
themselves into the parsed parameters. When the flags are present they are set
to true, when they are absent false::
- <?php
$parser->addOption('verbose', array(
'help' => 'Enable verbose output.',
'boolean' => true
@@ -644,7 +620,6 @@ The following option would result in ``$this->params['verbose']`` always
being available. This lets you omit ``empty()`` or ``isset()``
checks for boolean flags::
- <?php
if ($this->params['verbose']) {
// do something
}
@@ -664,7 +639,6 @@ have their own help and options. ``ConsoleOptionParser`` allows you to
define subcommands and provide command specific option parsers so the
shell knows how to parse commands for its tasks::
- <?php
$parser->addSubcommand('model', array(
'help' => 'Bake a model',
'parser' => $this->Model->getOptionParser()
@@ -701,7 +675,6 @@ As previously mentioned, when creating subcommand option parsers,
you can define the parser spec as an array for that method. This can help
make building subcommand parsers easier, as everything is an array::
- <?php
$parser->addSubcommand('check', array(
'help' => __('Check the permissions between an ACO and ARO.'),
'parser' => array(
@@ -725,7 +698,6 @@ arguments, and options, should follow the format that
:php:func:`ConsoleOptionParser::addArguments()` and :php:func:`ConsoleOptionParser::addOptions()`
use. You can also use buildFromArray on its own, to build an option parser::
- <?php
public function getOptionParser() {
return ConsoleOptionParser::buildFromArray(array(
'description' => array(
@@ -911,7 +883,6 @@ Shell API
It will return the users answer to the prompt, and allows you to provide a
list of valid options the user can choose from::
- <?php
$selection = $this->in('Red or Green?', array('R', 'G'), 'R');
The selection validation is case-insensitive.
@@ -951,7 +922,6 @@ Shell API
By formatting messages with style tags you can display styled output::
- <?php
$this->out('<warning>This will remove data from the filesystems.</warning>');
By default on \*nix systems ConsoleOutput objects default to colour output.
View
2 en/console-and-shells/acl-shell.rst
@@ -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
View
2 en/console-and-shells/code-generation-with-bake.rst
@@ -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
View
2 en/console-and-shells/schema-management-and-migrations.rst
@@ -57,7 +57,6 @@ table is being dropped or created and another for errors. Examples::
Adding data to a posts table for example would like this::
- <?php
App::uses('Post', 'Model');
public function after($event = array()) {
if (isset($event['create'])) {
@@ -82,7 +81,6 @@ When inserting data to more than one table you'll need to flush the database
cache after each table is created. Cache can be disable by setting
``$db->cacheSources = false`` in the before action(). ::
- <?php
public $connection = 'default';
public function before($event = array()) {
View
2 en/console-and-shells/testsuite-shell.rst
@@ -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
View
2 en/contributing.rst
@@ -16,4 +16,4 @@ cover the various ways you can contribute to CakePHP:
.. meta::
:title lang=en: Contributing
- :keywords lang=en: coding conventions,documentation,maxdepth
+ :keywords lang=en: coding conventions,documentation,maxdepth
View
18 en/contributing/cakephp-coding-conventions.rst
@@ -23,7 +23,6 @@ One tab will be used for indentation.
So, indentation should look like this::
- <?php
// base level
// level 1
// level 2
@@ -32,7 +31,6 @@ So, indentation should look like this::
Or::
- <?php
$booleanVariable = true;
$stringVariable = "moose";
if ($booleanVariable) {
@@ -48,7 +46,6 @@ Control Structures
Control structures are for example "``if``", "``for``", "``foreach``",
"``while``", "``switch``" etc. Below, an example with "``if``"::
- <?php
if ((expr_1) || (expr_2)) {
// action_1;
} elseif (!(expr_3) && (expr_4)) {
@@ -72,7 +69,6 @@ Control structures are for example "``if``", "``for``", "``foreach``",
::
- <?php
// wrong = no brackets, badly placed statement
if (expr) statement;
@@ -94,7 +90,6 @@ statements. Ternary operators should not ever be nested. Optionally
parentheses can be used around the condition check of the ternary for
clarity::
- <?php
//Good, simple and readable
$variable = isset($options['variable']) ? $options['variable'] : true;
@@ -108,7 +103,6 @@ Functions should be called without space between function's name and
starting bracket. There should be one space between every parameter of a
function call::
- <?php
$var = foo($bar, $bar2, $bar3);
As you can see above there should be one space on both sides of equals
@@ -119,7 +113,6 @@ Method definition
Example of a function definition::
- <?php
function someFunction($arg1, $arg2 = '') {
if (expr) {
statement;
@@ -132,7 +125,6 @@ definition. Try to make your functions return something, at least true
or false = so it can be determined whether the function call was
successful::
- <?php
function connection($dns, $persistent = false) {
if (is_array($dns)) {
$dnsInfo = $dns;
@@ -173,7 +165,6 @@ tags:
PhpDoc tags are very much like JavaDoc tags in Java. Tags are only
processed if they are the first thing in a DocBlock line, for example::
- <?php
/**
* Tag example.
* @author this tag is parsed, but this @version is ignored
@@ -182,7 +173,6 @@ processed if they are the first thing in a DocBlock line, for example::
::
- <?php
/**
* Example of inline phpDoc tags.
*
@@ -219,7 +209,6 @@ Functions
Write all functions in camelBack::
- <?php
function longFunctionName() {
}
@@ -228,7 +217,6 @@ Classes
Class names should be written in CamelCase, for example::
- <?php
class ExampleClass {
}
@@ -241,7 +229,6 @@ should be written in camelBack in case of multiple words. Variables
containing objects should start with a capital letter, and in some way
associate to the class the variable is an object of. Example::
- <?php
$user = 'John';
$users = array('John', 'Hans', 'Arne');
@@ -253,7 +240,6 @@ Member visibility
Use PHP5's private and protected keywords for methods and variables. Additionally,
protected method or variable names start with a single underscore ("\_"). Example::
- <?php
class A {
protected $_iAmAProtectedVariable;
@@ -264,7 +250,6 @@ protected method or variable names start with a single underscore ("\_"). Exampl
Private methods or variable names start with double underscore ("\_\_"). Example::
- <?php
class A {
private $__iAmAPrivateVariable;
@@ -279,7 +264,6 @@ Method Chaining
Method chaining should have multiple methods spread across separate lines, and
indented with one tab::
- <?php
$email->from('foo@example.com')
->to('bar@example.com')
->subject('A great message')
@@ -341,7 +325,6 @@ Constants should be defined in capital letters:
::
- <?php
define('CONSTANT', 1);
If a constant name consists of multiple words, they should be separated
@@ -349,7 +332,6 @@ by an underscore character, for example:
::
- <?php
define('LONG_NAMED_CONSTANT', 2);
View
2 en/contributing/tickets.rst
@@ -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
View
30 en/controllers.rst
@@ -40,7 +40,6 @@ AppController itself extends the Controller class included in the
CakePHP core library. As such, AppController is defined in
``/app/Controller/AppController.php`` like so::
- <?php
class AppController extends Controller {
}
@@ -74,7 +73,6 @@ var ``$helpers`` in your AppController
Please also remember to call AppController's callbacks within child
controller callbacks for best results::
- <?php
public function beforeFilter() {
parent::beforeFilter();
}
@@ -103,7 +101,6 @@ name. Returning to our online bakery example, our RecipesController might conta
``view()``, ``share()``, and ``search()`` actions. The controller would be found
in ``/app/Controller/RecipesController.php`` and contain::
- <?php
# /app/Controller/RecipesController.php
class RecipesController extends AppController {
@@ -144,7 +141,6 @@ you will often want to return data that isn't a string. If you have controller
methods that are used for normal web requests + requestAction you should check
the request type before returning::
- <?php
class RecipesController extends AppController {
public function popular() {
$popular = $this->Recipe->popular();
@@ -222,7 +218,6 @@ rendered from the controller.
controller to your view. Once you've used ``set()``, the variable
can be accessed in your view::
- <?php
// First you pass data from the controller:
$this->set('color', 'pink');
@@ -243,7 +238,6 @@ rendered from the controller.
::
- <?php
$data = array(
'color' => 'pink',
'type' => 'sugar',
@@ -259,7 +253,6 @@ rendered from the controller.
The attribute ``$pageTitle`` no longer exists, use ``set()`` to set
the title::
- <?php
$this->set('title_for_layout', 'This is the page title');
@@ -275,7 +268,6 @@ rendered from the controller.
If the ``search()`` action of the RecipesController is requested,
the view file in /app/View/Recipes/search.ctp will be rendered::
- <?php
class RecipesController extends AppController {
// ...
public function search() {
@@ -295,7 +287,6 @@ rendered from the controller.
direct rendering of elements, very useful in ajax calls.
::
- <?php
// Render the element in /View/Elements/ajaxreturn.ctp
$this->render('/Elements/ajaxreturn');
@@ -311,7 +302,6 @@ what would conventionally be done. You can do this by calling
``render()`` directly. Once you have called ``render()`` CakePHP
will not try to re-render the view::
- <?php
class PostsController extends AppController {
public function my_action() {
$this->render('custom_file');
@@ -331,7 +321,6 @@ Flow Control
CakePHP-relative URL. When a user has successfully placed an order,
you might wish to redirect them to a receipt screen.::
- <?php
public function place_order() {
// Logic for finalizing order goes here
if ($success) {
@@ -343,13 +332,11 @@ Flow Control
You can also use a relative or absolute URL as the $url argument::
- <?php
$this->redirect('/orders/thanks'));
$this->redirect('http://www.example.com');
You can also pass data to the action::
- <?php
$this->redirect(array('action' => 'edit', $id));
The second parameter of ``redirect()`` allows you to define an HTTP
@@ -362,14 +349,12 @@ Flow Control
If you need to redirect to the referer page you can use::
- <?php
$this->redirect($this->referer());
The method also supports name based parameters. If you want to redirect
to a URL like: ``http://www.example.com/orders/confirm/product:pizza/quantity:5``
you can use::
- <?php
$this->redirect(array('controller' => 'orders', 'action' => 'confirm', 'product' => 'pizza', 'quantity' => 5));
.. php:method:: flash(string $message, string $url, integer $pause, string $layout)
@@ -431,7 +416,6 @@ Other Useful Methods
HTTP\_REFERER cannot be read from headers. So, instead of doing
this::
- <?php
class UserController extends AppController {
public function delete($id) {
// delete code goes here, and then...
@@ -445,7 +429,6 @@ Other Useful Methods
you can do this::
- <?php
class UserController extends AppController {
public function delete($id) {
// delete code goes here, and then...
@@ -484,7 +467,6 @@ Other Useful Methods
to create a quick form based on the Order model. Then a controller action
can use the data posted from that form to craft find conditions::
- <?php
public function index() {
$conditions = $this->postConditions($this->request->data);
$orders = $this->Order->find('all', compact('conditions'));
@@ -499,7 +481,6 @@ Other Useful Methods
If you want to use a different SQL operator between terms, supply them
using the second parameter::
- <?php
/*
Contents of $this->request->data
array(
@@ -563,7 +544,6 @@ Other Useful Methods
layout. First we need to create a controller function that will
return the data::
- <?php
// Controller/CommentsController.php
class CommentsController extends AppController {
public function latest() {
@@ -581,7 +561,6 @@ Other Useful Methods
If we now create a simple element to call that function::
- <?php
// View/Elements/latest_comments.ctp
$comments = $this->requestAction('/comments/latest');
@@ -592,7 +571,6 @@ Other Useful Methods
We can then place that element anywhere to get the output
using::
- <?php
echo $this->element('latest_comments');
Written in this way, whenever the element is rendered, a request
@@ -601,7 +579,6 @@ Other Useful Methods
above it's best to make use of element caching to prevent needless
processing. By modifying the call to element to look like this::
- <?php
echo $this->element('latest_comments', array('cache' => '+1 hour'));
The ``requestAction`` call will not be made while the cached
@@ -609,7 +586,6 @@ Other Useful Methods
In addition, requestAction now takes array based cake style urls::
- <?php
echo $this->requestAction(
array('controller' => 'articles', 'action' => 'featured'),
array('return')
@@ -626,13 +602,11 @@ Other Useful Methods
array will also be made available in the requested action's
Controller::params array::
- <?php
echo $this->requestAction('/articles/featured/limit:3');
echo $this->requestAction('/articles/view/5');
As an array in the requestAction would then be::
- <?php
echo $this->requestAction(
array('controller' => 'articles', 'action' => 'featured'),
array('named' => array('limit' => 3))
@@ -661,7 +635,6 @@ Other Useful Methods
which is not the controller's default model or its associated
model::
- <?php
$this->loadModel('Article');
$recentArticles = $this->Article->find('all', array('limit' => 5, 'order' => 'Article.created DESC'));
@@ -683,7 +656,6 @@ visit the CakePHP API. Check out
primary model the controller uses. This property is not required,
but saves CakePHP from inflecting it::
- <?php
// $name controller attribute usage example
class RecipesController extends AppController {
public $name = 'Recipes';
@@ -738,7 +710,6 @@ given by ``$helpers`` to the view as an object reference variable
Let’s look at how to tell a CakePHP controller that you plan to use
additional MVC classes::
- <?php
class RecipesController extends AppController {
public $uses = array('Recipe', 'User');
public $helpers = array('Js');
@@ -776,7 +747,6 @@ own sections in the manual.
loads and configures the :php:class:`PaginatorComponent`. It is recommended
that you update your code to use normal component settings::
- <?php
class ArticlesController extends AppController {
public $components = array(
'Paginator' => array(
View
10 en/controllers/components.rst
@@ -37,7 +37,6 @@ components, and for components in general, is usually done in the
``$components`` array or your controller's ``beforeFilter()``
method::
- <?php
class PostsController extends AppController {
public $components = array(
'Auth' => array(
@@ -55,7 +54,6 @@ method. This is useful when you need to assign the results of a
function to a component property. The above could also be expressed
as::
- <?php
public function beforeFilter() {
$this->Auth->authorize = array('controller');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
@@ -68,7 +66,6 @@ configuration options to be set before the controller's
``beforeFilter()`` is run. To this end, some components allow
configuration options be set in the ``$components`` array::
- <?php
public $components = array(
'DebugKit.Toolbar' => array('panels' => array('history', 'session'))
);
@@ -81,7 +78,6 @@ alias components. This feature is useful when you want to
replace ``$this->Auth`` or another common Component reference with a custom
implementation::
- <?php
// app/Controller/PostsController.php
class PostsController extends AppController {
public $components = array(
@@ -114,7 +110,6 @@ controller. If you had loaded up the :php:class:`SessionComponent` and
the :php:class:`CookieComponent` in your controller, you could access
them like so::
- <?php
class PostsController extends AppController {
public $components = array('Session', 'Cookie');
@@ -139,7 +134,6 @@ In situations like this you can load a component at runtime using the
:doc:`Component Collection </core-libraries/collections>`. From inside a
controller you can do the following::
- <?php
$this->OneTimer = $this->Components->load('OneTimer');
$this->OneTimer->getTime();
@@ -163,7 +157,6 @@ The first step is to create a new component file and class. Create
the file in ``/app/Controller/Component/MathComponent.php``. The basic
structure for the component would look something like this::
- <?php
App::uses('Component', 'Controller');
class MathComponent extends Component {
public function doComplexOperation($amount1, $amount2) {
@@ -185,7 +178,6 @@ part) in the controller's ``$components`` array. The controller will
automatically be given a new attribute named after the component,
through which we can access an instance of it::
- <?php
/* Make the new component available at $this->Math,
as well as the standard $this->Session */
public $components = array('Math', 'Session');
@@ -199,7 +191,6 @@ set of parameters that will be passed on to the Component's
constructor. These parameters can then be handled by
the Component::
- <?php
public $components = array(
'Math' => array(
'precision' => 2,
@@ -222,7 +213,6 @@ Sometimes one of your components may need to use another component.
In this case you can include other components in your component the exact same
way you include them in controllers - using the ``$components`` var::
- <?php
// app/Controller/Component/CustomComponent.php
App::uses('Component', 'Controller');
class CustomComponent extends Component {
View
2 en/controllers/pages-controller.rst
@@ -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
View
35 en/controllers/request-response.rst
@@ -37,7 +37,6 @@ Accessing request parameters
CakeRequest exposes several interfaces for accessing request parameters. The first is as object
properties, the second is array indexes, and the third is through ``$this->request->params``::
- <?php
$this->request->controller;
$this->request['controller'];
$this->request->params['controller'];
@@ -50,7 +49,6 @@ In addition to :ref:`route-elements` you also often need access to
:ref:`passed-arguments` and :ref:`named-parameters`. These are both available
on the request object as well::
- <?php
// Passed arguments