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

  • 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:      * Name of the subcommand
 31:      *
 32:      * @var string
 33:      */
 34:     protected $_name = '';
 35: 
 36:     /**
 37:      * Help string for the subcommand
 38:      *
 39:      * @var string
 40:      */
 41:     protected $_help = '';
 42: 
 43:     /**
 44:      * The ConsoleOptionParser for this subcommand.
 45:      *
 46:      * @var \Cake\Console\ConsoleOptionParser
 47:      */
 48:     protected $_parser;
 49: 
 50:     /**
 51:      * Make a new Subcommand
 52:      *
 53:      * @param string|array $name The long name of the subcommand, or an array with all the properties.
 54:      * @param string $help The help text for this option.
 55:      * @param \Cake\Console\ConsoleOptionParser|array|null $parser A parser for this subcommand. Either a ConsoleOptionParser, or an
 56:      *   array that can be used with ConsoleOptionParser::buildFromArray().
 57:      */
 58:     public function __construct($name, $help = '', $parser = null)
 59:     {
 60:         if (is_array($name) && isset($name['name'])) {
 61:             foreach ($name as $key => $value) {
 62:                 $this->{'_' . $key} = $value;
 63:             }
 64:         } else {
 65:             $this->_name = $name;
 66:             $this->_help = $help;
 67:             $this->_parser = $parser;
 68:         }
 69:         if (is_array($this->_parser)) {
 70:             $this->_parser['command'] = $this->_name;
 71:             $this->_parser = ConsoleOptionParser::buildFromArray($this->_parser);
 72:         }
 73:     }
 74: 
 75:     /**
 76:      * Get the value of the name attribute.
 77:      *
 78:      * @return string Value of this->_name.
 79:      */
 80:     public function name()
 81:     {
 82:         return $this->_name;
 83:     }
 84: 
 85:     /**
 86:      * Get the raw help string for this command
 87:      *
 88:      * @return string
 89:      */
 90:     public function getRawHelp()
 91:     {
 92:         return $this->_help;
 93:     }
 94: 
 95:     /**
 96:      * Generate the help for this this subcommand.
 97:      *
 98:      * @param int $width The width to make the name of the subcommand.
 99:      * @return string
100:      */
101:     public function help($width = 0)
102:     {
103:         $name = $this->_name;
104:         if (strlen($name) < $width) {
105:             $name = str_pad($name, $width, ' ');
106:         }
107: 
108:         return $name . $this->_help;
109:     }
110: 
111:     /**
112:      * Get the usage value for this option
113:      *
114:      * @return \Cake\Console\ConsoleOptionParser|bool Either false or a ConsoleOptionParser
115:      */
116:     public function parser()
117:     {
118:         if ($this->_parser instanceof ConsoleOptionParser) {
119:             return $this->_parser;
120:         }
121: 
122:         return false;
123:     }
124: 
125:     /**
126:      * Append this subcommand to the Parent element
127:      *
128:      * @param \SimpleXMLElement $parent The parent element.
129:      * @return \SimpleXMLElement The parent with this subcommand appended.
130:      */
131:     public function xml(SimpleXMLElement $parent)
132:     {
133:         $command = $parent->addChild('command');
134:         $command->addAttribute('name', $this->_name);
135:         $command->addAttribute('help', $this->_help);
136: 
137:         return $parent;
138:     }
139: }
140: 
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