本文整理汇总了PHP中Zend_Filter_Inflector类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Inflector类的具体用法?PHP Zend_Filter_Inflector怎么用?PHP Zend_Filter_Inflector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Filter_Inflector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterText
public function filterText($text)
{
$inflector = new Zend_Filter_Inflector(':text');
$inflector->setRules(array(':text' => array(new Zend_Filter_StringToLower(), new Zend_Filter_StripTags(), new Zend_Filter_Word_DashToSeparator(), new Zend_Filter_Word_SeparatorToSeparator('/', '_'), new Zend_Filter_Word_UnderscoreToSeparator(), new Zend_Filter_StringTrim(), new Zend_Filter_Alnum(true), new Zend_Filter_Word_SeparatorToSeparator(' ', '_'))));
$text = $inflector->filter(array('text' => $text));
return $text;
}
示例2: generateSlug
public function generateSlug($rawSlug)
{
$inflector = new Zend_Filter_Inflector(':slug');
$inflector->setRules(array(':slug' => array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim(), new Zend_Filter_StripTags(), new Zend_Filter_Word_DashToSeparator(), new Zend_Filter_PregReplace(array('match' => '/[^A-Za-z0-9]/', 'replace' => ' ')), new Zend_Filter_Alnum(true), new Zend_Filter_Word_SeparatorToDash())));
$slug = $inflector->filter(array('slug' => $rawSlug));
return $slug;
}
示例3: getViewRenderer
/**
* Retrieves the view renderer object
*
* @return Zend_Controller_Action_Helper_ViewRenderer|null
* @throws Glitch_Application_Resource_Exception
*/
public function getViewRenderer()
{
if (null === $this->_viewRenderer) {
// Pull in the front controller; bootstrap first if necessary
$this->_bootstrap->bootstrap('FrontController');
$front = $this->_bootstrap->getResource('FrontController');
// Ignore if no view renderer is to be used
if ($front->getParam('noViewRenderer')) {
return null;
}
// Get existing renderer, if any, or create a new one
$this->_viewRenderer = Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer') ? Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer') : new $this->_className(null, $this->getOptions());
// Dynamic class loading; perform sanity check
if (!$this->_viewRenderer instanceof Zend_Controller_Action_Helper_ViewRenderer) {
throw new Glitch_Application_Resource_Exception('Class is not a valid view renderer instance');
}
// Register the view as the default view for handling view scripts
$this->_bootstrap->bootstrap('View');
$view = $this->_bootstrap->getResource('View');
$this->_viewRenderer->setView($view);
// It is paramount to set this base path spec: ZF otherwise uses its own
// spec, causing it to create a path to a conventional ZF-style directory
$this->_viewRenderer->setViewBasePathSpec(':module/' . Glitch_View::PATH_VIEW);
// Set empty inflector settings: all path translations are handled by the custom dispatcher
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array(), ':controller' => array(), ':action' => array()));
$this->_viewRenderer->setInflector($inflector, true);
if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::addHelper($this->_viewRenderer);
}
}
return $this->_viewRenderer;
}
示例4: _transformColumn
/**
* Inflektor pro ziskani nazvu atributu
* camelCase -> under_score
*
* @param string $columnName
* @return string
*/
protected function _transformColumn($columnName)
{
$inflector = new Zend_Filter_Inflector(":string");
$inflector->setRules(array(':string' => array('Word_CamelCaseToUnderscore', 'StringToLower')));
$columnName = $inflector->filter(array('string' => $columnName));
return $columnName;
}
示例5: _dasherise
/**
* Uses Zend's inflector rules to convert from class names to url segments
*
* @param string $name
* @return string
*/
protected function _dasherise($name)
{
$name = str_replace('Action', '', $name);
$inflector = new Zend_Filter_Inflector(':name');
$inflector->setRules(array(':name' => array('Word_CamelCaseToDash', 'StringToLower')));
return $inflector->filter(array('name' => $name));
}
示例6: _initView
protected function _initView()
{
// Start initail view
$this->bootstrap('layout');
$config = $this->getOption('views');
$resources = $this->getOption('resources');
$view = new Zend_View();
if (isset($resources['layout']['layoutPath'])) {
$view->assign('layoutRootPath', $resources['layout']['layoutPath']);
}
$this->bootstrap('db');
Zend_Loader::loadClass('Ht_Utils_SystemSetting');
$sysSetting = Ht_Utils_SystemSetting::getSettings();
$view->assign('sysSetting', $sysSetting);
$view->assign('profile', Zend_Auth::getInstance()->getIdentity());
Zend_Loader::loadClass("Ht_Model_SystemSetting");
$this->setSystemLogConfiguration($sysSetting);
// use the viewrenderer to keep the code DRY
// instantiate and add the helper in one go
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
$viewRenderer->setViewSuffix('phtml');
// add it to the action helper broker
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/**
* Set inflector for Zend_Layout
*/
$inflector = new Zend_Filter_Inflector(':script.:suffix');
$inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
// Initialise Zend_Layout's MVC helpers
$this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
return $this->getResource('layout')->getView();
}
示例7: getInflector
/**
* Get path inflector
* @return Zend_Filter_Inflector
*/
public static function getInflector()
{
if (null === self::$_inflector) {
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\\./', '-')), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower')))->setTarget('../application/modules/:module/views/scripts/:controller/:action.xsl');
self::setInflector($inflector);
}
return self::$_inflector;
}
示例8: getInflector
/**
* Get Inflector to use determing correct class name
*
* @return Zend_Filter_Inflector
*/
public function getInflector()
{
if (null === $this->_inflector) {
$filters = array('Word_DashToCamelCase', new Zend_Filter_Callback('ucfirst'));
$inflector = new Zend_Filter_Inflector(':module_Model_Service_:name');
$inflector->setRules(array(':module' => $filters, ':name' => $filters));
$this->_inflector = $inflector;
}
return $this->_inflector;
}
示例9: __construct
public function __construct($config = array())
{
parent::__construct($config);
// strip filename_orig from weird characters and transform underscores to camelcase
$pattern = '/(.*[\\\\\\/])?(.*)$/';
preg_match($pattern, $this->filename_orig, $matches);
$sanatized = str_replace(array(' ', ':', '*', '?', '"', '<', '>', '|'), '_', $matches[2]);
$inflector = new Zend_Filter_Inflector(':name');
$inflector->setRules(array(':name' => array('Word_UnderscoreToCamelCase')));
$filtered = $inflector->filter(array('name' => $sanatized));
$this->filename_orig = $filtered;
}
示例10: getInflector
/**
* Get inflector
*
* @return Zend_Filter_Inflector
*/
public function getInflector()
{
if (null === $this->_inflector) {
$this->_inflector = new Zend_Filter_Inflector();
$this->_inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\\./', '-')), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower')));
}
return $this->_inflector;
}
示例11: setInflector
/**
* Set inflector
*
* @param Zend_Filter_Inflector $inflector
* @param boolean $reference Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
* @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
*/
public function setInflector(Zend_Filter_Inflector $inflector, $reference = false)
{
$this->_inflector = $inflector;
if ($reference) {
$this->_inflector->setStaticRuleReference('suffix', $this->_viewSuffix)->setStaticRuleReference('moduleDir', $this->_moduleDir)->setTargetReference($this->_inflectorTarget);
}
return $this;
}
示例12: testSetConfigSetsStateAndRules
public function testSetConfigSetsStateAndRules()
{
$config = $this->getConfig();
$inflector = new Zend_Filter_Inflector();
$inflector->setConfig($config);
$this->_testOptions($inflector);
}
示例13: testNoInflectableTarget
/**
* @issue ZF-2964
*/
public function testNoInflectableTarget()
{
$inflector = new Zend_Filter_Inflector('abc');
$inflector->addRules(array(':foo' => array()));
$this->assertEquals($inflector->filter(array('fo' => 'bar')), 'abc');
}
示例14: testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag
public function testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag()
{
$this->request->setModuleName('bar')->setControllerName('index')->setActionName('test');
$controller = new Bar_IndexController($this->request, $this->response, array());
$this->helper->view->addBasePath($this->basePath . '/_files/modules/bar/views');
require_once 'Zend/Filter/PregReplace.php';
require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
$inflector = new Zend_Filter_Inflector('test.phtml');
$inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'stringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator(DIRECTORY_SEPARATOR), 'StringToLower'), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('/[^a-z0-9]+/i', '-'), 'StringToLower')));
$this->helper->setInflector($inflector, true);
$this->helper->render();
$body = $this->response->getBody();
$this->assertContains('Rendered index/test.phtml in bar module', $body);
}
示例15: _getInflected
/**
* Inflect the name using the inflector filter
*
* Changes camelCaseWord to Camel_Case_Word
*
* @param string $name The name to inflect
* @return string The inflected string
*/
private function _getInflected($name)
{
$inflector = new Zend_Filter_Inflector(':class');
$inflector->setRules(array(':class' => array('Word_CamelCaseToUnderscore')));
return ucfirst($inflector->filter(array('class' => $name)));
}