/** * Adds extensionPath to messages source */ public function attach($owner) { parent::attach($owner); if (!isset(Yii::app()->messages->extensionPaths[$this->messagesCategory])) { Yii::app()->messages->extensionPaths[$this->messagesCategory] = $this->messagesCategoryPath; } }
/** * Attach this behavior * @param CAuthAssignment owner */ public function attach($owner) { parent::attach($owner); $this->_item = Yii::app()->getAuthManager()->getAuthItem($this->getOwner()->itemName); $this->_item->attachBehavior('RbamAuthItemBehavior', 'RbamAuthItemBehavior'); $this->_user = $this->module->getUser($owner->userId); }
/** * Detaches the entity from a component * @param CComponent $owner the owner component */ public function detach($owner) { parent::detach($owner); if (method_exists($owner, "getPrimaryKey")) { $this->name = $this->_oldName; } }
public function attach($owner) { parent::attach($owner); $this->_eventInterceptor = new EventInterceptor(); $this->_eventInterceptor->initialize($owner); $this->_eventInterceptor->onEventIntercepted = array($this, 'forwardEvent'); }
public function attach($owner) { if (!property_exists($owner, 'modelClass')) { throw new CException('Property "modelClass" must be declared in all controllers that use CommonControllerBehavior, but it is not declared in ' . get_class($owner)); } parent::attach($owner); }
public function attach($owner) { if (!$owner instanceof CWidget) { throw new CException('owner must be an instance of CWidget'); } return parent::attach($owner); }
/** * Enables output log data into STDOUT whether console application. * * @param CComponent $owner behavior owner */ public function attach($owner) { parent::attach($owner); if (Yii::app() instanceof CConsoleApplication) { $this->attachEventHandler('onAfterLog', array('LogBehavior', 'stdout')); } }
public function attach($owner) { parent::attach($owner); foreach ($this->fields as $field) { $this->_fields[$field['fieldName']] = Yii::createComponent(array_merge(array('class' => 'X2StaticField', 'translationCategory' => $this->translationCategory, 'owner' => $this->owner), $field)); } $this->owner->setFormatter('application.components.formatters.FieldFormatter'); }
public function attach($owner) { parent::attach($owner); $id = $owner->id; $this->sortableOptions['update'] = "js:function(event, ui)\n {\n \$.post('{$this->saveUrl}', jQuery('#{$id} ul').sortable('serialize'));\n }"; $jsOptions = empty($this->sortableOptions) ? '' : CJavaScript::encode($this->sortableOptions); if ($owner instanceof CListView || $owner instanceof CGridView) { if (!$owner->afterAjaxUpdate) { $owner->afterAjaxUpdate = "js:function() {\n jQuery('#{$id} ul').sortable({$jsOptions});\n jQuery('#{$id} ul').disableSelection();\n }"; } } Yii::app()->getClientScript()->registerCoreScript('jquery.ui')->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id} ul').sortable({$jsOptions});jQuery('#{$id} ul').disableSelection();"); }
public function attach($owner) { if (YII_DEBUG && !$owner instanceof CClientScript) { throw new CException(__CLASS__ . ' owner must be an instance of CClientScript.'); } parent::attach($owner); if ($this->publish) { $this->publishJs = true; $this->publishCss = true; } $this->initPrefix($this->jsPath, $this->jsDir); $this->initPrefix($this->cssPath, $this->cssDir); }
/** * Initializes the controller. * This method is called by the application before the controller starts to execute. * You may override this method to perform the needed initialization for the controller. */ public function init() { parent::init(); // custom error action Yii::app()->errorHandler->errorAction = '/' . $this->id . '/error'; // do not redirect when not logged in Yii::app()->user->loginUrl = null; // allow login from any url if (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['PHP_AUTH_PW'])) { $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; // allow a secure link to api-login $identity = new $this->userIdentityClass($username, $password); if ($identity->authenticateApi()) { Yii::app()->user->login($identity, $duration = 0); } } // ensure the user is an api login if (!Yii::app()->user->isGuest && !Yii::app()->user->getState('UserIdentity.api')) { throw new CHttpException(403, Yii::t('dressing', 'Please login to the API interface.')); } }
/** * Overloads parent attach method so at the time the behavior is about to be * attached to the owner component, the behavior is initialized.<br/> * During the initialisation, following actions are performed:<br/> * <ul> * <li>The status attribute exists</li> * <li>Check whether or not, workflow events should be enabled, by testing if the owner component * class inherits from the 'SWComponent' or 'SWActiveRecord' class. </li> * </ul> * * @see base/CBehavior::attach() */ public function attach($owner) { if (!$this->canFireEvent($owner, $this->eventClassName)) { if ($this->swIsEventEnabled()) { // workflow events are enabled by configuration but the owner component is not // able to handle workflow event : warning Yii::log('events disabled : owner component doesn\'t inherit from ' . $this->eventClassName, CLogger::LEVEL_WARNING, self::SW_LOG_CATEGORY); } $this->enableEvent = false; // force } parent::attach($owner); if ($this->getOwner() instanceof CActiveRecord) { $statusAttributeCol = $this->getOwner()->getTableSchema()->getColumn($this->statusAttribute); if (!isset($statusAttributeCol) || $statusAttributeCol->type != 'string') { throw new SWException('attribute ' . $this->statusAttribute . ' not found', SWException::SW_ERR_ATTR_NOT_FOUND); } } // preload the workflow source component $this->_wfs = Yii::app()->{$this->workflowSourceComponent}; // load the default workflow id now because the owner model maybe able to provide it // together with the whole workflow definition. In this case, this definition must be pushed // to the SWWorkflowSource component (done by swGetDefaultWorkflowId). $defWid = $this->swGetDefaultWorkflowId(); // autoInsert now ! if ($this->autoInsert == true && $this->getOwner()->{$this->statusAttribute} == null) { $this->swInsertToWorkflow($defWid); } }
/** * @return \CController */ public function getOwner() { return parent::getOwner(); }
/** * Declares events and the event handler methods. * * See yii documentation on behavior; this is an override of * {@link CBehavior::events()} */ public function events() { return array_merge(parent::events(), array('onBeginRequest' => 'beginRequest')); }
/** * * @param type $owner */ public function attach($owner) { parent::attach($owner); $this->ruProperty('includeExtraneousOutput', YII_DEBUG); if ($this->handleErrors) { if (method_exists('ResponseUtil', 'respondWithError')) { set_error_handler('ResponseUtil::respondWithError'); } if (method_exists('ResponseUtil', 'respondFatalErrorMessage')) { register_shutdown_function('ResponseUtil::respondFatalErrorMessage'); } } if ($this->handleExceptions && method_exists('ResponseUtil', 'respondWithException')) { set_exception_handler('ResponseUtil::respondWithException'); } }
/** * Overloads parent attach method so at the time the behavior is about to be * attached to the owner component, the behavior is initialized.<br/> * During the initialisation, following actions are performed:<br/> * <ul> * <li>Is there a default workflow associated with the owner component ? : if not, and if the * behavior is initialized with autoInsert set to TRUE, an exception is thrown as it will not be * possible to insert the component into a workflow.</li> * <li>If a default workflow is available for the owner component, and if autoInsert is set to TRUE, * the component is inserted in the initial status of its default workflow. * </li> * <li>Check whether or not, workflow events should be enabled, by testing if the owner component * class inherits from the 'SWComponent' class. </li> * </ul> * * @see base/CBehavior::attach() */ public function attach($owner) { Yii::trace(__CLASS__ . '.' . __FUNCTION__, self::SW_LOG_CATEGORY); if (!$this->canFireEvent($owner, $this->eventClassName)) { if ($this->swIsEventEnabled()) { // workflow events are enabled by configuration but the owner component is not // able to handle workflow event : warning Yii::log(Yii::t(self::SW_I8N_CATEGORY, 'events disabled : owner component doesn\'t inherit from {className}', array('{className}' => $this->eventClassName)), CLogger::LEVEL_WARNING, self::SW_LOG_CATEGORY); } $this->enableEvent = false; // force } parent::attach($owner); $this->_wfs = Yii::app()->{$this->workflowSourceComponent}; $this->initialize(); }
/** * Calls the named method which is not a class method. * Do not call this method. This is a PHP magic method that we override * to implement the states feature. * @param string $name the method name * @param array $parameters method parameters * @return mixed the method return value */ public function __call($name, $parameters) { $state = $this->getState(); if (is_object($state) && method_exists($state, $name)) { return call_user_func_array(array($state, $name), $parameters); } return parent::__call($name, $parameters); }
/** * Attaches this behavior to the owner. * In addition to the CBehavior default implementation, the owner's event * handlers for wizard events are also attached. * @param CController $owner The controller that this behavior is to be attached to. */ public function attach($owner) { if (!$owner instanceof CController) { throw new CException(Yii::t('wizard', 'Owner must be an instance of CController')); } parent::attach($owner); foreach ($this->events as $event => $handler) { $this->attachEventHandler($event, array($owner, $handler)); } $this->_session = Yii::app()->getSession(); $this->_stepsKey = $this->sessionKey . '.steps'; $this->_branchKey = $this->sessionKey . '.branches'; $this->_timeoutKey = $this->sessionKey . '.timeout'; $this->parseSteps(); }
public function attach($owner) { parent::attach($owner); $this->attachBehaviors(array('settingsBehavior' => array('class' => $this->settingsBehavior, 'uid' => $this->owner->uid, 'modelClass' => $this->owner->modelClass))); }