/** * Returns the processed gadget spec * * @return Gadget */ public function createGadget() { if (!($gadgetContent = $this->context->getRawXml())) { $gadgetUrl = $this->context->getUrl(); if ($this->context->getBlacklist() != null && $this->context->getBlacklist()->isBlacklisted($gadgetUrl)) { throw new GadgetException("The Gadget ({$gadgetUrl}) is blacklisted and can not be rendered"); } // Fetch the gadget's content and create a GadgetSpec $gadgetContent = $this->fetchGadget($gadgetUrl); } $gadgetSpecParserClass = Config::get('gadget_spec_parser'); $gadgetSpecParser = new $gadgetSpecParserClass(); $gadgetSpec = $gadgetSpecParser->parse($gadgetContent, $this->context); $gadgetClass = Config::get('gadget_class'); $gadget = new $gadgetClass($gadgetSpec, $this->context); // Process the gadget: fetching remote resources, processing & applying the correct translations, user prefs and feature resolving $this->addSubstitutions($gadget); $this->fetchResources($gadget); $this->mergeLocales($gadget); $this->parseUserPrefs($gadget); $this->applySubstitutions($gadget); $this->parseFeatures($gadget); return $gadget; }