当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Filter_Inflector::addRules方法代码示例

本文整理汇总了PHP中Zend_Filter_Inflector::addRules方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Inflector::addRules方法的具体用法?PHP Zend_Filter_Inflector::addRules怎么用?PHP Zend_Filter_Inflector::addRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Filter_Inflector的用法示例。


在下文中一共展示了Zend_Filter_Inflector::addRules方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: _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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: preDispatch

 public function preDispatch()
 {
     $request = $this->getRequest();
     if (Axis_Area::isFrontend()) {
         if (!Axis::getCustomerId() && $this->getActionController() instanceof Axis_Account_Controller_Abstract) {
             $request->setModuleName('Axis_Account')->setControllerName('auth')->setActionName('index')->setDispatched(false);
         }
         return;
     }
     if (!Axis_Area::isBackend()) {
         return;
     }
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('admin'));
     if (in_array($request->getControllerName(), array('auth', 'forgot')) && 'Axis_Admin' === $request->getModuleName()) {
         return;
     }
     if (!$auth->hasIdentity()) {
         if ($request->isXmlHttpRequest()) {
             Axis::message()->addError(Axis::translate('admin')->__('Your session has been expired. Please relogin'));
             $jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
             $jsonHelper->sendFailure();
             return;
         }
         $request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('index')->setDispatched(false);
         return;
     }
     $user = Axis::single('admin/user')->find($auth->getIdentity())->current();
     if (!$user) {
         $request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('logout')->setDispatched(false);
         return;
     }
     $acl = new Zend_Acl();
     // add resources
     $resources = Axis::model('admin/acl_resource')->toFlatTree();
     foreach ($resources as $resource) {
         $parent = $resource['parent'];
         try {
             $acl->addResource($resource['id'], $parent);
         } catch (Zend_Acl_Exception $e) {
             Axis::message()->addError($e->getMessage());
         }
     }
     //add role(s)
     $role = (string) $user->role_id;
     $acl->addRole($role);
     //add permission
     $rowset = Axis::single('admin/acl_rule')->select('*')->where('role_id = ?', $role)->fetchRowset();
     foreach ($rowset as $row) {
         if (!$acl->has($row->resource_id)) {
             // $row->delete(); // remove invalid rule
             continue;
         }
         $action = 'deny';
         if ('allow' === $row->permission) {
             $action = 'allow';
         }
         try {
             $acl->{$action}($row->role_id, $row->resource_id);
         } catch (Zend_Acl_Exception $e) {
             Axis::message()->addError($e->getMessage());
         }
     }
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
     if (in_array($request->getControllerName(), array('error')) && 'Axis_Admin' === $request->getModuleName()) {
         return;
     }
     //get current resource by request
     $request = $this->getRequest();
     $inflector = new Zend_Filter_Inflector();
     $resource = $inflector->addRules(array(':module' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', 'StringToLower', new Zend_Filter_PregReplace('/admin_/', '')), ':action' => array('Word_CamelCaseToDash', 'StringToLower')))->setTarget('admin/:module/:controller/:action')->filter($request->getParams());
     if (!$acl->has($resource) || $acl->isAllowed($role, $resource)) {
         return;
     }
     if ($request->isXmlHttpRequest()) {
         Axis::message()->addError(Axis::translate('admin')->__('You have no permission for this operation'));
         $jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
         $jsonHelper->sendFailure();
         return;
     }
     $request->setModuleName('Axis_Admin')->setControllerName('error')->setActionName('access-denied')->setDispatched(false);
 }
开发者ID:rguedes,项目名称:axiscommerce,代码行数:83,代码来源:Auth.php

示例8: getInflector

 /**
  * Get inflector
  * 
  * @return Zend_Filter_Inflector
  */
 public function getInflector()
 {
     if (null === $this->_inflector) {
         require_once 'Zend/Filter/Inflector.php';
         require_once 'Zend/Filter/PregReplace.php';
         require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
         $this->_inflector = new Zend_Filter_Inflector();
         $this->_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')))->setStaticRuleReference('suffix', $this->_viewSuffix)->setStaticRuleReference('moduleDir', $this->_moduleDir)->setTargetReference($this->_inflectorTarget);
     }
     // Ensure that module directory is current
     $this->getModuleDirectory();
     return $this->_inflector;
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:18,代码来源:ViewRenderer.php

示例9: __construct

 /**
  * Constructor
  *
  * Accepts either:
  * - A string path to layouts
  * - An array of options
  * - A Zend_Config object with options
  *
  * Layout script path, either as argument or as key in options, is 
  * required.
  *
  * If mvcEnabled flag is false from options, simply sets layout script path. 
  * Otherwise, also instantiates and registers action helper and controller 
  * plugin.
  * 
  * @param  string|array|Zend_Config $options 
  * @return void
  */
 public function __construct($options = null, $initMvc = false)
 {
     if (null !== $options) {
         if (is_string($options)) {
             $this->setLayoutPath($options);
         } elseif (is_array($options)) {
             $this->setOptions($options);
         } elseif ($options instanceof Zend_Config) {
             $this->setConfig($options);
         } else {
             require_once 'Zend/Layout/Exception.php';
             throw new Zend_Layout_Exception('Invalid option provided to constructor');
         }
     }
     $this->_initVarContainer();
     if ($initMvc) {
         $this->_setMvcEnabled(true);
         $this->_initMvc();
     } else {
         $this->_setMvcEnabled(false);
     }
     if (null === $this->getInflector()) {
         require_once 'Zend/Filter/Inflector.php';
         $inflector = new Zend_Filter_Inflector(':script.:suffix');
         $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
         $this->setInflector($inflector);
     }
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:46,代码来源:Layout.php


注:本文中的Zend_Filter_Inflector::addRules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。