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.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.2
      • 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 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 8:  *
 9:  * Licensed under The MIT License
10:  * Redistributions of files must retain the above copyright notice.
11:  *
12:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
13:  * @link          http://cakephp.org CakePHP(tm) Project
14:  * @since         CakePHP(tm) v 2.0
15:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
16:  */
17: 
18: App::uses('ObjectCollection', 'Utility');
19: 
20: /**
21:  * Collection object for Tasks.  Provides features
22:  * for lazily loading tasks, and firing callbacks on loaded tasks.
23:  *
24:  * @package       Cake.Console
25:  */
26: class TaskCollection extends ObjectCollection {
27: 
28: /**
29:  * Shell to use to set params to tasks.
30:  *
31:  * @var Shell
32:  */
33:     protected $_Shell;
34: 
35: /**
36:  * The directory inside each shell path that contains tasks.
37:  *
38:  * @var string
39:  */
40:     public $taskPathPrefix = 'tasks/';
41: 
42: /**
43:  * Constructor
44:  *
45:  * @param Shell $Shell
46:  */
47:     public function __construct(Shell $Shell) {
48:         $this->_Shell = $Shell;
49:     }
50: 
51: /**
52:  * Loads/constructs a task.  Will return the instance in the collection
53:  * if it already exists.
54:  *
55:  * @param string $task Task name to load
56:  * @param array $settings Settings for the task.
57:  * @return Task A task object, Either the existing loaded task or a new one.
58:  * @throws MissingTaskException when the task could not be found
59:  */
60:     public function load($task, $settings = array()) {
61:         list($plugin, $name) = pluginSplit($task, true);
62: 
63:         if (isset($this->_loaded[$name])) {
64:             return $this->_loaded[$name];
65:         }
66:         $taskClass = $name . 'Task';
67:         App::uses($taskClass, $plugin . 'Console/Command/Task');
68:         if (!class_exists($taskClass)) {
69:             if (!class_exists($taskClass)) {
70:                 throw new MissingTaskException(array(
71:                     'class' => $taskClass
72:                 ));
73:             }
74:         }
75: 
76:         $this->_loaded[$name] = new $taskClass(
77:             $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
78:         );
79:         return $this->_loaded[$name];
80:     }
81: 
82: }
83: 
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