original_string: public function addComponent($name, $alias, $properties, $addToLayout = false)
      {
          $manager = ComponentManager::instance();
  
          if ($addToLayout) {
              if (!$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties)) {
                  throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
              }
  
              $componentObj->alias = $alias;
              $this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
          }
          else {
              if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) {
                  throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
              }
  
              $componentObj->alias = $alias;
              $this->vars[$alias] = $this->page->components[$alias] = $componentObj;
          }
  
          $this->setComponentPropertiesFromParams($componentObj);
          $componentObj->init();
          return $componentObj;
      }
code: public function addComponent($name, $alias, $properties, $addToLayout = false)
      {
          $manager = ComponentManager::instance();
  
          if ($addToLayout) {
              if (!$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties)) {
                  throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
              }
  
              $componentObj->alias = $alias;
              $this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
          }
          else {
              if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) {
                  throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
              }
  
              $componentObj->alias = $alias;
              $this->vars[$alias] = $this->page->components[$alias] = $componentObj;
          }
  
          $this->setComponentPropertiesFromParams($componentObj);
          $componentObj->init();
          return $componentObj;
      }
code_tokens: public function addComponent ( $ name , $ alias , $ properties , $ addToLayout = false ) { $ manager = ComponentManager :: instance ( ) ; if ( $ addToLayout ) { if ( ! $ componentObj = $ manager -> makeComponent ( $ name , $ this -> layoutObj , $ properties ) ) { throw new CmsException ( Lang :: get ( 'cms::lang.component.not_found' , [ 'name' => $ name ] ) ) ; } $ componentObj -> alias = $ alias ; $ this -> vars [ $ alias ] = $ this -> layout -> components [ $ alias ] = $ componentObj ; } else { if ( ! $ componentObj = $ manager -> makeComponent ( $ name , $ this -> pageObj , $ properties ) ) { throw new CmsException ( Lang :: get ( 'cms::lang.component.not_found' , [ 'name' => $ name ] ) ) ; } $ componentObj -> alias = $ alias ; $ this -> vars [ $ alias ] = $ this -> page -> components [ $ alias ] = $ componentObj ; } $ this -> setComponentPropertiesFromParams ( $ componentObj ) ; $ componentObj -> init ( ) ; return $ componentObj ; }
docstring: Adds a component to the page object
  @param mixed  $name        Component class name or short name
  @param string $alias       Alias to give the component
  @param array  $properties  Component properties
  @param bool   $addToLayout Add to layout, instead of page
  @return ComponentBase Component object
docstring_tokens: Adds a component to the page object