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


PHP sfMixer类代码示例

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


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

示例1: __call

 function __call($method, $arguments)
 {
     $r = "before __call\n";
     $r .= sfMixer::callMixins();
     $r .= "after __call\n";
     return $r;
 }
开发者ID:sensorsix,项目名称:app,代码行数:7,代码来源:sfMixerTest.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: 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

示例4: executeApprove

 public function executeApprove()
 {
     $approval = sfApprovalPeer::retrieveByUuid($this->getRequestParameter('uuid'));
     if (!$approval) {
         return 'NotFound';
     }
     $object = $approval->getRelatedObject();
     $this->setFlash('sf_approvable_object', $object);
     $class = get_class($object);
     $peerClass = get_class($object->getPeer());
     $destination = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . $class . '_destination', '@homepage');
     $approvedValue = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . $class . '_approved_value', true);
     $columnName = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . $class . '_column', 'is_approved');
     $method = 'set' . call_user_func(array($peerClass, 'translateFieldName'), $columnName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
     $ret = null;
     foreach (sfMixer::getCallables('sfApprovableActions:approve:pre') as $callable) {
         $ret = call_user_func($callable, $object);
     }
     if (!is_null($ret)) {
         return $ret;
     }
     $object->{$method}($approvedValue);
     $object->save();
     $approval->delete();
     foreach (sfMixer::getCallables('sfApprovableActions:approve:post') as $callable) {
         $ret = call_user_func($callable, $object);
     }
     if (!is_null($ret)) {
         return $ret;
     }
     $this->redirect($destination);
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:32,代码来源:BasesfApprovableActions.class.php

示例5: newSfGuardConnectionHook

 /**
  *
  * @param $sfGuardUser
  * @param $facebook_uid
  * @return unknown_type
  * @author fabriceb
  * @since Sep 1, 2009
  */
 public static function newSfGuardConnectionHook($sfGuardUser, $facebook_uid)
 {
     if (class_exists('sfEvent')) {
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($sfGuardUser, 'sf_guard.user.facebook.create', array('facebook_uid' => $facebook_uid)));
     } else {
         foreach (sfMixer::getCallables('sfFacebookConnect:newSfGuardConnection:preSave') as $callable) {
             call_user_func($callable, &$sfGuardUser, $facebook_uid);
         }
     }
 }
开发者ID:vcgato29,项目名称:poff,代码行数:18,代码来源:sfFacebookConnect.class.php

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

