/** \Zend\Filter\CamelCaseToDash() => Thêm dấu gạch trước chữ in hoa*/ public function index15Action() { $filter = new \Zend\Filter\Word\CamelCaseToDash(); $input = 'ZendFrameworkIsEasy'; $output = $filter->filter($input); echo "<h3>" . $input . "</h3>"; echo "<h3>" . $output . "</h3>"; return false; }
public function __invoke($dataTypes, $browse = false) { $filter = new \Zend\Filter\Word\CamelCaseToDash(); $view = $this->getView(); $scripts = array(); $html = ''; foreach ($dataTypes as $key1 => $data) { if ($browse) { $array = $data['configuration']['browse']; } else { $array = $data['configuration']['sources']; } foreach ($array as $key2 => $source) { $scriptName = strtolower($filter->filter($source['control'])); if (!in_array($scriptName, $scripts)) { $view->inlineScript()->prependFile($view->basePath('js/controls/' . $scriptName . '.js')); array_push($scripts, $scriptName); } } } return $html; }
/** * Save file methods information to sysmap cache * * @param string $fileName */ protected function getControllerMap($module, $alias, $className) { $class = new \Zend\Code\Reflection\ClassReflection($className); if ($class->isSubclassOf('\\Zend\\Mvc\\Controller\\ActionController')) { $controller = new \Zend\Config\Config(array(), true); $controller->level = 2; if ('' != $class->getDocComment()) { $controller->longDescr = $class->getDocblock()->getLongDescription(); $controller->shortDescr = $class->getDocblock()->getShortDescription(); } $toDashFilter = new \Zend\Filter\Word\CamelCaseToDash(); $controller->name = $alias; $controller->module = $module; $controller->hash = md5($controller->module . '.' . $controller->name . '.*'); $actions = array(); foreach ($class->getMethods() as $method) { if ($method instanceof \Zend\Code\Reflection\MethodReflection) { $methodName = $method->getName(); if (strstr($method->getName(), $this->_actionSuffix) && !in_array($method->getName(), $this->skipedActions)) { $addIt = true; $action = new \Zend\Config\Config(array(), true); $action->level = 3; $action->name = strtolower($toDashFilter->filter(str_replace($this->_actionSuffix, '', $methodName))); $action->hash = md5($controller->module . '.' . $controller->name . '.' . $action->name); if ($method->getDocBlock() !== false) { $docBlock = $method->getDocblock(); $action->shortDescr = $docBlock->getShortDescription(); $action->longDescr = $docBlock->getLongDescription(); foreach ($docBlock->getTags() as $tag) { if ($tag->getName() == $this->_paramFormTag) { $action->{$this->_paramFormTag} = trim(str_replace('@' . $this->_paramFormTag, '', $tag->returnValue(0))); } if ($tag->getName() == $this->_hiddenFormTag) { $addIt = false; } } } if ($addIt) { $actions[$action->name] = $action; } } } } $controller->_childrens = $actions; } else { return false; } return $controller; }
/** * Push actions into application actions stack * @param int $id * @param Templater_Api_Interface_Widget $widget * @param string $placeholder * @param array $params */ protected function _pushStack($id, \Zend\Controller\Request\AbstractRequest $request, $placeholder, $params = array()) { $params[$this->_widgetIdName] = md5($id); $camelFilter = new \Zend\Filter\Word\CamelCaseToDash('-'); $blockRequest = new \Zend\Controller\Request\Simple(strtolower($camelFilter->filter($request->getActionName())), strtolower($camelFilter->filter($request->getControllerName())), strtolower($camelFilter->filter($request->getModuleName())), array_merge($params, array($this->_marker => $placeholder))); $this->_stack->pushStack($blockRequest); }