本文整理汇总了PHP中CM_Util::getNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Util::getNamespace方法的具体用法?PHP CM_Util::getNamespace怎么用?PHP CM_Util::getNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Util
的用法示例。
在下文中一共展示了CM_Util::getNamespace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param CM_Frontend_Render $render
* @throws CM_Exception
*/
public function __construct(CM_Frontend_Render $render)
{
parent::__construct($render);
$this->addVariables();
$file = new CM_File(DIR_PUBLIC . 'static/css/library/icon.less');
if ($file->exists()) {
$this->add($file->read());
}
foreach (array_reverse($render->getSite()->getModules()) as $moduleName) {
foreach (array_reverse($render->getSite()->getThemes()) as $theme) {
foreach (CM_Util::rglob('*.less', $render->getThemeDir(true, $theme, $moduleName) . 'css/') as $path) {
$file = new CM_File($path);
$this->add($file->read());
}
}
}
$viewClasses = CM_View_Abstract::getClassChildren(true);
foreach ($viewClasses as $viewClassName) {
$validModule = in_array(CM_Util::getNamespace($viewClassName), $render->getSite()->getModules());
$validViewClass = $this->_isValidViewClass($viewClassName);
if ($validModule && $validViewClass) {
$asset = new CM_Asset_Css_View($this->_render, $viewClassName);
$this->add($asset->_getContent());
}
}
}
示例2: testGetNamespace
public function testGetNamespace()
{
$this->assertInternalType('string', CM_Util::getNamespace('CM_Util'));
$this->assertNull(CM_Util::getNamespace('NoNamespace', true));
try {
CM_Util::getNamespace('NoNamespace', false);
$this->fail('Namespace detected in a className without namespace.');
} catch (CM_Exception_Invalid $ex) {
$this->assertContains('Could not detect namespace of `NoNamespace`.', $ex->getMessage());
}
}
示例3: _generatePageContent
/**
* @param ReflectionClass $reflection
* @return null|string
*/
protected function _generatePageContent(ReflectionClass $reflection)
{
if ($reflection->isSubclassOf('CM_Page_Abstract')) {
$parentClassName = $reflection->getParentClass()->getName();
$content = "{extends file=\$render->getLayoutPath('" . $this->_extractTemplateName($parentClassName) . "default.tpl'";
if ($reflection->isAbstract()) {
$namespace = CM_Util::getNamespace($parentClassName);
$content .= ", '" . $namespace . "'";
}
$content .= ")}\n";
return $content;
}
return null;
}
示例4: _getClassNamespace
/**
* @throws CM_Exception_Invalid
* @return string
*/
protected static function _getClassNamespace()
{
return CM_Util::getNamespace(get_called_class());
}
示例5: createSite
/**
* @param string $className
* @param string $name
* @param string $domain
* @throws CM_Exception_Invalid
*/
public function createSite($className, $name, $domain)
{
$appInstallation = $this->_getAppInstallation();
$generatorPhp = new CM_Tools_Generator_Class_Php($appInstallation, $this->_getStreamOutput());
$generatorConfig = new CM_Tools_Generator_Config($appInstallation, $this->_getStreamOutput());
$moduleName = CM_Util::getNamespace($className);
$parentClassName = $generatorPhp->getParentClassName($className);
if (!is_a($parentClassName, 'CM_Site_Abstract', true)) {
throw new CM_Exception_Invalid('Detected parent className `' . $parentClassName . '` is not a `CM_Site_Abstract`.');
}
$classBlock = $generatorPhp->createClass($className);
$classBlock->addMethod(new \CodeGenerator\MethodBlock('__construct', "parent::__construct();\n\$this->_setModule('{$moduleName}');"));
$generatorPhp->createClassFileFromClass($classBlock);
$modulePath = $appInstallation->getModulePath($moduleName);
$file = new CM_File($modulePath . 'resources/config/default.php', $appInstallation->getFilesystem());
$config = new CM_Config_Node();
$config->{$className}->name = $name;
$config->{$className}->emailAddress = 'hello@' . $domain;
$generatorConfig->addEntries($file, $config);
$file = new CM_File('resources/config/local.php', $appInstallation->getFilesystem());
$config = new CM_Config_Node();
$config->{$className}->url = 'http://www.' . $domain;
$config->{$className}->urlCdn = 'http://origin-www.' . $domain;
$generatorConfig->addEntries($file, $config);
(new CM_App_Cli())->generateConfigInternal();
}
示例6: _getClassPath
/**
* @param string $className
* @return string
* @throws CM_Exception_Invalid
*/
protected function _getClassPath($className)
{
$namespace = CM_Util::getNamespace($className);
$namespacePath = $this->_appInstallation->getNamespacePath($namespace);
return $namespacePath . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
}
示例7: getNameByClassName
/**
* @param string $className
* @return string
*/
public static function getNameByClassName($className)
{
return str_replace('_', ' ', str_replace(CM_Util::getNamespace($className) . '_Action_', '', $className));
}