本文整理汇总了PHP中AgaviToolkit::canonicalName方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviToolkit::canonicalName方法的具体用法?PHP AgaviToolkit::canonicalName怎么用?PHP AgaviToolkit::canonicalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviToolkit
的用法示例。
在下文中一共展示了AgaviToolkit::canonicalName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Executes the task.
*/
public function main()
{
if ($this->property === null) {
throw new BuildException('The property attribute must be specified');
}
if ($this->string === null) {
throw new BuildException('The string attribute must be specified');
}
$result = str_replace('/', '_', AgaviToolkit::canonicalName($this->string));
$this->project->setUserProperty($this->property, $result);
}
示例2: getActionClass
private function getActionClass($moduleName, $actionName)
{
$actionName = AgaviToolkit::canonicalName($actionName);
$longActionName = str_replace('/', '_', $actionName);
$class = $moduleName . '_' . $longActionName . 'Action';
if (!class_exists($class)) {
if (false !== ($file = AppKitAgaviUtil::getAgaviControllerInstance()->checkActionFile($moduleName, $actionName))) {
require $file;
} else {
throw new AgaviException('Could not find file for Action "' . $actionName . '" in module "' . $moduleName . '"');
}
if (!class_exists($class, false)) {
throw new AgaviException('Could not find Action "' . $longActionName . '" for module "' . $moduleName . '"');
}
}
return $class;
}
示例3: assertViewForwards
/**
* assert that the view forwards to the given module/action
*
* @param string the expected module name
* @param string the expected action name
* @param string the message to emit on failure
*
* @author Felix Gilcher <felix.gilcher@bitextender.com>
* @since 1.0.0
*/
protected function assertViewForwards($expectedModule, $expectedAction, $message = 'Failed asserting that the view forwards to "%1$s" "%2$s".')
{
if (!$this->viewResult instanceof AgaviExecutionContainer) {
$this->fail(sprintf($message, $expectedModule, $expectedAction));
}
$this->assertEquals($expectedModule, $this->viewResult->getModuleName());
$this->assertEquals(AgaviToolkit::canonicalName($expectedAction), $this->viewResult->getActionName());
}
示例4: normalizeViewName
/**
* normalizes a viewname according to the configured rules
*
* Please do not use this method, it exists only for internal
* purposes and will be removed ASAP. You have been warned
*
* @param string the short view name
*
* @return string the full view name
*
* @author Felix Gilcher <felix.gilcher@bitextender.com>
* @since 1.0.0
*/
protected function normalizeViewName($shortName)
{
if ($shortName !== AgaviView::NONE) {
$shortName = AgaviToolkit::evaluateModuleDirective($this->moduleName, 'agavi.view.name', array('actionName' => $this->actionName, 'viewName' => $shortName));
$shortName = AgaviToolkit::canonicalName($shortName);
}
return $shortName;
}
示例5: getParametersForActionAndModule
/**
* Get validation information from agavi for the given action and module
* name for the request method 'read'.
*
* @author Jan Schütze <jans@dracoblue.de>
*
* @param string $action name of action
* @param string $module name of module
*
* @return array of parameters for all registered validators
*/
protected function getParametersForActionAndModule($action, $module, $method = 'read')
{
/*
* Agavi uses different coding standard, so we ignore the following...
*
* @codingStandardsIgnoreStart
*/
$parameters = array();
$this->getContext()->getController()->initializeModule($module);
$validationManager = $this->getContext()->createInstanceFor('validation_manager');
$validationConfig = \AgaviToolkit::evaluateModuleDirective($module, 'agavi.validate.path', array('moduleName' => $module, 'actionName' => \AgaviToolkit::canonicalName($action)));
if (is_readable($validationConfig)) {
require \AgaviConfigCache::checkConfig($validationConfig, $this->getContext()->getName());
}
foreach ($validationManager->getChilds() as $validator) {
$property = new \ReflectionProperty(get_class($validator), 'arguments');
$property->setAccessible(true);
$arguments = $property->getValue($validator);
$parameters[] = array('name' => implode(', ', $arguments), 'class' => $validator->getParameter('class'), 'required' => $validator->getParameter('required', 'true'), 'description' => $validator->getParameter('description', null), 'base' => $validator->getParameter('base', null));
}
/*
* @codingStandardsIgnoreEnd
*/
return $parameters;
}
示例6: getModel
/**
* Retrieve a Model implementation instance.
*
* @param string A model name.
* @param string A module name, if the requested model is a module model,
* or null for global models.
* @param array An array of parameters to be passed to initialize() or
* the constructor.
*
* @return AgaviModel A Model implementation instance.
*
* @throws AgaviAutloadException if class is ultimately not found.
*
* @author David Zülke <dz@bitxtender.com>
* @since 0.11.0
*/
public function getModel($modelName, $moduleName = null, array $parameters = null)
{
$origModelName = $modelName;
$modelName = AgaviToolkit::canonicalName($modelName);
$class = str_replace('/', '_', $modelName) . 'Model';
$file = null;
$rc = null;
if ($moduleName === null) {
// global model
// let's try to autoload that baby
if (!class_exists($class)) {
// it's not there. the hunt is on
$file = AgaviConfig::get('core.model_dir') . '/' . $modelName . 'Model.class.php';
}
} else {
try {
$this->controller->initializeModule($moduleName);
} catch (AgaviDisabledModuleException $e) {
// swallow, this will load the modules autoload but throw an exception
// if the module is disabled.
}
// module model
// alternative name
$class = $moduleName . '_' . $class;
// let's try to autoload the baby
if (!class_exists($class)) {
// it's not there. the hunt is on
$file = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/models/' . $modelName . 'Model.class.php';
}
}
if (null !== $file && is_readable($file)) {
require $file;
}
if (!class_exists($class)) {
// it's not there.
throw new AgaviAutoloadException(sprintf("Couldn't find class for Model %s", $origModelName));
}
// so if we're here, we found something, right? good.
$rc = new ReflectionClass($class);
if ($rc->implementsInterface('AgaviISingletonModel')) {
// it's a singleton
if (!isset($this->singletonModelInstances[$class])) {
// no instance yet, so we create one
if ($parameters === null || $rc->getConstructor() === null) {
// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
$this->singletonModelInstances[$class] = new $class();
} else {
// we use this approach so we can pass constructor params or if it doesn't have an initialize() method
$this->singletonModelInstances[$class] = $rc->newInstanceArgs($parameters);
}
}
$model = $this->singletonModelInstances[$class];
} else {
// create an instance
if ($parameters === null || $rc->getConstructor() === null) {
// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
$model = new $class();
} else {
// we use this approach so we can pass constructor params or if it doesn't have an initialize() method
$model = $rc->newInstanceArgs($parameters);
}
}
if (is_callable(array($model, 'initialize'))) {
// pass the constructor params again. dual use for the win
$model->initialize($this, (array) $parameters);
}
return $model;
}
示例7: testCanonicalName
public function testCanonicalName()
{
$this->assertEquals('path', AgaviToolkit::canonicalName("path"));
$this->assertEquals('/path/warm/hot/unbearable', AgaviToolkit::canonicalName("/path/warm/hot/unbearable"));
$this->assertEquals('path/warm/hot/unbearable', AgaviToolkit::canonicalName("path.warm.hot.unbearable"));
$this->assertEquals('/path//warm/hot///unbearable', AgaviToolkit::canonicalName(".path..warm.hot...unbearable"));
}
示例8: setViewName
/**
* Set the module name for this container.
*
* @param string A view name.
*
* @author David Zülke <dz@bitxtender.com>
* @since 0.11.0
*/
public function setViewName($viewName)
{
if (null === $viewName) {
$this->viewName = null;
} elseif (preg_match(self::SANE_VIEW_NAME, $viewName)) {
$viewName = AgaviToolkit::canonicalName($viewName);
$this->viewName = $viewName;
} else {
throw new AgaviException(sprintf('Invalid view name "%1$s"', $viewName));
}
}
示例9: modelExists
/**
* Indicates whether or not a module has a specific model.
*
* @param string A module name.
* @param string A model name.
*
* @return bool true, if the model exists, otherwise false.
*
* @author Sean Kerr <skerr@mojavi.org>
* @since 0.9.0
*/
public function modelExists($moduleName, $modelName)
{
$modelName = AgaviToolkit::canonicalName($modelName);
$file = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/models/' . $modelName . 'Model.class.php';
return is_readable($file);
}