本文整理汇总了PHP中PageManager::isDataSourceUsed方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::isDataSourceUsed方法的具体用法?PHP PageManager::isDataSourceUsed怎么用?PHP PageManager::isDataSourceUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::isDataSourceUsed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __canUninstallOrDisable
/**
* This function checks that if the given extension has provided Fields,
* Data Sources or Events, that they aren't in use before the extension
* is uninstalled or disabled. This prevents exceptions from occurring when
* accessing an object that was using something provided by this Extension
* can't anymore because it has been removed.
*
* @param Extension $obj
* An extension object
* @return boolean
*/
private static function __canUninstallOrDisable(Extension $obj)
{
$extension_handle = strtolower(preg_replace('/^extension_/i', NULL, get_class($obj)));
$about = self::about($extension_handle);
// Fields:
if (is_dir(EXTENSIONS . "/{$extension_handle}/fields")) {
foreach (glob(EXTENSIONS . "/{$extension_handle}/fields/field.*.php") as $file) {
$type = preg_replace(array('/^field\\./i', '/\\.php$/i'), NULL, basename($file));
if (FieldManager::isFieldUsed($type)) {
throw new Exception(__('The field ‘%s’, provided by the Extension ‘%s’, is currently in use.', array(basename($file), $about['name'])) . ' ' . __("Please remove it from your sections prior to uninstalling or disabling."));
}
}
}
// Data Sources:
if (is_dir(EXTENSIONS . "/{$extension_handle}/data-sources")) {
foreach (glob(EXTENSIONS . "/{$extension_handle}/data-sources/data.*.php") as $file) {
$handle = preg_replace(array('/^data\\./i', '/\\.php$/i'), NULL, basename($file));
if (PageManager::isDataSourceUsed($handle)) {
throw new Exception(__('The Data Source ‘%s’, provided by the Extension ‘%s’, is currently in use.', array(basename($file), $about['name'])) . ' ' . __("Please remove it from your pages prior to uninstalling or disabling."));
}
}
}
// Events
if (is_dir(EXTENSIONS . "/{$extension_handle}/events")) {
foreach (glob(EXTENSIONS . "/{$extension_handle}/events/event.*.php") as $file) {
$handle = preg_replace(array('/^event\\./i', '/\\.php$/i'), NULL, basename($file));
if (PageManager::isEventUsed($handle)) {
throw new Exception(__('The Event ‘%s’, provided by the Extension ‘%s’, is currently in use.', array(basename($file), $about['name'])) . ' ' . __("Please remove it from your pages prior to uninstalling or disabling."));
}
}
}
// Text Formatters
if (is_dir(EXTENSIONS . "/{$extension_handle}/text-formatters")) {
foreach (glob(EXTENSIONS . "/{$extension_handle}/text-formatters/formatter.*.php") as $file) {
$handle = preg_replace(array('/^formatter\\./i', '/\\.php$/i'), NULL, basename($file));
if (FieldManager::isTextFormatterUsed($handle)) {
throw new Exception(__('The Text Formatter ‘%s’, provided by the Extension ‘%s’, is currently in use.', array(basename($file), $about['name'])) . ' ' . __("Please remove it from your fields prior to uninstalling or disabling."));
}
}
}
}