本文整理汇总了PHP中News::setRelatedMonitorableModel方法的典型用法代码示例。如果您正苦于以下问题:PHP News::setRelatedMonitorableModel方法的具体用法?PHP News::setRelatedMonitorableModel怎么用?PHP News::setRelatedMonitorableModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News::setRelatedMonitorableModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateNews
/**
* create as many news as the number of monitorable objects related to the
* generating object
*
* @param BaseObject $object - the generator object
* @param int $priority - the priority (it's an override if not null)
* @param bool $isSuccNews - flag to generate a succNews (only called from batch script)
*
* @return int - the number of generated news
* @author Guglielmo Celata
**/
public function generateNews(BaseObject $object, $priority = null, $isSuccNews = null)
{
$n_gen_news = 0;
// fetch the monitorable objects related to this generator
$monitorable_objects = $this->getRelatedMonitorableObjects($object);
foreach ($monitorable_objects as $obj) {
// temporarily skip news generation when tagging emendamento
if (get_class($object) == 'Tagging' && $object->getTaggableModel() == 'OppEmendamento') {
continue;
}
$n = new News();
$n->setGeneratorModel(get_class($object));
$n->setGeneratorPrimaryKeys(serialize($this->getPrimaryKeysArray($object)));
$n->setRelatedMonitorableModel(get_class($obj));
$n->setRelatedMonitorableId($obj->getPrimaryKey());
// the following methods store data related to the generating object in the cache
// only data needed to sort, sum, average, or count, are cached
if ($object->getCreatedAt() != null) {
$n->setCreatedAt($object->getCreatedAt());
}
$n->setDate($object->getNewsDate());
if (!is_null($priority)) {
$n->setPriority($priority);
} else {
$n->setPriority($object->getNewsPriority());
}
# TODO: spostare le eccezioni fuori dal plugin, in un contesto di applicazione
// eccezioni
// eccezione per non generare notizia alla presentazione di un decreto legge
if ($object instanceof OppAtto && $object->getTipoAttoId() == 12) {
continue;
}
if ($obj instanceof OppAtto) {
$n->setDataPresentazioneAtto($obj->getDataPres());
$n->setTipoAttoId($obj->getOppTipoAtto()->getId());
$n->setRamoVotazione($obj->getRamo());
}
// eccezione per modifica valore campo succ (opp_atto)
if (isset($this->succNews) && $this->succNews || $isSuccNews) {
$n->setSucc($object->getSucc());
$succ_obj = OppAttoPeer::retrieveByPK($object->getSucc());
$n->setDate($succ_obj->getDataPres('Y-m-d h:i:s'));
}
// eccezione per news generate dal tagging
if ($object instanceof Tagging) {
$n->setTagId($object->getTagId());
}
$n->save();
$n_gen_news++;
}
return $n_gen_news;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:63,代码来源:deppPropelActAsNewsGeneratorBehavior.class.php
示例2: generateNewsForPolitico
public function generateNewsForPolitico()
{
// force generation of another news related to politico in case skip is activated
// we need the news related to the politician for the politician page
$n = new News();
$n->setGeneratorModel(get_class($this));
$n->setGeneratorPrimaryKeys(serialize($this->getPrimaryKeysArray()));
$n->setRelatedMonitorableModel('OppPolitico');
$n->setRelatedMonitorableId($this->getOppCarica()->getPoliticoId());
if ($this->getCreatedAt() != null) {
$n->setCreatedAt($this->getCreatedAt());
}
$n->setDate($this->getNewsDate());
$n->setPriority(2);
$n->save();
}
示例3: Criteria
define('SF_ENVIRONMENT', 'prod');
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
/*
duplica le notizie generate dal Tagging, relative a un OppAtto
per ogni notizia, genera una notizia relativa a Tag, con data equivalente
in questo modo, l'estrazione di notizie relative a un tag è semplificata
*/
echo "Fetching news to duplicate\n";
$c = new Criteria();
$c->add(NewsPeer::GENERATOR_MODEL, 'Tagging');
$c->add(NewsPeer::RELATED_MONITORABLE_MODEL, 'OppAtto');
$news = NewsPeer::doSelect($c);
echo "Found " . count($news) . " news\n";
foreach ($news as $i => $n) {
$nn = new News();
$nn->setGeneratorModel($n->getGeneratorModel());
$nn->setGeneratorPrimaryKeys($n->getGeneratorPrimaryKeys());
$nn->setRelatedMonitorableModel('Tag');
$nn->setRelatedMonitorableId($n->getTagId());
$nn->setCreatedAt($n->getCreatedAt());
$nn->setDate($n->getDate());
$nn->setPriority(1);
$nn->setTagId($n->getTagId());
$nn->save();
if ($i % 100 == 0) {
echo $i . " ";
}
}
echo "\n{$i} news processed and fixed\n";
示例4: addGroupVotation
/**
* insert a record in the sf_news_cache table, regarding votation on given
* date, place and act; see description of hasGroupVotation, for the meaning of
* parameters
*
* @param date $data - the date of the seduta when the votation happened
* @param char $ramo - the place where the votation happened (C|S)
* @param char $tipo_atto_id - the type of act the news is related to
* @param integer $atto_id - the identifier for the OppAtto object the votation is related to
*
* @return void
* @author Guglielmo Celata
**/
public static function addGroupVotation($data, $ramo, $tipo_atto_id, $atto_id = null)
{
if (!isset($data) || !isset($ramo) || !isset($tipo_atto_id)) {
throw new deppPropelActAsNewsGeneratorException('$data, $ramo and $tipo_atto_id are required');
}
$news = new News();
$news->setGeneratorModel('OppVotazioneHasAtto');
$news->setDate($data);
$news->setRamoVotazione($ramo);
$news->setRelatedMonitorableModel('OppAtto');
$news->setTipoAttoId($tipo_atto_id);
if (!isset($atto_id)) {
$news->setPriority(1);
} else {
$news->setPriority(2);
$news->setRelatedMonitorableId($atto_id);
}
$news->save();
}