### PHP Configuration Example Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Example of a PHP script returning configuration data. This data can be loaded by CConfiguration. ```php 'My Application', 'defaultController'=>'index', ); ?> ``` -------------------------------- ### Example Module Configuration Array Source: https://www.yiiframework.com/doc/api/1.0/CModule This example shows how to define modules using an array. It includes a simple module ID and a module with specific configuration parameters. ```php array( 'admin', 'payment'=>array( 'server'=>'paymentserver.com', ), ) ``` -------------------------------- ### CTabView Configuration Example Source: https://www.yiiframework.com/doc/api/1.0/CTabView An example demonstrating how to configure the 'tabs' property for the CTabView widget. ```APIDOC ## CTabView Configuration Example ### Description Example of configuring the `tabs` property for the CTabView widget. ### Tabs Property Configuration The `tabs` property takes an array where keys are tab IDs and values are tab definitions. Each tab definition is an array that can include: - `title`: The title of the tab. - `content`: The content to be displayed in the tab. Takes precedence over `view` if both are specified. - `view`: The name of the view to be rendered. Uses `CController::renderPartial`. - `url`: A URL to redirect to when the tab is clicked. ### Example ```php array( 'tab1'=>array( 'title'=>'tab 1 title', 'view'=>'view1', ), 'tab2'=>array( 'title'=>'tab 2 title', 'url'=>'https://www.yiiframework.com/', ), ) ``` ``` -------------------------------- ### ControllerMap Configuration Example Source: https://www.yiiframework.com/doc/api/1.0/CWebApplication Example of configuring the controllerMap property to map controller IDs to controller configurations, allowing for custom controller classes and properties. ```php array( 'post'=>array( 'class'=>'path.to.PostController', 'pageTitle'=>'something new', ), 'user'=>'path.to.UserController', ) ``` -------------------------------- ### Protected Methods Source: https://www.yiiframework.com/doc/api/1.0/CWebApplication Internal methods for application initialization and setup. ```APIDOC ## Protected Methods ### Description Internal methods for application initialization and setup. ### Methods - **init()** - Initializes the application. - Defined By: CWebApplication - **initSystemHandlers()** - Initializes the class autoloader and error handlers. - Defined By: CApplication - **loadGlobalState()** - Loads the global state data from persistent storage. - Defined By: CApplication - **parseActionParams(string $route)** - Parses a path info into an action ID and GET variables. - Parameters: - **route** (string) - Required - The route to parse. - Returns: array - Defined By: CWebApplication - **preinit()** - Preinitializes the module. - Defined By: CModule - **preloadComponents()** - Loads static application components. - Defined By: CModule - **registerCoreComponents()** - Registers the core application components. - Defined By: CWebApplication - **saveGlobalState()** - Saves the global state data into persistent storage. - Defined By: CApplication ``` -------------------------------- ### CatchAllRequest Configuration Example Source: https://www.yiiframework.com/doc/api/1.0/CWebApplication Example of configuring the catchAllRequest property to specify a controller for handling all user requests, often used for maintenance mode. ```php array( 'offline/notice', 'param1'=>'value1', 'param2'=>'value2', ) ``` -------------------------------- ### Start Session with Custom Storage Handlers Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Starts the session and sets custom session save handlers if custom storage is enabled. This method should not be called directly. ```php public function open() { if($this->getUseCustomStorage()) @session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession')); @session_start(); } ``` -------------------------------- ### Example Configuration File Structure Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Illustrates the expected format for a PHP configuration file, which should return an array of configuration parameters. ```php return array ( 'name'=>'My Application', 'defaultController'=>'index', ); ``` -------------------------------- ### Get URL Format Source: https://www.yiiframework.com/doc/api/1.0/CUrlManager Returns the current URL format setting, which can be 'path' or 'get'. This determines how URLs are constructed and parsed by the application. Refer to the guide for detailed differences. ```php public function getUrlFormat() { return $this->_urlFormat; } ``` -------------------------------- ### Get Module Configurations - CModule getModules() Source: https://www.yiiframework.com/doc/api/1.0/CModule Returns an array containing the configurations of all currently installed modules, indexed by their module IDs. ```php public function getModules() { return $this->_moduleConfig; } ``` -------------------------------- ### CHttpSession - init() Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Initializes the application component. ```APIDOC ## POST /websites/yiiframework_doc_api_1_0/CHttpSession/init ### Description Initializes the application component. This method is required by IApplicationComponent and is invoked by application. ### Method POST ### Endpoint /websites/yiiframework_doc_api_1_0/CHttpSession/init ### Parameters None ### Request Example None ### Response #### Success Response (200) - **status** (string) - Indicates successful initialization. #### Response Example ```json { "status": "initialized" } ``` ``` -------------------------------- ### Get Page Title - CController Source: https://www.yiiframework.com/doc/api/1.0/CController Retrieves the page title. Defaults to the controller name and action name if not explicitly set. Requires no specific setup. ```php public function getPageTitle() { if($this->_pageTitle!==null) return $this->_pageTitle; else { $name=ucfirst(basename($this->getId())); if($this->getAction()!==null && strcasecmp($this->getAction()->getId(),$this->defaultAction)) return $this->_pageTitle=Yii::app()->name.' - '.ucfirst($this->getAction()->getId()).' '.$name; else return $this->_pageTitle=Yii::app()->name.' - '.$name; } } ``` -------------------------------- ### Get GC Probability - PHP Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Retrieves the probability (as a percentage) that the garbage collection process will start during session initialization. This value is read from the 'session.gc_probability' PHP ini setting. ```php public function getGCProbability() { return (int)ini_get('session.gc_probability'); } ``` -------------------------------- ### init() Source: https://www.yiiframework.com/doc/api/1.0/CConsoleApplication Initializes the console application by setting up the command runner and processing initial configurations. ```APIDOC ## init() ### Description Initializes the application by creating the command runner and setting up command routes. ### Method protected ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response (200) Void. Initializes the application state. #### Response Example None ``` -------------------------------- ### Get GET or POST Parameter - CHttpRequest Source: https://www.yiiframework.com/doc/api/1.0/CHttpRequest Retrieves a parameter value from either the GET or POST request data. GET parameters take precedence. A default value is returned if the parameter is not found. ```php public function getParam($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue); } ``` -------------------------------- ### CGoogleApi::init() Source: https://www.yiiframework.com/doc/api/1.0/CGoogleApi Initializes the Google API by rendering the jsapi script file. It can optionally include an API key. ```APIDOC ## CGoogleApi::init() ### Description Initializes the Google API by rendering the jsapi script file. It can optionally include an API key. ### Method `public static string init(string $apiKey=NULL)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **string** - The script tag that loads Google jsapi. #### Response Example ```html ``` ```html ``` ``` -------------------------------- ### Get GET Parameter Value - PHP Source: https://www.yiiframework.com/doc/api/1.0/CHttpRequest Retrieves the value of a named GET parameter. Returns a default value if the parameter is not set. ```php public function getQuery($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : $defaultValue; } ``` -------------------------------- ### Get Request Type - CHttpRequest::getRequestType Source: https://www.yiiframework.com/doc/api/1.0/CHttpRequest Determines the request method (e.g., GET, POST). Defaults to 'GET' if not specified in the server environment. ```php public function getRequestType() { return strtoupper(isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'GET'); } ``` -------------------------------- ### Constructor: __construct() Source: https://www.yiiframework.com/doc/api/1.0/CApplication Initializes the application with a given configuration. The configuration can be a file path or an array of settings. It ensures the basePath is set and registers core components. ```APIDOC ## Constructor __construct() ### Description Initializes the application with a given configuration. The configuration can be a file path or an array of settings. It ensures the basePath is set and registers core components. ### Method public void __construct(mixed $config=NULL) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### public void init() Source: https://www.yiiframework.com/doc/api/1.0/CCache Initializes the application component. This method overrides the parent implementation by setting default cache key prefix. ```APIDOC ## init() ### Description Initializes the application component. This method overrides the parent implementation by setting default cache key prefix. ### Method public ### Source Code framework/caching/CCache.php#59 ``` -------------------------------- ### getParam() - Retrieve GET or POST Parameter Source: https://www.yiiframework.com/doc/api/1.0/CHttpRequest Retrieves the value of a named GET or POST parameter. If the parameter does not exist, a default value is returned. GET parameters take precedence over POST parameters. ```APIDOC ## GET /request/param ### Description Returns the named GET or POST parameter value. If the GET or POST parameter does not exist, the second parameter to this method will be returned. If both GET and POST contains such a named parameter, the GET parameter takes precedence. ### Method GET ### Endpoint /request/param ### Query Parameters - **name** (string) - Required - The name of the GET or POST parameter. - **defaultValue** (mixed) - Optional - The default parameter value if the GET or POST parameter does not exist. ### Response #### Success Response (200) - **paramValue** (mixed) - The value of the requested parameter. #### Response Example ```json { "paramValue": "some_value" } ``` ``` -------------------------------- ### Get Cookie Mode Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Gets the current cookie mode for session ID storage. ```APIDOC ## GET /session/cookieMode ### Description Gets how to use cookie to store session ID. ### Method GET ### Endpoint /session/cookieMode ### Response #### Success Response (200) - **mode** (string) - The cookie mode ('none', 'allow', or 'only'). Defaults to 'Allow'. #### Response Example ```json { "mode": "allow" } ``` ``` -------------------------------- ### init() Method Details Source: https://www.yiiframework.com/doc/api/1.0/CApplicationComponent Detailed information about the init() method. ```APIDOC ## POST /init ### Description Initializes the application component. This method is required by IApplicationComponent and is invoked by application. If you override this method, make sure to call the parent implementation so that the application component can be marked as initialized. ### Method POST ### Endpoint /init ### Request Example ```json { "example": "No request body needed for this method." } ``` ### Response #### Success Response (200) - **return** (void) - This method does not return a value. ### Response Example ```json { "example": "No response body for void return type." } ``` ``` -------------------------------- ### init() - Initializes the widget Source: https://www.yiiframework.com/doc/api/1.0/COutputProcessor Initializes the widget by starting output buffering. ```APIDOC ## init() ### Description Initializes the widget. This method starts the output buffering. ### Method public void ### Endpoint N/A (Class method) ### Parameters None ### Request Example None ### Response None ### Source Code ```php public function init() { ob_start(); ob_implicit_flush(false); } ``` ``` -------------------------------- ### CMemCache Configuration Example Source: https://www.yiiframework.com/doc/api/1.0/CMemCache Example of how to configure CMemCache as a cache application component in Yii. ```APIDOC ## CMemCache Configuration Example ### Description This snippet shows how to configure CMemCache as an application component, specifying a list of memcache servers. ### Method Configuration (within `config/main.php` or similar) ### Endpoint N/A ### Parameters N/A ### Request Example ```php array( 'components'=>array( 'cache'=>array( 'class'=>'CMemCache', 'servers'=>array( array( 'host'=>'server1', 'port'=>11211, 'weight'=>60, ), array( 'host'=>'server2', 'port'=>11211, 'weight'=>40, ), ), ), ), ) ``` ### Response N/A (This is a configuration example) ``` -------------------------------- ### Creating a Clip Source: https://www.yiiframework.com/doc/api/1.0/CBaseController Illustrates how to define and capture a 'clip' of output that can be reused elsewhere. Use beginClip and endClip to mark the content to be captured. ```php $this->beginClip('clipID'); // ... display the clip contents $this->endClip(); ``` -------------------------------- ### getUrlFormat() - Gets the URL format Source: https://www.yiiframework.com/doc/api/1.0/CUrlManager Returns the current URL format, which can be either 'path' or 'get'. ```APIDOC ## GET /status ### Description Retrieves the current status of the application. ### Method GET ### Endpoint /status ### Response #### Success Response (200) - **status** (string) - The current status of the application (e.g., 'operational', 'degraded'). #### Response Example ```json { "status": "operational" } ``` ``` -------------------------------- ### createWidget() - Widget Instantiation Source: https://www.yiiframework.com/doc/api/1.0/CBaseController Creates a widget and initializes it. This method first creates the specified widget instance, configures its properties, and then calls CWidget::init. ```APIDOC ## createWidget() ### Description Creates a widget and initializes it. This method first creates the specified widget instance. It then configures the widget's properties with the given initial values. At the end it calls CWidget::init to initialize the widget. ### Method `public CWidget createWidget(string $className, array $properties = array())` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **CWidget** - the fully initialized widget instance. ``` -------------------------------- ### getUrlFormat() - Method Details Source: https://www.yiiframework.com/doc/api/1.0/CUrlManager Gets the URL format used by the application. Valid values are 'path' and 'get'. ```APIDOC ## GET /api/urlmanager/getUrlFormat ### Description Gets the URL format used by the application. Valid values are 'path' and 'get'. ### Method GET ### Endpoint /api/urlmanager/getUrlFormat ### Response #### Success Response (200) - **urlFormat** (string) - The URL format ('path' or 'get'). ### Response Example ```json { "urlFormat": "path" } ``` ``` -------------------------------- ### Constructor: __construct() Source: https://www.yiiframework.com/doc/api/1.0/CModule Initializes the module with an ID, parent module, and configuration. It sets up the base path and preloads components. ```APIDOC ## CONSTRUCT __construct() ### Description Initializes the module with an ID, parent module, and configuration. It sets up the base path and preloads components. ### Method `public void __construct(string $id, CModule $parent, mixed $config=NULL)` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of this module. - **parent** (CModule) - Required - The parent module (if any). - **config** (mixed) - Optional - The module configuration. It can be either an array or the path of a PHP file returning the configuration array. ### Source Code `framework/base/CModule.php#52` ``` -------------------------------- ### Initialize CConfiguration with Data or File Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Constructs a CConfiguration object. Accepts either a configuration file path (string) or an array of configuration data. ```php public function __construct($data=null) { if(is_string($data)) parent::__construct(require($data)); else parent::__construct($data); } ``` -------------------------------- ### Valid Callback Examples in Yii Source: https://www.yiiframework.com/doc/api/1.0/CComponent Provides examples of valid PHP callbacks that can be used to attach event handlers to Yii components. ```php 'handleOnClick' // handleOnClick() is a global function array($object,'handleOnClick') // using $object->handleOnClick() array('Page','handleOnClick') // using Page::handleOnClick() ``` -------------------------------- ### init() Source: https://www.yiiframework.com/doc/api/1.0/CWebUser Initializes the application component, including session setup and cookie-based authentication. ```APIDOC ## init() ### Description Initializes the application component. This method overrides the parent implementation by starting session, performing cookie-based authentication if enabled, and updating the flash variables. ### Method POST ### Endpoint /websites/yiiframework_doc_api_1_0/CWebUser/init ### Parameters None ### Response #### Success Response (200) - **void** - This method does not return a value. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### init() Method Source: https://www.yiiframework.com/doc/api/1.0/CAutoComplete Initializes the CAutoComplete widget, registering client scripts and rendering the input. ```APIDOC ## init() Method ### Description Initializes the widget. This method registers all needed client scripts and renders the autocomplete input. ### Method `public void init()` ### Source Code ```php framework/web/widgets/CAutoComplete.php#199 ``` ``` -------------------------------- ### Get Sort Directions Source: https://www.yiiframework.com/doc/api/1.0/CSort Retrieves the current sort directions from the GET request or a cached value. It parses the sort parameters and validates attributes. ```php public function getDirections() { if($this->_directions===null) { $this->_directions=array(); if(isset($_GET[$this->sortVar])) { $attributes=explode($this->separators[0],$_GET[$this->sortVar]); foreach($attributes as $attribute) { if(($pos=strpos($attribute,$this->separators[1]))!==false) { $descending=substr($attribute,$pos+1)==='desc'; $attribute=substr($attribute,0,$pos); } else $descending=false; if(($attribute=$this->validateAttribute($attribute))!==false) $this->_directions[$attribute]=$descending; } if(!$this->multiSort) { foreach($this->_directions as $attribute=>$descending) return $this->_directions=array($attribute=>$descending); } } } return $this->_directions; } ``` -------------------------------- ### Method Details: init() Source: https://www.yiiframework.com/doc/api/1.0/CPhpMessageSource Details for the init() method, including its purpose and source code. ```APIDOC ## Method Details: init() Initializes the application component. This method overrides the parent implementation by preprocessing the user request data. ### Method public ### Returns - **void** ### Source Code ```php public function init() { parent::init(); if($this->basePath===null) $this->basePath=Yii::getPathOfAlias('application.messages'); } ``` ``` -------------------------------- ### Get Verification Code - CCaptchaAction Source: https://www.yiiframework.com/doc/api/1.0/CCaptchaAction Gets the verification code from the session. If the code is not set or regeneration is requested, it generates a new code and stores it in the session. ```php public function getVerifyCode($regenerate=false) { $session=Yii::app()->session; $session->open(); $name=$this->getSessionKey(); if($session[$name]===null || $regenerate) { $session[$name]=$this->generateVerifyCode(); $session[$name.'count']=1; } return $session[$name]; } ``` -------------------------------- ### Loading Configuration with CConfiguration Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Demonstrates how to load configuration data from a PHP file using the CConfiguration class. Ensure the path to the configuration file is correct. ```php $config=new CConfiguration('path/to/config.php'); ``` -------------------------------- ### Get Multiple Values from Cache - CMemCache::getValues Source: https://www.yiiframework.com/doc/api/1.0/CMemCache Retrieves multiple values from cache based on a list of keys. Uses getMulti for Memcached and get for Memcache. ```php protected function getValues($keys) { return $this->useMemcached ? $this->_cache->getMulti($keys) : $this->_cache->get($keys); } ``` -------------------------------- ### Configure Actions with Properties Source: https://www.yiiframework.com/doc/api/1.0/CController Example of configuring external actions with specific properties. Action IDs are keys, and values are class paths or configuration arrays. ```php return array( 'action1'=>'path.to.Action1Class', 'action2'=>array( 'class'=>'path.to.Action2Class', 'property1'=>'value1', 'property2'=>'value2', ), ); ``` -------------------------------- ### YiiBase::createConsoleApplication() Source: https://www.yiiframework.com/doc/api/1.0/YiiBase Creates a console application instance. ```APIDOC ## POST /application/create/console ### Description Creates a console application instance. ### Method POST ### Endpoint /application/create/console ### Parameters #### Request Body - **config** (array) - Optional - The configuration array for the console application. ### Request Example ```json { "config": { "basePath": "/path/to/app" } } ``` ### Response #### Success Response (200) - **CConsoleApplication** - The created console application instance. #### Response Example ```json { "application": "..." } ``` ``` -------------------------------- ### Example Named Scope Declarations Source: https://www.yiiframework.com/doc/api/1.0/CActiveRecord Example of how to declare named scopes for a model. Scopes are defined as an array where keys are scope names and values are CDbCriteria properties. ```php return array( 'published'=>array( 'condition'=>'status=1', ), 'recently'=>array( 'order'=>'createTime DESC', 'limit'=>5, ), ); ``` -------------------------------- ### Method: getOptions() Source: https://www.yiiframework.com/doc/api/1.0/CWebService Retrieves options for creating a SoapServer instance. ```APIDOC ## Method: getOptions() ### Description Retrieves options for creating a SoapServer instance based on the CWebService configuration. ### Method `getOptions` ### Endpoint N/A (This is a protected method of the CWebService class). ### Parameters None ### Request Example ```php // This is a protected method and typically not called directly from outside the class. // Example of internal usage: // $options = $this->getOptions(); ``` ### Response #### Success Response (200) - **return** (array) - An array of options for creating a SoapServer instance. #### Response Example ```json { "options": { "soap_version": 1, // or 2 for SOAP_1_2 "actor": null, "encoding": "UTF-8", "classmap": { "MyType": "MyClass" } } } ``` ### Source Code ```php protected function getOptions() { $options = array(); if ($this->soapVersion === '1.1') $options['soap_version'] = SOAP_1_1; else if ($this->soapVersion === '1.2') $options['soap_version'] = SOAP_1_2; if ($this->actor !== null) $options['actor'] = $this->actor; $options['encoding'] = $this->encoding; foreach ($this->classMap as $type => $className) { $className = Yii::import($className, true); if (is_int($type)) $type = $className; $options['classmap'][$type] = $className; } return $options; } ``` ``` -------------------------------- ### init() Method Source: https://www.yiiframework.com/doc/api/1.0/CLogRouter Initializes this application component. This method is required by the IApplicationComponent interface. ```APIDOC ## init() Method ### Description Initializes this application component. This method is required by the IApplicationComponent interface. ### Method public ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Check if Session is Started - PHP Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Determines if the session has been started by checking if a session ID exists. Returns true if a session ID is present, false otherwise. ```php public function getIsStarted() { return session_id()!==''; } ``` -------------------------------- ### Initialization Source: https://www.yiiframework.com/doc/api/1.0/CWebApplication Handles the initialization process for the application. ```APIDOC ## POST /init ### Description Initializes the application. Preloads the 'request' component to ensure it has a chance to respond to the onBeginRequest event. ### Method POST ### Endpoint /init ### Parameters None ### Request Body None ### Response #### Success Response (200) - **void** - No specific return value, indicates successful initialization. #### Response Example ```json { "example": "Initialization successful" } ``` ``` -------------------------------- ### Declaring Related Objects Example Source: https://www.yiiframework.com/doc/api/1.0/CActiveRecord Example of how to declare related objects for a 'Post' active record class, including BELONGS_TO, HAS_MANY, and MANY_MANY relations with additional options. ```php return array( 'author'=>array(self::BELONGS_TO, 'User', 'authorID'), 'comments'=>array(self::HAS_MANY, 'Comment', 'postID', 'with'=>'author', 'order'=>'createTime DESC'), 'tags'=>array(self::MANY_MANY, 'Tag', 'PostTag(postID, tagID)', 'order'=>'name'), ); ``` -------------------------------- ### YiiBase::createWebApplication() Source: https://www.yiiframework.com/doc/api/1.0/YiiBase Creates a web application instance. ```APIDOC ## POST /application/create/web ### Description Creates a web application instance. ### Method POST ### Endpoint /application/create/web ### Parameters #### Request Body - **config** (array) - Optional - The configuration array for the web application. ### Request Example ```json { "config": { "basePath": "/path/to/app" } } ``` ### Response #### Success Response (200) - **CWebApplication** - The created web application instance. #### Response Example ```json { "application": "..." } ``` ``` -------------------------------- ### parseUrl(CHttpRequest $request) - Parses the user request Source: https://www.yiiframework.com/doc/api/1.0/CUrlManager Parses the user's request to determine the route and any associated GET parameters, supporting both 'path' and 'get' URL formats. ```APIDOC ## PUT /users/{userId} ### Description Updates an existing user's information. ### Method PUT ### Endpoint /users/{userId} ### Parameters #### Path Parameters - **userId** (integer) - Required - The ID of the user to update. #### Request Body - **email** (string) - Optional - The updated email address for the user. - **status** (string) - Optional - The updated status of the user (e.g., 'active', 'inactive'). ### Request Example ```json { "email": "johndoe.updated@example.com", "status": "active" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the user was updated successfully. #### Response Example ```json { "message": "User updated successfully." } ``` ``` -------------------------------- ### Application Component Initialization Source: https://www.yiiframework.com/doc/api/1.0/IApplicationComponent The `init()` method is called after the application component has been configured. It's used for any setup logic required by the component. ```APIDOC ## POST /init ### Description Initializes the application component. This method is invoked after the application completes configuration. ### Method POST ### Endpoint /init ### Request Body This method does not accept a request body. ### Response #### Success Response (200) - **void** - Indicates successful initialization. #### Response Example (No response body for void methods) ``` -------------------------------- ### Get Current Page Number Source: https://www.yiiframework.com/doc/api/1.0/CPagination Retrieves the current page number, optionally recalculating it based on page size and item count. It reads the page number from GET parameters. ```php public function getCurrentPage($recalculate=true) { if($this->_currentPage===null || $recalculate) { if(isset($_GET[$this->pageVar])) { $this->_currentPage=(int)$_GET[$this->pageVar]-1; $pageCount=$this->getPageCount(); if($this->_currentPage>=$pageCount) $this->_currentPage=$pageCount-1; if($this->_currentPage<0) $this->_currentPage=0; } else $this->_currentPage=0; } return $this->_currentPage; } ``` -------------------------------- ### Constructor: __construct() Source: https://www.yiiframework.com/doc/api/1.0/CWebService Initializes a new instance of the CWebService class. ```APIDOC ## Constructor: __construct() ### Description Initializes a new instance of the CWebService class. ### Method `__construct` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **provider** (mixed) - The web service provider class name or object. - **wsdlUrl** (string) - The URL for WSDL. This is required by `run()`. - **serviceUrl** (string) - The URL for the Web service. This is required by `generateWsdl()` and `renderWsdl()`. ### Request Example ```php // Example usage (conceptual) $webService = new CWebService($provider, $wsdlUrl, $serviceUrl); ``` ### Response None (constructor) ### Source Code ```php public function __construct($provider, $wsdlUrl, $serviceUrl) { $this->provider = $provider; $this->wsdlUrl = $wsdlUrl; $this->serviceUrl = $serviceUrl; } ``` ``` -------------------------------- ### PRADO Template Syntax Examples Source: https://www.yiiframework.com/doc/api/1.0/CPradoViewRenderer Examples of PRADO-like template syntax supported by CPradoViewRenderer, including PHP tags, component tags, cache tags, clip tags, and comment tags. ```html // PHP tags: <%= expression %> // <?php echo expression ?> <% statement %> // <?php statement ?> ``` ```html // component tags: <com:WigetClass name1="value1" name2='value2' name3={value3} > // <?php $this->beginWidget('WigetClass', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3)); ?> </com:WigetClass > // <?php $this->endWidget('WigetClass'); ?> <com:WigetClass name1="value1" name2='value2' name3={value3} / // <?php $this->widget('WigetClass', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3)); ?> ``` ```html // cache tags: <cache:fragmentID name1="value1" name2='value2' name3={value3} > // <?php if($this->beginCache('fragmentID', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3))): ?> </cache:fragmentID > // <?php $this->endCache('fragmentID'); endif; ?> ``` ```html // clip tags: <clip:clipID > // <?php $this->beginClip('clipID'); ?> </clip:clipID > // <?php $this->endClip('clipID'); ?> ``` ```html // comment tags: <!--- comments ---> // the whole tag will be stripped off ``` -------------------------------- ### Initialize CConsoleApplication Source: https://www.yiiframework.com/doc/api/1.0/CConsoleApplication Initializes the console application. This method first calls the parent's init method, then checks if the script is run from the command line. It creates the command runner, assigns command maps, and adds commands from the specified command path. ```php protected function init() { parent::init(); if(!isset($_SERVER['argv'])) // || strncasecmp(php_sapi_name(),'cli',3)) die('This script must be run from the command line.'); $this->_runner=$this->createCommandRunner(); $this->_runner->commands=$this->commandMap; $this->_runner->addCommands($this->getCommandPath()); } ``` -------------------------------- ### Initialize Caching - COutputCache Source: https://www.yiiframework.com/doc/api/1.0/COutputCache Marks the start of content to be cached. If content is already cached, it replays actions. Otherwise, it starts output buffering and pushes the widget onto the controller's caching stack. ```php public function init() { if($this->getIsContentCached()) $this->replayActions(); else if($this->_cache!==null) { $this->getController()->getCachingStack()->push($this); ob_start(); ob_implicit_flush(false); } } ``` -------------------------------- ### Create Path Info for GET Parameters Source: https://www.yiiframework.com/doc/api/1.0/CUrlManager Generates a URL path segment from an array of GET parameters. It handles nested arrays and URL-encodes keys and values. Use this when constructing URLs with complex parameter structures. ```php public function createPathInfo($params,$equal,$ampersand, $key=null) { $pairs = array(); foreach($params as $k => $v) { if ($key!==null) $k = $key.'['.$k.']'; if (is_array($v)) $pairs[]=$this->createPathInfo($v,$equal,$ampersand, $k); else $pairs[]=urlencode($k).$equal.urlencode($v); } return implode($ampersand,$pairs); } ``` -------------------------------- ### getHelp() Source: https://www.yiiframework.com/doc/api/1.0/CConsoleCommand Provides the command description, which can be overridden for custom descriptions. ```APIDOC ## getHelp() ### Description Provides the command description. This method may be overridden to return the actual command description. ### Method public string ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **description** (string) - The command description. Defaults to 'Usage: php entry-script.php command-name'. #### Response Example None ``` -------------------------------- ### beginContent() - Content Decoration Source: https://www.yiiframework.com/doc/api/1.0/CBaseController Begins the rendering of content that is to be decorated by the specified view. ```APIDOC ## beginContent() ### Description Begins the rendering of content that is to be decorated by the specified view. ### Method `public void beginContent(mixed $view = NULL, array $data = array())` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ### See Also - beginContent - CContentDecorator ``` -------------------------------- ### getDbConnection() Source: https://www.yiiframework.com/doc/api/1.0/CDbSchema Gets the active database connection. ```APIDOC ## getDbConnection() ### Description Gets the active database connection. ### Method getDbConnection ### Parameters This method does not accept any parameters. ### Response #### Success Response (200) - **CDbConnection** - Database connection. The connection is active. #### Response Example ```json { "dbConnection": "CDbConnection_object" } ``` ``` -------------------------------- ### getScriptName() Source: https://www.yiiframework.com/doc/api/1.0/CConsoleCommandRunner Gets the entry script name. ```APIDOC ## getScriptName() ### Description Gets the entry script name. ### Method `public string getScriptName()` ### Returns - **string** - The entry script name. ### Source Code ```php public function getScriptName() { return $this->_scriptName; } ``` ``` -------------------------------- ### Load Configuration from File Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Loads configuration data from a specified file. Merges with existing data if the configuration is not empty, otherwise copies the data. ```php public function loadFromFile($configFile) { $data=require($configFile); if($this->getCount()>0) $this->mergeWith($data); else $this->copyFrom($data); } ``` -------------------------------- ### Using CHelpCommand in Console Source: https://www.yiiframework.com/doc/api/1.0/CHelpCommand To use this command, enter the following on the command line. If the command name is not provided, it will display all available commands. ```bash php path/to/entry_script.php help [command name] ``` -------------------------------- ### CHttpSession - getIsStarted() Source: https://www.yiiframework.com/doc/api/1.0/CHttpSession Checks if the session has been started. ```APIDOC ## GET /websites/yiiframework_doc_api_1_0/CHttpSession/is-started ### Description Checks whether the session has started. ### Method GET ### Endpoint /websites/yiiframework_doc_api_1_0/CHttpSession/is-started ### Parameters None ### Request Example None ### Response #### Success Response (200) - **isStarted** (boolean) - True if the session has started, false otherwise. #### Response Example ```json { "isStarted": true } ``` ``` -------------------------------- ### Get DB Connection for CDbLogRoute Source: https://www.yiiframework.com/doc/api/1.0/CDbLogRoute Retrieves the database connection instance. It first checks if a connection is already established, then attempts to get it from the application's components using connectionID, and finally creates a SQLite connection if none is found. ```php protected function getDbConnection() { if($this->_db!==null) return $this->_db; else if(($id=$this->connectionID)!==null) { if(($this->_db=Yii::app()->getComponent($id)) instanceof CDbConnection) return $this->_db; else throw new CException(Yii::t('yii','CDbLogRoute.connectionID "{id}" does not point to a valid CDbConnection application component.', array('{id}'=>$id))); } else { $dbFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'log-'.Yii::getVersion().'.db'; return $this->_db=new CDbConnection('sqlite:'.$dbFile); } } ``` -------------------------------- ### Constructor Source: https://www.yiiframework.com/doc/api/1.0/CConfiguration Initializes a new instance of the CConfiguration class. It can accept either a configuration file path (string) or configuration data (array). ```APIDOC ## Constructor ### Description Initializes a new instance of the CConfiguration class. ### Parameters - **$data** (mixed) - If string, it represents a config file (a PHP script returning the configuration as an array); If array, it is config data. ### Source Code framework/collections/CConfiguration.php#51 ``` -------------------------------- ### Initialize Clip Recording - CClipWidget Source: https://www.yiiframework.com/doc/api/1.0/CClipWidget Starts output buffering to capture content for a clip. This method should be called at the beginning of the content you want to capture. ```php public function init() { ob_start(); ob_implicit_flush(false); } ``` -------------------------------- ### CLocale::getNumberSymbol() Source: https://www.yiiframework.com/doc/api/1.0/CLocale Gets a specific number symbol. ```APIDOC ## GET /locale/numberSymbol ### Description Retrieves a specific locale-dependent number symbol, such as a decimal separator or grouping separator. ### Method GET ### Endpoint /locale/numberSymbol ### Parameters #### Query Parameters - **name** (string) - Required - The name of the number symbol to retrieve (e.g., 'decimalSeparator', 'groupingSeparator'). ### Request Example None ### Response #### Success Response (200) - **symbol** (string) - The value of the requested number symbol. #### Response Example ```json { "symbol": "." } ``` ``` -------------------------------- ### Constructor Source: https://www.yiiframework.com/doc/api/1.0/CAuthItem Initializes a new CAuthItem object. ```APIDOC ## __construct() ### Description Initializes a new CAuthItem object. ### Method public ### Parameters #### Path Parameters - **auth** (IAuthManager) - Required - The authorization manager instance. - **name** (string) - Required - The name of the authorization item. - **type** (integer) - Required - The type of the authorization item (0: operation, 1: task, 2: role). - **description** (string) - Optional - A description for the authorization item. - **bizRule** (string) - Optional - The business rule associated with this item. - **data** (mixed) - Optional - Additional data for this item. ### Request Example ```json { "auth": "IAuthManager_instance", "name": "itemName", "type": 0, "description": "Item description", "bizRule": "return $params['user']->isAdmin;", "data": {} } ``` ### Response #### Success Response (void) This method does not return a value. ``` -------------------------------- ### getCommandBuilder() Source: https://www.yiiframework.com/doc/api/1.0/CDbSchema Gets the SQL command builder for this connection. ```APIDOC ## getCommandBuilder() ### Description Gets the SQL command builder for this connection. ### Method getCommandBuilder ### Parameters This method does not accept any parameters. ### Response #### Success Response (200) - **CDbCommandBuilder** - The SQL command builder for this connection. #### Response Example ```json { "commandBuilder": "CDbCommandBuilder_instance" } ``` ``` -------------------------------- ### preinit() Source: https://www.yiiframework.com/doc/api/1.0/CModule Preinitializes the module. This method is called at the beginning of the module constructor before configuration is applied. ```APIDOC ## POST /preinit ### Description Preinitializes the module. This method is called at the beginning of the module constructor before configuration is applied. Override this method for custom preinitialization logic. ### Method POST ### Endpoint /preinit ### Parameters None ### Request Example None ### Response #### Success Response (200) - **status** (string) - Indicates the preinitialization status, typically 'success'. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Cookies Source: https://www.yiiframework.com/doc/api/1.0/CCookieCollection Retrieves all validated cookies from the request. ```APIDOC ## getCookies() ### Description Retrieves all validated cookies from the request. ### Method protected ### Returns - array: An array of CHttpCookie objects. ### Source Code ```php protected function getCookies() { $cookies=array(); if($this->_request->enableCookieValidation) { $sm=Yii::app()->getSecurityManager(); foreach($_COOKIE as $name=>$value) { if(($value=$sm->validateData($value))!==false) $cookies[$name]=new CHttpCookie($name,$value); } } else { foreach($_COOKIE as $name=>$value) $cookies[$name]=new CHttpCookie($name,$value); } return $cookies; } ``` ``` -------------------------------- ### getModules() Source: https://www.yiiframework.com/doc/api/1.0/CModule Retrieves the configuration of all currently installed modules. ```APIDOC ## GET /modules ### Description Retrieves the configuration of all currently installed modules. ### Method GET ### Endpoint /modules ### Parameters None ### Request Example None ### Response #### Success Response (200) - **modules** (array) - An associative array where keys are module IDs and values are their respective configurations. #### Response Example ```json { "modules": { "moduleId1": { /* configuration object */ }, "moduleId2": { /* configuration object */ } } } ``` ``` -------------------------------- ### Using a Widget with Begin/End Calls Source: https://www.yiiframework.com/doc/api/1.0/CBaseController Shows how to use a widget that requires explicit begin and end calls, allowing for content to be placed between the widget's execution. ```php $this->beginWidget('path.to.widgetClass',array('property1'=>'value1',...)); // ... display other contents here $this->endWidget(); ``` -------------------------------- ### Get Iterator Source: https://www.yiiframework.com/doc/api/1.0/CStack Returns an iterator for traversing the items in the stack. ```APIDOC ## getIterator() ### Description Returns an iterator for traversing the items in the stack. This method is required by the IteratorAggregate interface. ### Method GET ### Endpoint /getIterator ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **iterator** (Iterator) - An iterator object for the stack items. #### Response Example ```json { "iterator": "" } ``` ``` -------------------------------- ### Get Count Source: https://www.yiiframework.com/doc/api/1.0/CStack Returns the number of items currently in the stack. ```APIDOC ## getCount() ### Description Returns the number of items in the stack. ### Method GET ### Endpoint /getCount ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **count** (integer) - The number of items in the stack. #### Response Example ```json { "count": 5 } ``` ``` -------------------------------- ### Create Text Highlighter Instance Source: https://www.yiiframework.com/doc/api/1.0/CMarkdownParser Creates and returns an instance of Text_Highlighter based on provided options. It includes logic to load necessary vendor classes if they don't exist. ```php protected function createHighLighter($options) { if(!class_exists('Text_Highlighter', false)) { require_once(Yii::getPathOfAlias('system.vendors.TextHighlighter.Text.Highlighter').'.php'); require_once(Yii::getPathOfAlias('system.vendors.TextHighlighter.Text.Highlighter.Renderer.Html').'.php'); } $lang = current(preg_split("\s+", substr(substr($options,1), 0,-1),2)); $highlighter = Text_Highlighter::factory($lang); if($highlighter) $highlighter->setRenderer(new Text_Highlighter_Renderer_Html($this->getHiglightConfig($options))); return $highlighter; } ```