本文整理汇总了PHP中Doctrine_Record::hasRelation方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::hasRelation方法的具体用法?PHP Doctrine_Record::hasRelation怎么用?PHP Doctrine_Record::hasRelation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::hasRelation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchRelatedValues
public function fetchRelatedValues(Doctrine_Record $record, $property)
{
$values = array();
$skipDirectPropertyGet = false;
// Record available translations of property, if available
if ($record->hasRelation('Translation')) {
if (!is_null($this->cacheUriCulture) && $this->hasTranslation($record, $this->cacheUriCulture)) {
$translations = array($record->Translation[$this->cacheUriCulture]);
$skipDirectPropertyGet = true;
} else {
$translations = $record->Translation;
}
foreach ($translations as $translation) {
if (isset($translation[$property]) && $translation[$property]) {
$values[] = $translation[$property];
}
}
}
// Standard property get
if (false === $skipDirectPropertyGet) {
try {
if ($value = (string) $record->{$property}) {
$values[] = $value;
}
} catch (Exception $e) {
}
}
return array_unique($values);
}
开发者ID:jeremyb,项目名称:akDoctrineTemplateCacheInvaliderPlugin,代码行数:29,代码来源:akDoctrineCacheUriResolver.class.php
示例2: fetchRelatedValues
public function fetchRelatedValues(Doctrine_Record $record, $property)
{
if ($record->getTable()->isIdentifier($property)) {
$value = $record->{$property};
return $value ? array($value) : array();
}
$values = array();
$skipDirectPropertyGet = false;
// Record available translations of property, if available
if ($record->hasRelation('Translation')) {
if (!is_null($this->cacheUriCulture) && $this->hasTranslation($record, $this->cacheUriCulture)) {
$translations = array($record->Translation[$this->cacheUriCulture]);
$skipDirectPropertyGet = true;
} else {
$translations = $record->Translation;
}
foreach ($translations as $translation) {
if (isset($translation[$property]) && $translation[$property]) {
$values[] = $translation[$property];
}
}
}
// Standard property get
if (false === $skipDirectPropertyGet) {
try {
// circumvents a silly Doctrine behavior which may alter the record instance reference
// when trying to access some of its properties, so we copy it instead to be safe
$copy = $record->copy(false);
if ($value = (string) $copy->{$property}) {
$values[] = $value;
}
$copy->free(true);
} catch (Exception $e) {
$values[] = '*';
}
}
return array_unique($values);
}
开发者ID:n1k0,项目名称:akDoctrineTemplateCacheInvaliderPlugin,代码行数:38,代码来源:akDoctrineCacheUriResolver.class.php