/** * Get social profile entity * * @param \Cake\ORM\Entity $profile Social profile entity * @return \Cake\ORM\Entity */ protected function _profileEntity($profile = null) { if (!$profile) { $profile = $this->_profileModel->newEntity(['provider' => $this->adapter()->id]); } foreach (get_object_vars($this->profile()) as $key => $value) { switch ($key) { case 'webSiteURL': $profile->set('website_url', $value); break; case 'profileURL': $profile->set('profile_url', $value); break; case 'photoURL': $profile->set('photo_url', $value); break; default: $profile->set(Inflector::underscore($key), $value); break; } } return $profile; }
/** * Prefixes the field with the table alias if possible. * * @param \Cake\Datasource\RepositoryInterface $object Repository object. * @param array $order Order array. * @param bool $whitelisted Whether or not the field was whitelisted * @return array Final order array. */ protected function _prefix(RepositoryInterface $object, $order, $whitelisted = false) { $tableAlias = $object->alias(); $tableOrder = []; foreach ($order as $key => $value) { if (is_numeric($key)) { $tableOrder[] = $value; continue; } $field = $key; $alias = $tableAlias; if (strpos($key, '.') !== false) { list($alias, $field) = explode('.', $key); } $correctAlias = $tableAlias === $alias; if ($correctAlias && $whitelisted) { // Disambiguate fields in schema. As id is quite common. if ($object->hasField($field)) { $field = $alias . '.' . $field; } $tableOrder[$field] = $value; } elseif ($correctAlias && $object->hasField($field)) { $tableOrder[$tableAlias . '.' . $field] = $value; } elseif (!$correctAlias && $whitelisted) { $tableOrder[$alias . '.' . $field] = $value; } } return $tableOrder; }