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.7 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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

  • Arguments
  • Command
  • CommandCollection
  • CommandFactory
  • CommandRunner
  • ConsoleErrorHandler
  • ConsoleInput
  • ConsoleInputArgument
  • ConsoleInputOption
  • ConsoleInputSubcommand
  • ConsoleIo
  • ConsoleOptionParser
  • ConsoleOutput
  • Helper
  • HelperRegistry
  • HelpFormatter
  • Shell
  • ShellDispatcher
  • TaskRegistry

Interfaces

  • CommandCollectionAwareInterface
  • CommandFactoryInterface
  1: <?php
  2: /**
  3:  * ConsoleInputSubcommand file
  4:  *
  5:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  6:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  7:  *
  8:  * Licensed under The MIT License
  9:  * For full copyright and license information, please see the LICENSE.txt
 10:  * Redistributions of files must retain the above copyright notice.
 11:  *
 12:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 13:  * @link          https://cakephp.org CakePHP(tm) Project
 14:  * @since         2.0.0
 15:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 16:  */
 17: namespace Cake\Console;
 18: 
 19: use SimpleXMLElement;
 20: 
 21: /**
 22:  * An object to represent a single subcommand used in the command line.
 23:  * Created when you call ConsoleOptionParser::addSubcommand()
 24:  *
 25:  * @see \Cake\Console\ConsoleOptionParser::addSubcommand()
 26:  */
 27: class ConsoleInputSubcommand
 28: {
 29: 
 30:     /**
 31:      * Name of the subcommand
 32:      *
 33:      * @var string
 34:      */
 35:     protected $_name = '';
 36: 
 37:     /**
 38:      * Help string for the subcommand
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_help = '';
 43: 
 44:     /**
 45:      * The ConsoleOptionParser for this subcommand.
 46:      *
 47:      * @var \Cake\Console\ConsoleOptionParser
 48:      */
 49:     protected $_parser;
 50: 
 51:     /**
 52:      * Make a new Subcommand
 53:      *
 54:      * @param string|array $name The long name of the subcommand, or an array with all the properties.
 55:      * @param string $help The help text for this option.
 56:      * @param \Cake\Console\ConsoleOptionParser|array|null $parser A parser for this subcommand. Either a ConsoleOptionParser, or an
 57:      *   array that can be used with ConsoleOptionParser::buildFromArray().
 58:      */
 59:     public function __construct($name, $help = '', $parser = null)
 60:     {
 61:         if (is_array($name) && isset($name['name'])) {
 62:             foreach ($name as $key => $value) {
 63:                 $this->{'_' . $key} = $value;
 64:             }
 65:         } else {
 66:             $this->_name = $name;
 67:             $this->_help = $help;
 68:             $this->_parser = $parser;
 69:         }
 70:         if (is_array($this->_parser)) {
 71:             $this->_parser['command'] = $this->_name;
 72:             $this->_parser = ConsoleOptionParser::buildFromArray($this->_parser);
 73:         }
 74:     }
 75: 
 76:     /**
 77:      * Get the value of the name attribute.
 78:      *
 79:      * @return string Value of this->_name.
 80:      */
 81:     public function name()
 82:     {
 83:         return $this->_name;
 84:     }
 85: 
 86:     /**
 87:      * Get the raw help string for this command
 88:      *
 89:      * @return string
 90:      */
 91:     public function getRawHelp()
 92:     {
 93:         return $this->_help;
 94:     }
 95: 
 96:     /**
 97:      * Generate the help for this this subcommand.
 98:      *
 99:      * @param int $width The width to make the name of the subcommand.
100:      * @return string
101:      */
102:     public function help($width = 0)
103:     {
104:         $name = $this->_name;
105:         if (strlen($name) < $width) {
106:             $name = str_pad($name, $width, ' ');
107:         }
108: 
109:         return $name . $this->_help;
110:     }
111: 
112:     /**
113:      * Get the usage value for this option
114:      *
115:      * @return \Cake\Console\ConsoleOptionParser|bool Either false or a ConsoleOptionParser
116:      */
117:     public function parser()
118:     {
119:         if ($this->_parser instanceof ConsoleOptionParser) {
120:             return $this->_parser;
121:         }
122: 
123:         return false;
124:     }
125: 
126:     /**
127:      * Append this subcommand to the Parent element
128:      *
129:      * @param \SimpleXMLElement $parent The parent element.
130:      * @return \SimpleXMLElement The parent with this subcommand appended.
131:      */
132:     public function xml(SimpleXMLElement $parent)
133:     {
134:         $command = $parent->addChild('command');
135:         $command->addAttribute('name', $this->_name);
136:         $command->addAttribute('help', $this->_help);
137: 
138:         return $parent;
139:     }
140: }
141: 
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