Esempio n. 1
0
 /**
  * Подключение события
  * @param CComponent $owner - 'хозяин' события
  * @return void
  */
 public function attach($owner)
 {
     $this->lm = $owner->getUrlManager();
     if (is_array($this->lm->languages) && count($this->lm->languages) > 1) {
         $owner->attachEventHandler('onBeginRequest', [$this, 'handleLanguageBehavior']);
     }
 }
 /**
  * @param CComponent $owner
  */
 protected function attachNonApiRequestBehaviorsForInstalledApplication(CComponent $owner)
 {
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleSetupDatabaseConnection'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadActivitiesObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadConversationsObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadWorkflowsObserver'));
 }
Esempio n. 3
0
 /**
  * @param CComponent $owner
  */
 public function attach($owner)
 {
     $owner->attachEventHandler('onProductAdded', array($this, 'productAddedEvent'));
     $owner->attachEventHandler('onProductDeleted', array($this, 'productDeletedEvent'));
     $owner->attachEventHandler('onProductQuantityChanged', array($this, 'onProductQuantityChanged'));
     parent::attach($owner);
 }
Esempio n. 4
0
 /**
  * Detaches the behavior object from the component.
  * The default implementation will unset the {@link owner} property
  * and detach event handlers declared in {@link events}.
  * Make sure you call the parent implementation if you override this method.
  * @param CComponent $owner the component that this behavior is to be detached from.
  */
 public function detach($owner)
 {
     foreach ($this->events() as $event => $handler) {
         $owner->detachEventHandler($event, array($this, $handler));
     }
     $this->_owner = null;
 }
Esempio n. 5
0
 /**
  * Detaches the behavior object from the component.
  * The default implementation will unset the {@link owner} property
  * and detach event handlers declared in {@link events}.
  * This method will also set {@link enabled} to false.
  * Make sure you call the parent implementation if you override this method.
  * @param CComponent $owner the component that this behavior is to be detached from.
  */
 public function detach($owner)
 {
     foreach ($this->events() as $event => $handler) {
         $owner->detachEventHandler($event, [$this, $handler]);
     }
     $this->_owner = null;
     $this->_enabled = false;
 }
Esempio n. 6
0
 /**
  * @param \CComponent $component
  * @param string $action
  * @param string $beginEventName
  * @param string $endEventName
  */
 public function attach(\CComponent $component, $action, $beginEventName, $endEventName)
 {
     $component->attachEventHandler($beginEventName, function (\CEvent $event) use($action) {
         $this->handleBegin($event, $action);
     });
     $component->attachEventHandler($endEventName, function (\CEvent $event) use($action) {
         $this->handleEnd($event, $action);
     });
 }
 /**
  * Parse existing comments for searching types or comments for property
  *
  * @param CComponent $object
  */
 public function setTypeAndComment(CComponent $object)
 {
     if ($object instanceof CActiveRecord) {
         $scopes = $object->scopes();
         if (isset($scopes[$this->name])) {
             $this->type = get_class($object);
         }
     }
 }
Esempio n. 8
0
 public function testBehaviors()
 {
     $component = new CComponent();
     $hash = new ARedisHash("testAttribute" . uniqid(), $this->getConnection());
     $component->attachBehavior("testAttribute", $hash);
     $this->assertTrue(isset($component->testAttribute));
     $this->assertTrue($component->testAttribute->add("test", true));
     $this->assertTrue((bool) $component->testAttribute['test']);
     $component->testAttribute->clear();
 }
Esempio n. 9
0
 public function run($args)
 {
     $comp = new CComponent();
     $ubconfig = array_merge(array('class' => 'UpdaterBehavior', 'isConsole' => true, 'noHalt' => true));
     $comp->attachBehavior('UpdaterBehavior', $ubconfig);
     // The files directly involved in the update process:
     $updaterFiles = $comp->updaterFiles;
     // The web-based updater's action classes, which are defined separately:
     $updaterActions = $comp->getWebUpdaterActions(false);
     foreach ($updaterActions as $name => $properties) {
         $updaterFiles[] = UpdaterBehavior::classAliasPath($properties['class']);
     }
     echo "\$deps = ";
     var_export($updaterFiles);
 }
Esempio n. 10
0
 /**
  * @param string $key
  * @return mixed
  */
 public function __get($key)
 {
     if ($this->exists($key)) {
         return $this->get($key);
     }
     return parent::__get($key);
 }
Esempio n. 11
0
 public function __get($name)
 {
     if (in_array($name, EFileMetaData::$attributeLabels)) {
         return $this->getMetaData()->getAttribute($name);
     }
     return parent::__get($name);
 }
