예제 #1
0
 /**
  * Sets the schema for the element
  *
  * @param Element $obj The element to analyze
  *
  * @return Element the translated element
  */
 public function preCacheTranslateObject(ModelObject $obj)
 {
     // merge aspects
     //$db = $this->getConnection();
     //        $q = new Query();
     //        $q->select('aspectid');
     //        $q->from('elementaspectrel');
     //        $q->where("elementid = {$db->quote($obj->{$obj->getPrimaryKey()})}");
     //        $aspectIDs = $db->readCol($q);
     //        $this->populateRels();
     //        $aspectSlugs = array_key_exists($obj->Slug, $this->aspectrel)?$this->aspectrel[$obj->Slug]['Aspects']:array();
     $aspectSlugs = $obj->getAspectSlugs();
     $schema = new NodeSchema();
     if (!empty($aspectSlugs)) {
         $aspects = $this->AspectDAO->multiGetBySlug($aspectSlugs);
         $newAspects = array();
         foreach ($aspects as $aspect) {
             //                $plugin = $this->PluginService->getByID($aspect['PluginID']);
             //                if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled())
             //                    continue;
             $aspectSchema = $aspect->getSchema();
             foreach ($aspectSchema->getTagDefs() as $tagDef) {
                 $schema->addTagDef($tagDef);
             }
             foreach ($aspectSchema->getMetaDefs() as $metaDef) {
                 $schema->addMetaDef($metaDef);
             }
             $newAspects[] = $aspect;
         }
         $obj->setAspects($newAspects);
     }
     $obj->setSchema($schema);
     $obj->setAnchoredSite($this->SiteService->getAnchoredSite());
     $obj->setAnchoredSiteSlug($obj->getAnchoredSite()->getSlug());
     return $obj;
 }