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


PHP sfMixer::register方法代码示例

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


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

示例1: init

 public static function init()
 {
     if (self::$_started) {
         return;
     }
     $redirection_conf = sfConfig::get('app_redirection_databases', null);
     if ($redirection_conf === null) {
         return;
     }
     //Iterate over the databases configurations.
     foreach ($redirection_conf as $dbName => $dbOptions) {
         //Check if there are any slaves servers configured.
         if ($dbOptions['slaves'] === null) {
             continue;
         }
         foreach ($dbOptions['slaves'] as &$slave) {
             foreach ($slave as &$param) {
                 $param = sfConfigHandler::replaceConstants($param);
             }
             #Symfony uses 'username' but Propel expects 'user'.
             $slave['user'] = $slave['username'];
             unset($slave['username']);
         }
         self::$_slaveConfig[$dbName] = $dbOptions['slaves'];
         //Check if there is any entity that maybe be redirected to the slave.
         if ($dbOptions['entities'] === null) {
             continue;
         }
         //Iterate over the entities.
         foreach ($dbOptions['entities'] as $model => $options) {
             $peerClass = "{$model}Peer";
             //Check if the peer exits.
             if (!class_exists($peerClass)) {
                 continue;
             }
             $doSelectStmtHook = "{$peerClass}:doSelectStmt:doSelectStmt";
             $doCountHook = "{$peerClass}:doCount:doCount";
             //Register the interceptor function on the peer hooks.
             $interceptor = array('sfPropelRedirection', 'slaveConnection');
             sfMixer::register($doSelectStmtHook, $interceptor);
             sfMixer::register($doCountHook, $interceptor);
             //Check if the peer has conditions in order to be redirected to the slave.
             if (!isset($options['conditions'])) {
                 continue;
             }
             self::$_peerOptions[$peerClass]['conditions'] = $options['conditions'];
             //If there are zero conditions then we don't need to check a gen_column.
             if (!isset($options['gen_column'])) {
                 continue;
             }
             $columnName = strtolower($model) . '.' . strtoupper($options['gen_column']);
             //Check if the gen column really exists in the model
             if (!in_array($columnName, $peerClass::getFieldNames(BasePeer::TYPE_COLNAME))) {
                 continue;
             }
             self::$_peerOptions[$peerClass]['gen_column'] = $columnName;
         }
     }
     self::$_started = true;
 }
开发者ID:hnh12358,项目名称:symfony-plugins,代码行数:60,代码来源:sfPropelRedirection.class.php

