Skip to content

Commit

Permalink
Merge pull request #154 from s-nakajima/master
Browse files Browse the repository at this point in the history
継承して拡張できるようにprivateからprotectedに修正
  • Loading branch information
s-nakajima committed Nov 29, 2017
2 parents c5fbe28 + fd41724 commit 4a1f13a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Controller/UsersAvatarController.php
Expand Up @@ -51,24 +51,24 @@ public function download() {
/* @var $User AppModel */
/* @var $UserAttributeSetting AppModel */
// シンプルにしたかったためAppModelを利用。インスタンス生成時少し速かった。
$User = $this->__getSimpleModel('User');
$User = $this->_getSimpleModel('User');
$User->Behaviors->load('Users.Avatar');
// @see https://github.com/NetCommons3/Users/blob/3.1.2/Model/Behavior/AvatarBehavior.php#L42
$User->plugin = 'Users';
ClassRegistry::removeObject('User');
ClassRegistry::removeObject('AvatarBehavior');

$params = $this->__getBindParamsForUser();
$params = $this->_getBindParamsForUser();
$User->bindModel($params);

$query = $this->__getQueryForUser();
$query = $this->_getQueryForUser();
$user = $User->find('first', $query);
ClassRegistry::removeObject('UploadFile');

if (!$user ||
!$user['UploadFile']['id']
) {
return $this->__downloadNoImage($User, $user);
return $this->_downloadNoImage($User, $user);
}

$options = [
Expand All @@ -79,13 +79,13 @@ public function download() {
return $this->Download->doDownloadByUploadFileId($user['UploadFile']['id'], $options);
}

$UserAttributeSetting = $this->__getSimpleModel('UserAttributeSetting');
$UserAttributeSetting = $this->_getSimpleModel('UserAttributeSetting');
ClassRegistry::removeObject('UserAttributeSetting');

$params = $this->__getBindParamsForUserAttributeSetting($user);
$params = $this->_getBindParamsForUserAttributeSetting($user);
$UserAttributeSetting->bindModel($params);

$query = $this->__getQueryForUserAttributeSetting();
$query = $this->_getQueryForUserAttributeSetting();
$userAttributeSetting = $UserAttributeSetting->find('first', $query);
ClassRegistry::removeObject('UserAttributesRole');

Expand All @@ -101,7 +101,7 @@ public function download() {
!$userAttributeSetting['UserAttributeSetting']['display'] ||
!$userAttributeSetting['UserAttributesRole']['other_readable']
) {
return $this->__downloadNoImage($User, $user);
return $this->_downloadNoImage($User, $user);
}

return $this->Download->doDownloadByUploadFileId($user['UploadFile']['id'], $options);
Expand All @@ -114,7 +114,7 @@ public function download() {
* @param array $user User data
* @return void
*/
private function __downloadNoImage($User, $user) {
protected function _downloadNoImage($User, $user) {
$fieldName = $this->request->params['field_name'];
$fieldSize = $this->request->params['size'];

Expand All @@ -135,7 +135,7 @@ private function __downloadNoImage($User, $user) {
* @param string $modelName Model name
* @return void
*/
private function __getSimpleModel($modelName) {
protected function _getSimpleModel($modelName) {
// TestでAvatarBehavior::temporaryAvatar をMock にしているため、removeObjectしない。
// ClassRegistry::removeObject($modelName);
$Model = ClassRegistry::init($modelName);
Expand All @@ -156,7 +156,7 @@ private function __getSimpleModel($modelName) {
*
* @return void
*/
private function __getBindParamsForUser() {
protected function _getBindParamsForUser() {
$params = [
'hasOne' => [
'UploadFile' => [
Expand All @@ -180,7 +180,7 @@ private function __getBindParamsForUser() {
*
* @return void
*/
private function __getQueryForUser() {
protected function _getQueryForUser() {
$query = [
'conditions' => [
'User.id' => $this->request->params['user_id'],
Expand All @@ -201,7 +201,7 @@ private function __getQueryForUser() {
* @param array $user User data
* @return void
*/
private function __getBindParamsForUserAttributeSetting($user) {
protected function _getBindParamsForUserAttributeSetting($user) {
$params = [
'hasOne' => [
'UserAttributesRole' => [
Expand All @@ -223,7 +223,7 @@ private function __getBindParamsForUserAttributeSetting($user) {
*
* @return void
*/
private function __getQueryForUserAttributeSetting() {
protected function _getQueryForUserAttributeSetting() {
$query = [
'conditions' => [
'UserAttributeSetting.user_attribute_key' => $this->request->params['field_name'],
Expand Down

0 comments on commit 4a1f13a

Please sign in to comment.