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


PHP EventUtil::registerPersistentEventHandlerClass方法代码示例

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


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

示例1: upgrade

    /**
     * Upgrade the dynamic user data module from an old version.
     * 
     * @param string $oldversion The version from which the upgrade is beginning (the currently installed version); this should be compatible 
     *                              with {@link version_compare()}.
     * 
     * @return boolean True on success or false on failure.
     */
    public function upgrade($oldversion)
    {
        switch ($oldversion)
        {
            case '1.5.2':
                // 1.5.2 -> 1.6.0
                EventUtil::registerPersistentEventHandlerClass($this->name, 'Profile_Listener_UsersUiHandler');
                $connection = Doctrine_Manager::getInstance()->getConnection('default');
                $sqlStatements = array();
                // N.B. statements generated with PHPMyAdmin
                $sqlStatements[] = 'RENAME TABLE ' . DBUtil::getLimitedTablename('user_property') . " TO user_property";
                $sqlStatements[] = "ALTER TABLE `user_property` CHANGE  `pn_prop_id`  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
CHANGE  `pn_prop_label`  `label` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE  `pn_prop_dtype`  `dtype` INT( 11 ) NOT NULL DEFAULT  '0',
CHANGE  `pn_prop_modname`  `modname` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE  `pn_prop_weight`  `weight` INT( 11 ) NOT NULL DEFAULT  '0',
CHANGE  `pn_prop_validation`  `validation` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE  `pn_prop_attribute_name`  `attributename` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
                foreach ($sqlStatements as $sql) {
                    $stmt = $connection->prepare($sql);
                    try {
                        $stmt->execute();
                    } catch (Exception $e) {
                    }   
                }
                
            case '1.6.0':
            case '1.6.1':
                // 1.6.0 -> X.X.X when appropriate.
        }

        $modVars = $this->getVars();
        $defaultModVars = $this->getDefaultModVars();

        // Remove modvars no longer in the default set.
        foreach ($modVars as $modVar => $value) {
            if (!array_key_exists($modVar, $defaultModVars)) {
                $this->delVar($modVar);
            }
        }

        // Add vars defined in the default set, but missing from the current set.
        foreach ($defaultModVars as $modVar => $value) {
            if (!array_key_exists($modVar, $modVars)) {
                $this->setVar($modVar, $value);
            }
        }

        // Update successful
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:59,代码来源:Installer.php

示例2: upgrade

    /**
     * Upgrade the module from a prior version.
     *
     * This function must consider all the released versions of the module!
     * If the upgrade fails at some point, it returns the last upgraded version.
     *
     * @param string $oldVersion The version number string from which the upgrade starting.
     *
     * @return boolean|string True if the module is successfully upgraded to the current version; last valid version string or false if the upgrade fails.
     */
    function upgrade($oldVersion)
    {
        // Upgrade dependent on old version number
        switch ($oldVersion)
        {
            case '1.1':
                // Upgrade 1.1 -> 1.2
                $this->setVar('termsofuse', true);
                $this->setVar('privacypolicy', true);
                $this->setVar('accessibilitystatement', true);

            case '1.2':
                // Upgrade 1.2 -> 1.3
                // Nothing to do.

            case '1.3':
                // Upgrade 1.3 -> 2.0.0
                // Convert the module variables to the new names
                $this->setVar(Legal_Constant::MODVAR_TERMS_ACTIVE, $this->getVar('termsofuse', true));
                $this->delVar('termsofuse');
                $this->setVar(Legal_Constant::MODVAR_PRIVACY_ACTIVE, $this->getVar('privacypolicy', true));
                $this->delVar('privacypolicy');
                $this->setVar(Legal_Constant::MODVAR_ACCESSIBILITY_ACTIVE, $this->getVar('accessibilitystatement', true));
                $this->delVar('accessibilitystatement');

                // Set the new module variable -- but if Users set it for us during its upgrade, then don't overwrite it
                $this->setVar(Legal_Constant::MODVAR_MINIMUM_AGE, $this->getVar(Legal_Constant::MODVAR_MINIMUM_AGE, 0));

                // Set up the new persistent event handler, and any other event-related features.
                EventUtil::registerPersistentModuleHandler($this->name, 'user.login.veto', array('Legal_Listener_UsersLoginVeto', 'acceptPoliciesListener'));
                EventUtil::registerPersistentEventHandlerClass($this->name, 'Legal_Listener_UsersUiHandler');

            case '2.0.0':
                // Upgrade 2.0.0 -> 2.0.1
                // add vars for new document types
                $this->setVar(Legal_Constant::MODVAR_LEGALNOTICE_ACTIVE, false);
                $this->setVar(Legal_Constant::MODVAR_CANCELLATIONRIGHTPOLICY_ACTIVE, false);
                $this->setVar(Legal_Constant::MODVAR_TRADECONDITIONS_ACTIVE, false);

                // add vars for optional custom urls
                $this->setVar(Legal_Constant::MODVAR_LEGALNOTICE_URL, '');
                $this->setVar(Legal_Constant::MODVAR_TERMS_URL, '');
                $this->setVar(Legal_Constant::MODVAR_PRIVACY_URL, '');
                $this->setVar(Legal_Constant::MODVAR_ACCESSIBILITY_URL, '');
                $this->setVar(Legal_Constant::MODVAR_CANCELLATIONRIGHTPOLICY_URL, '');
                $this->setVar(Legal_Constant::MODVAR_TRADECONDITIONS_URL, '');

            case '2.0.1':
                // Upgrade 2.0.1 -> ?.?.?

                // The following break should be the only one in the switch, and should appear immediately prior to the default case.
                break;
            default:
                $this->registerError($this->__f('Upgrading the Legal module from version %1$s to %2$s is not supported.', array($oldVersion, $this->version->getVersion())));
                return $oldVersion;
        }

        // Update successful
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:70,代码来源:Installer.php


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