示例2: add

 public static function add($class, $behaviors)
 {
     foreach ($behaviors as $name => $parameters) {
         if (is_int($name)) {
             // no parameters
             $name = $parameters;
         } else {
             // register parameters
             foreach ($parameters as $key => $value) {
                 sfConfig::set('propel_behavior_' . $name . '_' . $class . '_' . $key, $value);
             }
         }
         if (!isset(self::$behaviors[$name])) {
             throw new sfConfigurationException(sprintf('Propel behavior "%s" is not registered', $name));
         }
         // register hooks
         foreach (self::$behaviors[$name]['hooks'] as $hook => $callables) {
             foreach ($callables as $callable) {
                 sfMixer::register('Base' . $class . $hook, $callable);
             }
         }
         // register new methods
         foreach (self::$behaviors[$name]['methods'] as $callable) {
             sfMixer::register('Base' . $class, $callable);
         }
     }
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:27,代码来源:sfPropelBehavior.class.php

示例3: launchTests

 public function launchTests($object, $class)
 {
     $this->t->diag('Mixins via sfMixer');
     sfMixer::register($class, array('myMixinTest', 'newMethod'));
     $this->t->is($object->newMethod(), 'ok', '__call() accepts mixins via sfMixer');
     try {
         $object->nonexistantmethodname();
         $this->t->fail('__call() throws an exception if the method does not exist as a mixin');
     } catch (sfException $e) {
         $this->t->pass('__call() throws an exception if the method does not exist as a mixin');
     }
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:12,代码来源:sfMixerTest.class.php

示例4: enableCustomColumnGetter

 protected function enableCustomColumnGetter()
 {
     // activate custom column getter if asColumns were added
     if ($this->getWithColumns() && !sfMixer::getCallable('Base' . $this->class . ':getColumn')) {
         sfMixer::register('Base' . $this->class, array($this, 'getColumn'));
     }
 }
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:7,代码来源:sfPropelFinder.php

示例5: doFind


//.........这里部分代码省略.........
     if ($this->getWithClasses() || $this->getWithColumns()) {
         $c = $this->prepareCompositeCriteria();
         if (method_exists($this->peerClass, 'doSelectRS')) {
             $resultSet = call_user_func(array($this->peerClass, 'doSelectRS'), $c, $this->getConnection());
             $propelVersion = '1.2';
             $nextFunction = 'next';
             $nextParam = null;
         } else {
             $resultSet = call_user_func(array($this->peerClass, 'doSelectStmt'), $c, $this->getConnection());
             $propelVersion = '1.3';
             $nextFunction = 'fetch';
             $nextParam = PDO::FETCH_NUM;
         }
         // Hydrate the objects based on the resultset
         $omClass = call_user_func(array($this->peerClass, 'getOMClass'));
         $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
         $objects = array();
         $withObjs = array();
         while ($row = $resultSet->{$nextFunction}($nextParam)) {
             // First come the columns of the main class
             $obj = new $cls();
             if ($propelVersion == '1.2') {
                 $startCol = $obj->hydrate($resultSet, 1);
             } else {
                 $startCol = $obj->hydrate($row, 0);
             }
             if ($this->culture) {
                 $obj->setCulture($this->culture);
             }
             // Then the related classes added by way of 'with'
             $objectsInJoin = array($obj);
             foreach ($this->getWithClasses() as $className) {
                 $withObj = new $className();
                 if ($propelVersion == '1.2') {
                     $startCol = $withObj->hydrate($resultSet, $startCol);
                 } else {
                     $startCol = $withObj->hydrate($row, $startCol);
                 }
                 // As we can be in a left join, there is a possibility that the hydrated related object is null
                 // In this case, we must not relate it to the main object
                 $isEmpty = true;
                 foreach ($withObj->toArray() as $value) {
                     if ($value !== null) {
                         $isEmpty = false;
                     }
                 }
                 if ($isEmpty) {
                     continue;
                 }
                 // initialize our object directory
                 if (!isset($withObjs[$className])) {
                     $withObjs[$className] = array();
                 }
                 // check if object is not already referenced in allObjects directory
                 $isNewObject = true;
                 foreach ($withObjs[$className] as $otherObject) {
                     if ($otherObject->getPrimaryKey() === $withObj->getPrimaryKey()) {
                         $isNewObject = false;
                         $withObj = $otherObject;
                         break;
                     }
                 }
                 if (strpos(get_class($withObj), 'I18n') !== false) {
                     sfPropelFinderUtils::relateI18nObjects($withObj, $objectsInJoin, $this->culture);
                 } else {
                     sfPropelFinderUtils::relateObjects($withObj, $objectsInJoin, $isNewObject);
                 }
                 $objectsInJoin[] = $withObj;
                 if ($isNewObject) {
                     $withObjs[$className][] = $withObj;
                 }
             }
             // Then the columns added one by one by way of 'withColumn'
             foreach ($this->getWithColumns() as $alias => $column) {
                 // Additional columns are stored in the object, in a special 'namespace'
                 // see getColumn() for how to retrieve the value afterwards
                 // Using the third parameter of withColumn() as a type. defaults to $rs->get() (= $rs->getString())
                 $typedGetter = 'get' . ucfirst($column['type']);
                 if ($propelVersion == '1.2') {
                     $this->setColumn($obj, $alias, $resultSet->{$typedGetter}($startCol));
                 } else {
                     $this->setColumn($obj, $alias, $row[$startCol]);
                 }
                 $startCol++;
             }
             $objects[] = $obj;
         }
         // activate custom column getter if asColumns were added
         if ($this->getWithColumns() && !sfMixer::getCallable('Base' . $cls . ':getColumn')) {
             sfMixer::register('Base' . $cls, array($this, 'getColumn'));
         }
     } else {
         // No 'with', so we use the native Propel doSelect()
         $objects = call_user_func(array($this->peerClass, 'doSelect'), $this->buildCriteria(), $this->getConnection());
     }
     if ($cache) {
         $cache->set($key, $objects);
     }
     return $objects;
 }
开发者ID:Zadkiel,项目名称:zadkiel_blog,代码行数:101,代码来源:sfPropelFinder.php

示例6: array

<?php

if (defined('SYMFONY_VERSION') && 0 !== strpos(SYMFONY_VERSION, '1.0')) {
    // >= symfony 1.1
    $listener = array('sfGoogleAnalyticsListener', 'observe');
    $this->dispatcher->connect('request.method_not_found', $listener);
    $this->dispatcher->connect('response.method_not_found', $listener);
    $this->dispatcher->connect('component.method_not_found', $listener);
    $this->dispatcher->connect('user.method_not_found', $listener);
} else {
    // symfony 1.0
    $getter = array('sfGoogleAnalyticsMixin', 'getTracker');
    $setter = array('sfGoogleAnalyticsMixin', 'setTracker');
    sfMixer::register('sfRequest', $getter);
    sfMixer::register('sfRequest', $setter);
    sfMixer::register('sfResponse', $getter);
    sfMixer::register('sfResponse', $setter);
    sfMixer::register('sfComponent', $getter);
    sfMixer::register('sfComponent', $setter);
    sfMixer::register('sfUser', $getter);
    sfMixer::register('sfUser', $setter);
}
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:22,代码来源:config.php

示例7: myMixinStaticMethodWithArgs

        myClass::$retStatic .= "in myStaticMethod mixin method\n";
    }
    public function myMixinStaticMethodWithArgs($class, $arg1, $arg2 = 'default')
    {
        myClass::$retStatic .= "in myStaticMethodWithArgs mixin method ({$arg1}, {$arg2})\n";
    }
    public function newMethod($object)
    {
        return "in newMethod mixin method\n";
    }
    public function newMethodWithArgs($object, $arg1, $arg2 = 'default')
    {
        return "in newMethodWithArgs mixin method ({$arg1}, {$arg2})\n";
    }
}
sfMixer::register('myClass:myMethod', array('myClassMixins', 'myMixinMethod'));
sfMixer::register('myClass:myStaticMethod', array('myClassMixins', 'myMixinStaticMethod'));
$t->is($m->myMethod(), "before myMethod\nin myMethod mixin method\nafter myMethod\n", 'method call with a mixin');
$t->is(myClass::myStaticMethod(), "before myStaticMethod\nin myStaticMethod mixin method\nafter myStaticMethod\n", 'static method call with a mixin');
sfMixer::register('myClass:myMethodWithArgs', array('myClassMixins', 'myMixinMethodWithArgs'));
$t->is($m->myMethodWithArgs('value'), "before myMethodWithArgs\nin myMethodWithArgs mixin method (value, default)\nafter myMethodWithArgs\n", 'method call with arguments with a mixin');
sfMixer::register('myClass:myStaticMethodWithArgs', array('myClassMixins', 'myMixinStaticMethodWithArgs'));
$t->is(myClass::myStaticMethodWithArgs('value'), "before myStaticMethodWithArgs\nin myStaticMethodWithArgs mixin method (value, default)\nafter myStaticMethodWithArgs\n", 'static method call with arguments with a mixin');
sfMixer::register('myClass', array('myClassMixins', 'newMethod'));
$t->is($m->newMethod(), "before __call\nin newMethod mixin method\nafter __call\n", 'method call from a mixin');
sfMixer::register('myClass', array('myClassMixins', 'newMethodWithArgs'));
$t->is($m->newMethodWithArgs('value'), "before __call\nin newMethodWithArgs mixin method (value, default)\nafter __call\n", 'method call from a mixin with arguments');
sfMixer::register('myClass:myMethodWithSeveralHooks:before', array('myClassMixins', 'myMethodWithSeveralHooksBefore'));
sfMixer::register('myClass:myMethodWithSeveralHooks', array('myClassMixins', 'myMethodWithSeveralHooks'));
sfMixer::register('myClass:myMethodWithSeveralHooks:after', array('myClassMixins', 'myMethodWithSeveralHooksAfter'));
$t->is($m->myMethodWithSeveralHooks(), "before myMethodWithSeveralHooks\nin myMethodWithSeveralHooks mixin method for before hook\nmyMethodWithSeveralHooks\nin myMethodWithSeveralHooks mixin method for default hook\nafter myMethodWithSeveralHooks\nin myMethodWithSeveralHooks mixin method for after hook\n", 'method call with several registered hooks');
开发者ID:sensorsix,项目名称:app,代码行数:31,代码来源:sfMixerTest.php

示例8: array

<?php

/*
 * This file is part of the sfErrorHandler plugin
 * (c) 2008-2009 Lee Bolding <lee@php.uk.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * sfHardenedRenderingFilter is a replacement for the sfRenderingFilter
 * The sfHardenedRendderingFilter dynamically replaces the sfRenderingFilter for an app
 * when the sfErrorHandler is one of the enabled modules
 *
 * @package    sfErrorHandlerPlugin
 * @author     Lee Bolding <lee@php.uk.com>
 * @version    SVN: $Id$
 */
if (in_array('sfErrorHandler', sfConfig::get('sf_enabled_modules', array()))) {
    sfMixer::register('sfException:printStackTrace', array('sfErrorHandler', 'logExpection'));
    sfConfig::set('sf_rendering_filter', array('sfHardenedRenderingFilter', array()));
}
开发者ID:royalterra,项目名称:pdns-gui,代码行数:22,代码来源:config.php

示例9: array

<?php

sfMixer::register('sfException:printStackTrace', array('sfErrorLogger', 'log500'));
sfMixer::register('sfController:forward:error404', array('sfErrorLogger', 'log404'));
开发者ID:sgrove,项目名称:cothinker,代码行数:4,代码来源:config.php


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