本文整理汇总了PHP中BlockType::getBlockTypeClass方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockType::getBlockTypeClass方法的具体用法?PHP BlockType::getBlockTypeClass怎么用?PHP BlockType::getBlockTypeClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockType
的用法示例。
在下文中一共展示了BlockType::getBlockTypeClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBlockControllerOverride
public function testBlockControllerOverride()
{
$env = Environment::get();
$env->clearOverrideCache();
$root = dirname(DIR_BASE_CORE . '../');
mkdir($root . '/application/blocks/core_area_layout/', 0777, true);
copy(dirname(__FILE__) . '/fixtures/CoreAreaLayoutController.php', $root . '/application/blocks/core_area_layout/controller.php');
$bt = new \BlockType();
$bt->setBlockTypeHandle('core_area_layout');
$class = $bt->getBlockTypeClass();
$classExists = class_exists($class);
unlink($root . '/application/blocks/core_area_layout/controller.php');
rmdir($root . '/application/blocks/core_area_layout');
$this->assertTrue($class == '\\Application\\Block\\CoreAreaLayout\\Controller');
$this->assertTrue($classExists);
}
示例2: doInstallBlockType
/**
* installs a block type
* @param string $btHandle
* @param BlockType $bt
* @param string $dir
* @param int $btID
* @param string $dirDbXml
*/
protected function doInstallBlockType($btHandle, $bt, $dir, $btID = 0, $dirDbXml) {
$db = Loader::db();
$env = Environment::get();
$env->clearOverrideCache();
if (file_exists($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER)) {
$class = $bt->getBlockTypeClass();
$path = $dirDbXml . '/' . $btHandle;
if (!class_exists($class)) {
require_once($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER);
}
if (!class_exists($class)) {
throw new Exception(t("%s not found. Please check that the block controller file contains the correct class name.", $class));
}
$bta = new $class;
//Attempt to run the subclass methods (install schema from db.xml, etc.)
$r = $bta->install($path);
//Validate
if ($r === false) {
return t('Error: Block Type cannot be installed because no db.xml file can be found. Either create a db.xml file for this block type, or remove the $btTable variable from its controller.');
} else if (!$r->result && $r->message) {
return $r->message;
} else if (!$r->result && !$r->message) {
return t('Error: Block Type cannot be installed due to an unknown database error. Please check that the db.xml file for this block type is formatted correctly.');
} else if ($message = BlockType::validateInstalledDatabaseTable($bta->getBlockTypeDatabaseTable())) {
$db->Execute('DROP TABLE IF EXISTS ' . $bta->getBlockTypeDatabaseTable());
return $message;
}
$currentLocale = Localization::activeLocale();
if ($currentLocale != 'en_US') {
// Prevent the database records being stored in wrong language
Localization::changeLocale('en_US');
}
//Install the block
$btd = new BlockTypeDB();
$btd->btHandle = $btHandle;
$btd->btName = $bta->getBlockTypeName();
$btd->btDescription = $bta->getBlockTypeDescription();
$btd->btActiveWhenAdded = $bta->isActiveWhenAdded();
$btd->btCopyWhenPropagate = $bta->isCopiedWhenPropagated();
$btd->btIncludeAll = $bta->includeAll();
$btd->btIsInternal = $bta->isBlockTypeInternal();
$btd->btInterfaceHeight = $bta->getInterfaceHeight();
$btd->btInterfaceWidth = $bta->getInterfaceWidth();
$btd->pkgID = $bt->getPackageID();
if ($currentLocale != 'en_US') {
Localization::changeLocale($currentLocale);
}
if ($btID > 0) {
$btd->btID = $btID;
$btDisplayOrder = $db->GetOne('select btDisplayOrder from BlockTypes where btID = ?', array($btID));
if (!$btDisplayOrder) {
$btDisplayOrder = 0;
}
$btd->btDisplayOrder = $btDisplayOrder;
$r = $btd->Replace();
} else {
if ($bta->isBlockTypeInternal()) {
$btd->btDisplayOrder = 0;
} else {
$btMax = $db->GetOne('select max(btDisplayOrder) from BlockTypes');
if ($btMax < 1 && $btMax !== '0') {
$btd->btDisplayOrder = 0;
} else {
$btd->btDisplayOrder = $btMax + 1;
}
}
$r = $btd->save();
}
// now we remove the block type from cache
$ca = new Cache();
$ca->delete('blockTypeByID', $btID);
$ca->delete('blockTypeByHandle', $btHandle);
$ca->delete('blockTypeList', false);
if (!$r) {
return $db->ErrorMsg();
}
} else {
return t("No block found with the handle %s.", $btHandle);
}
}