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


PHP ServiceUtil::get方法代码示例

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


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

示例1: setup

 /**
  * Post constructor hook.
  *
  * @return void
  */
 public function setup()
 {
     $this->view = \Zikula_View::getInstance(self::MODULENAME, false);
     // set caching off
     $this->_em = \ServiceUtil::get('doctrine.entitymanager');
     $this->domain = \ZLanguage::getModuleDomain(self::MODULENAME);
 }
开发者ID:Kaik,项目名称:KaikMediaGallery,代码行数:12,代码来源:MediaHandlers.php

示例2: smarty_function_selectmodobject

/**
 * render plugin for fetching a particular module object
 *
 * Examples
 *   {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
 *   {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
 *   {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  id          Identifier of desired object
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobject($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
    }
    if (!isset($params['assign']) || empty($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $class = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
        // intantiate object model
        $object = new $class();
        $idField = $object->getIDField();
        // assign object data
        // this performs a new database select operation
        // while the result will be saved within the object, we assign it to a local variable for convenience
        $objectData = $object->get(intval($params['id']), $idField);
        if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    } else {
        if ($params['recordClass'] instanceof \Doctrine_Record) {
            $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
            if ($objectData === false) {
                $view->trigger_error(__('Sorry! No such item found.'));
            }
        } else {
            /** @var $em Doctrine\ORM\EntityManager */
            $em = \ServiceUtil::get('doctrine.entitymanager');
            $result = $em->getRepository($params['recordClass'])->find($params['id']);
            $objectData = $result->toArray();
        }
    }
    $view->assign($params['assign'], $objectData);
}
开发者ID:Silwereth,项目名称:core,代码行数:76,代码来源:function.selectmodobject.php

示例3: loadModuleAnnotations

 public static function loadModuleAnnotations($entityNamespace, $path)
 {
     /** @var $em EntityManager */
     $em = ServiceUtil::get('doctrine.orm.entity_manager');
     /** @var $ORMConfig Configuration */
     $ORMConfig = $em->getConfiguration();
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(ServiceUtil::get('annotation_reader'), array($path));
     $chain = $ORMConfig->getMetadataDriverImpl();
     // driver chain
     $chain->addDriver($annotationDriver, $entityNamespace);
 }
开发者ID:rmaiwald,项目名称:core,代码行数:11,代码来源:MigrationUtil.php

示例4: getLocalDir

 /**
  * Get the location of the local cache directory.
  *
  * @param string $dir The name of the directory to get.
  *
  * @return string Location of the cache directory.
  */
 public static function getLocalDir($dir = null)
 {
     $array = array();
     $tmpDir = ServiceUtil::get('service_container')->getParameter('temp_dir');
     $array[] = DataUtil::formatForOS($tmpDir, true);
     if (!is_null($dir)) {
         $array[] = DataUtil::formatForOS($dir);
     }
     $path = implode('/', $array);
     return $path;
 }
开发者ID:Silwereth,项目名称:core,代码行数:18,代码来源:CacheUtil.php

示例5: getCookie

 /**
  * Get a cookie.
  *
  * @param string  $name    Name of cookie.
  * @param boolean $signed  Override system setting to use signatures.
  * @param boolean $default Default value.
  *
  * @return mixed Cookie value as string or bool false.
  */
 public static function getCookie($name, $signed = true, $default = '')
 {
     $request = \ServiceUtil::get('request');
     if (!$request->cookies->has($name)) {
         return $default;
     }
     $cookie = $request->cookies->get($name);
     if (System::getVar('signcookies') && !$signed == false) {
         return SecurityUtil::checkSignedData($cookie);
     }
     return $cookie;
 }
开发者ID:Silwereth,项目名称:core,代码行数:21,代码来源:CookieUtil.php

示例6: getService

 protected function getService($name)
 {
     if ($name == 'doctrine.entitymanager') {
         return \ServiceUtil::get($name);
     } else {
         if ($name == 'doctrine.connection') {
             return \ServiceUtil::get('doctrine.entitymanager')->getConnection();
         } else {
             return null;
         }
     }
 }
开发者ID:rtznprmpftl,项目名称:Zikulacore,代码行数:12,代码来源:DoctrineRegistryImpl.php

