本文整理匯總了PHP中Drupal\Core\Config\Config::validateName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::validateName方法的具體用法?PHP Config::validateName怎麽用?PHP Config::validateName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Config\Config
的用法示例。
在下文中一共展示了Config::validateName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onConfigImporterValidate
/**
* Validates the configuration to be imported.
*
* @param \Drupal\Core\Config\ConfigImporterEvent $event
* The Event to process.
*
* @throws \Drupal\Core\Config\ConfigNameException
*/
public function onConfigImporterValidate(ConfigImporterEvent $event)
{
foreach (array('delete', 'create', 'update') as $op) {
foreach ($event->getConfigImporter()->getUnprocessedConfiguration($op) as $name) {
try {
Config::validateName($name);
} catch (ConfigNameException $e) {
$message = $this->t('The config name @config_name is invalid.', array('@config_name' => $name));
$event->getConfigImporter()->logError($message);
}
}
}
}
示例2: onConfigImporterValidate
/**
* Validates the configuration to be imported.
*
* @param \Drupal\Core\Config\ConfigImporterEvent $event
* The Event to process.
*
* @throws \Drupal\Core\Config\ConfigNameException
*/
public function onConfigImporterValidate(ConfigImporterEvent $event)
{
foreach (array('delete', 'create', 'update') as $op) {
foreach ($event->getConfigImporter()->getUnprocessedConfiguration($op) as $name) {
try {
Config::validateName($name);
} catch (ConfigNameException $e) {
$message = $this->t('The config name @config_name is invalid.', array('@config_name' => $name));
$event->getConfigImporter()->logError($message);
}
}
}
$config_importer = $event->getConfigImporter();
if ($config_importer->getStorageComparer()->getSourceStorage()->exists('core.extension')) {
$this->validateModules($config_importer);
$this->validateThemes($config_importer);
$this->validateDependencies($config_importer);
} else {
$config_importer->logError($this->t('The core.extension configuration does not exist.'));
}
}
示例3: testValidateNameException
/**
* @covers ::validateName
* @expectedException \Drupal\Core\Config\ConfigNameException
* @dataProvider validateNameProvider
*/
public function testValidateNameException($name, $exception_message)
{
$this->setExpectedException('\\Drupal\\Core\\Config\\ConfigNameException', $exception_message);
$this->config->validateName($name);
}