정의 위치

  • ./classes/context/Context.class.php

정의 내용

/**
 * Get one more vars in object vars with given arguments(key1, key2, key3,...)
 *
 * @return object
 */
function gets()
{
    $num_args = func_num_args();
    if($num_args < 1)
    {
        return;
    }
    is_a($this, 'Context') ? $self = $this : $self = self::getInstance();

    $args_list = func_get_args();
    $output = new stdClass();
    foreach($args_list as $v)
    {
        $output->{$v} = $self->get($v);
    }
    return $output;
}

 

용도

  • 여러 키에 등록된 값을 가져오고자 할 때 이용합니다.
  • 여러 키에 대한 Context::get() 메소드를 한꺼번에 조금 더 빠르게, 편리하게 수행합니다.

파라메터

  • string $key : 변수 이름 문자열입니다. 여러 키를 불러올 때 Context::gets('key1', 'key2', 'key3'); 과 같이 이용합니다. 각 key 값 를 object의 자식 변수로 반환합니다.

예시

  1. ./modules/communication/communication.admin.controller.php 내용 중 procCommunicationAdminInsertConfig() 메소드
    • /**
      		 * save configurations of the communication module
      		 * @return void|Object (success : void, fail : Object)
      		 */
      		function procCommunicationAdminInsertConfig()
      		{
      		    // get the default information
      		    $args = Context::gets('skin', 'colorset', 'editor_skin', 'sel_editor_colorset', 'mskin', 'mcolorset', 'layout_srl', 'mlayout_srl', 'grant_write_default','grant_write_group');
      		    $args->editor_colorset = $args->sel_editor_colorset;
      		    unset($args->sel_editor_colorset);
      		
      		    if(!$args->skin)
      		    {
      		        $args->skin = 'default';
      		    }
      		
      		    if(!$args->colorset)
      		    {
      		        $args->colorset = 'white';
      		    }
      		
      		    if(!$args->editor_skin)
      		    {
      		        $args->editor_skin = 'default';
      		    }
      		
      		    if(!$args->mskin)
      		    {
      		        $args->mskin = 'default';
      		    }
      		
      		    if(!$args->layout_srl)
      		    {
      		        $args->layout_srl = NULL;
      		    }
      		
      		    $oCommunicationModel = getModel('communication');
      		    $args->grant_write = $oCommunicationModel->getGrantArray($args->grant_write_default, $args->grant_write_group);
      		    unset($args->grant_write_default);
      		    unset($args->grant_write_group);
      		
      		    // create the module module Controller object
      		    $oModuleController = getController('module');
      		    $output = $oModuleController->insertModuleConfig('communication', $args);
      		
      		    $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommunicationAdminConfig');
      		    
      		    return $this->setRedirectUrl($returnUrl, $output);
      		}

       
  • profile

    if(Context::get('layout') != 'none')
    {
    }
    레이아웃이 선택되지 않았을 경우란 뜻이 맞나요? ㅎ

  • profile
    예제
    if(Context::get('module') != 'admin' ){
    }
    admin 모듈이 아닐 경우