示例7: getUrl

 public function getUrl($ssl = null, $fqUrl = null)
 {
     $router = \ServiceUtil::get('router');
     $fqUrl = is_bool($fqUrl) && $fqUrl ? RouterInterface::ABSOLUTE_URL : RouterInterface::ABSOLUTE_PATH;
     $fragment = !empty($this->fragment) ? '#' . $this->fragment : '';
     $oldScheme = $router->getContext()->getScheme();
     if ($ssl) {
         $router->getContext()->setScheme('https');
     }
     $url = $router->generate($this->route, $this->args, $fqUrl) . $fragment;
     if ($ssl) {
         $router->getContext()->setScheme($oldScheme);
     }
     return $url;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:15,代码来源:RouteUrl.php

示例8: getJSConfig

 /**
  * Generate a configuration for javascript and return script tag to embed in HTML HEAD.
  *
  * @return string HTML code with script tag
  */
 public static function getJSConfig()
 {
     $return = '';
     $config = array('entrypoint' => System::getVar('entrypoint', 'index.php'), 'baseURL' => System::getBaseUrl(), 'baseURI' => System::getBaseUri() . '/', 'ajaxtimeout' => (int) System::getVar('ajaxtimeout', 5000), 'lang' => ZLanguage::getLanguageCode(), 'sessionName' => session_name(), 'uid' => (int) UserUtil::getVar('uid'));
     $polyfill_features = PageUtil::getVar('polyfill_features');
     // merge in features added via twig
     $featuresFromTwig = ServiceUtil::get('zikula_core.common.theme.pagevars')->get('polyfill_features', []);
     $polyfill_features = array_unique(array_merge($polyfill_features, $featuresFromTwig));
     if (!empty($polyfill_features)) {
         $config['polyfillFeatures'] = implode(' ', $polyfill_features);
     }
     $config = DataUtil::formatForDisplay($config);
     $return .= "<script type=\"text/javascript\">/* <![CDATA[ */ \n";
     if (System::isLegacyMode()) {
         $return .= 'document.location.entrypoint="' . $config['entrypoint'] . '";';
         $return .= 'document.location.pnbaseURL="' . $config['baseURL'] . '"; ';
         $return .= 'document.location.ajaxtimeout=' . $config['ajaxtimeout'] . ";\n";
     }
     $return .= "if (typeof(Zikula) == 'undefined') {var Zikula = {};}\n";
     $return .= "Zikula.Config = " . json_encode($config) . "\n";
     $return .= ' /* ]]> */</script>' . "\n";
     return $return;
 }
开发者ID:Silwereth,项目名称:core,代码行数:28,代码来源:JCSSUtil.php

示例9: registerPermissionError

 /**
  * Register a failed permission check.
  *
  * This method calls registerError and then logs the failed permission check so that it can be analyzed later.
  *
  * @param string  $url      The URL to redirect to (optional) (default=null).
  * @param boolean $redirect Whether to redirect not logged in users to the login form (default=true).
  *
  * @return false
  */
 public static function registerPermissionError($url = null, $redirect = true)
 {
     $code = 403;
     if (!UserUtil::isLoggedIn() && $redirect) {
         if (is_null($url)) {
             $request = ServiceUtil::get('request');
             $loginArgs = array();
             if ($request->isMethod('GET')) {
                 $loginArgs['returnpage'] = urlencode(System::getCurrentUri());
             }
             $url = ModUtil::url('ZikulaUsersModule', 'user', 'login', $loginArgs);
         }
         $code = null;
     }
     return self::registerError(self::getErrorMsgPermission(), $code, $url);
 }
开发者ID:Silwereth,项目名称:core,代码行数:26,代码来源:LogUtil.php

示例10: show

 /**
  * Show a block.
  *
  * @param string $modname Module name.
  * @param string $blockname Name of the block.
  * @param array $blockinfo Information parameters.
  * @param null $blockEntity
  * @return mixed Blockinfo array or null.
  */
 public static function show($modname, $blockname, $blockinfo = array(), $blockEntity = null)
 {
     global $blocks_modules;
     $content = '';
     $blockInstance = self::load($modname, $blockname);
     $displayfunc = array($blockInstance, 'display');
     $blockEntity = isset($blockEntity) ? $blockEntity : ServiceUtil::get('doctrine.entitymanager')->find('Zikula\\BlocksModule\\Entity\\BlockEntity', $blockinfo['bid']);
     $instanceArgs = $blockInstance instanceof AbstractBlockController ? $blockEntity->getContent() : $blockinfo;
     if (is_callable($displayfunc)) {
         $content = call_user_func($displayfunc, $instanceArgs);
     }
     if ($blockInstance instanceof AbstractBlockController) {
         // FC blocks require wrapping the content in the theme
         $blockinfo['content'] = $content;
         $content = Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
     }
     return $content;
 }
开发者ID:Silwereth,项目名称:core,代码行数:27,代码来源:BlockUtil.php

示例11: getSelector_EntityArray

 /**
  * Creates an Entity array selector.
  *
  * @param string  $modname        Module name.
  * @param string  $entity         Doctrine 2 entity classname.
  * @param string  $name           Select field name.
  * @param string  $field          Value field.
  * @param string  $displayField   Display field.
  * @param string  $where          Where clause.
  * @param string  $sort           Sort clause.
  * @param string  $selectedValue  Selected value.
  * @param string  $defaultValue   Value for "default" option.
  * @param string  $defaultText    Text for "default" option.
  * @param string  $allValue       Value for "all" option.
  * @param string  $allText        Text for "all" option.
  * @param string  $displayField2  Second display field.
  * @param boolean $submit         Submit on choose.
  * @param boolean $disabled       Add Disabled attribute to select.
  * @param string  $fieldSeparator Field seperator if $displayField2 is given.
  * @param integer $multipleSize   Size for multiple selects.
  *
  * @return string The rendered output.
  */
 public static function getSelector_EntityArray($modname, $entity, $name, $field = '', $displayField = 'name', $where = '', $sort = '', $selectedValue = '', $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $displayField2 = null, $submit = true, $disabled = false, $fieldSeparator = ', ', $multipleSize = 1)
 {
     if (!$modname) {
         throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_EntityArray')));
     }
     if (!$entity || !class_exists($entity)) {
         throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('entity', 'HtmlUtil::getSelector_EntityArray')));
     }
     if (!SecurityUtil::checkPermission("{$entity}::", '::', ACCESS_OVERVIEW)) {
         return __f('Security check failed for %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_EntityArray'));
     }
     /** @var $em \Doctrine\ORM\EntityManager */
     $em = ServiceUtil::get('doctrine.entitymanager');
     $qb = $em->createQueryBuilder();
     $qb->select('e')->from($entity, 'e');
     $dataArray = $qb->getQuery()->getResult();
     // array of Entities
     // @todo does not accommodate $sort or $where
     $data2 = array();
     foreach ($dataArray as $object) {
         $val = $object[$field];
         // relies on entityAccess
         $disp = $object[$displayField];
         if ($displayField2) {
             $disp .= $fieldSeparator . $object[$displayField2];
         }
         $data2[$val] = $disp;
     }
     return self::getSelector_Generic($name, $data2, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize);
 }
