/** * 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); }
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); }
/** * 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; } }
public function attach($owner) { parent::attach($owner); $this->_eventInterceptor = new EventInterceptor(); $this->_eventInterceptor->initialize($owner); $this->_eventInterceptor->onEventIntercepted = array($this, 'forwardEvent'); }
/** * 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) { 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); }
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();"); }
/** * Attaches the entity to a component * @throws CException if no name is set * @param CComponent $owner the owner component */ public function attach($owner) { parent::attach($owner); if ($this->name === null) { throw new CException("No name specified for " . get_class($this)); } if (method_exists($owner, "getPrimaryKey")) { $this->_oldName = $this->name; $pk = $owner->getPrimaryKey(); if (is_array($pk)) { foreach ($pk as $key => $value) { $pk[$key] = $key . ":" . $value; } $pk = implode(":", $pk); } $this->name = get_class($owner) . ":" . $pk . ":" . $this->name; } }
/** * 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); } }
/** * * @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(); }
/** * 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))); }
/** * Attaches the state machine to a component * @param CComponent $owner the component to attach to */ public function attach($owner) { parent::attach($owner); if ($this->_uniqueID === null) { $this->_uniqueID = uniqid(); } if (($state = $this->getState()) !== null) { $owner->attachBehavior($this->_uniqueID . "_" . $state->name, $state); } }