當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Filter_Inflector類代碼示例

本文整理匯總了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;
 }
開發者ID:rantoine,項目名稱:AdvisorIllustrator,代碼行數:7,代碼來源:CacheFilter.php

示例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;
 }
開發者ID:rantoine,項目名稱:AdvisorIllustrator,代碼行數:7,代碼來源:Slug.php

示例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;
 }
開發者ID:nstapelbroek,項目名稱:Glitch_Lib,代碼行數:39,代碼來源:Viewrenderer.php

示例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;
 }
開發者ID:cngroupdk,項目名稱:InterviewMe_Tym3,代碼行數:14,代碼來源:Row.php

示例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));
 }
開發者ID:jara,項目名稱:jara-base,代碼行數:13,代碼來源:StaticRoutes.php

示例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();
 }
開發者ID:kangza,項目名稱:hagtag,代碼行數:33,代碼來源:Bootstrap.php

示例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;
 }
開發者ID:kandy,項目名稱:system,代碼行數:13,代碼來源:PartialRenderer.php

示例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;
 }
開發者ID:JurJean,項目名稱:waf-model,代碼行數:15,代碼來源:Service.php

示例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;
 }
開發者ID:br00k,項目名稱:tnc-web,代碼行數:12,代碼來源:Item.php

示例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;
 }
開發者ID:kandy,項目名稱:system,代碼行數:13,代碼來源:SmartyStack.php

示例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;
 }
開發者ID:bcsgarcia,項目名稱:LojaTeste,代碼行數:15,代碼來源:ViewRenderer.php

示例12: testSetConfigSetsStateAndRules

 public function testSetConfigSetsStateAndRules()
 {
     $config = $this->getConfig();
     $inflector = new Zend_Filter_Inflector();
     $inflector->setConfig($config);
     $this->_testOptions($inflector);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:7,代碼來源:InflectorTest.php

示例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');
 }
開發者ID:lortnus,項目名稱:zf1,代碼行數:9,代碼來源:InflectorTest.php

示例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);
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:14,代碼來源:ViewRendererTest.php

示例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)));
 }
開發者ID:shadobladez,項目名稱:erp2,代碼行數:14,代碼來源:Abstract.php


注:本文中的Zend_Filter_Inflector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。