CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 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

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ConsoleErrorHandler
  • ConsoleInput
  • ConsoleInputArgument
  • ConsoleInputOption
  • ConsoleInputSubcommand
  • ConsoleOptionParser
  • ConsoleOutput
  • HelpFormatter
  • Shell
  • ShellDispatcher
  • TaskCollection
 1: <?php
 2: /**
 3:  * Task collection is used as a registry for loaded tasks and handles loading
 4:  * and constructing task class objects.
 5:  *
 6:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 7:  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 8:  *
 9:  * Licensed under The MIT License
10:  * For full copyright and license information, please see the LICENSE.txt
11:  * Redistributions of files must retain the above copyright notice.
12:  *
13:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
14:  * @link          http://cakephp.org CakePHP(tm) Project
15:  * @since         CakePHP(tm) v 2.0
16:  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17:  */
18: 
19: App::uses('ObjectCollection', 'Utility');
20: 
21: /**
22:  * Collection object for Tasks. Provides features
23:  * for lazily loading tasks, and firing callbacks on loaded tasks.
24:  *
25:  * @package       Cake.Console
26:  */
27: class TaskCollection extends ObjectCollection {
28: 
29: /**
30:  * Shell to use to set params to tasks.
31:  *
32:  * @var Shell
33:  */
34:     protected $_Shell;
35: 
36: /**
37:  * The directory inside each shell path that contains tasks.
38:  *
39:  * @var string
40:  */
41:     public $taskPathPrefix = 'tasks/';
42: 
43: /**
44:  * Constructor
45:  *
46:  * @param Shell $Shell
47:  */
48:     public function __construct(Shell $Shell) {
49:         $this->_Shell = $Shell;
50:     }
51: 
52: /**
53:  * Loads/constructs a task. Will return the instance in the collection
54:  * if it already exists.
55:  *
56:  * @param string $task Task name to load
57:  * @param array $settings Settings for the task.
58:  * @return Task A task object, Either the existing loaded task or a new one.
59:  * @throws MissingTaskException when the task could not be found
60:  */
61:     public function load($task, $settings = array()) {
62:         list($plugin, $name) = pluginSplit($task, true);
63: 
64:         if (isset($this->_loaded[$name])) {
65:             return $this->_loaded[$name];
66:         }
67: 
68:         $taskClass = $name . 'Task';
69:         App::uses($taskClass, $plugin . 'Console/Command/Task');
70: 
71:         $exists = class_exists($taskClass);
72:         if (!$exists) {
73:             throw new MissingTaskException(array(
74:                 'class' => $taskClass
75:             ));
76:         }
77: 
78:         $this->_loaded[$name] = new $taskClass(
79:             $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
80:         );
81:         return $this->_loaded[$name];
82:     }
83: 
84: }
85: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs