diff --git a/en/controllers.rst b/en/controllers.rst index e96ee0493d..3915b33aa9 100644 --- a/en/controllers.rst +++ b/en/controllers.rst @@ -244,8 +244,8 @@ If ``$view`` starts with '/', it is assumed to be a view or element file relative to the **templates** folder. This allows direct rendering of elements, very useful in AJAX calls:: - // Render the element in templates/Element/ajaxreturn.php - $this->render('/Element/ajaxreturn'); + // Render the element in templates/element/ajaxreturn.php + $this->render('/element/ajaxreturn'); The second parameter ``$layout`` of ``Controller::render()`` allows you to specify the layout with which the view is rendered. diff --git a/en/controllers/components.rst b/en/controllers/components.rst index 8e53c0d213..067bad7bde 100644 --- a/en/controllers/components.rst +++ b/en/controllers/components.rst @@ -37,39 +37,35 @@ Controller's ``initialize()`` method or via the ``$components`` array:: public function initialize(): void { parent::initialize(); - $this->loadComponent('Auth', [ - 'authorize' => 'Controller', - 'loginAction' => ['controller' => 'Users', 'action' => 'login'] + $this->loadComponent('RequestHandler', [ + 'viewClassMap' => ['json' => 'AppJsonView'], ]); $this->loadComponent('Security', ['blackholeCallback' => 'blackhole']); } } -You can configure components at runtime using the ``config()`` method. Often, +You can configure components at runtime using the ``setConfig()`` method. Often, this is done in your controller's ``beforeFilter()`` method. The above could also be expressed as:: public function beforeFilter(EventInterface $event) { - $this->Auth->config('authorize', ['controller']); - $this->Auth->config('loginAction', ['controller' => 'Users', 'action' => 'login']); - - $this->Cookie->config('name', 'CookieMonster'); + $this->RequestHandler->setConfig('viewClassMap', ['rss' => 'MyRssView']); } -Like helpers, components implement a ``config()`` method that is used to get and +Like helpers, components implement a ``getConfig()`` method that is used to get and set any configuration data for a component:: // Read config data. - $this->Auth->config('loginAction'); + $this->RequestHandler->getConfig('viewClassMap'); // Set config - $this->Csrf->config('cookieName', 'token'); + $this->Csrf->setConfig('cookieName', 'token'); As with helpers, components will automatically merge their ``$_defaultConfig`` property with constructor configuration to create the ``$_config`` property -which is accessible with ``config()``. +which is accessible with ``getConfig()`` and ``setConfig()``. Aliasing Components ------------------- diff --git a/en/controllers/components/authentication.rst b/en/controllers/components/authentication.rst index 4a6f0c5fef..2a97b93172 100644 --- a/en/controllers/components/authentication.rst +++ b/en/controllers/components/authentication.rst @@ -78,10 +78,10 @@ configuration information into each authentication object using an array:: // Simple setup - $this->Auth->config('authenticate', ['Form']); + $this->Auth->setConfig('authenticate', ['Form']); // Pass settings in - $this->Auth->config('authenticate', [ + $this->Auth->setConfig('authenticate', [ 'Basic' => ['userModel' => 'Members'], 'Form' => ['userModel' => 'Members'] ]); @@ -93,7 +93,7 @@ to every attached object. The ``all`` key is also exposed as ``AuthComponent::ALL``:: // Pass settings in using 'all' - $this->Auth->config('authenticate', [ + $this->Auth->setConfig('authenticate', [ AuthComponent::ALL => ['userModel' => 'Members'], 'Basic', 'Form' @@ -514,7 +514,7 @@ Using Custom Authentication Objects Once you've created your custom authentication objects, you can use them by including them in ``AuthComponent``'s authenticate array:: - $this->Auth->config('authenticate', [ + $this->Auth->setConfig('authenticate', [ 'Openid', // app authentication object. 'AuthBag.Openid', // plugin authentication object. ]); @@ -560,7 +560,7 @@ messages ``AuthComponent`` uses. In your controller's ``beforeFilter()``, or component settings you can use ``authError`` to customize the error used for when authorization fails:: - $this->Auth->config('authError', "Woopsie, you are not authorized to access this area."); + $this->Auth->setConfig('authError', "Woopsie, you are not authorized to access this area."); Sometimes, you want to display the authorization error only after the user has already logged-in. You can suppress this message by setting @@ -569,7 +569,7 @@ its value to boolean ``false``. In your controller's ``beforeFilter()`` or component settings:: if (!$this->Auth->user()) { - $this->Auth->config('authError', false); + $this->Auth->setConfig('authError', false); } .. _hashing-passwords: @@ -784,7 +784,7 @@ In some cases you may want to use ``$this->Auth->user()`` in the authentication checks should be done:: //Set up AuthComponent to authenticate in initialize() - $this->Auth->config('checkAuthIn', 'Controller.initialize'); + $this->Auth->setConfig('checkAuthIn', 'Controller.initialize'); Default value for ``checkAuthIn`` is ``'Controller.startup'`` - but by using ``'Controller.initialize'`` initial authentication is done before ``beforeFilter()`` @@ -833,10 +833,10 @@ configuration information into each authorization object, using an array:: // Basic setup - $this->Auth->config('authorize', ['Controller']); + $this->Auth->setConfig('authorize', ['Controller']); // Pass settings in - $this->Auth->config('authorize', [ + $this->Auth->setConfig('authorize', [ 'Actions' => ['actionPath' => 'controllers/'], 'Controller' ]); @@ -847,7 +847,7 @@ to set settings that are passed to every attached object. The ``all`` key is also exposed as ``AuthComponent::ALL``:: // Pass settings in using 'all' - $this->Auth->config('authorize', [ + $this->Auth->setConfig('authorize', [ AuthComponent::ALL => ['actionPath' => 'controllers/'], 'Actions', 'Controller' @@ -898,7 +898,7 @@ Using Custom Authorize Objects Once you've created your custom authorize object, you can use them by including them in your ``AuthComponent``'s authorize array:: - $this->Auth->config('authorize', [ + $this->Auth->setConfig('authorize', [ 'Ldap', // app authorize object. 'AuthBag.Combo', // plugin authorize object. ]); @@ -908,7 +908,7 @@ Using No Authorization If you'd like to not use any of the built-in authorization objects and want to handle things entirely outside of ``AuthComponent``, you can set -``$this->Auth->config('authorize', false);``. By default ``AuthComponent`` +``$this->Auth->setConfig('authorize', false);``. By default ``AuthComponent`` starts off with ``authorize`` set to ``false``. If you don't use an authorization scheme, make sure to check authorization yourself in your controller's ``beforeFilter()`` or with another component. @@ -1012,7 +1012,7 @@ Configuration options ===================== The following settings can all be defined either in your controller's -``initialize()`` method or using ``$this->Auth->config()`` in your ``beforeFilter()``: +``initialize()`` method or using ``$this->Auth->setConfig()`` in your ``beforeFilter()``: ajaxLogin The name of an optional view element to render when an AJAX request is made @@ -1070,12 +1070,12 @@ checkAuthIn if you want the check to be done before controller's ``beforeFilter()`` method is run. -You can get current configuration values by calling ``$this->Auth->config()``:: +You can get current configuration values by calling ``$this->Auth->getConfig()``:: only the configuration option:: - $this->Auth->config('loginAction'); + $this->Auth->getConfig('loginAction'); - $this->redirect($this->Auth->config('loginAction')); + $this->redirect($this->Auth->getConfig('loginAction')); This is useful if you want to redirect a user to the ``login`` route for example. Without a parameter, the full configuration will be returned. diff --git a/en/controllers/components/flash.rst b/en/controllers/components/flash.rst index 339ae74414..f886083dc6 100644 --- a/en/controllers/components/flash.rst +++ b/en/controllers/components/flash.rst @@ -17,14 +17,14 @@ Setting Flash Messages FlashComponent provides two ways to set flash messages: its ``__call()`` magic method and its ``set()`` method. To furnish your application with verbosity, FlashComponent's ``__call()`` magic method allows you use a method name that -maps to an element located under the **templates/Element/Flash** directory. +maps to an element located under the **templates/element/Flash** directory. By convention, camelcased methods will map to the lowercased and underscored element name:: - // Uses templates/Element/Flash/success.php + // Uses templates/element/Flash/success.php $this->Flash->success('This was successful'); - // Uses templates/Element/Flash/great_success.php + // Uses templates/element/Flash/great_success.php $this->Flash->greatSuccess('This was greatly successful'); Alternatively, to set a plain-text message without rendering an element, you can @@ -64,7 +64,7 @@ An example of using these options:: // In your View = $this->Flash->render('positive') ?> - +
@@ -77,7 +77,7 @@ set the ``plugin`` parameter. For example:: $this->Flash->warning('My message', ['plugin' => 'PluginName']); The code above will use the **warning.php** element under -**plugins/PluginName/templates/Element/Flash** for rendering the flash +**plugins/PluginName/templates/element/Flash** for rendering the flash message. .. note:: diff --git a/en/controllers/components/pagination.rst b/en/controllers/components/pagination.rst index 913e5c066c..ef64ab8006 100644 --- a/en/controllers/components/pagination.rst +++ b/en/controllers/components/pagination.rst @@ -232,7 +232,7 @@ additional details on how to use the table registry:: ]; // Register an additional table object to allow differentiating in pagination component - TableRegistry::config('UnpublishedArticles', [ + TableRegistry::getTableLocator()->setConfig('UnpublishedArticles', [ 'className' => 'App\Model\Table\ArticlesTable', 'table' => 'articles', 'entityClass' => 'App\Model\Entity\Article', diff --git a/en/controllers/components/request-handling.rst b/en/controllers/components/request-handling.rst index b27fbfa4da..b2dc483b51 100644 --- a/en/controllers/components/request-handling.rst +++ b/en/controllers/components/request-handling.rst @@ -167,7 +167,7 @@ callbacks like ``json_decode``:: $this->RequestHandler->addInputType('json', ['json_decode', true]); // After 3.1.0 you should use - $this->RequestHandler->config('inputTypeMap.json', ['json_decode', true]); + $this->RequestHandler->setConfig('inputTypeMap.json', ['json_decode', true]); The above will make ``$this->request->getData()`` an array of the JSON input data, without the additional ``true`` you'd get a set of ``stdClass`` objects. diff --git a/en/controllers/components/security.rst b/en/controllers/components/security.rst index fd226dae9c..df8a929dec 100644 --- a/en/controllers/components/security.rst +++ b/en/controllers/components/security.rst @@ -76,10 +76,6 @@ works:: // redirect to HTTPS version of the requested page. } -.. note:: - - use ``$this->Security->config()`` for CakePHP versions prior to 3.4 - The ``$type`` parameter can have the following values: * 'auth' Indicates a form validation error, or a controller/action mismatch @@ -114,8 +110,7 @@ allowedActions This can be used to control cross controller requests. These configuration options allow you to restrict cross controller -communication. Set them with the ``setConfig()`` method, or -``config()`` if you are using a CakePHP version below 3.4. +communication. Form Tampering Prevention ========================= @@ -149,8 +144,6 @@ validatePost Set to ``false`` to completely skip the validation of POST requests, essentially turning off form validation. -The above configuration options can be set with ``setConfig()`` or -``config()`` for CakePHP versions below 3.4. Usage ===== diff --git a/en/core-libraries/caching.rst b/en/core-libraries/caching.rst index 1bec153457..b74a753cdc 100644 --- a/en/core-libraries/caching.rst +++ b/en/core-libraries/caching.rst @@ -44,7 +44,7 @@ Regardless of the CacheEngine you choose to use, your application interacts with Configuring Cache Engines ========================= -.. php:staticmethod:: config($key, $config = null) +.. php:staticmethod:: setConfig($key, $config = null) Your application can configure any number of 'engines' during its bootstrap process. Cache engine configurations are defined in **config/app.php**. @@ -81,7 +81,7 @@ following:: Configuration options can also be provided as a :term:`DSN` string. This is useful when working with environment variables or :term:`PaaS` providers:: - Cache::config('short', [ + Cache::setConfig('short', [ 'url' => 'memcached://user:password@cache-host/?timeout=3600&prefix=myapp_', ]); @@ -91,7 +91,7 @@ query string arguments. You can also configure Cache engines at runtime:: // Using a short name - Cache::config('short', [ + Cache::setConfig('short', [ 'className' => 'File', 'duration' => '+1 hours', 'path' => CACHE, @@ -99,7 +99,7 @@ You can also configure Cache engines at runtime:: ]); // Using a fully namespaced name. - Cache::config('long', [ + Cache::setConfig('long', [ 'className' => 'Cake\Cache\Engine\FileEngine', 'duration' => '+1 week', 'probability' => 100, @@ -108,7 +108,7 @@ You can also configure Cache engines at runtime:: // Using a constructed object. $object = new FileEngine($config); - Cache::config('other', $object); + Cache::setConfig('other', $object); The name of these engine configurations ('short' and 'long') are used as the ``$config`` parameter for :php:meth:`Cake\\Cache\\Cache::write()` and @@ -116,16 +116,16 @@ parameter for :php:meth:`Cake\\Cache\\Cache::write()` and refer to the class name using the following syntaxes:: // Short name (in App\ or Cake namespaces) - Cache::config('long', ['className' => 'File']); + Cache::setConfig('long', ['className' => 'File']); // Plugin short name - Cache::config('long', ['className' => 'MyPlugin.SuperCache']); + Cache::setConfig('long', ['className' => 'MyPlugin.SuperCache']); // Full namespace - Cache::config('long', ['className' => 'Cake\Cache\Engine\FileEngine']); + Cache::setConfig('long', ['className' => 'Cake\Cache\Engine\FileEngine']); // An object implementing CacheEngineInterface - Cache::config('long', ['className' => $myCache]); + Cache::setConfig('long', ['className' => $myCache]); .. note:: @@ -199,7 +199,7 @@ cache failure. You can configure Cache configurations to fall back to a specified config using the ``fallback`` configuration key:: - Cache::config('redis', [ + Cache::setConfig('redis', [ 'className' => 'Redis', 'duration' => '+1 hours', 'prefix' => 'cake_redis_', @@ -216,7 +216,7 @@ from throwing an uncaught exception. You can turn off cache fallbacks with ``false``:: - Cache::config('redis', [ + Cache::setConfig('redis', [ 'className' => 'Redis', 'duration' => '+1 hours', 'prefix' => 'cake_redis_', @@ -234,7 +234,7 @@ Removing Configured Cache Engines Once a configuration is created you cannot change it. Instead you should drop the configuration and re-create it using :php:meth:`Cake\\Cache\\Cache::drop()` and -:php:meth:`Cake\\Cache\\Cache::config()`. Dropping a cache engine will remove +:php:meth:`Cake\\Cache\\Cache::setConfig()`. Dropping a cache engine will remove the config and destroy the adapter if it was constructed. Writing to a Cache @@ -462,7 +462,7 @@ group or namespace. This is a common requirement for mass-invalidating keys whenever some information changes that is shared among all entries in the same group. This is possible by declaring the groups in cache configuration:: - Cache::config('site_home', [ + Cache::setConfig('site_home', [ 'className' => 'Redis', 'duration' => '+999 days', 'groups' => ['comment', 'article'] @@ -548,7 +548,7 @@ Or in **plugins/MyPlugin/src/Cache/Engine/MyCustomCacheEngine.php** as part of a plugin. Cache configs from plugins need to use the plugin dot syntax:: - Cache::config('custom', [ + Cache::setConfig('custom', [ 'className' => 'MyPlugin.MyCustomCache', // ... ]); diff --git a/en/core-libraries/email.rst b/en/core-libraries/email.rst index 9aada4b43a..8f10c5c948 100644 --- a/en/core-libraries/email.rst +++ b/en/core-libraries/email.rst @@ -57,8 +57,8 @@ original sender using the Sender header. You can do so using ``setSender()``:: Configuration ============= -Configuration for ``Email`` defaults is created using ``config()`` and -``configTransport()``. You should put your email presets in the +Configuration for ``Email`` defaults is created using ``setConfig()`` and +``TransportFactory::setConfig()``. You should put your email presets in the **config/app.php** file. The **config/app.default.php** file is an example of this file. It is not required to define email configuration in **config/app.php**. ``Email`` can be used without it and use the respective @@ -381,7 +381,7 @@ transport). To start off your file should look like:: } You must implement the method ``send(Email $email)`` with your custom logic. -Optionally, you can implement the ``config($config)`` method. ``config()`` is +Optionally, you can implement the ``setConfig($config)`` method. ``setConfig()`` is called before send() and allows you to accept user configurations. By default, this method puts the configuration in protected attribute ``$_config``. @@ -416,7 +416,7 @@ want do setup a bunch of configuration ahead of time. :php:meth:`Cake\\Mailer\\Email::deliver()` is intended for that purpose. You can create your configuration using -:php:meth:`Cake\\Mailer\\Email::config()`, or use an array with all +:php:meth:`Cake\\Mailer\\Email::setConfig()`, or use an array with all options that you need and use the static method ``Email::deliver()``. Example:: diff --git a/en/core-libraries/logging.rst b/en/core-libraries/logging.rst index c689ff3851..b23e5c7dca 100644 --- a/en/core-libraries/logging.rst +++ b/en/core-libraries/logging.rst @@ -31,7 +31,7 @@ configured using :php:class:`Cake\\Log\\Log`. An example would be:: use Cake\Log\Log; // Short classname - Log::config('debug', [ + Log::setConfig('debug', [ 'className' => 'File', 'path' => LOGS, 'levels' => ['notice', 'info', 'debug'], @@ -39,7 +39,7 @@ configured using :php:class:`Cake\\Log\\Log`. An example would be:: ]); // Fully namespaced name. - Log::config('error', [ + Log::setConfig('error', [ 'className' => 'Cake\Log\Engine\FileLog', 'path' => LOGS, 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], @@ -54,20 +54,20 @@ information on the different levels and what they mean. Once a configuration is created you cannot change it. Instead you should drop the configuration and re-create it using :php:meth:`Cake\\Log\\Log::drop()` and -:php:meth:`Cake\\Log\\Log::config()`. +:php:meth:`Cake\\Log\\Log::setConfig()`. It is also possible to create loggers by providing a closure. This is useful when you need full control over how the logger object is built. The closure has to return the constructed logger instance. For example:: - Log::config('special', function () { + Log::setConfig('special', function () { return new \Cake\Log\Engine\FileLog(['path' => LOGS, 'file' => 'log']); }); Configuration options can also be provided as a :term:`DSN` string. This is useful when working with environment variables or :term:`PaaS` providers:: - Log::config('error', [ + Log::setConfig('error', [ 'url' => 'file:///?levels[]=warning&levels[]=error&file=error', ]); @@ -83,18 +83,18 @@ plugins. If for example you had a database logger called ``DatabaseLog``. As part of your application it would be placed in **src/Log/Engine/DatabaseLog.php**. As part of a plugin it would be placed in **plugins/LoggingPack/src/Log/Engine/DatabaseLog.php**. To configure log -adapters you should use :php:meth:`Cake\\Log\\Log::config()`. For example +adapters you should use :php:meth:`Cake\\Log\\Log::setConfig()`. For example configuring our DatabaseLog would look like:: // For src/Log - Log::config('otherFile', [ + Log::setConfig('otherFile', [ 'className' => 'Database', 'model' => 'LogEntry', // ... ]); // For plugin called LoggingPack - Log::config('otherFile', [ + Log::setConfig('otherFile', [ 'className' => 'LoggingPack.Database', 'model' => 'LogEntry', // ... @@ -189,7 +189,7 @@ You can configure additional/alternate FileLog locations when configuring a logger. FileLog accepts a ``path`` which allows for custom paths to be used:: - Log::config('custom_path', [ + Log::setConfig('custom_path', [ 'className' => 'File', 'path' => '/path/to/custom/place/' ]); @@ -213,7 +213,7 @@ to specify ``Syslog`` as the engine to be used for logging. The following configuration snippet will replace the default logger with syslog, this should be done in the **bootstrap.php** file:: - Log::config('default', [ + Log::setConfig('default', [ 'engine' => 'Syslog' ]); @@ -298,7 +298,7 @@ the log messages will be directed to those loggers. For example:: // Configure logs/shops.log to receive all levels, but only // those with `orders` and `payments` scope. - Log::config('shops', [ + Log::setConfig('shops', [ 'className' => 'File', 'path' => LOGS, 'levels' => [], @@ -308,7 +308,7 @@ the log messages will be directed to those loggers. For example:: // Configure logs/payments.log to receive all levels, but only // those with `payments` scope. - Log::config('payments', [ + Log::setConfig('payments', [ 'className' => 'File', 'path' => LOGS, 'levels' => [], @@ -339,7 +339,7 @@ Log API A simple class for writing to logs. -.. php:staticmethod:: config($key, $config) +.. php:staticmethod:: setConfig($key, $config) :param string $name: Name for the logger being connected, used to drop a logger later on. @@ -408,14 +408,14 @@ the CakePHP loggers, it is easy to use in your application as the default logger. After installing Monolog using composer, configure the logger using the -``Log::config()`` method:: +``Log::setConfig()`` method:: // config/bootstrap.php use Monolog\Logger; use Monolog\Handler\StreamHandler; - Log::config('default', function () { + Log::setConfig('default', function () { $log = new Logger('app'); $log->pushHandler(new StreamHandler('path/to/your/combined.log')); return $log; @@ -432,7 +432,7 @@ Use similar methods if you want to configure a different logger for your console use Monolog\Logger; use Monolog\Handler\StreamHandler; - Log::config('default', function () { + Log::setConfig('default', function () { $log = new Logger('cli'); $log->pushHandler(new StreamHandler('path/to/your/combined-cli.log')); return $log; diff --git a/en/core-libraries/number.rst b/en/core-libraries/number.rst index 3163acd5ff..446b7f4432 100644 --- a/en/core-libraries/number.rst +++ b/en/core-libraries/number.rst @@ -338,7 +338,7 @@ to various methods. Example:: - Number::config('en_IN', \NumberFormatter::CURRENCY, [ + Number::setConfig('en_IN', \NumberFormatter::CURRENCY, [ 'pattern' => '#,##,##0' ]); diff --git a/en/debug-kit.rst b/en/debug-kit.rst index aa142d1695..1ab72b544e 100644 --- a/en/debug-kit.rst +++ b/en/debug-kit.rst @@ -222,7 +222,7 @@ Each Panel is expected to have a view element that renders the content from the panel. The element name must be the underscored inflection of the class name. For example ``SessionPanel`` has an element named **session_panel.php**, and SqllogPanel has an element named **sqllog_panel.php**. These elements should be -located in the root of your **templates/Element** directory. +located in the root of your **templates/element** directory. Custom Titles and Elements -------------------------- diff --git a/en/development/configuration.rst b/en/development/configuration.rst index 7e65b8757d..19cdd0afd3 100644 --- a/en/development/configuration.rst +++ b/en/development/configuration.rst @@ -18,7 +18,7 @@ Configuration is generally stored in either PHP or INI files, and loaded during the application bootstrap. CakePHP comes with one configuration file by default, but if required you can add additional configuration files and load them in your application's bootstrap code. :php:class:`Cake\\Core\\Configure` is used -for global configuration, and classes like ``Cache`` provide ``config()`` +for global configuration, and classes like ``Cache`` provide ``setConfig()`` methods to make configuration simple and transparent. Loading Additional Configuration Files @@ -31,7 +31,7 @@ configuration into multiple files. After creating each of the files in your use Cake\Core\Configure; use Cake\Core\Configure\Engine\PhpConfig; - Configure::config('default', new PhpConfig()); + Configure::setConfig('default', new PhpConfig()); Configure::load('app', 'default', false); Configure::load('other_config', 'default'); @@ -398,7 +398,7 @@ exist, a :php:class:`RuntimeException` will be thrown:: Reading and writing configuration files ======================================= -.. php:staticmethod:: config($name, $engine) +.. php:staticmethod:: setConfig($name, $engine) CakePHP comes with two built-in configuration file engines. :php:class:`Cake\\Core\\Configure\\Engine\\PhpConfig` is able to read PHP config diff --git a/en/development/sessions.rst b/en/development/sessions.rst index f1a53f4a98..58174d6061 100644 --- a/en/development/sessions.rst +++ b/en/development/sessions.rst @@ -12,7 +12,7 @@ avoided in CakePHP, and instead usage of the Session classes is preferred. Session Configuration ===================== -Session configuration is generally defined in ``/config/app.php``. The available +Session configuration is generally defined in **/config/app.php**. The available options are: * ``Session.timeout`` - The number of *minutes* before CakePHP's session @@ -164,7 +164,7 @@ This configuration requires a database table, having this schema:: PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -You can find a copy of the schema for the sessions table in the `application skeleton