checks existence of properties and related components
public hasRelation ( mixed $fieldName ) : boolean | ||
$fieldName | mixed | name of the property or reference |
Результат | boolean |
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); }
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); }