/** * 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')); }
/** * 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); }
/** * 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); }
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')); } }
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); }
/** * 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; }
/** * Calls methods defined via {@link sfMixer}. */ public function __call($method, $arguments) { if (!($callable = sfMixer::getCallable('BasePcSubscriptionThankyouPageImpression:' . $method))) { throw new sfException(sprintf('Call to undefined method BasePcSubscriptionThankyouPageImpression::%s', $method)); } array_unshift($arguments, $this); return call_user_func_array($callable, $arguments); }
public function __call($method, $arguments) { if (!($callable = sfMixer::getCallable('BaseAutoCourseRatingMismatched:' . $method))) { throw new sfException(sprintf('Call to undefined method BaseAutoCourseRatingMismatched::%s', $method)); } array_unshift($arguments, $this); return call_user_func_array($callable, $arguments); }
public function __call($method, $arguments) { if (!($callable = sfMixer::getCallable('BaseRpMissionLegsOriginDestination:' . $method))) { throw new sfException(sprintf('Call to undefined method BaseRpMissionLegsOriginDestination::%s', $method)); } array_unshift($arguments, $this); return call_user_func_array($callable, $arguments); }
/** * This methods inspects the columns of the object's table and if one of them if a foreign key, * it returns the change log of the referenced object IF it points to the specified object (parameter). * * @param mixed $object * @param date $from_date * @param transformToAdapters * * @return Array of ncChangeLogEntry */ public function getNNRelatedChangeLog($object, $from_date = null, $transformToAdapters = true) { $relatedChangeLog = array(); $relatedObjects = array(); if (!is_null($object)) { // Obtain object's information $object_class = get_class($object); $peer = constant($object_class . '::PEER'); // Get all tableMaps and make the queries to retrieve all object instances that reference the object!!! ncClassFinder::getInstance()->reloadClasses(); foreach (ncClassFinder::getInstance()->getPeerClasses() as $class => $path) { if ($class != get_class($object) && class_exists($class) && method_exists($class, 'getTableMap')) { $criteria = new Criteria(); $tableMap = call_user_func(array($class, 'getTableMap')); foreach ($tableMap->getColumns() as $c) { if ($c->isForeignKey()) { $method = 'get' . $c->getPhpName(); $relatedTableName = $c->getRelatedTableName(); $relatedColName = $c->getRelatedColumnName(); $relatedPeerClass = ncClassFinder::getInstance()->findPeerClassName($relatedTableName); $relatedClass = ncClassFinder::getInstance()->findClassName($relatedTableName, $relatedPeerClass); // Traverse all collumns. If any has as its `relatedClass` the class of $object, make a // Criteria object to fetch every related object. if ($relatedClass == get_class($object)) { $criterion = $criteria->getNewCriterion(constant($class . '::' . $c->getName()), $object->getPrimaryKey()); $criteria->addOr($criterion); } } } if ($criteria->size() > 0) { $relatedObjects[$class] = call_user_func(array($class, 'doSelect'), $criteria); } } } // Get every object's change log foreach ($relatedObjects as $tableName => $objects) { foreach ($objects as $o) { $criteria = new Criteria(); if (!is_null($from_date)) { $criteria->add(ncChangeLogEntryPeer::CREATED_AT, $from_date, Criteria::GREATER_THAN); } if (sfMixer::getCallable('Base' . get_class($o) . ':getChangeLog') && count($changes = $o->getChangeLog($criteria)) > 0) { if (method_exists($o, '__toString')) { $relatedChangeLog[$tableName][strval($o)] = $changes; } else { $relatedChangeLog[$tableName][$o->getPrimaryKey()] = $changes; } } } } } return $relatedChangeLog; }