示例7: isBookmarkable

 /**
  * Returns true if the passed model name is bookmarkable
  * 
  * @author     Xavier Lacot
  * @param      string  $object_name
  * @return     boolean
  */
 public static function isBookmarkable($model)
 {
     if (is_object($model)) {
         $model = get_class($model);
     }
     if (!is_string($model)) {
         throw new Exception('The param passed to the metod isBookmarkable must be either an object or a string.');
     }
     if (!class_exists($model)) {
         throw new Exception(sprintf('Unknown class %s', $model));
     }
     $base_class = sprintf('Base%s', $model);
     return !is_null(sfMixer::getCallable($base_class . ':getBookmarkableReferenceKey'));
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:21,代码来源:deppPropelActAsBookmarkableToolkit.class.php

示例8: isCountable

 /**
  * Returns true if the passed model name is countable
  * 
  * @author     Xavier Lacot
  * @param      string  $object_name
  * @return     boolean
  */
 public static function isCountable($model)
 {
     if (is_object($model)) {
         $model = get_class($model);
     }
     if (!is_string($model)) {
         throw new Exception('The param passed to the method isCountable must be a string.');
     }
     if (!class_exists($model)) {
         throw new Exception(sprintf('Unknown class %s', $model));
     }
     $base_class = sprintf('Base%s', $model);
     return !is_null(sfMixer::getCallable($base_class . ':incrementCounter'));
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:21,代码来源:sfPropelActAsCountableToolkit.class.php

示例9: __call

 public function __call($name, $arguments)
 {
     if (strpos($name, 'get') === 0) {
         $key = strtolower(preg_replace('/^get/', '', $name, 1));
         return $this->storage->get($key);
         //todo allow backfetching?
     } elseif (strpos($name, 'set') === 0 && array_key_exists(0, $arguments)) {
         $key = strtolower(preg_replace('/^set/', '', $name, 1));
         return $this->storage->set($key, $arguments[0]);
         // forgot the return here
     } elseif (strpos($name, 'has') === 0) {
         $key = strtolower(preg_replace('/^has/', '', $name, 1));
         return $this->storage->has($key);
     }
     return sfMixer::callMixins();
     // We're going to need mixin support
 }
开发者ID:WIZARDISHUNGRY,项目名称:sfDomFeedPlugin,代码行数:17,代码来源:sfDomStorage.class.php

示例10: executeAnonymousComment

 /**
  * Saves a comment, for a non authentified user
  */
 public function executeAnonymousComment()
 {
     $this->getConfig();
     if ($this->config_anonymous['enabled'] && $this->getRequest()->getMethod() == sfRequest::POST) {
         $token = $this->getRequestParameter('sf_comment_object_token');
         $object = sfPropelActAsCommentableToolkit::retrieveFromToken($token);
         $namespace = $this->getRequestParameter('sf_comment_namespace', null);
         $this->namespace = $namespace;
         $this->validateNamespace($namespace);
         $comment = array('title' => $this->getRequestParameter('sf_comment_title'), 'text' => $this->getRequestParameter('sf_comment'), 'author_name' => $this->getRequestParameter('sf_comment_name'), 'author_email' => $this->getRequestParameter('sf_comment_email'), 'namespace' => $namespace);
         foreach (sfMixer::getCallables('sfCommentActions:addComment:pre') as $callable) {
             call_user_func($callable, $comment, $object);
         }
         $comment_object = $object->addComment($comment);
         foreach (sfMixer::getCallables('sfCommentActions:addComment:post') as $callable) {
             call_user_func($callable, $comment_object, $object);
         }
         $this->object = $object;
         if (!$this->getContext()->getRequest()->isXmlHttpRequest()) {
             $this->redirect($this->getRequestParameter('sf_comment_referer'));
         }
     }
     $this->setTemplate('comment');
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:27,代码来源:BasesfCommentActions.class.php

示例11: doCount

 public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
 {
     // we may modify criteria, so copy it first
     $criteria = clone $criteria;
     // We need to set the primary table name, since in the case that there are no WHERE columns
     // it will be impossible for the BasePeer::createSelectSql() method to determine which
     // tables go into the FROM clause.
     $criteria->setPrimaryTableName(FormularioPeer::TABLE_NAME);
     if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
         $criteria->setDistinct();
     }
     if (!$criteria->hasSelectClause()) {
         FormularioPeer::addSelectColumns($criteria);
     }
     $criteria->clearOrderByColumns();
     // ORDER BY won't ever affect the count
     $criteria->setDbName(self::DATABASE_NAME);
     // Set the correct dbName
     if ($con === null) {
         $con = Propel::getConnection(FormularioPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     foreach (sfMixer::getCallables('BaseFormularioPeer:doCount:doCount') as $callable) {
         call_user_func($callable, 'BaseFormularioPeer', $criteria, $con);
     }
     $criteria = self::kriterio($criteria);
     // BasePeer returns a PDOStatement
     $stmt = BasePeer::doCount($criteria, $con);
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $count = (int) $row[0];
     } else {
         $count = 0;
         // no rows returned; we infer that means 0 matches.
     }
     $stmt->closeCursor();
     return $count;
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:36,代码来源:FormularioPeer.php

示例12: doSelectStmt

 /**
  * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  *
  * Use this method directly if you want to work with an executed statement durirectly (for example
  * to perform your own object hydration).
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      PropelPDO $con The connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  * @return     PDOStatement The executed PDOStatement object.
  * @see        BasePeer::doSelect()
  */
 public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ProveedorPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     if (!$criteria->hasSelectClause()) {
         $criteria = clone $criteria;
         ProveedorPeer::addSelectColumns($criteria);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseProveedorPeer', $criteria, $con);
     }
     // BasePeer returns a PDOStatement
     return BasePeer::doSelect($criteria, $con);
 }
开发者ID:nestorfsandoval,项目名称:2012_pw2_tp2,代码行数:31,代码来源:BaseProveedorPeer.php

示例13: __call

 /**
  * Catches calls to virtual methods
  */
 public function __call($name, $params)
 {
     // symfony_behaviors behavior
     if ($callable = sfMixer::getCallable('BaseCountry:' . $name)) {
         array_unshift($params, $this);
         return call_user_func_array($callable, $params);
     }
     return parent::__call($name, $params);
 }
开发者ID:homer6,项目名称:blank_altumo,代码行数:12,代码来源:BaseCountry.php

示例14: doSelectJoinAllExceptCiudadRelatedByIdCiudad

 /**
  * Selects a collection of Cliente objects pre-filled with all related objects except CiudadRelatedByIdCiudad.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Cliente objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptCiudadRelatedByIdCiudad(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     ClientePeer::addSelectColumns($criteria);
     $startcol2 = ClientePeer::NUM_HYDRATE_COLUMNS;
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseClientePeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ClientePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ClientePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = ClientePeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ClientePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
开发者ID:nestorfsandoval,项目名称:2012_pw2_tp2,代码行数:45,代码来源:BaseClientePeer.php

示例15: doSelectJoinAll

 /**
  * Selects a collection of GalleryImage objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of GalleryImage objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(GalleryImagePeer::DATABASE_NAME);
     }
     GalleryImagePeer::addSelectColumns($criteria);
     $startcol2 = GalleryImagePeer::NUM_HYDRATE_COLUMNS;
     GalleryFolderPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + GalleryFolderPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(GalleryImagePeer::GALLERY_FOLDER_ID, GalleryFolderPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseGalleryImagePeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = GalleryImagePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = GalleryImagePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = GalleryImagePeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             GalleryImagePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined GalleryFolder rows
         $key2 = GalleryFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = GalleryFolderPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = GalleryFolderPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 GalleryFolderPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (GalleryImage) to the collection in $obj2 (GalleryFolder)
             $obj2->addGalleryImage($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
开发者ID:jorisros,项目名称:sfWidgetCKEditorPlugin,代码行数:61,代码来源:BaseGalleryImagePeer.php


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