Esempio n. 12
0
 public function __isset($name)
 {
     if ($this->hasComponent($name)) {
         return $this->getComponent($name) !== null;
     } else {
         return parent::__isset($name);
     }
 }
 /**
  * @param CComponent $owner
  */
 protected function attachNonApiRequestBehaviorsForInstalledApplication(CComponent $owner)
 {
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleSetupDatabaseConnection'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadActivitiesObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadConversationsObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadEmailMessagesObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadWorkflowsObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadReadPermissionSubscriptionObserver'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLoadAccountContactAffiliationObserver'));
 }
Esempio n. 14
0
 /**
  * Any requests to set or get attributes or call methods on this class that are not found are redirected to the Swift_Message object
  * @param string the method name
  */
 public function __call($name, $parameters)
 {
     try {
         return parent::__call($name, $parameters);
     } catch (CException $e) {
         if (method_exists($this->message, $name)) {
             return call_user_func_array(array($this->message, $name), $parameters);
         } else {
             throw $e;
         }
     }
 }
Esempio n. 15
0
 public function __set($name, $val)
 {
     try {
         return parent::__set($name, $val);
     } catch (CException $e) {
         $method_name = Yii::app()->text->underscoreToCamelcase($name);
         $method_name = 'set' . ucfirst($method_name);
         if (method_exists($this, $method_name)) {
             return $this->{$method_name}($val);
         } else {
             throw new CException($e->getMessage());
         }
     }
 }
Esempio n. 16
0
 /**
  * Overrides the default magic method defined at the CComponent level in order to
  * return a metadata value if parent method fails.
  *
  * @see CComponent::__get()
  */
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (CException $e) {
         if (isset($this->_metadata[$name])) {
             return $this->_metadata[$name];
         } else {
             throw new SWException('Property "' . $name . '" is not found.', SWException::SW_ERR_ATTR_NOT_FOUND);
         }
     }
 }
 public function instantiate()
 {
     $component = new CComponent();
     $component->attachBehavior('messageParser', array('class' => 'X2TranslationBehavior'));
     return $component;
 }
Esempio n. 18
0
 /**
  * Checks if a attribute value is null.
  * This method overrides the parent implementation by checking
  * if the attribute is null or not.
  *
  * @param string $name the attribute name.
  * @return boolean whether the attribute value is null.
  */
 public function __isset($name)
 {
     if ($this->hasAttribute($name)) {
         return true;
     } else {
         return parent::__isset($name);
     }
 }
 protected function attachNonApiRequestBehaviorsForInstalledApplication(CComponent $owner)
 {
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleSetupDatabaseConnection'));
 }
Esempio n. 20
0
 public function __isset($name)
 {
     return parent::__isset($name);
 }
 /**
  * This function fetches all needed data of the related Object and returns them
  * in an array that is prepared for use in ListData.
  */
 public function getRelatedData()
 {
     /* At first we determine, if we want to display all parent Objects, or
      * if the User supplied an list of Objects */
     if (is_object($this->parentObjects)) {
         $parentobjects = array($this->parentObjects);
     } else {
         if (is_array($this->parentObjects)) {
             $parentobjects = $this->parentObjects;
         } else {
             $parentobjects = CActiveRecord::model(get_class($this->_relatedModel))->findAll();
         }
     }
     if ($this->allowEmpty) {
         if (is_string($this->allowEmpty)) {
             $dataArray[0] = $this->allowEmpty;
         } else {
             $dataArray[0] = Yii::t('app', 'None');
         }
     }
     foreach ($parentobjects as $obj) {
         if (!is_array($this->fields)) {
             $this->fields = array($this->fields);
         }
         $fields = '';
         foreach ($this->fields as $field) {
             $rule = sprintf('{%s}', $field);
             $rules[$rule] = $obj->{$field};
             $fields .= $this->getModelData($obj, $field);
             if (count($this->fields) > 1) {
                 $fields .= $this->delimiter;
             }
         }
         $defaultrules = array('{fields}' => $fields, '{id}' => $obj->id);
         // Look for user-contributed functions and evaluate them
         if ($this->functions != array()) {
             foreach ($this->functions as $key => $function) {
                 $funcrules[sprintf('{func%d}', $key)] = CComponent::evaluateExpression(strtr($function, $defaultrules));
             }
         }
         // Merge the evaluated rules, if exist
         if (isset($funcrules)) {
             $rules = array_merge($rules, $funcrules);
         }
         // Merge the default rules into our ruleset
         $rules = array_merge($rules, $defaultrules);
         // Apply the rules to the template
         $value = strtr($this->template, $rules);
         if ($this->groupParentsBy != '') {
             $dataArray[$obj->{$this->groupParentsBy}][$obj->{$this->relatedPk}] = $value;
         } else {
             $dataArray[$obj->{$this->relatedPk}] = $value;
         }
     }
     if (!isset($dataArray) || !is_array($dataArray)) {
         $dataArray = array();
     }
     return $dataArray;
 }
