本文整理汇总了PHP中CComponent类的典型用法代码示例。如果您正苦于以下问题:PHP CComponent类的具体用法?PHP CComponent怎么用?PHP CComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach
/**
* Подключение события
* @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']);
}
}
示例2: attachNonApiRequestBehaviorsForInstalledApplication
/**
* @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'));
}
示例3: attach
/**
* @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);
}
示例4: detach
/**
* 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;
}
示例5: detach
/**
* 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;
}
示例6: attach
/**
* @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);
});
}
示例7: setTypeAndComment
/**
* 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);
}
}
}
示例8: testBehaviors
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();
}
示例9: run
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);
}
示例10: attachNonApiRequestBehaviorsForInstalledApplication
/**
* @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'));
}
示例11: __get
/**
* 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);
}
}
}
示例12: instantiate
public function instantiate()
{
$component = new CComponent();
$component->attachBehavior('messageParser', array('class' => 'X2TranslationBehavior'));
return $component;
}
示例13: attachNonApiRequestBehaviorsForInstalledApplication
protected function attachNonApiRequestBehaviorsForInstalledApplication(CComponent $owner)
{
$owner->attachEventHandler('onBeginRequest', array($this, 'handleSetupDatabaseConnection'));
}
示例14: __get
/**
* @param string $key
* @return mixed
*/
public function __get($key)
{
if ($this->exists($key)) {
return $this->get($key);
}
return parent::__get($key);
}
示例15: __get
public function __get($name)
{
if (in_array($name, EFileMetaData::$attributeLabels)) {
return $this->getMetaData()->getAttribute($name);
}
return parent::__get($name);
}