CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • ChainMessagesLoader
  • Date
  • FrozenDate
  • FrozenTime
  • I18n
  • MessagesFileLoader
  • Number
  • PluralRules
  • Time
  • TranslatorRegistry

Traits

  • DateFormatTrait
 1: <?php
 2: /**
 3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
 4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 5:  *
 6:  * Licensed under The MIT License
 7:  * For full copyright and license information, please see the LICENSE.txt
 8:  * Redistributions of files must retain the above copyright notice.
 9:  *
10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11:  * @link          https://cakephp.org CakePHP(tm) Project
12:  * @since         3.0.0
13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
14:  */
15: namespace Cake\I18n;
16: 
17: use Aura\Intl\Package;
18: use RuntimeException;
19: 
20: /**
21:  * Wraps multiple message loaders calling them one after another until
22:  * one of them returns a non-empty package.
23:  */
24: class ChainMessagesLoader
25: {
26:     /**
27:      * The list of callables to execute one after another for loading messages
28:      *
29:      * @var callable[]
30:      */
31:     protected $_loaders = [];
32: 
33:     /**
34:      * Receives a list of callable functions or objects that will be executed
35:      * one after another until one of them returns a non-empty translations package
36:      *
37:      * @param callable[] $loaders List of callables to execute
38:      */
39:     public function __construct(array $loaders)
40:     {
41:         $this->_loaders = $loaders;
42:     }
43: 
44:     /**
45:      * Executes this object returning the translations package as configured in
46:      * the chain.
47:      *
48:      * @return \Aura\Intl\Package
49:      * @throws \RuntimeException if any of the loaders in the chain is not a valid callable
50:      */
51:     public function __invoke()
52:     {
53:         foreach ($this->_loaders as $k => $loader) {
54:             if (!is_callable($loader)) {
55:                 throw new RuntimeException(sprintf(
56:                     'Loader "%s" in the chain is not a valid callable',
57:                     $k
58:                 ));
59:             }
60: 
61:             $package = $loader();
62:             if (!$package) {
63:                 continue;
64:             }
65: 
66:             if (!($package instanceof Package)) {
67:                 throw new RuntimeException(sprintf(
68:                     'Loader "%s" in the chain did not return a valid Package object',
69:                     $k
70:                 ));
71:             }
72: 
73:             return $package;
74:         }
75: 
76:         return new Package();
77:     }
78: }
79: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs