Exemple #1
0
 protected function parseName($name)
 {
     if (!Dynamics_Configuration_Definition_Package::checkIsValidPackageName($name)) {
         throw new Dynamics_Error_InvalidPackageName(sprintf('"%s" is not a valid package name.', $name));
     }
     if (false === ($extensionPosition = strrpos($name, '.'))) {
         throw new Dynamics_Error_InvalidAssetType('No extension given.');
     }
     $extension = substr($name, $extensionPosition + 1);
     $name = substr($name, 0, $extensionPosition);
     return array($name, $extension);
 }
Exemple #2
0
 /**
  * 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($resource);
     }
     foreach ($xml->package as $package) {
         $packageName = (string) $package['name'];
         if (!Dynamics_Configuration_Definition_Package::checkIsValidPackageName($packageName)) {
             throw new sfConfigurationException(sprintf('Invalid package name «%s»', $packageName));
         }
         $this->doPackage($packageName, $package);
     }
 }