public function executeAsset($request) { try { $name = $this->getRequest()->getParameter('name'); $this->forward404Unless(sfDynamicsPackageDefinition::checkIsValidPackageName($name)); $extensionPosition = strrpos($name, '.'); $assetExtension = substr($name, $extensionPosition + 1); $assetType = sfDynamics::getTypeFromExtension($assetExtension); $name = substr($name, 0, $extensionPosition); $this->package = sfDynamics::getManager()->getPackage($name); $this->{'pre' . ucfirst($assetType)}(); return $this->renderText(sfDynamics::getRenderer()->getAsset($name, $this->package, $assetType, $assetExtension)); } catch (Exception $e) { throw new sfError404Exception($e->getMessage()); } }
/** * parseXml * * @param mixed $xml * @return void */ public function parseXml($xml) { if (!($xml && $xml instanceof SimpleXMLElement)) { throw new InvalidArgumentException('Invalid XML given'); } if ($xml->getName() != 'dynamics') { throw new sfDynamicsConfigurationException('Invalid XML file.' . "\n\n" . 'Root node\'s tag name must be «dynamics».'); } foreach ($xml->import as $import) { if (!($resource = (string) $import['resource'])) { throw new sfDynamicsConfigurationException('Invalid «import» tag.' . "\n\n" . 'A «resource» attribute is needed, containing the name of the resource to import.'); } $this->doImport('config/' . $resource); } foreach ($xml->package as $package) { $packageName = (string) $package['name']; if (!sfDynamicsPackageDefinition::checkIsValidPackageName($packageName)) { throw new sfConfigurationException(sprintf('Invalid package name «%s»', $packageName)); } $this->doPackage($packageName, $package); } }