本文整理汇总了PHP中PHPCR\Util\PathHelper::assertValidLocalName方法的典型用法代码示例。如果您正苦于以下问题:PHP PathHelper::assertValidLocalName方法的具体用法?PHP PathHelper::assertValidLocalName怎么用?PHP PathHelper::assertValidLocalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\Util\PathHelper
的用法示例。
在下文中一共展示了PathHelper::assertValidLocalName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValidNodename
/**
* Check if this node name is valid. Returns null if valid, an exception otherwise.
*
* @param string $nodeName The node local name
*
* @return RepositoryException|null
*/
public function isValidNodename($nodeName)
{
try {
$parts = explode(':', $nodeName);
if (1 > count($parts) || 2 < count($parts)) {
return new RepositoryException("Name contains illegal characters: {$nodeName}");
}
if (0 === strlen($parts[0])) {
return new RepositoryException("Name may not be empty: {$nodeName}");
}
PathHelper::assertValidLocalName($parts[0]);
if (2 == count($parts)) {
// [0] was the namespace prefix, also check the name
PathHelper::assertValidLocalName($parts[1]);
if (0 === strlen($parts[1])) {
return new RepositoryException("Local name may not be empty: {$nodeName}");
}
}
} catch (RepositoryException $e) {
return $e;
}
return null;
}
示例2: testAssertInvalidLocalName
/**
* @dataProvider dataproviderInvalidLocalNames
* @expectedException \PHPCR\RepositoryException
*/
public function testAssertInvalidLocalName($name)
{
PathHelper::assertValidLocalName($name);
}
示例3: validateWorkspaceName
private function validateWorkspaceName($name)
{
$res = PathHelper::assertValidLocalName($name);
if (!$res) {
throw new RepositoryException(sprintf('Invalid workspace name "%s"', $name));
}
}
示例4: assertValidName
/**
* Minimal check according to the jcr spec to see if this node name
* conforms to the specification
*
* If it can't be avoided, extending transports may overwrite this method to add
* additional checks. But this will reduce interchangeability, thus it is better to
* properly encode and decode characters that are not natively allowed by the storage.
*
* @param string $name The name to check
*
* @return boolean always true, if the name is not valid a RepositoryException is thrown
*
* @see http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.2.2%20Local%20Names
*
* @throws RepositoryException if the name contains invalid characters
*/
public function assertValidName($name)
{
return PathHelper::assertValidLocalName($name);
}