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

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.0
      • 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
        • Auth
    • Core
    • Error
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • 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-2011, 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-2011, 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:  * Shell to use to set params to tasks.
29:  *
30:  * @var Shell
31:  */
32:     protected $_Shell;
33: 
34: /**
35:  * The directory inside each shell path that contains tasks.
36:  *
37:  * @var string
38:  */
39:     public $taskPathPrefix = 'tasks/';
40: 
41: /**
42:  * Constructor
43:  *
44:  * @param Shell $Shell
45:  */
46:     public function __construct(Shell $Shell) {
47:         $this->_Shell = $Shell;
48:     }
49: 
50: /**
51:  * Loads/constructs a task.  Will return the instance in the collection
52:  * if it already exists.
53:  *
54:  * @param string $task Task name to load
55:  * @param array $settings Settings for the task.
56:  * @return Task A task object, Either the existing loaded task or a new one.
57:  * @throws MissingTaskException when the task could not be found
58:  */
59:     public function load($task, $settings = array()) {
60:         list($plugin, $name) = pluginSplit($task, true);
61: 
62:         if (isset($this->_loaded[$name])) {
63:             return $this->_loaded[$name];
64:         }
65:         $taskClass = $name . 'Task';
66:         App::uses($taskClass, $plugin . 'Console/Command/Task');
67:         if (!class_exists($taskClass)) {
68:             if (!class_exists($taskClass)) {
69:                 throw new MissingTaskException(array(
70:                     'class' => $taskClass
71:                 ));
72:             }
73:         }
74: 
75:         $this->_loaded[$name] = new $taskClass(
76:             $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
77:         );
78:         $enable = isset($settings['enabled']) ? $settings['enabled'] : true;
79:         if ($enable === true) {
80:             $this->_enabled[] = $name;
81:         }
82:         return $this->_loaded[$name];
83:     }
84: 
85: }
86: 
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