| 79 | | if (null === $this->profile) |
|---|
| 80 | | { |
|---|
| 81 | | $profileClass = sfConfig::get('app_sf_guard_plugin_profile_class', 'sfGuardUserProfile'); |
|---|
| 82 | | if (!class_exists($profileClass)) |
|---|
| 83 | | { |
|---|
| 84 | | throw new sfException(sprintf('The user profile class "%s" does not exist.', $profileClass)); |
|---|
| 85 | | } |
|---|
| 86 | | |
|---|
| 87 | | $fieldName = sfConfig::get('app_sf_guard_plugin_profile_field_name', 'user_id'); |
|---|
| 88 | | $profilePeerClass = $profileClass.'Peer'; |
|---|
| 89 | | |
|---|
| 90 | | // to avoid php segmentation fault |
|---|
| 91 | | class_exists($profilePeerClass); |
|---|
| 92 | | |
|---|
| 93 | | $foreignKeyColumn = call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME)); |
|---|
| 94 | | |
|---|
| 95 | | if (!$foreignKeyColumn) |
|---|
| 96 | | { |
|---|
| 97 | | throw new sfException(sprintf('The user profile class "%s" does not contain a "%s" column.', $profileClass, $fieldName)); |
|---|
| 98 | | } |
|---|
| 99 | | |
|---|
| 100 | | $c = new Criteria(); |
|---|
| 101 | | $c->add($foreignKeyColumn, $this->getId()); |
|---|
| 102 | | |
|---|
| 103 | | $this->profile = call_user_func_array(array($profileClass.'Peer', 'doSelectOne'), array($c)); |
|---|
| 104 | | |
|---|
| 105 | | if (!$this->profile) |
|---|
| 106 | | { |
|---|
| 107 | | $this->profile = new $profileClass(); |
|---|
| 108 | | $method = 'set'.call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME)); |
|---|
| 109 | | $this->profile->$method($this->getId()); |
|---|
| 110 | | } |
|---|
| | 79 | if (!is_null($this->profile)) |
|---|
| | 80 | { |
|---|
| | 81 | return $this->profile; |
|---|
| | 82 | } |
|---|
| | 83 | |
|---|
| | 84 | $profileClass = sfConfig::get('app_sf_guard_plugin_profile_class', 'sfGuardUserProfile'); |
|---|
| | 85 | if (!class_exists($profileClass)) |
|---|
| | 86 | { |
|---|
| | 87 | throw new sfException(sprintf('The user profile class "%s" does not exist.', $profileClass)); |
|---|
| | 88 | } |
|---|
| | 89 | |
|---|
| | 90 | $fieldName = sfConfig::get('app_sf_guard_plugin_profile_field_name', 'user_id'); |
|---|
| | 91 | $profilePeerClass = $profileClass.'Peer'; |
|---|
| | 92 | |
|---|
| | 93 | // to avoid php segmentation fault |
|---|
| | 94 | class_exists($profilePeerClass); |
|---|
| | 95 | |
|---|
| | 96 | $foreignKeyColumn = call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME)); |
|---|
| | 97 | |
|---|
| | 98 | if (!$foreignKeyColumn) |
|---|
| | 99 | { |
|---|
| | 100 | throw new sfException(sprintf('The user profile class "%s" does not contain a "%s" column.', $profileClass, $fieldName)); |
|---|
| | 101 | } |
|---|
| | 102 | |
|---|
| | 103 | $c = new Criteria(); |
|---|
| | 104 | $c->add($foreignKeyColumn, $this->getId()); |
|---|
| | 105 | |
|---|
| | 106 | $this->profile = call_user_func_array(array($profileClass.'Peer', 'doSelectOne'), array($c)); |
|---|
| | 107 | |
|---|
| | 108 | if (!$this->profile) |
|---|
| | 109 | { |
|---|
| | 110 | $this->profile = new $profileClass(); |
|---|
| | 111 | $method = 'set'.call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME)); |
|---|
| | 112 | $this->profile->$method($this->getId()); |
|---|