function __call($method, $arguments) { $r = "before __call\n"; $r .= sfMixer::callMixins(); $r .= "after __call\n"; return $r; }
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); } } }
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; }
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); }
/** * * @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); } } }
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'); } }
/** * 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')); }
/** * 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')); }
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 }
/** * 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'); }
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; }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }
/** * Selects a collection of StatusAction objects pre-filled with all related objects except File. * * @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 StatusAction objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFile(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); } StatusActionPeer::addSelectColumns($criteria); $startcol2 = StatusActionPeer::NUM_HYDRATE_COLUMNS; sfGuardUserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + sfGuardUserPeer::NUM_HYDRATE_COLUMNS; RepositoryPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RepositoryPeer::NUM_HYDRATE_COLUMNS; BranchPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + BranchPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(StatusActionPeer::USER_ID, sfGuardUserPeer::ID, $join_behavior); $criteria->addJoin(StatusActionPeer::REPOSITORY_ID, RepositoryPeer::ID, $join_behavior); $criteria->addJoin(StatusActionPeer::BRANCH_ID, BranchPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseStatusActionPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = StatusActionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = StatusActionPeer::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 = StatusActionPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); StatusActionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardUser rows $key2 = sfGuardUserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardUserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = sfGuardUserPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardUserPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (StatusAction) to the collection in $obj2 (sfGuardUser) $obj2->addStatusAction($obj1); } // if joined row is not null // Add objects for joined Repository rows $key3 = RepositoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RepositoryPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RepositoryPeer::getOMClass(false); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RepositoryPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (StatusAction) to the collection in $obj3 (Repository) $obj3->addStatusAction($obj1); } // if joined row is not null // Add objects for joined Branch rows $key4 = BranchPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = BranchPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = BranchPeer::getOMClass(false); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); BranchPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (StatusAction) to the collection in $obj4 (Branch) $obj4->addStatusAction($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Selects a collection of SystemEventInstance objects pre-filled with all related objects except User. * * @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 SystemEventInstance objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUser(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); } SystemEventInstancePeer::addSelectColumns($criteria); $startcol2 = SystemEventInstancePeer::NUM_HYDRATE_COLUMNS; SystemEventPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + SystemEventPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(SystemEventInstancePeer::SYSTEM_EVENT_ID, SystemEventPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseSystemEventInstancePeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SystemEventInstancePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SystemEventInstancePeer::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 = SystemEventInstancePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); SystemEventInstancePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined SystemEvent rows $key2 = SystemEventPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = SystemEventPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = SystemEventPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); SystemEventPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (SystemEventInstance) to the collection in $obj2 (SystemEvent) $obj2->addSystemEventInstance($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Prints the stack trace for this exception. * * @param Exception An Exception implementation instance */ public function printStackTrace($exception = null) { if (!$exception) { $exception = $this; } // don't print message if it is an sfStopException exception if (method_exists($exception, 'getName') && $exception->getName() == 'sfStopException') { if (!sfConfig::get('sf_test')) { exit(1); } return; } if (class_exists('sfMixer', false)) { foreach (sfMixer::getCallables('sfException:printStackTrace:printStackTrace') as $callable) { $ret = call_user_func($callable, $this, $exception); if ($ret) { if (!sfConfig::get('sf_test')) { exit(1); } return; } } } if (!sfConfig::get('sf_test')) { header('HTTP/1.0 500 Internal Server Error'); // clean current output buffer while (@ob_end_clean()) { } ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); } // send an error 500 if not in debug mode if (!sfConfig::get('sf_debug')) { error_log($exception->getMessage()); $file = sfConfig::get('sf_web_dir') . '/errors/error500.php'; include is_readable($file) ? $file : sfConfig::get('sf_symfony_data_dir') . '/web/errors/error500.php'; if (!sfConfig::get('sf_test')) { exit(1); } return; } $message = null !== $exception->getMessage() ? $exception->getMessage() : 'n/a'; $name = get_class($exception); $format = 0 == strncasecmp(PHP_SAPI, 'cli', 3) ? 'plain' : 'html'; $traces = $this->getTraces($exception, $format); // extract error reference from message $error_reference = ''; if (preg_match('/\\[(err\\d+)\\]/', $message, $matches)) { $error_reference = $matches[1]; } // dump main objects values $sf_settings = ''; $settingsTable = $requestTable = $responseTable = $globalsTable = ''; if (class_exists('sfContext', false) && sfContext::hasInstance()) { $context = sfContext::getInstance(); $settingsTable = $this->formatArrayAsHtml(sfDebug::settingsAsArray()); $requestTable = $this->formatArrayAsHtml(sfDebug::requestAsArray($context->getRequest())); $responseTable = $this->formatArrayAsHtml(sfDebug::responseAsArray($context->getResponse())); $globalsTable = $this->formatArrayAsHtml(sfDebug::globalsAsArray()); } include sfConfig::get('sf_symfony_data_dir') . '/data/exception.' . ($format == 'html' ? 'php' : 'txt'); // if test, do not exit if (!sfConfig::get('sf_test')) { exit(1); } }
/** * Finalizes the query, executes it and hydrates results * * @return array List of Propel objects */ public function doFind() { if ($cache = $this->cache) { $key = $this->getUniqueIdentifier(); $ret = $cache->getIfSet($key); if ($ret !== false) { return $ret; } } 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; }
/** * Selects a collection of Afiliado objects pre-filled with all related objects except Localidad. * * @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 Afiliado objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptLocalidad(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); } AfiliadoPeer::addSelectColumns($criteria); $startcol2 = AfiliadoPeer::NUM_HYDRATE_COLUMNS; PlanPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + PlanPeer::NUM_HYDRATE_COLUMNS; TipodocPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + TipodocPeer::NUM_HYDRATE_COLUMNS; ReparticionPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + ReparticionPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(AfiliadoPeer::PLAN_ID, PlanPeer::ID, $join_behavior); $criteria->addJoin(AfiliadoPeer::TIPODOC_ID, TipodocPeer::ID, $join_behavior); $criteria->addJoin(AfiliadoPeer::REPARTICION_ID, ReparticionPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseAfiliadoPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = AfiliadoPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = AfiliadoPeer::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 = AfiliadoPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); AfiliadoPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Plan rows $key2 = PlanPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = PlanPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = PlanPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); PlanPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Afiliado) to the collection in $obj2 (Plan) $obj2->addAfiliado($obj1); } // if joined row is not null // Add objects for joined Tipodoc rows $key3 = TipodocPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = TipodocPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = TipodocPeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); TipodocPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Afiliado) to the collection in $obj3 (Tipodoc) $obj3->addAfiliado($obj1); } // if joined row is not null // Add objects for joined Reparticion rows $key4 = ReparticionPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = ReparticionPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = ReparticionPeer::getOMClass(); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); ReparticionPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Afiliado) to the collection in $obj4 (Reparticion) $obj4->addAfiliado($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
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')); } }
/** * Method perform an UPDATE on the database, given a ExamCommentDig or Criteria object. * * @param mixed $values Criteria or ExamCommentDig object containing data that is used to create the UPDATE statement. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). * @return int The number of affected rows (if supported by underlying database driver). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doUpdate($values, PropelPDO $con = null) { foreach (sfMixer::getCallables('BaseExamCommentDigPeer:doUpdate:pre') as $callable) { $ret = call_user_func($callable, 'BaseExamCommentDigPeer', $values, $con); if (false !== $ret) { return $ret; } } if ($con === null) { $con = Propel::getConnection(ExamCommentDigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(ExamCommentDigPeer::IP); $selectCriteria->add(ExamCommentDigPeer::IP, $criteria->remove(ExamCommentDigPeer::IP), $comparison); $comparison = $criteria->getComparison(ExamCommentDigPeer::COMMENT_ID); $selectCriteria->add(ExamCommentDigPeer::COMMENT_ID, $criteria->remove(ExamCommentDigPeer::COMMENT_ID), $comparison); } else { // $values is ExamCommentDig object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con); foreach (sfMixer::getCallables('BaseExamCommentDigPeer:doUpdate:post') as $callable) { call_user_func($callable, 'BaseExamCommentDigPeer', $values, $con, $ret); } return $ret; }
/** * Hook for sfMixer */ public function __call($a, $b) { return sfMixer::callMixins(); }
/** * Adapts the ->getXXX() methods to solr. */ public function __call($method, $args = array()) { if (substr($method, 0, 3) == 'get') { return $this->result->__get($this->getProperty($method, 'get')); } elseif (substr($method, 0, 3) == 'has') { try { $this->result->__get($this->getProperty($method, 'has')); return true; } catch (Exception $e) { return false; } } $call = array($this->result, $method); if (is_callable($call)) { return call_user_func_array($call, $args); } return sfMixer::callMixins(); }
/** * Method perform an UPDATE on the database, given a PcBlogComment or Criteria object. * * @param mixed $values Criteria or PcBlogComment object containing data that is used to create the UPDATE statement. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). * @return int The number of affected rows (if supported by underlying database driver). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doUpdate($values, PropelPDO $con = null) { // symfony_behaviors behavior foreach (sfMixer::getCallables('BasePcBlogCommentPeer:doUpdate:pre') as $sf_hook) { if (false !== ($sf_hook_retval = call_user_func($sf_hook, 'BasePcBlogCommentPeer', $values, $con))) { return $sf_hook_retval; } } if ($con === null) { $con = Propel::getConnection(PcBlogCommentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(PcBlogCommentPeer::ID); $selectCriteria->add(PcBlogCommentPeer::ID, $criteria->remove(PcBlogCommentPeer::ID), $comparison); } else { // $values is PcBlogComment object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BasePcBlogCommentPeer:doUpdate:post') as $sf_hook) { call_user_func($sf_hook, 'BasePcBlogCommentPeer', $values, $con, $ret); } return $ret; }
/** * Selects a collection of {@link Product} objects with a {@link ProductI18n} translation populated. * * @param Criteria $criteria * @param string $culture * @param PropelPDO $con * @param string $join_behavior * * @return array */ public static function doSelectWithI18n(Criteria $criteria, $culture = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if (null === $culture) { $culture = sfPropel::getDefaultCulture(); } // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } ProductPeer::addSelectColumns($criteria); $startcol = ProductPeer::NUM_COLUMNS - ProductPeer::NUM_LAZY_LOAD_COLUMNS; ProductI18nPeer::addSelectColumns($criteria); $criteria->addJoin(ProductPeer::ID, ProductI18nPeer::ID, $join_behavior); $criteria->add(ProductI18nPeer::CULTURE, $culture); foreach (sfMixer::getCallables('BaseProduct:doSelectJoin:doSelectJoin') as $sf_hook) { call_user_func($sf_hook, 'Product', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = ProductPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); ProductPeer::addInstanceToPool($obj1, $key1); } // if $obj1 already loaded $key2 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); if ($key2 !== null) { $obj2 = ProductI18nPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = ProductI18nPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol); ProductI18nPeer::addInstanceToPool($obj2, $key2); } // if obj2 already loaded $obj1->setTranslationForCulture($obj2, $culture); } // if joined row was not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public static function doUpdate($values, $con = null) { foreach (sfMixer::getCallables('BasenahoWikiPagePeer:doUpdate:pre') as $callable) { $ret = call_user_func($callable, 'BasenahoWikiPagePeer', $values, $con); if (false !== $ret) { return $ret; } } if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $selectCriteria = new Criteria(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; $comparison = $criteria->getComparison(nahoWikiPagePeer::ID); $selectCriteria->add(nahoWikiPagePeer::ID, $criteria->remove(nahoWikiPagePeer::ID), $comparison); } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } $criteria->setDbName(self::DATABASE_NAME); $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con); foreach (sfMixer::getCallables('BasenahoWikiPagePeer:doUpdate:post') as $callable) { call_user_func($callable, 'BasenahoWikiPagePeer', $values, $con, $ret); } return $ret; }
public static function doSelectJoinCustom(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { foreach (sfMixer::getCallables('MissionPeer:doSelectJoinCustom:doSelectJoinCustom') as $callable) { call_user_func($callable, 'MissionPeer', $c, $con); } $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } MissionPeer::addSelectColumns($c); $startcol2 = MissionPeer::NUM_COLUMNS - MissionPeer::NUM_LAZY_LOAD_COLUMNS; ItineraryPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ItineraryPeer::NUM_COLUMNS - ItineraryPeer::NUM_LAZY_LOAD_COLUMNS); MissionTypePeer::addSelectColumns($c); $startcol4 = $startcol3 + (MissionTypePeer::NUM_COLUMNS - MissionTypePeer::NUM_LAZY_LOAD_COLUMNS); PassengerPeer::addSelectColumns($c); $startcol5 = $startcol4 + (PassengerPeer::NUM_COLUMNS - PassengerPeer::NUM_LAZY_LOAD_COLUMNS); MissionLegPeer::addSelectColumns($c); $startcol6 = $startcol5 + (MissionLegPeer::NUM_COLUMNS - MissionLegPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(MissionPeer::ITINERARY_ID), array(ItineraryPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::MISSION_TYPE_ID), array(MissionTypePeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::PASSENGER_ID), array(PassengerPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::ID), array(MissionLegPeer::MISSION_ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = MissionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = MissionPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = MissionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); MissionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Itinerary rows $key2 = ItineraryPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ItineraryPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ItineraryPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ItineraryPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Mission) to the collection in $obj3 (Itinerary) $obj2->addMission($obj1); } // if joined row not null // Add objects for joined MissionType rows $key3 = MissionTypePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = MissionTypePeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = MissionTypePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); MissionTypePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (Mission) to the collection in $obj3 (MissionType) $obj3->addMission($obj1); } // if joined row not null // Add objects for joined Passenger rows $key4 = PassengerPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = PassengerPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = PassengerPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); PassengerPeer::addInstanceToPool($obj4, $key4); } // if obj4 loaded // Add the $obj1 (Mission) to the collection in $obj4 (Passenger) $obj4->addMission($obj1); } // if joined row not null // Add objects for joined MissionLeg rows $key5 = MissionLegPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = MissionLegPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = MissionLegPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); MissionLegPeer::addInstanceToPool($obj5, $key5); } // if obj5 loaded // Add the $obj1 (Mission) to the collection in $obj5 (MissionLeg) $obj5->setMission($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Calls methods defined via {@link sfMixer}. */ public function __call($method, $arguments) { if (!($callable = sfMixer::getCallable('BasePcContactNote:' . $method))) { throw new sfException(sprintf('Call to undefined method BasePcContactNote::%s', $method)); } array_unshift($arguments, $this); return call_user_func_array($callable, $arguments); }
public function __call($method, $arguments) { if (!($callable = sfMixer::getCallable('BaseSchemaPropertyElementHistory:' . $method))) { throw new sfException(sprintf('Call to undefined method BaseSchemaPropertyElementHistory::%s', $method)); } array_unshift($arguments, $this); return call_user_func_array($callable, $arguments); }