Esempio n. 22
0
 /**
  * Instantiates a new CComponent object with {@link UpdaterBehavior attached
  * to it, and returns it.
  * @return CComponent
  */
 public function instantiateUBe($properties = array())
 {
     $comp = new CComponent();
     $ubconfig = array_merge(array('class' => 'UpdaterBehavior', 'isConsole' => true, 'noHalt' => true), $properties);
     $comp->attachBehavior('UpdaterBehavior', $ubconfig);
     return $comp;
 }
Esempio n. 23
0
 public function instantiate($config = array())
 {
     $obj = new CComponent();
     $obj->attachBehavior('CampaignMailing', array_merge(array('class' => 'CampaignMailingBehavior', 'itemId' => $this->listItem('testUser_unsent')->id, 'campaign' => $this->campaign('testUser')), $config));
     return $obj;
 }
Esempio n. 24
0
 /**
  * Magic call to wrapped amazon aws methods. If not command found, then call parent component
  * @param string $method
  * @param array $args
  * @return mixed
  * @throws CException
  */
 public function __call($method, $args)
 {
     // the "current" is nessesary here:
     if ($args == false) {
         $args = array();
     } else {
         $args = current($args);
     }
     try {
         $command = $this->getClient()->getCommand(Inflector::getDefault()->camel($method), $args);
         if ($command) {
             return $this->getClient()->execute($command, $args);
         }
     } catch (Exception $e) {
         // do nothing
         throw new CException(Yii::t('zii', $e->getMessage()));
         //custom added
     }
     return parent::__call($method, $args);
 }
Esempio n. 25
0
 /**
  * If we have operator add it otherwise call parent implementation
  * @see CComponent::__call()
  * @since v1.0
  */
 public function __call($fieldName, $parameters)
 {
     if (isset($parameters[0])) {
         $operatorName = strtolower($parameters[0]);
     }
     if (isset($parameters[1]) || $parameters[1] === null) {
         $value = $parameters[1];
     }
     if (is_numeric($operatorName)) {
         $operatorName = strtolower(trim($value));
         $value = strtolower(trim($value)) === 'exists' ? true : false;
     }
     if (in_array($operatorName, array_keys(self::$operators))) {
         array_push($this->_workingFields, $fieldName);
         $fieldName = implode('.', $this->_workingFields);
         $this->_workingFields = array();
         switch ($operatorName) {
             case 'exists':
                 $this->addCond($fieldName, $operatorName, true);
                 break;
             case 'notexists':
                 $this->addCond($fieldName, $operatorName, false);
                 break;
             default:
                 $this->addCond($fieldName, $operatorName, $value);
         }
         return $this;
     } else {
         return parent::__call($fieldName, $parameters);
     }
 }
Esempio n. 26
0
File: XPage.php Progetto: hung5s/yap
 public function init()
 {
     parent::init();
 }
Esempio n. 27
0
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case 'objCart':
             $this->objCart = $mixValue;
             return;
         case 'CheckoutForm':
             $this->CheckoutForm = $mixValue;
             return;
         default:
             return parent::__set($strName, $mixValue);
     }
 }
Esempio n. 28
0
 public function __isset($name)
 {
     return isset($this->_match[$name]) || isset($this->_attributes[$name]) || parent::__isset($name);
 }
Esempio n. 29
0
 /**
  * Verify correct operation of {@link prepareExportDeliverable}.
  * Currently, the exportDestinations with test cases include: download, server, ftp, scp
  * exportDestinations remaining to be tested: s3, gdrive
  */
 public function testPrepareExportDeliverable()
 {
     $component = new CComponent();
     $component->attachBehavior('importexport', new ImportExportBehavior());
     $testfile = implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'tests', 'data', 'csvs', 'contacts.csv'));
     // Ensure failure when the exportDestination is not specified
     $ret = $component->prepareExportDeliverable($testfile, array());
     $this->assertFalse($ret);
     // Test standard browser download method
     $params = array('exportDestination' => 'download');
     $ret = $component->prepareExportDeliverable($testfile, $params);
     $this->assertTrue($ret);
     $params['compressOutput'] = true;
     $ret = $component->prepareExportDeliverable($testfile, $params);
     $this->assertTrue($ret);
     $this->assertFileExists($component->safePath('contacts.zip'));
     unlink($component->safePath('contacts.zip'));
 }
 public function __get($name)
 {
     $getter = 'get' . $name;
     if (false !== method_exists($this, $getter)) {
         return call_user_func(array($this, $getter));
     } else {
         if (false !== property_exists($this, $name)) {
             return $this->{$name};
         } else {
             if (false !== $this->getIsProxy() && false !== method_exists($this->_instance, $getter)) {
                 return call_user_func(array($this->_instance, $getter));
             } else {
                 if (false !== $this->getIsProxy() && false !== property_exists($this->_instance, $name)) {
                     return $this->_instance->{$name};
                 } else {
                     if (false === $this->getIsProxy() && false !== array_key_exists($name, $this->abstract)) {
                         return $this->abstract[$name];
                     }
                 }
             }
         }
     }
     return parent::__get($name);
 }