本文整理汇总了PHP中sfMixer::getCallable方法的典型用法代码示例。如果您正苦于以下问题:PHP sfMixer::getCallable方法的具体用法?PHP sfMixer::getCallable怎么用?PHP sfMixer::getCallable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfMixer
的用法示例。
在下文中一共展示了sfMixer::getCallable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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'));
}
示例3: __call
/**
* 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);
}
示例4: __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);
}
示例5: 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'));
}
}
示例6: __call
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);
}
示例7: 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;
}
示例8: getNNRelatedChangeLog
/**
* 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;
}