Author: fabien
Date: 2010-02-14 15:00:05 +0100 (Sun, 14 Feb 2010)
New Revision: 28024
Modified:
branches/2.0/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php
Log:
Merge branch 'master' of git://github.com/symfony/symfony
Modified:
branches/2.0/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php
===================================================================
---
branches/2.0/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php
2010-02-14 13:09:44 UTC (rev 28023)
+++
branches/2.0/src/Symfony/Components/DependencyInjection/BuilderConfiguration.php
2010-02-14 14:00:05 UTC (rev 28024)
@@ -2,6 +2,8 @@
namespace Symfony\Components\DependencyInjection;
+use Symfony\Components\DependencyInjection\Loader\Loader;
+
/*
* This file is part of the symfony framework.
*
@@ -45,16 +47,22 @@
* Adds a resource for this configuration.
*
* @param ResourceInterface $resource A resource instance
+ *
+ * @return BuilderConfiguration The current instance
*/
public function addResource(ResourceInterface $resource)
{
$this->resources[] = $resource;
+
+ return $this;
}
/**
* Merges a BuilderConfiguration with the current one.
*
* @param BuilderConfiguration $configuration
+ *
+ * @return BuilderConfiguration The current instance
*/
public function merge(BuilderConfiguration $configuration = null)
{
@@ -71,12 +79,35 @@
{
$this->addResource($resource);
}
+
+ return $this;
}
/**
+ * Merges the configuration given by an extension.
+ *
+ * @param $key string The extension tag to load (namespace.tag)
+ * @param $values array An array of values to customize the extension
+ *
+ * @return BuilderConfiguration The current instance
+ */
+ public function mergeExtension($key, array $values = array())
+ {
+ list($namespace, $tag) = explode('.', $key);
+
+ $config = Loader::getExtension($namespace)->load($tag, $values);
+
+ $this->merge($config);
+
+ return $this;
+ }
+
+ /**
* Sets the service container parameters.
*
* @param array $parameters An array of parameters
+ *
+ * @return BuilderConfiguration The current instance
*/
public function setParameters(array $parameters)
{
@@ -85,16 +116,22 @@
{
$this->parameters[strtolower($key)] = $value;
}
+
+ return $this;
}
/**
* Adds parameters to the service container parameters.
*
* @param array $parameters An array of parameters
+ *
+ * @return BuilderConfiguration The current instance
*/
public function addParameters(array $parameters)
{
$this->setParameters(array_merge($this->parameters, $parameters));
+
+ return $this;
}
/**
@@ -143,10 +180,14 @@
*
* @param string $name The parameter name
* @param mixed $parameters The parameter value
+ *
+ * @return BuilderConfiguration The current instance
*/
public function setParameter($name, $value)
{
$this->parameters[strtolower($name)] = $value;
+
+ return $this;
}
/**
@@ -154,18 +195,24 @@
*
* @param string $alias The alias to create
* @param string $id The service to alias
+ *
+ * @return BuilderConfiguration The current instance
*/
public function setAlias($alias, $id)
{
unset($this->definitions[$alias]);
$this->aliases[$alias] = $id;
+
+ return $this;
}
/**
* Adds definition aliases.
*
* @param array $aliases An array of aliases
+ *
+ * @return BuilderConfiguration The current instance
*/
public function addAliases(array $aliases)
{
@@ -173,6 +220,8 @@
{
$this->setAlias($alias, $id);
}
+
+ return $this;
}
/**
@@ -221,18 +270,24 @@
*
* @param string $id The identifier
* @param Definition $definition A Definition instance
+ *
+ * @return BuilderConfiguration The current instance
*/
public function setDefinition($id, Definition $definition)
{
unset($this->aliases[$id]);
return $this->definitions[$id] = $definition;
+
+ return $this;
}
/**
* Adds the definitions.
*
* @param array $definitions An array of definitions
+ *
+ * @return BuilderConfiguration The current instance
*/
public function addDefinitions(array $definitions)
{
@@ -240,17 +295,23 @@
{
$this->setDefinition($id, $definition);
}
+
+ return $this;
}
/**
* Sets the definitions.
*
* @param array $definitions An array of definitions
+ *
+ * @return BuilderConfiguration The current instance
*/
public function setDefinitions(array $definitions)
{
$this->definitions = array();
$this->addDefinitions($definitions);
+
+ return $this;
}
/**
Modified:
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php
===================================================================
---
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php
2010-02-14 13:09:44 UTC (rev 28023)
+++
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/LoaderExtensionInterface.php
2010-02-14 14:00:05 UTC (rev 28024)
@@ -46,6 +46,13 @@
public function getNamespace();
/**
+ * Returns the base path for the XSD files.
+ *
+ * @return string The XSD base path
+ */
+ public function getXsdValidationBasePath();
+
+ /**
* Returns the recommanded alias to use in XML.
*
* This alias is also the mandatory prefix to use when using YAML.
Modified:
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
===================================================================
---
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
2010-02-14 13:09:44 UTC (rev 28023)
+++
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
2010-02-14 14:00:05 UTC (rev 28024)
@@ -258,7 +258,17 @@
$items = preg_split('/\s+/', $element);
for ($i = 0, $nb = count($items); $i < $nb; $i += 2)
{
- $schemaLocations[$items[$i]] =
str_replace('http://www.symfony-project.org/', str_replace('\\', '/',
__DIR__).'/', $items[$i + 1]);
+ if ($extension = static::getExtension($items[$i]))
+ {
+ $path = str_replace('http://www.symfony-project.org/',
str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i +
1]);
+
+ if (!file_exists($path))
+ {
+ throw new \RuntimeException(sprintf('Extension "%s" references a
non-existent XSD file "%s"', get_class($extension), $path));
+ }
+
+ $schemaLocations[$items[$i]] = $path;
+ }
}
}
@@ -343,6 +353,9 @@
$values = static::convertDomElementToArray($node);
$config =
$this->getExtension($node->namespaceURI)->load($node->localName,
is_array($values) ? $values : array($values));
+ $r = new \ReflectionObject($this->getExtension($node->namespaceURI));
+ $config->addResource(new FileResource($r->getFileName()));
+
$configuration->merge($config);
}
}
Modified:
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php
===================================================================
---
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php
2010-02-14 13:09:44 UTC (rev 28023)
+++
branches/2.0/src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php
2010-02-14 14:00:05 UTC (rev 28024)
@@ -253,7 +253,7 @@
protected function loadFromExtensions(BuilderConfiguration $configuration,
$content)
{
- foreach ($content as $key => $config)
+ foreach ($content as $key => $values)
{
if (in_array($key, array('imports', 'parameters', 'services')))
{
@@ -262,12 +262,17 @@
list($namespace, $tag) = explode('.', $key);
- if (!is_array($config))
+ if (!is_array($values))
{
- $config = array();
+ $values = array();
}
- $configuration->merge(static::getExtension($namespace)->load($tag,
$config));
+ $config = static::getExtension($namespace)->load($tag, $values);
+
+ $r = new \ReflectionObject($this->getExtension($namespace));
+ $config->addResource(new FileResource($r->getFileName()));
+
+ $configuration->merge($config);
}
}
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.