本文整理汇总了PHP中CComponent::attachBehavior方法的典型用法代码示例。如果您正苦于以下问题:PHP CComponent::attachBehavior方法的具体用法?PHP CComponent::attachBehavior怎么用?PHP CComponent::attachBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComponent
的用法示例。
在下文中一共展示了CComponent::attachBehavior方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: instantiate
public function instantiate()
{
$component = new CComponent();
$component->attachBehavior('messageParser', array('class' => 'X2TranslationBehavior'));
return $component;
}
示例4: instantiateUBe
/**
* 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;
}
示例5: instantiate
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;
}
示例6: testPrepareExportDeliverable
/**
* 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'));
}