/**
  * Creates a component from cache.
  *
  * This method unserializes a component from memory or a file.
  *
  * Derived classes may override this method to provide other ways of caching component.
  * Be sure to override {@link cacheComponent} to make it consistent.
  * @param string the type of the component to be created
  * @see cacheComponent()
  * @return TComponent the component created, null if failed.
  */
 public function cloneComponent($type)
 {
     if (!$this->enabled) {
         return null;
     }
     $id = empty($this->currentModule) ? $type : $this->currentModule . '.' . $type;
     $data = null;
     if (isset($this->components[$id])) {
         $data = unserialize($this->components[$id]);
     } else {
         if (!empty($this->savePath)) {
             $cacheFile = $this->savePath . '/' . $type . self::EXT_CACHE;
             if (is_file($cacheFile)) {
                 $this->components[$id] = file_get_contents($cacheFile);
                 $data = unserialize($this->components[$id]);
             }
         }
     }
     if (is_array($data) && count($data) == 2) {
         if ($data[1] instanceof TPage) {
             TComponent::setDefinition(null, $data[0]);
         } else {
             TComponent::setDefinition($type, $data[0]);
         }
         return $data[1];
     } else {
         return null;
     }
 }