开发者ID:Silwereth,项目名称:core,代码行数:53,代码来源:HtmlUtil.php

示例12: getRegisteredModuleCategoriesIds

 /**
  * Get the IDs of the property registers.
  *
  * @param string $modname       The module name.
  * @param string $entityname    The entity name for which we wish to get the property for.
  *
  * @return array The associative field array of register ids for the specified module.
  */
 public static function getRegisteredModuleCategoriesIds($modname, $entityname)
 {
     if (!$modname || !$entityname) {
         return z_exit(__f("Error! Received invalid specifications %1{$s}, %2{$s}.", array($modname, $entityname)));
     }
     $em = \ServiceUtil::get('doctrine')->getManager();
     $rCategories = $em->getRepository('Zikula\\Core\\Doctrine\\Entity\\CategoryRegistry')->findBy(array('modname' => $modname, 'entityname' => $entityname));
     $fArr = array();
     foreach ($rCategories as $rCategory) {
         $fArr[$rCategory['property']] = $rCategory['id'];
     }
     return $fArr;
 }
开发者ID:rtznprmpftl,项目名称:Zikulacore,代码行数:21,代码来源:CategoryRegistryUtil.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param Zikula_ServiceManager $serviceManager ServiceManager.
  * @param string                $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
 {
     $this->serviceManager = $serviceManager;
     $this->eventManager = $this->serviceManager->get('event_dispatcher');
     $this->request = \ServiceUtil::get('request');
     // set the error reporting level
     $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
     $this->error_reporting &= ~E_USER_DEPRECATED;
     $this->allow_php_tag = true;
     // get variables from input
     $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     // set vars based on the module structures
     $this->homepage = PageUtil::isHomepage();
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $theme = $this->themeinfo['directory'];
     $themeBundle = ThemeUtil::getTheme($this->themeinfo['name']);
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPathNew = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         default:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir('lib/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir(isset($themeBundle) ? $themeBundle->getRelativePath() . '/plugins' : "themes/{$theme}/plugins");
     // Theme plugins
     $this->addPluginDir('plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPathNew);
     // Plugins for current module
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin or adminplugin
     $legacyControllerType = FormUtil::getPassedValue('lct', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     if ($type === 'admin' || $type === 'adminplugin' || $legacyControllerType === 'admin') {
         // include plugins of the Admin module to the plugins_dir array
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     // theme plugins module overrides
     $themePluginsPath = isset($themeBundle) ? $themeBundle->getRelativePath() . '/modules/$moduleName/plugins' : "themes/{$theme}/templates/modules/{$moduleName}/plugins";
     $this->addPluginDir($themePluginsPath);
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('ZikulaThemeModule', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
//.........这里部分代码省略.........
开发者ID:Silwereth,项目名称:core,代码行数:101,代码来源:View.php

示例14: delVar

 /**
  * The delVar method deletes a module variable.
  *
  * Delete a module variables. If the optional name parameter is not supplied all variables
  * for the module 'modname' are deleted.
  *
  * @param string $modname The name of the module.
  * @param string $name    The name of the variable (optional).
  *
  * @return boolean True if successful, false otherwise.
  */
 public static function delVar($modname, $name = '')
 {
     // define input, all numbers and booleans to strings
     if ('ZConfig' !== $modname) {
         $modname = preg_match('/\\w+Module$/', $modname) || !$modname ? $modname : $modname . 'Module';
     }
     $modname = isset($modname) ? (string) $modname : '';
     // validate
     if (!System::varValidate($modname, 'modvar')) {
         return false;
     }
     $val = null;
     if (!isset(self::$modvars[$modname])) {
         return $val;
     }
     if (empty($name)) {
         if (array_key_exists($modname, self::$modvars)) {
             unset(self::$modvars[$modname]);
         }
     } else {
         if (array_key_exists($name, self::$modvars[$modname])) {
             $val = self::$modvars[$modname][$name];
             // we're dealing with an ArrayObject, so we cannot unset() deep keys.
             $array = self::$modvars[$modname];
             unset($array[$name]);
             self::$modvars[$modname] = $array;
         }
     }
     $em = ServiceUtil::get('doctrine')->getEntityManager();
     // if $name is not provided, delete all variables of this module
     // else just delete this specific variable
     if (empty($name)) {
         $dql = "DELETE FROM Zikula\\Core\\Doctrine\\Entity\\ExtensionVar v WHERE v.modname = '{$modname}'";
     } else {
         $dql = "DELETE FROM Zikula\\Core\\Doctrine\\Entity\\ExtensionVar v WHERE v.modname = '{$modname}' AND v.name = '{$name}'";
     }
     $query = $em->createQuery($dql);
     $result = $query->getResult();
     return (bool) $result;
 }
开发者ID:rtznprmpftl,项目名称:Zikulacore,代码行数:51,代码来源:ModUtil.php

示例15: queryStringDecode

 /**
  * Decode the path string into a set of variable/value pairs.
  *
  * This API works in conjunction with the new short urls
  * system to extract a path based variable set into the Get, Post
  * and request superglobals.
  * A sample path is /modname/function/var1:value1.
  *
  * @return void
  */
 public static function queryStringDecode(Request $request)
 {
     if (self::isInstalling()) {
         return;
     }
     // Try to match a route first.
     // Make sure we have the correct request context.
     $requestContext = ServiceUtil::get('router.request_context');
     $requestContext->fromRequest($request);
     /** @var \Symfony\Component\Routing\Matcher\RequestMatcherInterface $router */
     $router = ServiceUtil::get('router');
     try {
         $parameters = $router->matchRequest($request);
         if (!isset($parameters['_zkModule']) || !isset($parameters['_zkType']) || !isset($parameters['_zkFunc'])) {
             // This might be the web profiler or another native bundle.
             return;
         }
         // The following block is needed as long as not every url is a route. To be removed when all legacy routing
         // is removed.
         if ($parameters['_route'] == 'zikularoutesmodule_redirectingcontroller_removetrailingslash') {
             $pathInfo = $request->getPathInfo();
             $requestUri = $request->getRequestUri();
             // Check if url without slash exists. If it doesn't exist, it will throw an exception which is caught
             // by the try->catch below.
             $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);
             $router->match($url);
         }
         $modname = strtolower($parameters['_zkModule']);
         $type = strtolower($parameters['_zkType']);
         $func = strtolower($parameters['_zkFunc']);
         if (isset($parameters['_locale'])) {
             $lang = strtolower($parameters['_locale']);
             $request->query->set('lang', $lang);
             self::queryStringSetVar('lang', $lang);
         }
         $request->attributes->set('_zkModule', $modname);
         $request->attributes->set('_zkType', $type);
         $request->attributes->set('_zkFunc', $func);
         $request->query->set('module', $modname);
         $request->query->set('type', $type);
         $request->query->set('func', $func);
         self::queryStringSetVar('module', $modname);
         self::queryStringSetVar('type', $type);
         self::queryStringSetVar('func', $func);
         return;
     } catch (ResourceNotFoundException $e) {
         // This is an old style url.
     } catch (RouteNotFoundException $e) {
         // This is an old style url.
     } catch (MethodNotAllowedException $e) {
         // this is an old style url.
     }
     // get our base parameters to work out if we need to decode the url
     $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $func = FormUtil::getPassedValue('func', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $type = FormUtil::getPassedValue('type', null, 'GETPOST', FILTER_SANITIZE_STRING);
     // check if we need to decode the url
     $shorturls = self::getVar('shorturls');
     if ($shorturls && empty($module) && empty($type) && empty($func)) {
         // user language is not set at this stage
         $lang = self::getVar('language_i18n', '');
         $customentrypoint = self::getVar('entrypoint');
         $expectEntrypoint = !self::getVar('shorturlsstripentrypoint');
         $root = empty($customentrypoint) ? 'index.php' : $customentrypoint;
         // check if we hit baseurl, e.g. domain.com/ and if we require the language URL
         // then we should redirect to the language URL.
         if (ZLanguage::isRequiredLangParam() && self::getCurrentUrl() == self::getBaseUrl()) {
             $uri = $expectEntrypoint ? "{$root}/{$lang}" : $lang;
             self::redirect(self::getBaseUrl() . $uri);
             self::shutDown();
         }
         // check if entry point is part of the URL expectation.  If so throw error if it's not present
         // since this URL is technically invalid.
         if ($expectEntrypoint && self::getCurrentUrl() != self::getBaseUrl() && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) !== 0) {
             $protocol = self::serverGetVar('SERVER_PROTOCOL');
             header("{$protocol} 404 Not Found");
             echo __('The requested URL cannot be found');
             self::shutDown();
         }
         if (!$expectEntrypoint && self::getCurrentUrl() == self::getBaseUrl() . $root) {
             self::redirect(self::getHomepageUrl(), array(), 302, true);
             self::shutDown();
         }
         if (!$expectEntrypoint && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) === 0) {
             $protocol = self::serverGetVar('SERVER_PROTOCOL');
             header("{$protocol} 404 Not Found");
             echo __('The requested URL cannot be found');
             self::shutDown();
         }
         // get base path to work out our current url
//.........这里部分代码省略.........
开发者ID:Silwereth,项目名称:core,代码行数:101,代码来源:System.php


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