Version Notes
Download this release
Release Info
Developer | Integrations Team |
Extension | Bitpay_Core |
Version | 2.1.3 |
Comparing to | |
See all releases |
Code changes from version 2.1.2 to 2.1.3
- app/code/community/Bitpay/Core/Helper/Data.php +13 -47
- {lib/Symfony/Component/Config → app/code/community/Bitpay/Core}/LICENSE +7 -5
- app/code/community/Bitpay/Core/Model/Config/PairingCode.php +1 -1
- app/code/community/Bitpay/Core/Model/Invoice.php +4 -4
- app/code/community/Bitpay/Core/Model/Ipn.php +1 -1
- app/code/community/Bitpay/Core/Model/Method/Bitcoin.php +1 -1
- app/code/community/Bitpay/Core/Model/Mysql4/Invoice.php +1 -1
- app/code/community/Bitpay/Core/Model/Mysql4/Invoice/Collection.php +1 -1
- app/code/community/Bitpay/Core/Model/Mysql4/Ipn.php +1 -1
- app/code/community/Bitpay/Core/Model/Mysql4/Ipn/Collection.php +1 -1
- app/code/community/Bitpay/Core/Model/Network.php +1 -1
- app/code/community/Bitpay/Core/Model/Observer.php +1 -1
- app/code/community/Bitpay/Core/Model/Resource/Mysql4/Setup.php +1 -1
- app/code/community/Bitpay/Core/Model/Status.php +1 -1
- app/code/community/Bitpay/Core/Model/TransactionSpeed.php +1 -1
- app/code/community/Bitpay/Core/README.md +68 -0
- app/code/community/Bitpay/Core/controllers/IpnController.php +4 -4
- app/code/community/Bitpay/Core/etc/config.xml +1 -1
- app/code/community/Bitpay/Core/sql/bitpay_setup/{mysql4-install-2.0.0.php → install-2.1.3.php} +1 -1
- app/code/community/Bitpay/Core/sql/bitpay_setup/upgrade-2.0.1-2.1.3.php +15 -0
- lib/Bitpay/Client/Client.php +6 -2
- lib/Symfony/Component/Config/CHANGELOG.md +0 -21
- lib/Symfony/Component/Config/ConfigCache.php +0 -126
- lib/Symfony/Component/Config/Definition/ArrayNode.php +0 -390
- lib/Symfony/Component/Config/Definition/BaseNode.php +0 -360
- lib/Symfony/Component/Config/Definition/BooleanNode.php +0 -39
- lib/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +0 -488
- lib/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php +0 -42
- lib/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php +0 -53
- lib/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +0 -238
- lib/Symfony/Component/Config/Definition/Builder/FloatNodeDefinition.php +0 -32
- lib/Symfony/Component/Config/Definition/Builder/IntegerNodeDefinition.php +0 -32
- lib/Symfony/Component/Config/Definition/Builder/MergeBuilder.php +0 -72
- lib/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +0 -245
- lib/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +0 -343
- lib/Symfony/Component/Config/Definition/Builder/NodeParentInterface.php +0 -21
- lib/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php +0 -67
- lib/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php +0 -61
- lib/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php +0 -26
- lib/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php +0 -32
- lib/Symfony/Component/Config/Definition/Builder/TreeBuilder.php +0 -63
- lib/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php +0 -51
- lib/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php +0 -64
- lib/Symfony/Component/Config/Definition/ConfigurationInterface.php +0 -27
- lib/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +0 -300
- lib/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +0 -199
- lib/Symfony/Component/Config/Definition/EnumNode.php +0 -58
- lib/Symfony/Component/Config/Definition/Exception/DuplicateKeyException.php +0 -22
- lib/Symfony/Component/Config/Definition/Exception/Exception.php +0 -21
- lib/Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php +0 -22
- lib/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php +0 -33
- lib/Symfony/Component/Config/Definition/Exception/InvalidDefinitionException.php +0 -21
- lib/Symfony/Component/Config/Definition/Exception/InvalidTypeException.php +0 -21
- lib/Symfony/Component/Config/Definition/Exception/UnsetKeyException.php +0 -22
- lib/Symfony/Component/Config/Definition/FloatNode.php +0 -40
- lib/Symfony/Component/Config/Definition/IntegerNode.php +0 -35
- lib/Symfony/Component/Config/Definition/NodeInterface.php +0 -88
- lib/Symfony/Component/Config/Definition/NumericNode.php +0 -55
- lib/Symfony/Component/Config/Definition/Processor.php +0 -97
- lib/Symfony/Component/Config/Definition/PrototypeNodeInterface.php +0 -27
- lib/Symfony/Component/Config/Definition/PrototypedArrayNode.php +0 -331
- lib/Symfony/Component/Config/Definition/ReferenceDumper.php +0 -21
- lib/Symfony/Component/Config/Definition/ScalarNode.php +0 -46
- lib/Symfony/Component/Config/Definition/VariableNode.php +0 -116
- lib/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +0 -27
- lib/Symfony/Component/Config/Exception/FileLoaderLoadException.php +0 -81
- lib/Symfony/Component/Config/FileLocator.php +0 -95
- lib/Symfony/Component/Config/FileLocatorInterface.php +0 -31
- lib/Symfony/Component/Config/Loader/DelegatingLoader.php +0 -55
- lib/Symfony/Component/Config/Loader/FileLoader.php +0 -124
- lib/Symfony/Component/Config/Loader/Loader.php +0 -78
- lib/Symfony/Component/Config/Loader/LoaderInterface.php +0 -54
- lib/Symfony/Component/Config/Loader/LoaderResolver.php +0 -75
- lib/Symfony/Component/Config/Loader/LoaderResolverInterface.php +0 -30
- lib/Symfony/Component/Config/README.md +0 -17
- lib/Symfony/Component/Config/Resource/DirectoryResource.php +0 -99
- lib/Symfony/Component/Config/Resource/FileResource.php +0 -75
- lib/Symfony/Component/Config/Resource/ResourceInterface.php +0 -43
- lib/Symfony/Component/Config/Util/XmlUtils.php +0 -236
- lib/Symfony/Component/Config/composer.json +0 -32
- lib/Symfony/Component/Config/phpunit.xml.dist +0 -29
- lib/Symfony/Component/DependencyInjection/Alias.php +0 -71
- lib/Symfony/Component/DependencyInjection/CHANGELOG.md +0 -35
- lib/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +0 -148
- lib/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +0 -79
- lib/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +0 -90
- lib/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php +0 -63
- lib/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +0 -167
- lib/Symfony/Component/DependencyInjection/Compiler/Compiler.php +0 -120
- lib/Symfony/Component/DependencyInjection/Compiler/CompilerPassInterface.php +0 -33
- lib/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php +0 -54
- lib/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +0 -152
- lib/Symfony/Component/DependencyInjection/Compiler/LoggingFormatter.php +0 -45
- lib/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +0 -59
- lib/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +0 -256
- lib/Symfony/Component/DependencyInjection/Compiler/RemoveAbstractDefinitionsPass.php +0 -38
- lib/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php +0 -44
- lib/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php +0 -84
- lib/Symfony/Component/DependencyInjection/Compiler/RepeatablePassInterface.php +0 -28
- lib/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php +0 -88
- lib/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +0 -125
- lib/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php +0 -154
- lib/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +0 -105
- lib/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php +0 -63
- lib/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +0 -99
- lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php +0 -114
- lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php +0 -70
- lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php +0 -122
- lib/Symfony/Component/DependencyInjection/Container.php +0 -567
- lib/Symfony/Component/DependencyInjection/ContainerAware.php +0 -41
- lib/Symfony/Component/DependencyInjection/ContainerAwareInterface.php +0 -31
- lib/Symfony/Component/DependencyInjection/ContainerAwareTrait.php +0 -35
- lib/Symfony/Component/DependencyInjection/ContainerBuilder.php +0 -1168
- lib/Symfony/Component/DependencyInjection/ContainerInterface.php +0 -158
- lib/Symfony/Component/DependencyInjection/Definition.php +0 -742
- lib/Symfony/Component/DependencyInjection/DefinitionDecorator.php +0 -219
- lib/Symfony/Component/DependencyInjection/Dumper/Dumper.php +0 -38
- lib/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php +0 -33
- lib/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +0 -302
- lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +0 -1448
- lib/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +0 -337
- lib/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +0 -336
- lib/Symfony/Component/DependencyInjection/Exception/BadMethodCallException.php +0 -19
- lib/Symfony/Component/DependencyInjection/Exception/ExceptionInterface.php +0 -22
- lib/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php +0 -41
- lib/Symfony/Component/DependencyInjection/Exception/InvalidArgumentException.php +0 -21
- lib/Symfony/Component/DependencyInjection/Exception/LogicException.php +0 -19
- lib/Symfony/Component/DependencyInjection/Exception/OutOfBoundsException.php +0 -19
- lib/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php +0 -34
- lib/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php +0 -95
- lib/Symfony/Component/DependencyInjection/Exception/RuntimeException.php +0 -21
- lib/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php +0 -65
- lib/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php +0 -64
- lib/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php +0 -41
- lib/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php +0 -56
- lib/Symfony/Component/DependencyInjection/ExpressionLanguage.php +0 -42
- lib/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php +0 -33
- lib/Symfony/Component/DependencyInjection/Extension/Extension.php +0 -124
- lib/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php +0 -65
- lib/Symfony/Component/DependencyInjection/Extension/PrependExtensionInterface.php +0 -24
- lib/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php +0 -30
- lib/Symfony/Component/DependencyInjection/LICENSE +0 -19
- lib/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php +0 -37
- lib/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php +0 -33
- lib/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php +0 -50
- lib/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php +0 -46
- lib/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php +0 -53
- lib/Symfony/Component/DependencyInjection/Loader/FileLoader.php +0 -39
- lib/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +0 -52
- lib/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +0 -49
- lib/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +0 -528
- lib/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +0 -392
- lib/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +0 -189
- lib/Symfony/Component/DependencyInjection/Parameter.php +0 -44
- lib/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php +0 -72
- lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +0 -304
- lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +0 -115
- lib/Symfony/Component/DependencyInjection/README.md +0 -81
- lib/Symfony/Component/DependencyInjection/Reference.php +0 -72
- lib/Symfony/Component/DependencyInjection/Scope.php +0 -50
- lib/Symfony/Component/DependencyInjection/ScopeInterface.php +0 -32
- lib/Symfony/Component/DependencyInjection/SimpleXMLElement.php +0 -114
- lib/Symfony/Component/DependencyInjection/TaggedContainerInterface.php +0 -33
- lib/Symfony/Component/DependencyInjection/Variable.php +0 -50
- lib/Symfony/Component/DependencyInjection/composer.json +0 -41
- lib/Symfony/Component/DependencyInjection/phpunit.xml.dist +0 -29
- lib/Symfony/Component/Filesystem/CHANGELOG.md +0 -23
- lib/Symfony/Component/Filesystem/Exception/ExceptionInterface.php +0 -23
- lib/Symfony/Component/Filesystem/Exception/FileNotFoundException.php +0 -34
- lib/Symfony/Component/Filesystem/Exception/IOException.php +0 -41
- lib/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php +0 -27
- lib/Symfony/Component/Filesystem/Filesystem.php +0 -490
- lib/Symfony/Component/Filesystem/LICENSE +0 -19
- lib/Symfony/Component/Filesystem/README.md +0 -47
- lib/Symfony/Component/Filesystem/composer.json +0 -31
- lib/Symfony/Component/Filesystem/phpunit.xml.dist +0 -27
- package.xml +1 -1
app/code/community/Bitpay/Core/Helper/Data.php
CHANGED
@@ -101,7 +101,7 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
101 |
}
|
102 |
|
103 |
$this->_privateKey = new Bitpay\PrivateKey('payment/bitpay/private_key');
|
104 |
-
|
105 |
if (false === isset($this->_privateKey) || true === empty($this->_privateKey)) {
|
106 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::generateAndSaveKeys(): could not create new Bitpay private key object. Cannot continue!');
|
107 |
throw new \Exception('In Bitpay_Core_Helper_Data::generateAndSaveKeys(): could not create new Bitpay private key object. Cannot continue!');
|
@@ -251,7 +251,7 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
251 |
return $this->_publicKey;
|
252 |
} else {
|
253 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getPublicKey(): could not load or generate a new public key. Cannot continue!');
|
254 |
-
throw new \Exception('In Bitpay_Core_Helper_Data::getPublicKey(): could not load or generate a new public key. Cannot continue!');
|
255 |
}
|
256 |
}
|
257 |
|
@@ -283,7 +283,7 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
283 |
return $this->_privateKey;
|
284 |
} else {
|
285 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getPrivateKey(): could not load or generate a new private key. Cannot continue!');
|
286 |
-
throw new \Exception('In Bitpay_Core_Helper_Data::getPrivateKey(): could not load or generate a new private key. Cannot continue!');
|
287 |
}
|
288 |
}
|
289 |
|
@@ -298,7 +298,7 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
298 |
}
|
299 |
|
300 |
$this->_keyManager = new Bitpay\KeyManager(new Bitpay\Storage\MagentoStorage());
|
301 |
-
|
302 |
if (false === isset($this->_keyManager) || true === empty($this->_keyManager)) {
|
303 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getKeyManager(): could not create new BitPay KeyManager object. Cannot continue!');
|
304 |
throw new \Exception('In Bitpay_Core_Helper_Data::getKeyManager(): could not create new BitPay KeyManager object. Cannot continue!');
|
@@ -310,47 +310,6 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
310 |
return $this->_keyManager;
|
311 |
}
|
312 |
|
313 |
-
/**
|
314 |
-
* Initialize an instance of Bitpay or return the one that has already
|
315 |
-
* been created.
|
316 |
-
*
|
317 |
-
* @return Bitpay\Bitpay
|
318 |
-
*/
|
319 |
-
public function getBitpay()
|
320 |
-
{
|
321 |
-
if (true === empty($this->_bitpay)) {
|
322 |
-
if (true === empty($this->_autoloaderRegistered)) {
|
323 |
-
$this->registerAutoloader();
|
324 |
-
}
|
325 |
-
|
326 |
-
$this->_bitpay = new Bitpay\Bitpay(array('bitpay' => $this->getBitpayConfig()));
|
327 |
-
|
328 |
-
if (false === isset($this->_bitpay) || true === empty($this->_bitpay)) {
|
329 |
-
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getBitpay(): could not create new BitPay object. Cannot continue!');
|
330 |
-
throw new \Exception('In Bitpay_Core_Helper_Data::getBitpay(): could not create new BitPay object. Cannot continue!');
|
331 |
-
} else {
|
332 |
-
$this->debugData('[INFO] In Bitpay_Core_Helper_Data::getBitpay(): successfully created new BitPay object.');
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
return $this->_bitpay;
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* Sets up the bitpay container with settings for magento
|
341 |
-
*
|
342 |
-
* @return array
|
343 |
-
*/
|
344 |
-
protected function getBitpayConfig()
|
345 |
-
{
|
346 |
-
return array(
|
347 |
-
'public_key' => 'payment/bitpay/public_key',
|
348 |
-
'private_key' => 'payment/bitpay/private_key',
|
349 |
-
'network' => \Mage::getStoreConfig('payment/bitpay/network'),
|
350 |
-
'key_storage' => '\\Bitpay\\Storage\\MagentoStorage',
|
351 |
-
);
|
352 |
-
}
|
353 |
-
|
354 |
/**
|
355 |
* @return Bitpay\Client
|
356 |
*/
|
@@ -373,10 +332,17 @@ class Bitpay_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
|
373 |
$this->debugData('[INFO] In Bitpay_Core_Helper_Data::getBitpayClient(): successfully created new BitPay Client object.');
|
374 |
}
|
375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
$this->_client->setPublicKey($this->getPublicKey());
|
377 |
$this->_client->setPrivateKey($this->getPrivateKey());
|
378 |
-
$this->_client->setNetwork($
|
379 |
-
$this->_client->setAdapter($
|
380 |
$this->_client->setToken($this->getToken());
|
381 |
|
382 |
return $this->_client;
|
101 |
}
|
102 |
|
103 |
$this->_privateKey = new Bitpay\PrivateKey('payment/bitpay/private_key');
|
104 |
+
|
105 |
if (false === isset($this->_privateKey) || true === empty($this->_privateKey)) {
|
106 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::generateAndSaveKeys(): could not create new Bitpay private key object. Cannot continue!');
|
107 |
throw new \Exception('In Bitpay_Core_Helper_Data::generateAndSaveKeys(): could not create new Bitpay private key object. Cannot continue!');
|
251 |
return $this->_publicKey;
|
252 |
} else {
|
253 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getPublicKey(): could not load or generate a new public key. Cannot continue!');
|
254 |
+
throw new \Exception('In Bitpay_Core_Helper_Data::getPublicKey(): could not load or generate a new public key. Cannot continue!');
|
255 |
}
|
256 |
}
|
257 |
|
283 |
return $this->_privateKey;
|
284 |
} else {
|
285 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getPrivateKey(): could not load or generate a new private key. Cannot continue!');
|
286 |
+
throw new \Exception('In Bitpay_Core_Helper_Data::getPrivateKey(): could not load or generate a new private key. Cannot continue!');
|
287 |
}
|
288 |
}
|
289 |
|
298 |
}
|
299 |
|
300 |
$this->_keyManager = new Bitpay\KeyManager(new Bitpay\Storage\MagentoStorage());
|
301 |
+
|
302 |
if (false === isset($this->_keyManager) || true === empty($this->_keyManager)) {
|
303 |
$this->debugData('[ERROR] In Bitpay_Core_Helper_Data::getKeyManager(): could not create new BitPay KeyManager object. Cannot continue!');
|
304 |
throw new \Exception('In Bitpay_Core_Helper_Data::getKeyManager(): could not create new BitPay KeyManager object. Cannot continue!');
|
310 |
return $this->_keyManager;
|
311 |
}
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
/**
|
314 |
* @return Bitpay\Client
|
315 |
*/
|
332 |
$this->debugData('[INFO] In Bitpay_Core_Helper_Data::getBitpayClient(): successfully created new BitPay Client object.');
|
333 |
}
|
334 |
|
335 |
+
if(\Mage::getStoreConfig('payment/bitpay/network') === 'livenet') {
|
336 |
+
$network = new Bitpay\Network\Livenet();
|
337 |
+
} else {
|
338 |
+
$network = new Bitpay\Network\Testnet();
|
339 |
+
}
|
340 |
+
$adapter = new Bitpay\Client\Adapter\CurlAdapter();
|
341 |
+
|
342 |
$this->_client->setPublicKey($this->getPublicKey());
|
343 |
$this->_client->setPrivateKey($this->getPrivateKey());
|
344 |
+
$this->_client->setNetwork($network);
|
345 |
+
$this->_client->setAdapter($adapter);
|
346 |
$this->_client->setToken($this->getToken());
|
347 |
|
348 |
return $this->_client;
|
{lib/Symfony/Component/Config → app/code/community/Bitpay/Core}/LICENSE
RENAMED
@@ -1,14 +1,16 @@
|
|
1 |
-
|
|
|
|
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
of this software and associated documentation files (the "Software"), to deal
|
5 |
in the Software without restriction, including without limitation the rights
|
6 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is
|
8 |
-
to do so, subject to the following conditions:
|
9 |
|
10 |
-
The above copyright notice and this permission notice shall be included in
|
11 |
-
copies or substantial portions of the Software.
|
12 |
|
13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2011-2014 BitPay, Inc.
|
4 |
|
5 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
of this software and associated documentation files (the "Software"), to deal
|
7 |
in the Software without restriction, including without limitation the rights
|
8 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
|
12 |
+
The above copyright notice and this permission notice shall be included in
|
13 |
+
all copies or substantial portions of the Software.
|
14 |
|
15 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
app/code/community/Bitpay/Core/Model/Config/PairingCode.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Invoice.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
@@ -39,9 +39,9 @@ class Bitpay_Core_Model_Invoice extends Mage_Core_Model_Abstract
|
|
39 |
'price' => $invoice->getPrice(),
|
40 |
'currency' => $invoice->getCurrency()->getCode(),
|
41 |
'order_id' => $invoice->getOrderId(),
|
42 |
-
'invoice_time' => $invoice->getInvoiceTime(),
|
43 |
-
'expiration_time' => $invoice->getExpirationTime(),
|
44 |
-
'current_time' => $invoice->getCurrentTime(),
|
45 |
'btc_paid' => $invoice->getBtcPaid(),
|
46 |
'rate' => $invoice->getRate(),
|
47 |
'exception_status' => $invoice->getExceptionStatus(),
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
39 |
'price' => $invoice->getPrice(),
|
40 |
'currency' => $invoice->getCurrency()->getCode(),
|
41 |
'order_id' => $invoice->getOrderId(),
|
42 |
+
'invoice_time' => intval($invoice->getInvoiceTime() / 1000),
|
43 |
+
'expiration_time' => intval($invoice->getExpirationTime() / 1000),
|
44 |
+
'current_time' => intval($invoice->getCurrentTime() / 1000),
|
45 |
'btc_paid' => $invoice->getBtcPaid(),
|
46 |
'rate' => $invoice->getRate(),
|
47 |
'exception_status' => $invoice->getExceptionStatus(),
|
app/code/community/Bitpay/Core/Model/Ipn.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Method/Bitcoin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Mysql4/Invoice.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Mysql4/Invoice/Collection.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Mysql4/Ipn.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Mysql4/Ipn/Collection.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Network.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Observer.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Resource/Mysql4/Setup.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/Status.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/Model/TransactionSpeed.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @license Copyright 2011-
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
4 |
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
*/
|
6 |
|
app/code/community/Bitpay/Core/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Description
|
2 |
+
|
3 |
+
Bitcoin payment plugin for Magento using the bitpay.com service.
|
4 |
+
|
5 |
+
[![Build Status](https://travis-ci.org/bitpay/magento-plugin.svg?branch=master)](https://travis-ci.org/bitpay/magento-plugin)
|
6 |
+
|
7 |
+
|
8 |
+
## Quick Start Guide
|
9 |
+
|
10 |
+
To get up and running with our plugin quickly, see the GUIDE here: https://github.com/bitpay/magento-plugin/blob/master/GUIDE.md
|
11 |
+
|
12 |
+
## Support
|
13 |
+
|
14 |
+
**BitPay Support:**
|
15 |
+
|
16 |
+
* [GitHub Issues](https://github.com/bitpay/magento-plugin/issues)
|
17 |
+
* Open an issue if you are having issues with this plugin.
|
18 |
+
* [Support](https://support.bitpay.com)
|
19 |
+
* BitPay merchant support documentation
|
20 |
+
|
21 |
+
**Magento Support:**
|
22 |
+
|
23 |
+
* [Homepage](http://magento.com)
|
24 |
+
* [Documentation](http://docs.magentocommerce.com)
|
25 |
+
* [Community Edition Support Forums](https://www.magentocommerce.com/support/ce/)
|
26 |
+
|
27 |
+
## Troubleshooting
|
28 |
+
|
29 |
+
1. Ensure a valid SSL certificate is installed on your server. Also ensure your root CA cert is updated. If your CA cert is not current, you will see curl SSL verification errors.
|
30 |
+
2. Verify that your web server is not blocking POSTs from servers it may not recognize. Double check this on your firewall as well, if one is being used.
|
31 |
+
3. Check the `payment_bitpay.log` file for any errors during BitPay payment attempts. If you contact BitPay support, they will ask to see the log file to help diagnose the problem. The log file will be found inside your Magento's `var/log/` directory. **NOTE:** You will need to enable the debugging setting for the extension to output information into the log file.
|
32 |
+
4. Check the version of this plugin against the official plugin repository to ensure you are using the latest version. Your issue might have been addressed in a newer version! See the [Releases](https://github.com/bitpay/magento-plugin/releases) page or the Magento Connect store for the latest version.
|
33 |
+
5. If all else fails, send an email describing your issue **in detail** to support@bitpay.com
|
34 |
+
|
35 |
+
**TIP:** When contacting support it will help us is you provide:
|
36 |
+
|
37 |
+
* Magento CE Version (Found at the bottom page in the Administration section)
|
38 |
+
* Other extensions you have installed
|
39 |
+
* Some extensions do not play nice
|
40 |
+
* Configuration settings for the extension (Most merchants take screen grabs)
|
41 |
+
* Any log files that will help
|
42 |
+
* web server error logs
|
43 |
+
* enabled debugging for this extension and send us `var/log/payment_bitpay.log`
|
44 |
+
* Screen grabs of error message if applicable.
|
45 |
+
|
46 |
+
|
47 |
+
## Contribute
|
48 |
+
|
49 |
+
For developers wanting to contribute to this project, it is assumed you have a stable Magento environment to work with, and are familiar with developing for Magento. You will need to clone this repository or fork and clone the repository you created.
|
50 |
+
|
51 |
+
Once you have cloned the repository, you will need to run [composer install](https://getcomposer.org/doc/00-intro.md#using-composer). Using and setting up composer is outside the scope, however you will find the documentation on their site comprehensive. You can then run the ``scripts/package`` script to create a distribution files which you can find in ``build/dist``. This is the file that you can upload to your server to unzip or do with what you will.
|
52 |
+
|
53 |
+
If you encounter any issues or implement any updates or changes, please open an [issue](https://github.com/bitpay/magento-plugin/issues) or submit a Pull Request.
|
54 |
+
|
55 |
+
**NOTE:** The ``scripts/package`` file contains some configuration settings that will need to change for different releases. If you are using this script to build files that are for distribution, these will need to be updated.
|
56 |
+
|
57 |
+
|
58 |
+
## License
|
59 |
+
|
60 |
+
The MIT License (MIT)
|
61 |
+
|
62 |
+
Copyright (c) 2011-2015 BitPay, Inc.
|
63 |
+
|
64 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
65 |
+
|
66 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
67 |
+
|
68 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
app/code/community/Bitpay/Core/controllers/IpnController.php
CHANGED
@@ -60,9 +60,9 @@ class Bitpay_Core_IpnController extends Mage_Core_Controller_Front_Action
|
|
60 |
'btc_price' => isset($ipn->btcPrice) ? $ipn->btcPrice : '',
|
61 |
'price' => isset($ipn->price) ? $ipn->price : '',
|
62 |
'currency' => isset($ipn->currency) ? $ipn->currency : '',
|
63 |
-
'invoice_time' => isset($ipn->invoiceTime) ? $ipn->invoiceTime : '',
|
64 |
-
'expiration_time' => isset($ipn->expirationTime) ? $ipn->expirationTime : '',
|
65 |
-
'current_time' => isset($ipn->currentTime) ? $ipn->currentTime : '',
|
66 |
'btc_paid' => isset($ipn->btcPaid) ? $ipn->btcPaid : '',
|
67 |
'rate' => isset($ipn->rate) ? $ipn->rate : '',
|
68 |
'exception_status' => isset($ipn->exceptionStatus) ? $ipn->exceptionStatus : '',
|
@@ -103,7 +103,7 @@ class Bitpay_Core_IpnController extends Mage_Core_Controller_Front_Action
|
|
103 |
// Update the order to notifiy that it has been paid
|
104 |
if (true === in_array($invoice->getStatus(), array('paid', 'confirmed', 'complete'))) {
|
105 |
$payment = \Mage::getModel('sales/order_payment')->setOrder($order);
|
106 |
-
|
107 |
if (true === isset($payment) && false === empty($payment)) {
|
108 |
$payment->registerCaptureNotification($invoice->getPrice());
|
109 |
$order->addPayment($payment);
|
60 |
'btc_price' => isset($ipn->btcPrice) ? $ipn->btcPrice : '',
|
61 |
'price' => isset($ipn->price) ? $ipn->price : '',
|
62 |
'currency' => isset($ipn->currency) ? $ipn->currency : '',
|
63 |
+
'invoice_time' => isset($ipn->invoiceTime) ? intval($ipn->invoiceTime / 1000) : '',
|
64 |
+
'expiration_time' => isset($ipn->expirationTime) ? intval($ipn->expirationTime / 1000) : '',
|
65 |
+
'current_time' => isset($ipn->currentTime) ? intval($ipn->currentTime / 1000) : '',
|
66 |
'btc_paid' => isset($ipn->btcPaid) ? $ipn->btcPaid : '',
|
67 |
'rate' => isset($ipn->rate) ? $ipn->rate : '',
|
68 |
'exception_status' => isset($ipn->exceptionStatus) ? $ipn->exceptionStatus : '',
|
103 |
// Update the order to notifiy that it has been paid
|
104 |
if (true === in_array($invoice->getStatus(), array('paid', 'confirmed', 'complete'))) {
|
105 |
$payment = \Mage::getModel('sales/order_payment')->setOrder($order);
|
106 |
+
|
107 |
if (true === isset($payment) && false === empty($payment)) {
|
108 |
$payment->registerCaptureNotification($invoice->getPrice());
|
109 |
$order->addPayment($payment);
|
app/code/community/Bitpay/Core/etc/config.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
<config>
|
9 |
<modules>
|
10 |
<Bitpay_Core>
|
11 |
-
<version>2.
|
12 |
</Bitpay_Core>
|
13 |
</modules>
|
14 |
|
8 |
<config>
|
9 |
<modules>
|
10 |
<Bitpay_Core>
|
11 |
+
<version>2.1.3</version>
|
12 |
</Bitpay_Core>
|
13 |
</modules>
|
14 |
|
app/code/community/Bitpay/Core/sql/bitpay_setup/{mysql4-install-2.0.0.php → install-2.1.3.php}
RENAMED
@@ -20,7 +20,7 @@ $ipnTable->addColumn('price', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(16, 8));
|
|
20 |
$ipnTable->addColumn('currency', Varien_Db_Ddl_Table::TYPE_TEXT, 10);
|
21 |
$ipnTable->addColumn('invoice_time', Varien_Db_Ddl_Table::TYPE_INTEGER, 11);
|
22 |
$ipnTable->addColumn('expiration_time', Varien_Db_Ddl_Table::TYPE_INTEGER, 11);
|
23 |
-
$ipnTable->addColumn('
|
24 |
$ipnTable->addColumn('pos_data', Varien_Db_Ddl_Table::TYPE_TEXT, 255);
|
25 |
$ipnTable->addColumn('btc_paid', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(16, 8));
|
26 |
$ipnTable->addColumn('rate', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(16, 8));
|
20 |
$ipnTable->addColumn('currency', Varien_Db_Ddl_Table::TYPE_TEXT, 10);
|
21 |
$ipnTable->addColumn('invoice_time', Varien_Db_Ddl_Table::TYPE_INTEGER, 11);
|
22 |
$ipnTable->addColumn('expiration_time', Varien_Db_Ddl_Table::TYPE_INTEGER, 11);
|
23 |
+
$ipnTable->addColumn('current_time', Varien_Db_Ddl_Table::TYPE_INTEGER, 11);
|
24 |
$ipnTable->addColumn('pos_data', Varien_Db_Ddl_Table::TYPE_TEXT, 255);
|
25 |
$ipnTable->addColumn('btc_paid', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(16, 8));
|
26 |
$ipnTable->addColumn('rate', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(16, 8));
|
app/code/community/Bitpay/Core/sql/bitpay_setup/upgrade-2.0.1-2.1.3.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
4 |
+
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
5 |
+
*/
|
6 |
+
$this->startSetup();
|
7 |
+
|
8 |
+
/**
|
9 |
+
* IPN Log Table, used to keep track of incoiming IPNs
|
10 |
+
*/
|
11 |
+
$ipnTable = new Varien_Db_Ddl_Table();
|
12 |
+
$ipnTable->setName($this->getTable('bitpay/ipn'));
|
13 |
+
$this->getConnection()->changeColumn($ipnTable, 'curent_time', 'current_time', array('type' => Varien_Db_Ddl_Table::TYPE_INTEGER));
|
14 |
+
|
15 |
+
$this->endSetup();
|
lib/Bitpay/Client/Client.php
CHANGED
@@ -156,8 +156,12 @@ class Client implements ClientInterface
|
|
156 |
$this->response = $this->sendRequest($request);
|
157 |
|
158 |
$body = json_decode($this->response->getBody(), true);
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
$data = $body['data'];
|
163 |
$invoice
|
156 |
$this->response = $this->sendRequest($request);
|
157 |
|
158 |
$body = json_decode($this->response->getBody(), true);
|
159 |
+
$error_message = false;
|
160 |
+
$error_message = (!empty($body['error'])) ? $body['error'] : $error_message;
|
161 |
+
$error_message = (!empty($body['errors'])) ? $body['errors'] : $error_message;
|
162 |
+
$error_message = (is_array($error_message)) ? implode("\n", $error_message) : $error_message;
|
163 |
+
if (false !== $error_message) {
|
164 |
+
throw new \Exception($error_message);
|
165 |
}
|
166 |
$data = $body['data'];
|
167 |
$invoice
|
lib/Symfony/Component/Config/CHANGELOG.md
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
CHANGELOG
|
2 |
-
=========
|
3 |
-
|
4 |
-
2.2.0
|
5 |
-
-----
|
6 |
-
|
7 |
-
* added ArrayNodeDefinition::canBeEnabled() and ArrayNodeDefinition::canBeDisabled()
|
8 |
-
to ease configuration when some sections are respectively disabled / enabled
|
9 |
-
by default.
|
10 |
-
* added a `normalizeKeys()` method for array nodes (to avoid key normalization)
|
11 |
-
* added numerical type handling for config definitions
|
12 |
-
* added convenience methods for optional configuration sections to ArrayNodeDefinition
|
13 |
-
* added a utils class for XML manipulations
|
14 |
-
|
15 |
-
2.1.0
|
16 |
-
-----
|
17 |
-
|
18 |
-
* added a way to add documentation on configuration
|
19 |
-
* implemented `Serializable` on resources
|
20 |
-
* LoaderResolverInterface is now used instead of LoaderResolver for type
|
21 |
-
hinting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/ConfigCache.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Resource\ResourceInterface;
|
15 |
-
use Symfony\Component\Filesystem\Exception\IOException;
|
16 |
-
use Symfony\Component\Filesystem\Filesystem;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* ConfigCache manages PHP cache files.
|
20 |
-
*
|
21 |
-
* When debug is enabled, it knows when to flush the cache
|
22 |
-
* thanks to an array of ResourceInterface instances.
|
23 |
-
*
|
24 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
-
*/
|
26 |
-
class ConfigCache
|
27 |
-
{
|
28 |
-
private $debug;
|
29 |
-
private $file;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Constructor.
|
33 |
-
*
|
34 |
-
* @param string $file The absolute cache path
|
35 |
-
* @param bool $debug Whether debugging is enabled or not
|
36 |
-
*/
|
37 |
-
public function __construct($file, $debug)
|
38 |
-
{
|
39 |
-
$this->file = $file;
|
40 |
-
$this->debug = (bool) $debug;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Gets the cache file path.
|
45 |
-
*
|
46 |
-
* @return string The cache file path
|
47 |
-
*/
|
48 |
-
public function __toString()
|
49 |
-
{
|
50 |
-
return $this->file;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Checks if the cache is still fresh.
|
55 |
-
*
|
56 |
-
* This method always returns true when debug is off and the
|
57 |
-
* cache file exists.
|
58 |
-
*
|
59 |
-
* @return bool true if the cache is fresh, false otherwise
|
60 |
-
*/
|
61 |
-
public function isFresh()
|
62 |
-
{
|
63 |
-
if (!is_file($this->file)) {
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
|
67 |
-
if (!$this->debug) {
|
68 |
-
return true;
|
69 |
-
}
|
70 |
-
|
71 |
-
$metadata = $this->getMetaFile();
|
72 |
-
if (!is_file($metadata)) {
|
73 |
-
return false;
|
74 |
-
}
|
75 |
-
|
76 |
-
$time = filemtime($this->file);
|
77 |
-
$meta = unserialize(file_get_contents($metadata));
|
78 |
-
foreach ($meta as $resource) {
|
79 |
-
if (!$resource->isFresh($time)) {
|
80 |
-
return false;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
return true;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Writes cache.
|
89 |
-
*
|
90 |
-
* @param string $content The content to write in the cache
|
91 |
-
* @param ResourceInterface[] $metadata An array of ResourceInterface instances
|
92 |
-
*
|
93 |
-
* @throws \RuntimeException When cache file can't be written
|
94 |
-
*/
|
95 |
-
public function write($content, array $metadata = null)
|
96 |
-
{
|
97 |
-
$mode = 0666;
|
98 |
-
$umask = umask();
|
99 |
-
$filesystem = new Filesystem();
|
100 |
-
$filesystem->dumpFile($this->file, $content, null);
|
101 |
-
try {
|
102 |
-
$filesystem->chmod($this->file, $mode, $umask);
|
103 |
-
} catch (IOException $e) {
|
104 |
-
// discard chmod failure (some filesystem may not support it)
|
105 |
-
}
|
106 |
-
|
107 |
-
if (null !== $metadata && true === $this->debug) {
|
108 |
-
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
|
109 |
-
try {
|
110 |
-
$filesystem->chmod($this->getMetaFile(), $mode, $umask);
|
111 |
-
} catch (IOException $e) {
|
112 |
-
// discard chmod failure (some filesystem may not support it)
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Gets the meta file path.
|
119 |
-
*
|
120 |
-
* @return string The meta file path
|
121 |
-
*/
|
122 |
-
private function getMetaFile()
|
123 |
-
{
|
124 |
-
return $this->file.'.meta';
|
125 |
-
}
|
126 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/ArrayNode.php
DELETED
@@ -1,390 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
15 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
16 |
-
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Represents an Array node in the config tree.
|
20 |
-
*
|
21 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
22 |
-
*/
|
23 |
-
class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
24 |
-
{
|
25 |
-
protected $xmlRemappings = array();
|
26 |
-
protected $children = array();
|
27 |
-
protected $allowFalse = false;
|
28 |
-
protected $allowNewKeys = true;
|
29 |
-
protected $addIfNotSet = false;
|
30 |
-
protected $performDeepMerging = true;
|
31 |
-
protected $ignoreExtraKeys = false;
|
32 |
-
protected $normalizeKeys = true;
|
33 |
-
|
34 |
-
public function setNormalizeKeys($normalizeKeys)
|
35 |
-
{
|
36 |
-
$this->normalizeKeys = (bool) $normalizeKeys;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Normalizes keys between the different configuration formats.
|
41 |
-
*
|
42 |
-
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
|
43 |
-
* After running this method, all keys are normalized to foo_bar.
|
44 |
-
*
|
45 |
-
* If you have a mixed key like foo-bar_moo, it will not be altered.
|
46 |
-
* The key will also not be altered if the target key already exists.
|
47 |
-
*
|
48 |
-
* @param mixed $value
|
49 |
-
*
|
50 |
-
* @return array The value with normalized keys
|
51 |
-
*/
|
52 |
-
protected function preNormalize($value)
|
53 |
-
{
|
54 |
-
if (!$this->normalizeKeys || !is_array($value)) {
|
55 |
-
return $value;
|
56 |
-
}
|
57 |
-
|
58 |
-
foreach ($value as $k => $v) {
|
59 |
-
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
60 |
-
$value[$normalizedKey] = $v;
|
61 |
-
unset($value[$k]);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
return $value;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Retrieves the children of this node.
|
70 |
-
*
|
71 |
-
* @return array The children
|
72 |
-
*/
|
73 |
-
public function getChildren()
|
74 |
-
{
|
75 |
-
return $this->children;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Sets the xml remappings that should be performed.
|
80 |
-
*
|
81 |
-
* @param array $remappings an array of the form array(array(string, string))
|
82 |
-
*/
|
83 |
-
public function setXmlRemappings(array $remappings)
|
84 |
-
{
|
85 |
-
$this->xmlRemappings = $remappings;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Gets the xml remappings that should be performed.
|
90 |
-
*
|
91 |
-
* @return array $remappings an array of the form array(array(string, string))
|
92 |
-
*/
|
93 |
-
public function getXmlRemappings()
|
94 |
-
{
|
95 |
-
return $this->xmlRemappings;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Sets whether to add default values for this array if it has not been
|
100 |
-
* defined in any of the configuration files.
|
101 |
-
*
|
102 |
-
* @param bool $boolean
|
103 |
-
*/
|
104 |
-
public function setAddIfNotSet($boolean)
|
105 |
-
{
|
106 |
-
$this->addIfNotSet = (bool) $boolean;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Sets whether false is allowed as value indicating that the array should be unset.
|
111 |
-
*
|
112 |
-
* @param bool $allow
|
113 |
-
*/
|
114 |
-
public function setAllowFalse($allow)
|
115 |
-
{
|
116 |
-
$this->allowFalse = (bool) $allow;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Sets whether new keys can be defined in subsequent configurations.
|
121 |
-
*
|
122 |
-
* @param bool $allow
|
123 |
-
*/
|
124 |
-
public function setAllowNewKeys($allow)
|
125 |
-
{
|
126 |
-
$this->allowNewKeys = (bool) $allow;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Sets if deep merging should occur.
|
131 |
-
*
|
132 |
-
* @param bool $boolean
|
133 |
-
*/
|
134 |
-
public function setPerformDeepMerging($boolean)
|
135 |
-
{
|
136 |
-
$this->performDeepMerging = (bool) $boolean;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Whether extra keys should just be ignore without an exception.
|
141 |
-
*
|
142 |
-
* @param bool $boolean To allow extra keys
|
143 |
-
*/
|
144 |
-
public function setIgnoreExtraKeys($boolean)
|
145 |
-
{
|
146 |
-
$this->ignoreExtraKeys = (bool) $boolean;
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Sets the node Name.
|
151 |
-
*
|
152 |
-
* @param string $name The node's name
|
153 |
-
*/
|
154 |
-
public function setName($name)
|
155 |
-
{
|
156 |
-
$this->name = $name;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Checks if the node has a default value.
|
161 |
-
*
|
162 |
-
* @return bool
|
163 |
-
*/
|
164 |
-
public function hasDefaultValue()
|
165 |
-
{
|
166 |
-
return $this->addIfNotSet;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Retrieves the default value.
|
171 |
-
*
|
172 |
-
* @return array The default value
|
173 |
-
*
|
174 |
-
* @throws \RuntimeException if the node has no default value
|
175 |
-
*/
|
176 |
-
public function getDefaultValue()
|
177 |
-
{
|
178 |
-
if (!$this->hasDefaultValue()) {
|
179 |
-
throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath()));
|
180 |
-
}
|
181 |
-
|
182 |
-
$defaults = array();
|
183 |
-
foreach ($this->children as $name => $child) {
|
184 |
-
if ($child->hasDefaultValue()) {
|
185 |
-
$defaults[$name] = $child->getDefaultValue();
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
return $defaults;
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Adds a child node.
|
194 |
-
*
|
195 |
-
* @param NodeInterface $node The child node to add
|
196 |
-
*
|
197 |
-
* @throws \InvalidArgumentException when the child node has no name
|
198 |
-
* @throws \InvalidArgumentException when the child node's name is not unique
|
199 |
-
*/
|
200 |
-
public function addChild(NodeInterface $node)
|
201 |
-
{
|
202 |
-
$name = $node->getName();
|
203 |
-
if (!strlen($name)) {
|
204 |
-
throw new \InvalidArgumentException('Child nodes must be named.');
|
205 |
-
}
|
206 |
-
if (isset($this->children[$name])) {
|
207 |
-
throw new \InvalidArgumentException(sprintf('A child node named "%s" already exists.', $name));
|
208 |
-
}
|
209 |
-
|
210 |
-
$this->children[$name] = $node;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Finalizes the value of this node.
|
215 |
-
*
|
216 |
-
* @param mixed $value
|
217 |
-
*
|
218 |
-
* @return mixed The finalised value
|
219 |
-
*
|
220 |
-
* @throws UnsetKeyException
|
221 |
-
* @throws InvalidConfigurationException if the node doesn't have enough children
|
222 |
-
*/
|
223 |
-
protected function finalizeValue($value)
|
224 |
-
{
|
225 |
-
if (false === $value) {
|
226 |
-
$msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value));
|
227 |
-
throw new UnsetKeyException($msg);
|
228 |
-
}
|
229 |
-
|
230 |
-
foreach ($this->children as $name => $child) {
|
231 |
-
if (!array_key_exists($name, $value)) {
|
232 |
-
if ($child->isRequired()) {
|
233 |
-
$msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath());
|
234 |
-
$ex = new InvalidConfigurationException($msg);
|
235 |
-
$ex->setPath($this->getPath());
|
236 |
-
|
237 |
-
throw $ex;
|
238 |
-
}
|
239 |
-
|
240 |
-
if ($child->hasDefaultValue()) {
|
241 |
-
$value[$name] = $child->getDefaultValue();
|
242 |
-
}
|
243 |
-
|
244 |
-
continue;
|
245 |
-
}
|
246 |
-
|
247 |
-
try {
|
248 |
-
$value[$name] = $child->finalize($value[$name]);
|
249 |
-
} catch (UnsetKeyException $unset) {
|
250 |
-
unset($value[$name]);
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
return $value;
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Validates the type of the value.
|
259 |
-
*
|
260 |
-
* @param mixed $value
|
261 |
-
*
|
262 |
-
* @throws InvalidTypeException
|
263 |
-
*/
|
264 |
-
protected function validateType($value)
|
265 |
-
{
|
266 |
-
if (!is_array($value) && (!$this->allowFalse || false !== $value)) {
|
267 |
-
$ex = new InvalidTypeException(sprintf(
|
268 |
-
'Invalid type for path "%s". Expected array, but got %s',
|
269 |
-
$this->getPath(),
|
270 |
-
gettype($value)
|
271 |
-
));
|
272 |
-
$ex->setPath($this->getPath());
|
273 |
-
|
274 |
-
throw $ex;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Normalizes the value.
|
280 |
-
*
|
281 |
-
* @param mixed $value The value to normalize
|
282 |
-
*
|
283 |
-
* @return mixed The normalized value
|
284 |
-
*
|
285 |
-
* @throws InvalidConfigurationException
|
286 |
-
*/
|
287 |
-
protected function normalizeValue($value)
|
288 |
-
{
|
289 |
-
if (false === $value) {
|
290 |
-
return $value;
|
291 |
-
}
|
292 |
-
|
293 |
-
$value = $this->remapXml($value);
|
294 |
-
|
295 |
-
$normalized = array();
|
296 |
-
foreach ($value as $name => $val) {
|
297 |
-
if (isset($this->children[$name])) {
|
298 |
-
$normalized[$name] = $this->children[$name]->normalize($val);
|
299 |
-
unset($value[$name]);
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
// if extra fields are present, throw exception
|
304 |
-
if (count($value) && !$this->ignoreExtraKeys) {
|
305 |
-
$msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());
|
306 |
-
$ex = new InvalidConfigurationException($msg);
|
307 |
-
$ex->setPath($this->getPath());
|
308 |
-
|
309 |
-
throw $ex;
|
310 |
-
}
|
311 |
-
|
312 |
-
return $normalized;
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Remaps multiple singular values to a single plural value.
|
317 |
-
*
|
318 |
-
* @param array $value The source values
|
319 |
-
*
|
320 |
-
* @return array The remapped values
|
321 |
-
*/
|
322 |
-
protected function remapXml($value)
|
323 |
-
{
|
324 |
-
foreach ($this->xmlRemappings as $transformation) {
|
325 |
-
list($singular, $plural) = $transformation;
|
326 |
-
|
327 |
-
if (!isset($value[$singular])) {
|
328 |
-
continue;
|
329 |
-
}
|
330 |
-
|
331 |
-
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
|
332 |
-
unset($value[$singular]);
|
333 |
-
}
|
334 |
-
|
335 |
-
return $value;
|
336 |
-
}
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Merges values together.
|
340 |
-
*
|
341 |
-
* @param mixed $leftSide The left side to merge.
|
342 |
-
* @param mixed $rightSide The right side to merge.
|
343 |
-
*
|
344 |
-
* @return mixed The merged values
|
345 |
-
*
|
346 |
-
* @throws InvalidConfigurationException
|
347 |
-
* @throws \RuntimeException
|
348 |
-
*/
|
349 |
-
protected function mergeValues($leftSide, $rightSide)
|
350 |
-
{
|
351 |
-
if (false === $rightSide) {
|
352 |
-
// if this is still false after the last config has been merged the
|
353 |
-
// finalization pass will take care of removing this key entirely
|
354 |
-
return false;
|
355 |
-
}
|
356 |
-
|
357 |
-
if (false === $leftSide || !$this->performDeepMerging) {
|
358 |
-
return $rightSide;
|
359 |
-
}
|
360 |
-
|
361 |
-
foreach ($rightSide as $k => $v) {
|
362 |
-
// no conflict
|
363 |
-
if (!array_key_exists($k, $leftSide)) {
|
364 |
-
if (!$this->allowNewKeys) {
|
365 |
-
$ex = new InvalidConfigurationException(sprintf(
|
366 |
-
'You are not allowed to define new elements for path "%s". '
|
367 |
-
.'Please define all elements for this path in one config file. '
|
368 |
-
.'If you are trying to overwrite an element, make sure you redefine it '
|
369 |
-
.'with the same name.',
|
370 |
-
$this->getPath()
|
371 |
-
));
|
372 |
-
$ex->setPath($this->getPath());
|
373 |
-
|
374 |
-
throw $ex;
|
375 |
-
}
|
376 |
-
|
377 |
-
$leftSide[$k] = $v;
|
378 |
-
continue;
|
379 |
-
}
|
380 |
-
|
381 |
-
if (!isset($this->children[$k])) {
|
382 |
-
throw new \RuntimeException('merge() expects a normalized config array.');
|
383 |
-
}
|
384 |
-
|
385 |
-
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
|
386 |
-
}
|
387 |
-
|
388 |
-
return $leftSide;
|
389 |
-
}
|
390 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/BaseNode.php
DELETED
@@ -1,360 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\Exception;
|
15 |
-
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
|
16 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
17 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* The base node class.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
abstract class BaseNode implements NodeInterface
|
25 |
-
{
|
26 |
-
protected $name;
|
27 |
-
protected $parent;
|
28 |
-
protected $normalizationClosures = array();
|
29 |
-
protected $finalValidationClosures = array();
|
30 |
-
protected $allowOverwrite = true;
|
31 |
-
protected $required = false;
|
32 |
-
protected $equivalentValues = array();
|
33 |
-
protected $attributes = array();
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Constructor.
|
37 |
-
*
|
38 |
-
* @param string $name The name of the node
|
39 |
-
* @param NodeInterface $parent The parent of this node
|
40 |
-
*
|
41 |
-
* @throws \InvalidArgumentException if the name contains a period.
|
42 |
-
*/
|
43 |
-
public function __construct($name, NodeInterface $parent = null)
|
44 |
-
{
|
45 |
-
if (false !== strpos($name, '.')) {
|
46 |
-
throw new \InvalidArgumentException('The name must not contain ".".');
|
47 |
-
}
|
48 |
-
|
49 |
-
$this->name = $name;
|
50 |
-
$this->parent = $parent;
|
51 |
-
}
|
52 |
-
|
53 |
-
public function setAttribute($key, $value)
|
54 |
-
{
|
55 |
-
$this->attributes[$key] = $value;
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getAttribute($key, $default = null)
|
59 |
-
{
|
60 |
-
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
|
61 |
-
}
|
62 |
-
|
63 |
-
public function hasAttribute($key)
|
64 |
-
{
|
65 |
-
return isset($this->attributes[$key]);
|
66 |
-
}
|
67 |
-
|
68 |
-
public function getAttributes()
|
69 |
-
{
|
70 |
-
return $this->attributes;
|
71 |
-
}
|
72 |
-
|
73 |
-
public function setAttributes(array $attributes)
|
74 |
-
{
|
75 |
-
$this->attributes = $attributes;
|
76 |
-
}
|
77 |
-
|
78 |
-
public function removeAttribute($key)
|
79 |
-
{
|
80 |
-
unset($this->attributes[$key]);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Sets an info message.
|
85 |
-
*
|
86 |
-
* @param string $info
|
87 |
-
*/
|
88 |
-
public function setInfo($info)
|
89 |
-
{
|
90 |
-
$this->setAttribute('info', $info);
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Returns info message.
|
95 |
-
*
|
96 |
-
* @return string The info text
|
97 |
-
*/
|
98 |
-
public function getInfo()
|
99 |
-
{
|
100 |
-
return $this->getAttribute('info');
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Sets the example configuration for this node.
|
105 |
-
*
|
106 |
-
* @param string|array $example
|
107 |
-
*/
|
108 |
-
public function setExample($example)
|
109 |
-
{
|
110 |
-
$this->setAttribute('example', $example);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Retrieves the example configuration for this node.
|
115 |
-
*
|
116 |
-
* @return string|array The example
|
117 |
-
*/
|
118 |
-
public function getExample()
|
119 |
-
{
|
120 |
-
return $this->getAttribute('example');
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Adds an equivalent value.
|
125 |
-
*
|
126 |
-
* @param mixed $originalValue
|
127 |
-
* @param mixed $equivalentValue
|
128 |
-
*/
|
129 |
-
public function addEquivalentValue($originalValue, $equivalentValue)
|
130 |
-
{
|
131 |
-
$this->equivalentValues[] = array($originalValue, $equivalentValue);
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Set this node as required.
|
136 |
-
*
|
137 |
-
* @param bool $boolean Required node
|
138 |
-
*/
|
139 |
-
public function setRequired($boolean)
|
140 |
-
{
|
141 |
-
$this->required = (bool) $boolean;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Sets if this node can be overridden.
|
146 |
-
*
|
147 |
-
* @param bool $allow
|
148 |
-
*/
|
149 |
-
public function setAllowOverwrite($allow)
|
150 |
-
{
|
151 |
-
$this->allowOverwrite = (bool) $allow;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Sets the closures used for normalization.
|
156 |
-
*
|
157 |
-
* @param \Closure[] $closures An array of Closures used for normalization
|
158 |
-
*/
|
159 |
-
public function setNormalizationClosures(array $closures)
|
160 |
-
{
|
161 |
-
$this->normalizationClosures = $closures;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Sets the closures used for final validation.
|
166 |
-
*
|
167 |
-
* @param \Closure[] $closures An array of Closures used for final validation
|
168 |
-
*/
|
169 |
-
public function setFinalValidationClosures(array $closures)
|
170 |
-
{
|
171 |
-
$this->finalValidationClosures = $closures;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Checks if this node is required.
|
176 |
-
*
|
177 |
-
* @return bool
|
178 |
-
*/
|
179 |
-
public function isRequired()
|
180 |
-
{
|
181 |
-
return $this->required;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Returns the name of this node.
|
186 |
-
*
|
187 |
-
* @return string The Node's name.
|
188 |
-
*/
|
189 |
-
public function getName()
|
190 |
-
{
|
191 |
-
return $this->name;
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Retrieves the path of this node.
|
196 |
-
*
|
197 |
-
* @return string The Node's path
|
198 |
-
*/
|
199 |
-
public function getPath()
|
200 |
-
{
|
201 |
-
$path = $this->name;
|
202 |
-
|
203 |
-
if (null !== $this->parent) {
|
204 |
-
$path = $this->parent->getPath().'.'.$path;
|
205 |
-
}
|
206 |
-
|
207 |
-
return $path;
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Merges two values together.
|
212 |
-
*
|
213 |
-
* @param mixed $leftSide
|
214 |
-
* @param mixed $rightSide
|
215 |
-
*
|
216 |
-
* @return mixed The merged value
|
217 |
-
*
|
218 |
-
* @throws ForbiddenOverwriteException
|
219 |
-
*/
|
220 |
-
final public function merge($leftSide, $rightSide)
|
221 |
-
{
|
222 |
-
if (!$this->allowOverwrite) {
|
223 |
-
throw new ForbiddenOverwriteException(sprintf(
|
224 |
-
'Configuration path "%s" cannot be overwritten. You have to '
|
225 |
-
.'define all options for this path, and any of its sub-paths in '
|
226 |
-
.'one configuration section.',
|
227 |
-
$this->getPath()
|
228 |
-
));
|
229 |
-
}
|
230 |
-
|
231 |
-
$this->validateType($leftSide);
|
232 |
-
$this->validateType($rightSide);
|
233 |
-
|
234 |
-
return $this->mergeValues($leftSide, $rightSide);
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Normalizes a value, applying all normalization closures.
|
239 |
-
*
|
240 |
-
* @param mixed $value Value to normalize.
|
241 |
-
*
|
242 |
-
* @return mixed The normalized value.
|
243 |
-
*/
|
244 |
-
final public function normalize($value)
|
245 |
-
{
|
246 |
-
$value = $this->preNormalize($value);
|
247 |
-
|
248 |
-
// run custom normalization closures
|
249 |
-
foreach ($this->normalizationClosures as $closure) {
|
250 |
-
$value = $closure($value);
|
251 |
-
}
|
252 |
-
|
253 |
-
// replace value with their equivalent
|
254 |
-
foreach ($this->equivalentValues as $data) {
|
255 |
-
if ($data[0] === $value) {
|
256 |
-
$value = $data[1];
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
// validate type
|
261 |
-
$this->validateType($value);
|
262 |
-
|
263 |
-
// normalize value
|
264 |
-
return $this->normalizeValue($value);
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Normalizes the value before any other normalization is applied.
|
269 |
-
*
|
270 |
-
* @param $value
|
271 |
-
*
|
272 |
-
* @return $value The normalized array value
|
273 |
-
*/
|
274 |
-
protected function preNormalize($value)
|
275 |
-
{
|
276 |
-
return $value;
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Returns parent node for this node.
|
281 |
-
*
|
282 |
-
* @return NodeInterface|null
|
283 |
-
*/
|
284 |
-
public function getParent()
|
285 |
-
{
|
286 |
-
return $this->parent;
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Finalizes a value, applying all finalization closures.
|
291 |
-
*
|
292 |
-
* @param mixed $value The value to finalize
|
293 |
-
*
|
294 |
-
* @return mixed The finalized value
|
295 |
-
*
|
296 |
-
* @throws Exception
|
297 |
-
* @throws InvalidConfigurationException
|
298 |
-
*/
|
299 |
-
final public function finalize($value)
|
300 |
-
{
|
301 |
-
$this->validateType($value);
|
302 |
-
|
303 |
-
$value = $this->finalizeValue($value);
|
304 |
-
|
305 |
-
// Perform validation on the final value if a closure has been set.
|
306 |
-
// The closure is also allowed to return another value.
|
307 |
-
foreach ($this->finalValidationClosures as $closure) {
|
308 |
-
try {
|
309 |
-
$value = $closure($value);
|
310 |
-
} catch (Exception $correctEx) {
|
311 |
-
throw $correctEx;
|
312 |
-
} catch (\Exception $invalid) {
|
313 |
-
throw new InvalidConfigurationException(sprintf(
|
314 |
-
'Invalid configuration for path "%s": %s',
|
315 |
-
$this->getPath(),
|
316 |
-
$invalid->getMessage()
|
317 |
-
), $invalid->getCode(), $invalid);
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
return $value;
|
322 |
-
}
|
323 |
-
|
324 |
-
/**
|
325 |
-
* Validates the type of a Node.
|
326 |
-
*
|
327 |
-
* @param mixed $value The value to validate
|
328 |
-
*
|
329 |
-
* @throws InvalidTypeException when the value is invalid
|
330 |
-
*/
|
331 |
-
abstract protected function validateType($value);
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Normalizes the value.
|
335 |
-
*
|
336 |
-
* @param mixed $value The value to normalize.
|
337 |
-
*
|
338 |
-
* @return mixed The normalized value
|
339 |
-
*/
|
340 |
-
abstract protected function normalizeValue($value);
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Merges two values together.
|
344 |
-
*
|
345 |
-
* @param mixed $leftSide
|
346 |
-
* @param mixed $rightSide
|
347 |
-
*
|
348 |
-
* @return mixed The merged value
|
349 |
-
*/
|
350 |
-
abstract protected function mergeValues($leftSide, $rightSide);
|
351 |
-
|
352 |
-
/**
|
353 |
-
* Finalizes a value.
|
354 |
-
*
|
355 |
-
* @param mixed $value The value to finalize
|
356 |
-
*
|
357 |
-
* @return mixed The finalized value
|
358 |
-
*/
|
359 |
-
abstract protected function finalizeValue($value);
|
360 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/BooleanNode.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents a Boolean value in the config tree.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class BooleanNode extends ScalarNode
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* {@inheritdoc}
|
25 |
-
*/
|
26 |
-
protected function validateType($value)
|
27 |
-
{
|
28 |
-
if (!is_bool($value)) {
|
29 |
-
$ex = new InvalidTypeException(sprintf(
|
30 |
-
'Invalid type for path "%s". Expected boolean, but got %s.',
|
31 |
-
$this->getPath(),
|
32 |
-
gettype($value)
|
33 |
-
));
|
34 |
-
$ex->setPath($this->getPath());
|
35 |
-
|
36 |
-
throw $ex;
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
DELETED
@@ -1,488 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\ArrayNode;
|
15 |
-
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
16 |
-
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* This class provides a fluent interface for defining an array node.
|
20 |
-
*
|
21 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
22 |
-
*/
|
23 |
-
class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
|
24 |
-
{
|
25 |
-
protected $performDeepMerging = true;
|
26 |
-
protected $ignoreExtraKeys = false;
|
27 |
-
protected $children = array();
|
28 |
-
protected $prototype;
|
29 |
-
protected $atLeastOne = false;
|
30 |
-
protected $allowNewKeys = true;
|
31 |
-
protected $key;
|
32 |
-
protected $removeKeyItem;
|
33 |
-
protected $addDefaults = false;
|
34 |
-
protected $addDefaultChildren = false;
|
35 |
-
protected $nodeBuilder;
|
36 |
-
protected $normalizeKeys = true;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
-
public function __construct($name, NodeParentInterface $parent = null)
|
42 |
-
{
|
43 |
-
parent::__construct($name, $parent);
|
44 |
-
|
45 |
-
$this->nullEquivalent = array();
|
46 |
-
$this->trueEquivalent = array();
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Sets a custom children builder.
|
51 |
-
*
|
52 |
-
* @param NodeBuilder $builder A custom NodeBuilder
|
53 |
-
*/
|
54 |
-
public function setBuilder(NodeBuilder $builder)
|
55 |
-
{
|
56 |
-
$this->nodeBuilder = $builder;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Returns a builder to add children nodes.
|
61 |
-
*
|
62 |
-
* @return NodeBuilder
|
63 |
-
*/
|
64 |
-
public function children()
|
65 |
-
{
|
66 |
-
return $this->getNodeBuilder();
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Sets a prototype for child nodes.
|
71 |
-
*
|
72 |
-
* @param string $type the type of node
|
73 |
-
*
|
74 |
-
* @return NodeDefinition
|
75 |
-
*/
|
76 |
-
public function prototype($type)
|
77 |
-
{
|
78 |
-
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Adds the default value if the node is not set in the configuration.
|
83 |
-
*
|
84 |
-
* This method is applicable to concrete nodes only (not to prototype nodes).
|
85 |
-
* If this function has been called and the node is not set during the finalization
|
86 |
-
* phase, it's default value will be derived from its children default values.
|
87 |
-
*
|
88 |
-
* @return ArrayNodeDefinition
|
89 |
-
*/
|
90 |
-
public function addDefaultsIfNotSet()
|
91 |
-
{
|
92 |
-
$this->addDefaults = true;
|
93 |
-
|
94 |
-
return $this;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Adds children with a default value when none are defined.
|
99 |
-
*
|
100 |
-
* @param int|string|array|null $children The number of children|The child name|The children names to be added
|
101 |
-
*
|
102 |
-
* This method is applicable to prototype nodes only.
|
103 |
-
*
|
104 |
-
* @return ArrayNodeDefinition
|
105 |
-
*/
|
106 |
-
public function addDefaultChildrenIfNoneSet($children = null)
|
107 |
-
{
|
108 |
-
$this->addDefaultChildren = $children;
|
109 |
-
|
110 |
-
return $this;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Requires the node to have at least one element.
|
115 |
-
*
|
116 |
-
* This method is applicable to prototype nodes only.
|
117 |
-
*
|
118 |
-
* @return ArrayNodeDefinition
|
119 |
-
*/
|
120 |
-
public function requiresAtLeastOneElement()
|
121 |
-
{
|
122 |
-
$this->atLeastOne = true;
|
123 |
-
|
124 |
-
return $this;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Disallows adding news keys in a subsequent configuration.
|
129 |
-
*
|
130 |
-
* If used all keys have to be defined in the same configuration file.
|
131 |
-
*
|
132 |
-
* @return ArrayNodeDefinition
|
133 |
-
*/
|
134 |
-
public function disallowNewKeysInSubsequentConfigs()
|
135 |
-
{
|
136 |
-
$this->allowNewKeys = false;
|
137 |
-
|
138 |
-
return $this;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Sets a normalization rule for XML configurations.
|
143 |
-
*
|
144 |
-
* @param string $singular The key to remap
|
145 |
-
* @param string $plural The plural of the key for irregular plurals
|
146 |
-
*
|
147 |
-
* @return ArrayNodeDefinition
|
148 |
-
*/
|
149 |
-
public function fixXmlConfig($singular, $plural = null)
|
150 |
-
{
|
151 |
-
$this->normalization()->remap($singular, $plural);
|
152 |
-
|
153 |
-
return $this;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Sets the attribute which value is to be used as key.
|
158 |
-
*
|
159 |
-
* This is useful when you have an indexed array that should be an
|
160 |
-
* associative array. You can select an item from within the array
|
161 |
-
* to be the key of the particular item. For example, if "id" is the
|
162 |
-
* "key", then:
|
163 |
-
*
|
164 |
-
* array(
|
165 |
-
* array('id' => 'my_name', 'foo' => 'bar'),
|
166 |
-
* );
|
167 |
-
*
|
168 |
-
* becomes
|
169 |
-
*
|
170 |
-
* array(
|
171 |
-
* 'my_name' => array('foo' => 'bar'),
|
172 |
-
* );
|
173 |
-
*
|
174 |
-
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
175 |
-
* array, then you can set the second argument of this method to false.
|
176 |
-
*
|
177 |
-
* This method is applicable to prototype nodes only.
|
178 |
-
*
|
179 |
-
* @param string $name The name of the key
|
180 |
-
* @param bool $removeKeyItem Whether or not the key item should be removed.
|
181 |
-
*
|
182 |
-
* @return ArrayNodeDefinition
|
183 |
-
*/
|
184 |
-
public function useAttributeAsKey($name, $removeKeyItem = true)
|
185 |
-
{
|
186 |
-
$this->key = $name;
|
187 |
-
$this->removeKeyItem = $removeKeyItem;
|
188 |
-
|
189 |
-
return $this;
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Sets whether the node can be unset.
|
194 |
-
*
|
195 |
-
* @param bool $allow
|
196 |
-
*
|
197 |
-
* @return ArrayNodeDefinition
|
198 |
-
*/
|
199 |
-
public function canBeUnset($allow = true)
|
200 |
-
{
|
201 |
-
$this->merge()->allowUnset($allow);
|
202 |
-
|
203 |
-
return $this;
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Adds an "enabled" boolean to enable the current section.
|
208 |
-
*
|
209 |
-
* By default, the section is disabled. If any configuration is specified then
|
210 |
-
* the node will be automatically enabled:
|
211 |
-
*
|
212 |
-
* enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden
|
213 |
-
* enableableArrayNode: ~ # The config is enabled & use the default values
|
214 |
-
* enableableArrayNode: true # The config is enabled & use the default values
|
215 |
-
* enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden
|
216 |
-
* enableableArrayNode: {enabled: false, ...} # The config is disabled
|
217 |
-
* enableableArrayNode: false # The config is disabled
|
218 |
-
*
|
219 |
-
* @return ArrayNodeDefinition
|
220 |
-
*/
|
221 |
-
public function canBeEnabled()
|
222 |
-
{
|
223 |
-
$this
|
224 |
-
->addDefaultsIfNotSet()
|
225 |
-
->treatFalseLike(array('enabled' => false))
|
226 |
-
->treatTrueLike(array('enabled' => true))
|
227 |
-
->treatNullLike(array('enabled' => true))
|
228 |
-
->beforeNormalization()
|
229 |
-
->ifArray()
|
230 |
-
->then(function ($v) {
|
231 |
-
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
|
232 |
-
|
233 |
-
return $v;
|
234 |
-
})
|
235 |
-
->end()
|
236 |
-
->children()
|
237 |
-
->booleanNode('enabled')
|
238 |
-
->defaultFalse()
|
239 |
-
;
|
240 |
-
|
241 |
-
return $this;
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Adds an "enabled" boolean to enable the current section.
|
246 |
-
*
|
247 |
-
* By default, the section is enabled.
|
248 |
-
*
|
249 |
-
* @return ArrayNodeDefinition
|
250 |
-
*/
|
251 |
-
public function canBeDisabled()
|
252 |
-
{
|
253 |
-
$this
|
254 |
-
->addDefaultsIfNotSet()
|
255 |
-
->treatFalseLike(array('enabled' => false))
|
256 |
-
->treatTrueLike(array('enabled' => true))
|
257 |
-
->treatNullLike(array('enabled' => true))
|
258 |
-
->children()
|
259 |
-
->booleanNode('enabled')
|
260 |
-
->defaultTrue()
|
261 |
-
;
|
262 |
-
|
263 |
-
return $this;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Disables the deep merging of the node.
|
268 |
-
*
|
269 |
-
* @return ArrayNodeDefinition
|
270 |
-
*/
|
271 |
-
public function performNoDeepMerging()
|
272 |
-
{
|
273 |
-
$this->performDeepMerging = false;
|
274 |
-
|
275 |
-
return $this;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Allows extra config keys to be specified under an array without
|
280 |
-
* throwing an exception.
|
281 |
-
*
|
282 |
-
* Those config values are simply ignored. This should be used only
|
283 |
-
* in special cases where you want to send an entire configuration
|
284 |
-
* array through a special tree that processes only part of the array.
|
285 |
-
*
|
286 |
-
* @return ArrayNodeDefinition
|
287 |
-
*/
|
288 |
-
public function ignoreExtraKeys()
|
289 |
-
{
|
290 |
-
$this->ignoreExtraKeys = true;
|
291 |
-
|
292 |
-
return $this;
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Sets key normalization.
|
297 |
-
*
|
298 |
-
* @param bool $bool Whether to enable key normalization
|
299 |
-
*
|
300 |
-
* @return ArrayNodeDefinition
|
301 |
-
*/
|
302 |
-
public function normalizeKeys($bool)
|
303 |
-
{
|
304 |
-
$this->normalizeKeys = (bool) $bool;
|
305 |
-
|
306 |
-
return $this;
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Appends a node definition.
|
311 |
-
*
|
312 |
-
* $node = new ArrayNodeDefinition()
|
313 |
-
* ->children()
|
314 |
-
* ->scalarNode('foo')->end()
|
315 |
-
* ->scalarNode('baz')->end()
|
316 |
-
* ->end()
|
317 |
-
* ->append($this->getBarNodeDefinition())
|
318 |
-
* ;
|
319 |
-
*
|
320 |
-
* @param NodeDefinition $node A NodeDefinition instance
|
321 |
-
*
|
322 |
-
* @return ArrayNodeDefinition This node
|
323 |
-
*/
|
324 |
-
public function append(NodeDefinition $node)
|
325 |
-
{
|
326 |
-
$this->children[$node->name] = $node->setParent($this);
|
327 |
-
|
328 |
-
return $this;
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Returns a node builder to be used to add children and prototype.
|
333 |
-
*
|
334 |
-
* @return NodeBuilder The node builder
|
335 |
-
*/
|
336 |
-
protected function getNodeBuilder()
|
337 |
-
{
|
338 |
-
if (null === $this->nodeBuilder) {
|
339 |
-
$this->nodeBuilder = new NodeBuilder();
|
340 |
-
}
|
341 |
-
|
342 |
-
return $this->nodeBuilder->setParent($this);
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* {@inheritdoc}
|
347 |
-
*/
|
348 |
-
protected function createNode()
|
349 |
-
{
|
350 |
-
if (null === $this->prototype) {
|
351 |
-
$node = new ArrayNode($this->name, $this->parent);
|
352 |
-
|
353 |
-
$this->validateConcreteNode($node);
|
354 |
-
|
355 |
-
$node->setAddIfNotSet($this->addDefaults);
|
356 |
-
|
357 |
-
foreach ($this->children as $child) {
|
358 |
-
$child->parent = $node;
|
359 |
-
$node->addChild($child->getNode());
|
360 |
-
}
|
361 |
-
} else {
|
362 |
-
$node = new PrototypedArrayNode($this->name, $this->parent);
|
363 |
-
|
364 |
-
$this->validatePrototypeNode($node);
|
365 |
-
|
366 |
-
if (null !== $this->key) {
|
367 |
-
$node->setKeyAttribute($this->key, $this->removeKeyItem);
|
368 |
-
}
|
369 |
-
|
370 |
-
if (true === $this->atLeastOne) {
|
371 |
-
$node->setMinNumberOfElements(1);
|
372 |
-
}
|
373 |
-
|
374 |
-
if ($this->default) {
|
375 |
-
$node->setDefaultValue($this->defaultValue);
|
376 |
-
}
|
377 |
-
|
378 |
-
if (false !== $this->addDefaultChildren) {
|
379 |
-
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
|
380 |
-
if ($this->prototype instanceof static && null === $this->prototype->prototype) {
|
381 |
-
$this->prototype->addDefaultsIfNotSet();
|
382 |
-
}
|
383 |
-
}
|
384 |
-
|
385 |
-
$this->prototype->parent = $node;
|
386 |
-
$node->setPrototype($this->prototype->getNode());
|
387 |
-
}
|
388 |
-
|
389 |
-
$node->setAllowNewKeys($this->allowNewKeys);
|
390 |
-
$node->addEquivalentValue(null, $this->nullEquivalent);
|
391 |
-
$node->addEquivalentValue(true, $this->trueEquivalent);
|
392 |
-
$node->addEquivalentValue(false, $this->falseEquivalent);
|
393 |
-
$node->setPerformDeepMerging($this->performDeepMerging);
|
394 |
-
$node->setRequired($this->required);
|
395 |
-
$node->setIgnoreExtraKeys($this->ignoreExtraKeys);
|
396 |
-
$node->setNormalizeKeys($this->normalizeKeys);
|
397 |
-
|
398 |
-
if (null !== $this->normalization) {
|
399 |
-
$node->setNormalizationClosures($this->normalization->before);
|
400 |
-
$node->setXmlRemappings($this->normalization->remappings);
|
401 |
-
}
|
402 |
-
|
403 |
-
if (null !== $this->merge) {
|
404 |
-
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
405 |
-
$node->setAllowFalse($this->merge->allowFalse);
|
406 |
-
}
|
407 |
-
|
408 |
-
if (null !== $this->validation) {
|
409 |
-
$node->setFinalValidationClosures($this->validation->rules);
|
410 |
-
}
|
411 |
-
|
412 |
-
return $node;
|
413 |
-
}
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Validate the configuration of a concrete node.
|
417 |
-
*
|
418 |
-
* @param ArrayNode $node The related node
|
419 |
-
*
|
420 |
-
* @throws InvalidDefinitionException
|
421 |
-
*/
|
422 |
-
protected function validateConcreteNode(ArrayNode $node)
|
423 |
-
{
|
424 |
-
$path = $node->getPath();
|
425 |
-
|
426 |
-
if (null !== $this->key) {
|
427 |
-
throw new InvalidDefinitionException(
|
428 |
-
sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path)
|
429 |
-
);
|
430 |
-
}
|
431 |
-
|
432 |
-
if (true === $this->atLeastOne) {
|
433 |
-
throw new InvalidDefinitionException(
|
434 |
-
sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path)
|
435 |
-
);
|
436 |
-
}
|
437 |
-
|
438 |
-
if ($this->default) {
|
439 |
-
throw new InvalidDefinitionException(
|
440 |
-
sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path)
|
441 |
-
);
|
442 |
-
}
|
443 |
-
|
444 |
-
if (false !== $this->addDefaultChildren) {
|
445 |
-
throw new InvalidDefinitionException(
|
446 |
-
sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path)
|
447 |
-
);
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* Validate the configuration of a prototype node.
|
453 |
-
*
|
454 |
-
* @param PrototypedArrayNode $node The related node
|
455 |
-
*
|
456 |
-
* @throws InvalidDefinitionException
|
457 |
-
*/
|
458 |
-
protected function validatePrototypeNode(PrototypedArrayNode $node)
|
459 |
-
{
|
460 |
-
$path = $node->getPath();
|
461 |
-
|
462 |
-
if ($this->addDefaults) {
|
463 |
-
throw new InvalidDefinitionException(
|
464 |
-
sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path)
|
465 |
-
);
|
466 |
-
}
|
467 |
-
|
468 |
-
if (false !== $this->addDefaultChildren) {
|
469 |
-
if ($this->default) {
|
470 |
-
throw new InvalidDefinitionException(
|
471 |
-
sprintf('A default value and default children might not be used together at path "%s"', $path)
|
472 |
-
);
|
473 |
-
}
|
474 |
-
|
475 |
-
if (null !== $this->key && (null === $this->addDefaultChildren || is_integer($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
|
476 |
-
throw new InvalidDefinitionException(
|
477 |
-
sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path)
|
478 |
-
);
|
479 |
-
}
|
480 |
-
|
481 |
-
if (null === $this->key && (is_string($this->addDefaultChildren) || is_array($this->addDefaultChildren))) {
|
482 |
-
throw new InvalidDefinitionException(
|
483 |
-
sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path)
|
484 |
-
);
|
485 |
-
}
|
486 |
-
}
|
487 |
-
}
|
488 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\BooleanNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class provides a fluent interface for defining a node.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class BooleanNodeDefinition extends ScalarNodeDefinition
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* {@inheritdoc}
|
25 |
-
*/
|
26 |
-
public function __construct($name, NodeParentInterface $parent = null)
|
27 |
-
{
|
28 |
-
parent::__construct($name, $parent);
|
29 |
-
|
30 |
-
$this->nullEquivalent = true;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Instantiate a Node.
|
35 |
-
*
|
36 |
-
* @return BooleanNode The node
|
37 |
-
*/
|
38 |
-
protected function instantiateNode()
|
39 |
-
{
|
40 |
-
return new BooleanNode($this->name, $this->parent);
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\EnumNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Enum Node Definition.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class EnumNodeDefinition extends ScalarNodeDefinition
|
22 |
-
{
|
23 |
-
private $values;
|
24 |
-
|
25 |
-
public function values(array $values)
|
26 |
-
{
|
27 |
-
$values = array_unique($values);
|
28 |
-
|
29 |
-
if (count($values) <= 1) {
|
30 |
-
throw new \InvalidArgumentException('->values() must be called with at least two distinct values.');
|
31 |
-
}
|
32 |
-
|
33 |
-
$this->values = $values;
|
34 |
-
|
35 |
-
return $this;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Instantiate a Node.
|
40 |
-
*
|
41 |
-
* @return EnumNode The node
|
42 |
-
*
|
43 |
-
* @throws \RuntimeException
|
44 |
-
*/
|
45 |
-
protected function instantiateNode()
|
46 |
-
{
|
47 |
-
if (null === $this->values) {
|
48 |
-
throw new \RuntimeException('You must call ->values() on enum nodes.');
|
49 |
-
}
|
50 |
-
|
51 |
-
return new EnumNode($this->name, $this->parent, $this->values);
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/ExprBuilder.php
DELETED
@@ -1,238 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class builds an if expression.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
* @author Christophe Coevoet <stof@notk.org>
|
21 |
-
*/
|
22 |
-
class ExprBuilder
|
23 |
-
{
|
24 |
-
protected $node;
|
25 |
-
public $ifPart;
|
26 |
-
public $thenPart;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Constructor.
|
30 |
-
*
|
31 |
-
* @param NodeDefinition $node The related node
|
32 |
-
*/
|
33 |
-
public function __construct(NodeDefinition $node)
|
34 |
-
{
|
35 |
-
$this->node = $node;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Marks the expression as being always used.
|
40 |
-
*
|
41 |
-
* @param \Closure $then
|
42 |
-
*
|
43 |
-
* @return ExprBuilder
|
44 |
-
*/
|
45 |
-
public function always(\Closure $then = null)
|
46 |
-
{
|
47 |
-
$this->ifPart = function ($v) { return true; };
|
48 |
-
|
49 |
-
if (null !== $then) {
|
50 |
-
$this->thenPart = $then;
|
51 |
-
}
|
52 |
-
|
53 |
-
return $this;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Sets a closure to use as tests.
|
58 |
-
*
|
59 |
-
* The default one tests if the value is true.
|
60 |
-
*
|
61 |
-
* @param \Closure $closure
|
62 |
-
*
|
63 |
-
* @return ExprBuilder
|
64 |
-
*/
|
65 |
-
public function ifTrue(\Closure $closure = null)
|
66 |
-
{
|
67 |
-
if (null === $closure) {
|
68 |
-
$closure = function ($v) { return true === $v; };
|
69 |
-
}
|
70 |
-
|
71 |
-
$this->ifPart = $closure;
|
72 |
-
|
73 |
-
return $this;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Tests if the value is a string.
|
78 |
-
*
|
79 |
-
* @return ExprBuilder
|
80 |
-
*/
|
81 |
-
public function ifString()
|
82 |
-
{
|
83 |
-
$this->ifPart = function ($v) { return is_string($v); };
|
84 |
-
|
85 |
-
return $this;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Tests if the value is null.
|
90 |
-
*
|
91 |
-
* @return ExprBuilder
|
92 |
-
*/
|
93 |
-
public function ifNull()
|
94 |
-
{
|
95 |
-
$this->ifPart = function ($v) { return null === $v; };
|
96 |
-
|
97 |
-
return $this;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Tests if the value is an array.
|
102 |
-
*
|
103 |
-
* @return ExprBuilder
|
104 |
-
*/
|
105 |
-
public function ifArray()
|
106 |
-
{
|
107 |
-
$this->ifPart = function ($v) { return is_array($v); };
|
108 |
-
|
109 |
-
return $this;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Tests if the value is in an array.
|
114 |
-
*
|
115 |
-
* @param array $array
|
116 |
-
*
|
117 |
-
* @return ExprBuilder
|
118 |
-
*/
|
119 |
-
public function ifInArray(array $array)
|
120 |
-
{
|
121 |
-
$this->ifPart = function ($v) use ($array) { return in_array($v, $array, true); };
|
122 |
-
|
123 |
-
return $this;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Tests if the value is not in an array.
|
128 |
-
*
|
129 |
-
* @param array $array
|
130 |
-
*
|
131 |
-
* @return ExprBuilder
|
132 |
-
*/
|
133 |
-
public function ifNotInArray(array $array)
|
134 |
-
{
|
135 |
-
$this->ifPart = function ($v) use ($array) { return !in_array($v, $array, true); };
|
136 |
-
|
137 |
-
return $this;
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Sets the closure to run if the test pass.
|
142 |
-
*
|
143 |
-
* @param \Closure $closure
|
144 |
-
*
|
145 |
-
* @return ExprBuilder
|
146 |
-
*/
|
147 |
-
public function then(\Closure $closure)
|
148 |
-
{
|
149 |
-
$this->thenPart = $closure;
|
150 |
-
|
151 |
-
return $this;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Sets a closure returning an empty array.
|
156 |
-
*
|
157 |
-
* @return ExprBuilder
|
158 |
-
*/
|
159 |
-
public function thenEmptyArray()
|
160 |
-
{
|
161 |
-
$this->thenPart = function ($v) { return array(); };
|
162 |
-
|
163 |
-
return $this;
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Sets a closure marking the value as invalid at validation time.
|
168 |
-
*
|
169 |
-
* if you want to add the value of the node in your message just use a %s placeholder.
|
170 |
-
*
|
171 |
-
* @param string $message
|
172 |
-
*
|
173 |
-
* @return ExprBuilder
|
174 |
-
*
|
175 |
-
* @throws \InvalidArgumentException
|
176 |
-
*/
|
177 |
-
public function thenInvalid($message)
|
178 |
-
{
|
179 |
-
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
|
180 |
-
|
181 |
-
return $this;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Sets a closure unsetting this key of the array at validation time.
|
186 |
-
*
|
187 |
-
* @return ExprBuilder
|
188 |
-
*
|
189 |
-
* @throws UnsetKeyException
|
190 |
-
*/
|
191 |
-
public function thenUnset()
|
192 |
-
{
|
193 |
-
$this->thenPart = function ($v) { throw new UnsetKeyException('Unsetting key'); };
|
194 |
-
|
195 |
-
return $this;
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Returns the related node.
|
200 |
-
*
|
201 |
-
* @return NodeDefinition
|
202 |
-
*
|
203 |
-
* @throws \RuntimeException
|
204 |
-
*/
|
205 |
-
public function end()
|
206 |
-
{
|
207 |
-
if (null === $this->ifPart) {
|
208 |
-
throw new \RuntimeException('You must specify an if part.');
|
209 |
-
}
|
210 |
-
if (null === $this->thenPart) {
|
211 |
-
throw new \RuntimeException('You must specify a then part.');
|
212 |
-
}
|
213 |
-
|
214 |
-
return $this->node;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Builds the expressions.
|
219 |
-
*
|
220 |
-
* @param ExprBuilder[] $expressions An array of ExprBuilder instances to build
|
221 |
-
*
|
222 |
-
* @return array
|
223 |
-
*/
|
224 |
-
public static function buildExpressions(array $expressions)
|
225 |
-
{
|
226 |
-
foreach ($expressions as $k => $expr) {
|
227 |
-
if ($expr instanceof ExprBuilder) {
|
228 |
-
$if = $expr->ifPart;
|
229 |
-
$then = $expr->thenPart;
|
230 |
-
$expressions[$k] = function ($v) use ($if, $then) {
|
231 |
-
return $if($v) ? $then($v) : $v;
|
232 |
-
};
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
return $expressions;
|
237 |
-
}
|
238 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/FloatNodeDefinition.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\FloatNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class provides a fluent interface for defining a float node.
|
18 |
-
*
|
19 |
-
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
20 |
-
*/
|
21 |
-
class FloatNodeDefinition extends NumericNodeDefinition
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Instantiates a Node.
|
25 |
-
*
|
26 |
-
* @return FloatNode The node
|
27 |
-
*/
|
28 |
-
protected function instantiateNode()
|
29 |
-
{
|
30 |
-
return new FloatNode($this->name, $this->parent, $this->min, $this->max);
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/IntegerNodeDefinition.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\IntegerNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class provides a fluent interface for defining an integer node.
|
18 |
-
*
|
19 |
-
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
20 |
-
*/
|
21 |
-
class IntegerNodeDefinition extends NumericNodeDefinition
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Instantiates a Node.
|
25 |
-
*
|
26 |
-
* @return IntegerNode The node
|
27 |
-
*/
|
28 |
-
protected function instantiateNode()
|
29 |
-
{
|
30 |
-
return new IntegerNode($this->name, $this->parent, $this->min, $this->max);
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This class builds merge conditions.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class MergeBuilder
|
20 |
-
{
|
21 |
-
protected $node;
|
22 |
-
public $allowFalse = false;
|
23 |
-
public $allowOverwrite = true;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Constructor.
|
27 |
-
*
|
28 |
-
* @param NodeDefinition $node The related node
|
29 |
-
*/
|
30 |
-
public function __construct(NodeDefinition $node)
|
31 |
-
{
|
32 |
-
$this->node = $node;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Sets whether the node can be unset.
|
37 |
-
*
|
38 |
-
* @param bool $allow
|
39 |
-
*
|
40 |
-
* @return MergeBuilder
|
41 |
-
*/
|
42 |
-
public function allowUnset($allow = true)
|
43 |
-
{
|
44 |
-
$this->allowFalse = $allow;
|
45 |
-
|
46 |
-
return $this;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Sets whether the node can be overwritten.
|
51 |
-
*
|
52 |
-
* @param bool $deny Whether the overwriting is forbidden or not
|
53 |
-
*
|
54 |
-
* @return MergeBuilder
|
55 |
-
*/
|
56 |
-
public function denyOverwrite($deny = true)
|
57 |
-
{
|
58 |
-
$this->allowOverwrite = !$deny;
|
59 |
-
|
60 |
-
return $this;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Returns the related node.
|
65 |
-
*
|
66 |
-
* @return NodeDefinition
|
67 |
-
*/
|
68 |
-
public function end()
|
69 |
-
{
|
70 |
-
return $this->node;
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
DELETED
@@ -1,245 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This class provides a fluent interface for building a node.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class NodeBuilder implements NodeParentInterface
|
20 |
-
{
|
21 |
-
protected $parent;
|
22 |
-
protected $nodeMapping;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor.
|
26 |
-
*/
|
27 |
-
public function __construct()
|
28 |
-
{
|
29 |
-
$this->nodeMapping = array(
|
30 |
-
'variable' => __NAMESPACE__.'\\VariableNodeDefinition',
|
31 |
-
'scalar' => __NAMESPACE__.'\\ScalarNodeDefinition',
|
32 |
-
'boolean' => __NAMESPACE__.'\\BooleanNodeDefinition',
|
33 |
-
'integer' => __NAMESPACE__.'\\IntegerNodeDefinition',
|
34 |
-
'float' => __NAMESPACE__.'\\FloatNodeDefinition',
|
35 |
-
'array' => __NAMESPACE__.'\\ArrayNodeDefinition',
|
36 |
-
'enum' => __NAMESPACE__.'\\EnumNodeDefinition',
|
37 |
-
);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Set the parent node.
|
42 |
-
*
|
43 |
-
* @param ParentNodeDefinitionInterface $parent The parent node
|
44 |
-
*
|
45 |
-
* @return NodeBuilder This node builder
|
46 |
-
*/
|
47 |
-
public function setParent(ParentNodeDefinitionInterface $parent = null)
|
48 |
-
{
|
49 |
-
$this->parent = $parent;
|
50 |
-
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Creates a child array node.
|
56 |
-
*
|
57 |
-
* @param string $name The name of the node
|
58 |
-
*
|
59 |
-
* @return ArrayNodeDefinition The child node
|
60 |
-
*/
|
61 |
-
public function arrayNode($name)
|
62 |
-
{
|
63 |
-
return $this->node($name, 'array');
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Creates a child scalar node.
|
68 |
-
*
|
69 |
-
* @param string $name the name of the node
|
70 |
-
*
|
71 |
-
* @return ScalarNodeDefinition The child node
|
72 |
-
*/
|
73 |
-
public function scalarNode($name)
|
74 |
-
{
|
75 |
-
return $this->node($name, 'scalar');
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Creates a child Boolean node.
|
80 |
-
*
|
81 |
-
* @param string $name The name of the node
|
82 |
-
*
|
83 |
-
* @return BooleanNodeDefinition The child node
|
84 |
-
*/
|
85 |
-
public function booleanNode($name)
|
86 |
-
{
|
87 |
-
return $this->node($name, 'boolean');
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Creates a child integer node.
|
92 |
-
*
|
93 |
-
* @param string $name the name of the node
|
94 |
-
*
|
95 |
-
* @return IntegerNodeDefinition The child node
|
96 |
-
*/
|
97 |
-
public function integerNode($name)
|
98 |
-
{
|
99 |
-
return $this->node($name, 'integer');
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Creates a child float node.
|
104 |
-
*
|
105 |
-
* @param string $name the name of the node
|
106 |
-
*
|
107 |
-
* @return FloatNodeDefinition The child node
|
108 |
-
*/
|
109 |
-
public function floatNode($name)
|
110 |
-
{
|
111 |
-
return $this->node($name, 'float');
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Creates a child EnumNode.
|
116 |
-
*
|
117 |
-
* @param string $name
|
118 |
-
*
|
119 |
-
* @return EnumNodeDefinition
|
120 |
-
*/
|
121 |
-
public function enumNode($name)
|
122 |
-
{
|
123 |
-
return $this->node($name, 'enum');
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Creates a child variable node.
|
128 |
-
*
|
129 |
-
* @param string $name The name of the node
|
130 |
-
*
|
131 |
-
* @return VariableNodeDefinition The builder of the child node
|
132 |
-
*/
|
133 |
-
public function variableNode($name)
|
134 |
-
{
|
135 |
-
return $this->node($name, 'variable');
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Returns the parent node.
|
140 |
-
*
|
141 |
-
* @return ParentNodeDefinitionInterface The parent node
|
142 |
-
*/
|
143 |
-
public function end()
|
144 |
-
{
|
145 |
-
return $this->parent;
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Creates a child node.
|
150 |
-
*
|
151 |
-
* @param string $name The name of the node
|
152 |
-
* @param string $type The type of the node
|
153 |
-
*
|
154 |
-
* @return NodeDefinition The child node
|
155 |
-
*
|
156 |
-
* @throws \RuntimeException When the node type is not registered
|
157 |
-
* @throws \RuntimeException When the node class is not found
|
158 |
-
*/
|
159 |
-
public function node($name, $type)
|
160 |
-
{
|
161 |
-
$class = $this->getNodeClass($type);
|
162 |
-
|
163 |
-
$node = new $class($name);
|
164 |
-
|
165 |
-
$this->append($node);
|
166 |
-
|
167 |
-
return $node;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Appends a node definition.
|
172 |
-
*
|
173 |
-
* Usage:
|
174 |
-
*
|
175 |
-
* $node = new ArrayNodeDefinition('name')
|
176 |
-
* ->children()
|
177 |
-
* ->scalarNode('foo')->end()
|
178 |
-
* ->scalarNode('baz')->end()
|
179 |
-
* ->append($this->getBarNodeDefinition())
|
180 |
-
* ->end()
|
181 |
-
* ;
|
182 |
-
*
|
183 |
-
* @param NodeDefinition $node
|
184 |
-
*
|
185 |
-
* @return NodeBuilder This node builder
|
186 |
-
*/
|
187 |
-
public function append(NodeDefinition $node)
|
188 |
-
{
|
189 |
-
if ($node instanceof ParentNodeDefinitionInterface) {
|
190 |
-
$builder = clone $this;
|
191 |
-
$builder->setParent(null);
|
192 |
-
$node->setBuilder($builder);
|
193 |
-
}
|
194 |
-
|
195 |
-
if (null !== $this->parent) {
|
196 |
-
$this->parent->append($node);
|
197 |
-
// Make this builder the node parent to allow for a fluid interface
|
198 |
-
$node->setParent($this);
|
199 |
-
}
|
200 |
-
|
201 |
-
return $this;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Adds or overrides a node Type.
|
206 |
-
*
|
207 |
-
* @param string $type The name of the type
|
208 |
-
* @param string $class The fully qualified name the node definition class
|
209 |
-
*
|
210 |
-
* @return NodeBuilder This node builder
|
211 |
-
*/
|
212 |
-
public function setNodeClass($type, $class)
|
213 |
-
{
|
214 |
-
$this->nodeMapping[strtolower($type)] = $class;
|
215 |
-
|
216 |
-
return $this;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Returns the class name of the node definition.
|
221 |
-
*
|
222 |
-
* @param string $type The node type
|
223 |
-
*
|
224 |
-
* @return string The node definition class name
|
225 |
-
*
|
226 |
-
* @throws \RuntimeException When the node type is not registered
|
227 |
-
* @throws \RuntimeException When the node class is not found
|
228 |
-
*/
|
229 |
-
protected function getNodeClass($type)
|
230 |
-
{
|
231 |
-
$type = strtolower($type);
|
232 |
-
|
233 |
-
if (!isset($this->nodeMapping[$type])) {
|
234 |
-
throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
|
235 |
-
}
|
236 |
-
|
237 |
-
$class = $this->nodeMapping[$type];
|
238 |
-
|
239 |
-
if (!class_exists($class)) {
|
240 |
-
throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
|
241 |
-
}
|
242 |
-
|
243 |
-
return $class;
|
244 |
-
}
|
245 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
DELETED
@@ -1,343 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\NodeInterface;
|
15 |
-
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* This class provides a fluent interface for defining a node.
|
19 |
-
*
|
20 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
21 |
-
*/
|
22 |
-
abstract class NodeDefinition implements NodeParentInterface
|
23 |
-
{
|
24 |
-
protected $name;
|
25 |
-
protected $normalization;
|
26 |
-
protected $validation;
|
27 |
-
protected $defaultValue;
|
28 |
-
protected $default = false;
|
29 |
-
protected $required = false;
|
30 |
-
protected $merge;
|
31 |
-
protected $allowEmptyValue = true;
|
32 |
-
protected $nullEquivalent;
|
33 |
-
protected $trueEquivalent = true;
|
34 |
-
protected $falseEquivalent = false;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var NodeParentInterface|null
|
38 |
-
*/
|
39 |
-
protected $parent;
|
40 |
-
protected $attributes = array();
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor.
|
44 |
-
*
|
45 |
-
* @param string $name The name of the node
|
46 |
-
* @param NodeParentInterface|null $parent The parent
|
47 |
-
*/
|
48 |
-
public function __construct($name, NodeParentInterface $parent = null)
|
49 |
-
{
|
50 |
-
$this->parent = $parent;
|
51 |
-
$this->name = $name;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Sets the parent node.
|
56 |
-
*
|
57 |
-
* @param NodeParentInterface $parent The parent
|
58 |
-
*
|
59 |
-
* @return NodeDefinition
|
60 |
-
*/
|
61 |
-
public function setParent(NodeParentInterface $parent)
|
62 |
-
{
|
63 |
-
$this->parent = $parent;
|
64 |
-
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Sets info message.
|
70 |
-
*
|
71 |
-
* @param string $info The info text
|
72 |
-
*
|
73 |
-
* @return NodeDefinition
|
74 |
-
*/
|
75 |
-
public function info($info)
|
76 |
-
{
|
77 |
-
return $this->attribute('info', $info);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Sets example configuration.
|
82 |
-
*
|
83 |
-
* @param string|array $example
|
84 |
-
*
|
85 |
-
* @return NodeDefinition
|
86 |
-
*/
|
87 |
-
public function example($example)
|
88 |
-
{
|
89 |
-
return $this->attribute('example', $example);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Sets an attribute on the node.
|
94 |
-
*
|
95 |
-
* @param string $key
|
96 |
-
* @param mixed $value
|
97 |
-
*
|
98 |
-
* @return NodeDefinition
|
99 |
-
*/
|
100 |
-
public function attribute($key, $value)
|
101 |
-
{
|
102 |
-
$this->attributes[$key] = $value;
|
103 |
-
|
104 |
-
return $this;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Returns the parent node.
|
109 |
-
*
|
110 |
-
* @return NodeParentInterface|null The builder of the parent node
|
111 |
-
*/
|
112 |
-
public function end()
|
113 |
-
{
|
114 |
-
return $this->parent;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Creates the node.
|
119 |
-
*
|
120 |
-
* @param bool $forceRootNode Whether to force this node as the root node
|
121 |
-
*
|
122 |
-
* @return NodeInterface
|
123 |
-
*/
|
124 |
-
public function getNode($forceRootNode = false)
|
125 |
-
{
|
126 |
-
if ($forceRootNode) {
|
127 |
-
$this->parent = null;
|
128 |
-
}
|
129 |
-
|
130 |
-
if (null !== $this->normalization) {
|
131 |
-
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
|
132 |
-
}
|
133 |
-
|
134 |
-
if (null !== $this->validation) {
|
135 |
-
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
|
136 |
-
}
|
137 |
-
|
138 |
-
$node = $this->createNode();
|
139 |
-
$node->setAttributes($this->attributes);
|
140 |
-
|
141 |
-
return $node;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Sets the default value.
|
146 |
-
*
|
147 |
-
* @param mixed $value The default value
|
148 |
-
*
|
149 |
-
* @return NodeDefinition
|
150 |
-
*/
|
151 |
-
public function defaultValue($value)
|
152 |
-
{
|
153 |
-
$this->default = true;
|
154 |
-
$this->defaultValue = $value;
|
155 |
-
|
156 |
-
return $this;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Sets the node as required.
|
161 |
-
*
|
162 |
-
* @return NodeDefinition
|
163 |
-
*/
|
164 |
-
public function isRequired()
|
165 |
-
{
|
166 |
-
$this->required = true;
|
167 |
-
|
168 |
-
return $this;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Sets the equivalent value used when the node contains null.
|
173 |
-
*
|
174 |
-
* @param mixed $value
|
175 |
-
*
|
176 |
-
* @return NodeDefinition
|
177 |
-
*/
|
178 |
-
public function treatNullLike($value)
|
179 |
-
{
|
180 |
-
$this->nullEquivalent = $value;
|
181 |
-
|
182 |
-
return $this;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Sets the equivalent value used when the node contains true.
|
187 |
-
*
|
188 |
-
* @param mixed $value
|
189 |
-
*
|
190 |
-
* @return NodeDefinition
|
191 |
-
*/
|
192 |
-
public function treatTrueLike($value)
|
193 |
-
{
|
194 |
-
$this->trueEquivalent = $value;
|
195 |
-
|
196 |
-
return $this;
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Sets the equivalent value used when the node contains false.
|
201 |
-
*
|
202 |
-
* @param mixed $value
|
203 |
-
*
|
204 |
-
* @return NodeDefinition
|
205 |
-
*/
|
206 |
-
public function treatFalseLike($value)
|
207 |
-
{
|
208 |
-
$this->falseEquivalent = $value;
|
209 |
-
|
210 |
-
return $this;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Sets null as the default value.
|
215 |
-
*
|
216 |
-
* @return NodeDefinition
|
217 |
-
*/
|
218 |
-
public function defaultNull()
|
219 |
-
{
|
220 |
-
return $this->defaultValue(null);
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Sets true as the default value.
|
225 |
-
*
|
226 |
-
* @return NodeDefinition
|
227 |
-
*/
|
228 |
-
public function defaultTrue()
|
229 |
-
{
|
230 |
-
return $this->defaultValue(true);
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Sets false as the default value.
|
235 |
-
*
|
236 |
-
* @return NodeDefinition
|
237 |
-
*/
|
238 |
-
public function defaultFalse()
|
239 |
-
{
|
240 |
-
return $this->defaultValue(false);
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Sets an expression to run before the normalization.
|
245 |
-
*
|
246 |
-
* @return ExprBuilder
|
247 |
-
*/
|
248 |
-
public function beforeNormalization()
|
249 |
-
{
|
250 |
-
return $this->normalization()->before();
|
251 |
-
}
|
252 |
-
|
253 |
-
/**
|
254 |
-
* Denies the node value being empty.
|
255 |
-
*
|
256 |
-
* @return NodeDefinition
|
257 |
-
*/
|
258 |
-
public function cannotBeEmpty()
|
259 |
-
{
|
260 |
-
$this->allowEmptyValue = false;
|
261 |
-
|
262 |
-
return $this;
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Sets an expression to run for the validation.
|
267 |
-
*
|
268 |
-
* The expression receives the value of the node and must return it. It can
|
269 |
-
* modify it.
|
270 |
-
* An exception should be thrown when the node is not valid.
|
271 |
-
*
|
272 |
-
* @return ExprBuilder
|
273 |
-
*/
|
274 |
-
public function validate()
|
275 |
-
{
|
276 |
-
return $this->validation()->rule();
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Sets whether the node can be overwritten.
|
281 |
-
*
|
282 |
-
* @param bool $deny Whether the overwriting is forbidden or not
|
283 |
-
*
|
284 |
-
* @return NodeDefinition
|
285 |
-
*/
|
286 |
-
public function cannotBeOverwritten($deny = true)
|
287 |
-
{
|
288 |
-
$this->merge()->denyOverwrite($deny);
|
289 |
-
|
290 |
-
return $this;
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Gets the builder for validation rules.
|
295 |
-
*
|
296 |
-
* @return ValidationBuilder
|
297 |
-
*/
|
298 |
-
protected function validation()
|
299 |
-
{
|
300 |
-
if (null === $this->validation) {
|
301 |
-
$this->validation = new ValidationBuilder($this);
|
302 |
-
}
|
303 |
-
|
304 |
-
return $this->validation;
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Gets the builder for merging rules.
|
309 |
-
*
|
310 |
-
* @return MergeBuilder
|
311 |
-
*/
|
312 |
-
protected function merge()
|
313 |
-
{
|
314 |
-
if (null === $this->merge) {
|
315 |
-
$this->merge = new MergeBuilder($this);
|
316 |
-
}
|
317 |
-
|
318 |
-
return $this->merge;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Gets the builder for normalization rules.
|
323 |
-
*
|
324 |
-
* @return NormalizationBuilder
|
325 |
-
*/
|
326 |
-
protected function normalization()
|
327 |
-
{
|
328 |
-
if (null === $this->normalization) {
|
329 |
-
$this->normalization = new NormalizationBuilder($this);
|
330 |
-
}
|
331 |
-
|
332 |
-
return $this->normalization;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Instantiate and configure the node according to this definition.
|
337 |
-
*
|
338 |
-
* @return NodeInterface $node The node instance
|
339 |
-
*
|
340 |
-
* @throws InvalidDefinitionException When the definition is invalid
|
341 |
-
*/
|
342 |
-
abstract protected function createNode();
|
343 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/NodeParentInterface.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* An interface that must be implemented by all node parents.
|
16 |
-
*
|
17 |
-
* @author Victor Berchet <victor@suumit.com>
|
18 |
-
*/
|
19 |
-
interface NodeParentInterface
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This class builds normalization conditions.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class NormalizationBuilder
|
20 |
-
{
|
21 |
-
protected $node;
|
22 |
-
public $before = array();
|
23 |
-
public $remappings = array();
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Constructor.
|
27 |
-
*
|
28 |
-
* @param NodeDefinition $node The related node
|
29 |
-
*/
|
30 |
-
public function __construct(NodeDefinition $node)
|
31 |
-
{
|
32 |
-
$this->node = $node;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Registers a key to remap to its plural form.
|
37 |
-
*
|
38 |
-
* @param string $key The key to remap
|
39 |
-
* @param string $plural The plural of the key in case of irregular plural
|
40 |
-
*
|
41 |
-
* @return NormalizationBuilder
|
42 |
-
*/
|
43 |
-
public function remap($key, $plural = null)
|
44 |
-
{
|
45 |
-
$this->remappings[] = array($key, null === $plural ? $key.'s' : $plural);
|
46 |
-
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Registers a closure to run before the normalization or an expression builder to build it if null is provided.
|
52 |
-
*
|
53 |
-
* @param \Closure $closure
|
54 |
-
*
|
55 |
-
* @return ExprBuilder|NormalizationBuilder
|
56 |
-
*/
|
57 |
-
public function before(\Closure $closure = null)
|
58 |
-
{
|
59 |
-
if (null !== $closure) {
|
60 |
-
$this->before[] = $closure;
|
61 |
-
|
62 |
-
return $this;
|
63 |
-
}
|
64 |
-
|
65 |
-
return $this->before[] = new ExprBuilder($this->node);
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Abstract class that contains common code of integer and float node definitions.
|
16 |
-
*
|
17 |
-
* @author David Jeanmonod <david.jeanmonod@gmail.com>
|
18 |
-
*/
|
19 |
-
abstract class NumericNodeDefinition extends ScalarNodeDefinition
|
20 |
-
{
|
21 |
-
protected $min;
|
22 |
-
protected $max;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Ensures that the value is smaller than the given reference.
|
26 |
-
*
|
27 |
-
* @param mixed $max
|
28 |
-
*
|
29 |
-
* @return NumericNodeDefinition
|
30 |
-
*
|
31 |
-
* @throws \InvalidArgumentException when the constraint is inconsistent
|
32 |
-
*/
|
33 |
-
public function max($max)
|
34 |
-
{
|
35 |
-
if (isset($this->min) && $this->min > $max) {
|
36 |
-
throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s)', $max, $this->min));
|
37 |
-
}
|
38 |
-
$this->max = $max;
|
39 |
-
|
40 |
-
return $this;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Ensures that the value is bigger than the given reference.
|
45 |
-
*
|
46 |
-
* @param mixed $min
|
47 |
-
*
|
48 |
-
* @return NumericNodeDefinition
|
49 |
-
*
|
50 |
-
* @throws \InvalidArgumentException when the constraint is inconsistent
|
51 |
-
*/
|
52 |
-
public function min($min)
|
53 |
-
{
|
54 |
-
if (isset($this->max) && $this->max < $min) {
|
55 |
-
throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s)', $min, $this->max));
|
56 |
-
}
|
57 |
-
$this->min = $min;
|
58 |
-
|
59 |
-
return $this;
|
60 |
-
}
|
61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* An interface that must be implemented by nodes which can have children.
|
16 |
-
*
|
17 |
-
* @author Victor Berchet <victor@suumit.com>
|
18 |
-
*/
|
19 |
-
interface ParentNodeDefinitionInterface
|
20 |
-
{
|
21 |
-
public function children();
|
22 |
-
|
23 |
-
public function append(NodeDefinition $node);
|
24 |
-
|
25 |
-
public function setBuilder(NodeBuilder $builder);
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\ScalarNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class provides a fluent interface for defining a node.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class ScalarNodeDefinition extends VariableNodeDefinition
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Instantiate a Node.
|
25 |
-
*
|
26 |
-
* @return ScalarNode The node
|
27 |
-
*/
|
28 |
-
protected function instantiateNode()
|
29 |
-
{
|
30 |
-
return new ScalarNode($this->name, $this->parent);
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/TreeBuilder.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\NodeInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This is the entry class for building a config tree.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class TreeBuilder implements NodeParentInterface
|
22 |
-
{
|
23 |
-
protected $tree;
|
24 |
-
protected $root;
|
25 |
-
protected $builder;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Creates the root node.
|
29 |
-
*
|
30 |
-
* @param string $name The name of the root node
|
31 |
-
* @param string $type The type of the root node
|
32 |
-
* @param NodeBuilder $builder A custom node builder instance
|
33 |
-
*
|
34 |
-
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
35 |
-
*
|
36 |
-
* @throws \RuntimeException When the node type is not supported
|
37 |
-
*/
|
38 |
-
public function root($name, $type = 'array', NodeBuilder $builder = null)
|
39 |
-
{
|
40 |
-
$builder = $builder ?: new NodeBuilder();
|
41 |
-
|
42 |
-
return $this->root = $builder->node($name, $type)->setParent($this);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Builds the tree.
|
47 |
-
*
|
48 |
-
* @return NodeInterface
|
49 |
-
*
|
50 |
-
* @throws \RuntimeException
|
51 |
-
*/
|
52 |
-
public function buildTree()
|
53 |
-
{
|
54 |
-
if (null === $this->root) {
|
55 |
-
throw new \RuntimeException('The configuration tree has no root node.');
|
56 |
-
}
|
57 |
-
if (null !== $this->tree) {
|
58 |
-
return $this->tree;
|
59 |
-
}
|
60 |
-
|
61 |
-
return $this->tree = $this->root->getNode(true);
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This class builds validation conditions.
|
16 |
-
*
|
17 |
-
* @author Christophe Coevoet <stof@notk.org>
|
18 |
-
*/
|
19 |
-
class ValidationBuilder
|
20 |
-
{
|
21 |
-
protected $node;
|
22 |
-
public $rules = array();
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor.
|
26 |
-
*
|
27 |
-
* @param NodeDefinition $node The related node
|
28 |
-
*/
|
29 |
-
public function __construct(NodeDefinition $node)
|
30 |
-
{
|
31 |
-
$this->node = $node;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Registers a closure to run as normalization or an expression builder to build it if null is provided.
|
36 |
-
*
|
37 |
-
* @param \Closure $closure
|
38 |
-
*
|
39 |
-
* @return ExprBuilder|ValidationBuilder
|
40 |
-
*/
|
41 |
-
public function rule(\Closure $closure = null)
|
42 |
-
{
|
43 |
-
if (null !== $closure) {
|
44 |
-
$this->rules[] = $closure;
|
45 |
-
|
46 |
-
return $this;
|
47 |
-
}
|
48 |
-
|
49 |
-
return $this->rules[] = new ExprBuilder($this->node);
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Builder;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\VariableNode;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class provides a fluent interface for defining a node.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class VariableNodeDefinition extends NodeDefinition
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Instantiate a Node.
|
25 |
-
*
|
26 |
-
* @return VariableNode The node
|
27 |
-
*/
|
28 |
-
protected function instantiateNode()
|
29 |
-
{
|
30 |
-
return new VariableNode($this->name, $this->parent);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* {@inheritdoc}
|
35 |
-
*/
|
36 |
-
protected function createNode()
|
37 |
-
{
|
38 |
-
$node = $this->instantiateNode();
|
39 |
-
|
40 |
-
if (null !== $this->normalization) {
|
41 |
-
$node->setNormalizationClosures($this->normalization->before);
|
42 |
-
}
|
43 |
-
|
44 |
-
if (null !== $this->merge) {
|
45 |
-
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
46 |
-
}
|
47 |
-
|
48 |
-
if (true === $this->default) {
|
49 |
-
$node->setDefaultValue($this->defaultValue);
|
50 |
-
}
|
51 |
-
|
52 |
-
$node->setAllowEmptyValue($this->allowEmptyValue);
|
53 |
-
$node->addEquivalentValue(null, $this->nullEquivalent);
|
54 |
-
$node->addEquivalentValue(true, $this->trueEquivalent);
|
55 |
-
$node->addEquivalentValue(false, $this->falseEquivalent);
|
56 |
-
$node->setRequired($this->required);
|
57 |
-
|
58 |
-
if (null !== $this->validation) {
|
59 |
-
$node->setFinalValidationClosures($this->validation->rules);
|
60 |
-
}
|
61 |
-
|
62 |
-
return $node;
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/ConfigurationInterface.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Configuration interface.
|
16 |
-
*
|
17 |
-
* @author Victor Berchet <victor@suumit.com>
|
18 |
-
*/
|
19 |
-
interface ConfigurationInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Generates the configuration tree builder.
|
23 |
-
*
|
24 |
-
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
25 |
-
*/
|
26 |
-
public function getConfigTreeBuilder();
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php
DELETED
@@ -1,300 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
15 |
-
use Symfony\Component\Config\Definition\NodeInterface;
|
16 |
-
use Symfony\Component\Config\Definition\ArrayNode;
|
17 |
-
use Symfony\Component\Config\Definition\EnumNode;
|
18 |
-
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Dumps a XML reference configuration for the given configuration/node instance.
|
22 |
-
*
|
23 |
-
* @author Wouter J <waldio.webdesign@gmail.com>
|
24 |
-
*/
|
25 |
-
class XmlReferenceDumper
|
26 |
-
{
|
27 |
-
private $reference;
|
28 |
-
|
29 |
-
public function dump(ConfigurationInterface $configuration, $namespace = null)
|
30 |
-
{
|
31 |
-
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
|
32 |
-
}
|
33 |
-
|
34 |
-
public function dumpNode(NodeInterface $node, $namespace = null)
|
35 |
-
{
|
36 |
-
$this->reference = '';
|
37 |
-
$this->writeNode($node, 0, true, $namespace);
|
38 |
-
$ref = $this->reference;
|
39 |
-
$this->reference = null;
|
40 |
-
|
41 |
-
return $ref;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @param NodeInterface $node
|
46 |
-
* @param int $depth
|
47 |
-
* @param bool $root If the node is the root node
|
48 |
-
* @param string $namespace The namespace of the node
|
49 |
-
*/
|
50 |
-
private function writeNode(NodeInterface $node, $depth = 0, $root = false, $namespace = null)
|
51 |
-
{
|
52 |
-
$rootName = ($root ? 'config' : $node->getName());
|
53 |
-
$rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null));
|
54 |
-
|
55 |
-
// xml remapping
|
56 |
-
if ($node->getParent()) {
|
57 |
-
$remapping = array_filter($node->getParent()->getXmlRemappings(), function ($mapping) use ($rootName) {
|
58 |
-
return $rootName === $mapping[1];
|
59 |
-
});
|
60 |
-
|
61 |
-
if (count($remapping)) {
|
62 |
-
list($singular, $plural) = current($remapping);
|
63 |
-
$rootName = $singular;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
$rootName = str_replace('_', '-', $rootName);
|
67 |
-
|
68 |
-
$rootAttributes = array();
|
69 |
-
$rootAttributeComments = array();
|
70 |
-
$rootChildren = array();
|
71 |
-
$rootComments = array();
|
72 |
-
|
73 |
-
if ($node instanceof ArrayNode) {
|
74 |
-
$children = $node->getChildren();
|
75 |
-
|
76 |
-
// comments about the root node
|
77 |
-
if ($rootInfo = $node->getInfo()) {
|
78 |
-
$rootComments[] = $rootInfo;
|
79 |
-
}
|
80 |
-
|
81 |
-
if ($rootNamespace) {
|
82 |
-
$rootComments[] = 'Namespace: '.$rootNamespace;
|
83 |
-
}
|
84 |
-
|
85 |
-
// render prototyped nodes
|
86 |
-
if ($node instanceof PrototypedArrayNode) {
|
87 |
-
array_unshift($rootComments, 'prototype');
|
88 |
-
|
89 |
-
if ($key = $node->getKeyAttribute()) {
|
90 |
-
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
91 |
-
}
|
92 |
-
|
93 |
-
$prototype = $node->getPrototype();
|
94 |
-
|
95 |
-
if ($prototype instanceof ArrayNode) {
|
96 |
-
$children = $prototype->getChildren();
|
97 |
-
} else {
|
98 |
-
if ($prototype->hasDefaultValue()) {
|
99 |
-
$prototypeValue = $prototype->getDefaultValue();
|
100 |
-
} else {
|
101 |
-
switch (get_class($prototype)) {
|
102 |
-
case 'Symfony\Component\Config\Definition\ScalarNode':
|
103 |
-
$prototypeValue = 'scalar value';
|
104 |
-
break;
|
105 |
-
|
106 |
-
case 'Symfony\Component\Config\Definition\FloatNode':
|
107 |
-
case 'Symfony\Component\Config\Definition\IntegerNode':
|
108 |
-
$prototypeValue = 'numeric value';
|
109 |
-
break;
|
110 |
-
|
111 |
-
case 'Symfony\Component\Config\Definition\BooleanNode':
|
112 |
-
$prototypeValue = 'true|false';
|
113 |
-
break;
|
114 |
-
|
115 |
-
case 'Symfony\Component\Config\Definition\EnumNode':
|
116 |
-
$prototypeValue = implode('|', array_map('json_encode', $prototype->getValues()));
|
117 |
-
break;
|
118 |
-
|
119 |
-
default:
|
120 |
-
$prototypeValue = 'value';
|
121 |
-
}
|
122 |
-
}
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
// get attributes and elements
|
127 |
-
foreach ($children as $child) {
|
128 |
-
if (!$child instanceof ArrayNode) {
|
129 |
-
// get attributes
|
130 |
-
|
131 |
-
// metadata
|
132 |
-
$name = str_replace('_', '-', $child->getName());
|
133 |
-
$value = '%%%%not_defined%%%%'; // use a string which isn't used in the normal world
|
134 |
-
|
135 |
-
// comments
|
136 |
-
$comments = array();
|
137 |
-
if ($info = $child->getInfo()) {
|
138 |
-
$comments[] = $info;
|
139 |
-
}
|
140 |
-
|
141 |
-
if ($example = $child->getExample()) {
|
142 |
-
$comments[] = 'Example: '.$example;
|
143 |
-
}
|
144 |
-
|
145 |
-
if ($child->isRequired()) {
|
146 |
-
$comments[] = 'Required';
|
147 |
-
}
|
148 |
-
|
149 |
-
if ($child instanceof EnumNode) {
|
150 |
-
$comments[] = 'One of '.implode('; ', array_map('json_encode', $child->getValues()));
|
151 |
-
}
|
152 |
-
|
153 |
-
if (count($comments)) {
|
154 |
-
$rootAttributeComments[$name] = implode(";\n", $comments);
|
155 |
-
}
|
156 |
-
|
157 |
-
// default values
|
158 |
-
if ($child->hasDefaultValue()) {
|
159 |
-
$value = $child->getDefaultValue();
|
160 |
-
}
|
161 |
-
|
162 |
-
// append attribute
|
163 |
-
$rootAttributes[$name] = $value;
|
164 |
-
} else {
|
165 |
-
// get elements
|
166 |
-
$rootChildren[] = $child;
|
167 |
-
}
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
// render comments
|
172 |
-
|
173 |
-
// root node comment
|
174 |
-
if (count($rootComments)) {
|
175 |
-
foreach ($rootComments as $comment) {
|
176 |
-
$this->writeLine('<!-- '.$comment.' -->', $depth);
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
// attribute comments
|
181 |
-
if (count($rootAttributeComments)) {
|
182 |
-
foreach ($rootAttributeComments as $attrName => $comment) {
|
183 |
-
$commentDepth = $depth + 4 + strlen($attrName) + 2;
|
184 |
-
$commentLines = explode("\n", $comment);
|
185 |
-
$multiline = (count($commentLines) > 1);
|
186 |
-
$comment = implode(PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
|
187 |
-
|
188 |
-
if ($multiline) {
|
189 |
-
$this->writeLine('<!--', $depth);
|
190 |
-
$this->writeLine($attrName.': '.$comment, $depth + 4);
|
191 |
-
$this->writeLine('-->', $depth);
|
192 |
-
} else {
|
193 |
-
$this->writeLine('<!-- '.$attrName.': '.$comment.' -->', $depth);
|
194 |
-
}
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
// render start tag + attributes
|
199 |
-
$rootIsVariablePrototype = isset($prototypeValue);
|
200 |
-
$rootIsEmptyTag = (0 === count($rootChildren) && !$rootIsVariablePrototype);
|
201 |
-
$rootOpenTag = '<'.$rootName;
|
202 |
-
if (1 >= ($attributesCount = count($rootAttributes))) {
|
203 |
-
if (1 === $attributesCount) {
|
204 |
-
$rootOpenTag .= sprintf(' %s="%s"', current(array_keys($rootAttributes)), $this->writeValue(current($rootAttributes)));
|
205 |
-
}
|
206 |
-
|
207 |
-
$rootOpenTag .= $rootIsEmptyTag ? ' />' : '>';
|
208 |
-
|
209 |
-
if ($rootIsVariablePrototype) {
|
210 |
-
$rootOpenTag .= $prototypeValue.'</'.$rootName.'>';
|
211 |
-
}
|
212 |
-
|
213 |
-
$this->writeLine($rootOpenTag, $depth);
|
214 |
-
} else {
|
215 |
-
$this->writeLine($rootOpenTag, $depth);
|
216 |
-
|
217 |
-
$i = 1;
|
218 |
-
|
219 |
-
foreach ($rootAttributes as $attrName => $attrValue) {
|
220 |
-
$attr = sprintf('%s="%s"', $attrName, $this->writeValue($attrValue));
|
221 |
-
|
222 |
-
$this->writeLine($attr, $depth + 4);
|
223 |
-
|
224 |
-
if ($attributesCount === $i++) {
|
225 |
-
$this->writeLine($rootIsEmptyTag ? '/>' : '>', $depth);
|
226 |
-
|
227 |
-
if ($rootIsVariablePrototype) {
|
228 |
-
$rootOpenTag .= $prototypeValue.'</'.$rootName.'>';
|
229 |
-
}
|
230 |
-
}
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
// render children tags
|
235 |
-
foreach ($rootChildren as $child) {
|
236 |
-
$this->writeLine('');
|
237 |
-
$this->writeNode($child, $depth + 4);
|
238 |
-
}
|
239 |
-
|
240 |
-
// render end tag
|
241 |
-
if (!$rootIsEmptyTag && !$rootIsVariablePrototype) {
|
242 |
-
$this->writeLine('');
|
243 |
-
|
244 |
-
$rootEndTag = '</'.$rootName.'>';
|
245 |
-
$this->writeLine($rootEndTag, $depth);
|
246 |
-
}
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Outputs a single config reference line
|
251 |
-
*
|
252 |
-
* @param string $text
|
253 |
-
* @param int $indent
|
254 |
-
*/
|
255 |
-
private function writeLine($text, $indent = 0)
|
256 |
-
{
|
257 |
-
$indent = strlen($text) + $indent;
|
258 |
-
$format = '%'.$indent.'s';
|
259 |
-
|
260 |
-
$this->reference .= sprintf($format, $text)."\n";
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Renders the string conversion of the value.
|
265 |
-
*
|
266 |
-
* @param mixed $value
|
267 |
-
*
|
268 |
-
* @return string
|
269 |
-
*/
|
270 |
-
private function writeValue($value)
|
271 |
-
{
|
272 |
-
if ('%%%%not_defined%%%%' === $value) {
|
273 |
-
return '';
|
274 |
-
}
|
275 |
-
|
276 |
-
if (is_string($value) || is_numeric($value)) {
|
277 |
-
return $value;
|
278 |
-
}
|
279 |
-
|
280 |
-
if (false === $value) {
|
281 |
-
return 'false';
|
282 |
-
}
|
283 |
-
|
284 |
-
if (true === $value) {
|
285 |
-
return 'true';
|
286 |
-
}
|
287 |
-
|
288 |
-
if (null === $value) {
|
289 |
-
return 'null';
|
290 |
-
}
|
291 |
-
|
292 |
-
if (empty($value)) {
|
293 |
-
return '';
|
294 |
-
}
|
295 |
-
|
296 |
-
if (is_array($value)) {
|
297 |
-
return implode(',', $value);
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php
DELETED
@@ -1,199 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
15 |
-
use Symfony\Component\Config\Definition\NodeInterface;
|
16 |
-
use Symfony\Component\Config\Definition\ArrayNode;
|
17 |
-
use Symfony\Component\Config\Definition\ScalarNode;
|
18 |
-
use Symfony\Component\Config\Definition\EnumNode;
|
19 |
-
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
20 |
-
use Symfony\Component\Yaml\Inline;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Dumps a Yaml reference configuration for the given configuration/node instance.
|
24 |
-
*
|
25 |
-
* @author Kevin Bond <kevinbond@gmail.com>
|
26 |
-
*/
|
27 |
-
class YamlReferenceDumper
|
28 |
-
{
|
29 |
-
private $reference;
|
30 |
-
|
31 |
-
public function dump(ConfigurationInterface $configuration)
|
32 |
-
{
|
33 |
-
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
|
34 |
-
}
|
35 |
-
|
36 |
-
public function dumpNode(NodeInterface $node)
|
37 |
-
{
|
38 |
-
$this->reference = '';
|
39 |
-
$this->writeNode($node);
|
40 |
-
$ref = $this->reference;
|
41 |
-
$this->reference = null;
|
42 |
-
|
43 |
-
return $ref;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @param NodeInterface $node
|
48 |
-
* @param int $depth
|
49 |
-
*/
|
50 |
-
private function writeNode(NodeInterface $node, $depth = 0)
|
51 |
-
{
|
52 |
-
$comments = array();
|
53 |
-
$default = '';
|
54 |
-
$defaultArray = null;
|
55 |
-
$children = null;
|
56 |
-
$example = $node->getExample();
|
57 |
-
|
58 |
-
// defaults
|
59 |
-
if ($node instanceof ArrayNode) {
|
60 |
-
$children = $node->getChildren();
|
61 |
-
|
62 |
-
if ($node instanceof PrototypedArrayNode) {
|
63 |
-
$prototype = $node->getPrototype();
|
64 |
-
|
65 |
-
if ($prototype instanceof ArrayNode) {
|
66 |
-
$children = $prototype->getChildren();
|
67 |
-
}
|
68 |
-
|
69 |
-
// check for attribute as key
|
70 |
-
if ($key = $node->getKeyAttribute()) {
|
71 |
-
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
|
72 |
-
$keyNode = new $keyNodeClass($key, $node);
|
73 |
-
$keyNode->setInfo('Prototype');
|
74 |
-
|
75 |
-
// add children
|
76 |
-
foreach ($children as $childNode) {
|
77 |
-
$keyNode->addChild($childNode);
|
78 |
-
}
|
79 |
-
$children = array($key => $keyNode);
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
if (!$children) {
|
84 |
-
if ($node->hasDefaultValue() && count($defaultArray = $node->getDefaultValue())) {
|
85 |
-
$default = '';
|
86 |
-
} elseif (!is_array($example)) {
|
87 |
-
$default = '[]';
|
88 |
-
}
|
89 |
-
}
|
90 |
-
} elseif ($node instanceof EnumNode) {
|
91 |
-
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
|
92 |
-
$default = '~';
|
93 |
-
} else {
|
94 |
-
$default = '~';
|
95 |
-
|
96 |
-
if ($node->hasDefaultValue()) {
|
97 |
-
$default = $node->getDefaultValue();
|
98 |
-
|
99 |
-
if (is_array($default)) {
|
100 |
-
if (count($defaultArray = $node->getDefaultValue())) {
|
101 |
-
$default = '';
|
102 |
-
} elseif (!is_array($example)) {
|
103 |
-
$default = '[]';
|
104 |
-
}
|
105 |
-
} else {
|
106 |
-
$default = Inline::dump($default);
|
107 |
-
}
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
// required?
|
112 |
-
if ($node->isRequired()) {
|
113 |
-
$comments[] = 'Required';
|
114 |
-
}
|
115 |
-
|
116 |
-
// example
|
117 |
-
if ($example && !is_array($example)) {
|
118 |
-
$comments[] = 'Example: '.$example;
|
119 |
-
}
|
120 |
-
|
121 |
-
$default = (string) $default != '' ? ' '.$default : '';
|
122 |
-
$comments = count($comments) ? '# '.implode(', ', $comments) : '';
|
123 |
-
|
124 |
-
$text = rtrim(sprintf('%-20s %s %s', $node->getName().':', $default, $comments), ' ');
|
125 |
-
|
126 |
-
if ($info = $node->getInfo()) {
|
127 |
-
$this->writeLine('');
|
128 |
-
// indenting multi-line info
|
129 |
-
$info = str_replace("\n", sprintf("\n%".($depth * 4)."s# ", ' '), $info);
|
130 |
-
$this->writeLine('# '.$info, $depth * 4);
|
131 |
-
}
|
132 |
-
|
133 |
-
$this->writeLine($text, $depth * 4);
|
134 |
-
|
135 |
-
// output defaults
|
136 |
-
if ($defaultArray) {
|
137 |
-
$this->writeLine('');
|
138 |
-
|
139 |
-
$message = count($defaultArray) > 1 ? 'Defaults' : 'Default';
|
140 |
-
|
141 |
-
$this->writeLine('# '.$message.':', $depth * 4 + 4);
|
142 |
-
|
143 |
-
$this->writeArray($defaultArray, $depth + 1);
|
144 |
-
}
|
145 |
-
|
146 |
-
if (is_array($example)) {
|
147 |
-
$this->writeLine('');
|
148 |
-
|
149 |
-
$message = count($example) > 1 ? 'Examples' : 'Example';
|
150 |
-
|
151 |
-
$this->writeLine('# '.$message.':', $depth * 4 + 4);
|
152 |
-
|
153 |
-
$this->writeArray($example, $depth + 1);
|
154 |
-
}
|
155 |
-
|
156 |
-
if ($children) {
|
157 |
-
foreach ($children as $childNode) {
|
158 |
-
$this->writeNode($childNode, $depth + 1);
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Outputs a single config reference line
|
165 |
-
*
|
166 |
-
* @param string $text
|
167 |
-
* @param int $indent
|
168 |
-
*/
|
169 |
-
private function writeLine($text, $indent = 0)
|
170 |
-
{
|
171 |
-
$indent = strlen($text) + $indent;
|
172 |
-
$format = '%'.$indent.'s';
|
173 |
-
|
174 |
-
$this->reference .= sprintf($format, $text)."\n";
|
175 |
-
}
|
176 |
-
|
177 |
-
private function writeArray(array $array, $depth)
|
178 |
-
{
|
179 |
-
$isIndexed = array_values($array) === $array;
|
180 |
-
|
181 |
-
foreach ($array as $key => $value) {
|
182 |
-
if (is_array($value)) {
|
183 |
-
$val = '';
|
184 |
-
} else {
|
185 |
-
$val = $value;
|
186 |
-
}
|
187 |
-
|
188 |
-
if ($isIndexed) {
|
189 |
-
$this->writeLine('- '.$val, $depth * 4);
|
190 |
-
} else {
|
191 |
-
$this->writeLine(sprintf('%-20s %s', $key.':', $val), $depth * 4);
|
192 |
-
}
|
193 |
-
|
194 |
-
if (is_array($value)) {
|
195 |
-
$this->writeArray($value, $depth + 1);
|
196 |
-
}
|
197 |
-
}
|
198 |
-
}
|
199 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/EnumNode.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Node which only allows a finite set of values.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class EnumNode extends ScalarNode
|
22 |
-
{
|
23 |
-
private $values;
|
24 |
-
|
25 |
-
public function __construct($name, NodeInterface $parent = null, array $values = array())
|
26 |
-
{
|
27 |
-
$values = array_unique($values);
|
28 |
-
if (count($values) <= 1) {
|
29 |
-
throw new \InvalidArgumentException('$values must contain at least two distinct elements.');
|
30 |
-
}
|
31 |
-
|
32 |
-
parent::__construct($name, $parent);
|
33 |
-
$this->values = $values;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getValues()
|
37 |
-
{
|
38 |
-
return $this->values;
|
39 |
-
}
|
40 |
-
|
41 |
-
protected function finalizeValue($value)
|
42 |
-
{
|
43 |
-
$value = parent::finalizeValue($value);
|
44 |
-
|
45 |
-
if (!in_array($value, $this->values, true)) {
|
46 |
-
$ex = new InvalidConfigurationException(sprintf(
|
47 |
-
'The value %s is not allowed for path "%s". Permissible values: %s',
|
48 |
-
json_encode($value),
|
49 |
-
$this->getPath(),
|
50 |
-
implode(', ', array_map('json_encode', $this->values))));
|
51 |
-
$ex->setPath($this->getPath());
|
52 |
-
|
53 |
-
throw $ex;
|
54 |
-
}
|
55 |
-
|
56 |
-
return $value;
|
57 |
-
}
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/DuplicateKeyException.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown whenever the key of an array is not unique. This can
|
16 |
-
* only be the case if the configuration is coming from an XML file.
|
17 |
-
*
|
18 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
19 |
-
*/
|
20 |
-
class DuplicateKeyException extends InvalidConfigurationException
|
21 |
-
{
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/Exception.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base exception for all configuration exceptions.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class Exception extends \RuntimeException
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when a configuration path is overwritten from a
|
16 |
-
* subsequent configuration file, but the entry node specifically forbids this.
|
17 |
-
*
|
18 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
19 |
-
*/
|
20 |
-
class ForbiddenOverwriteException extends InvalidConfigurationException
|
21 |
-
{
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* A very general exception which can be thrown whenever non of the more specific
|
16 |
-
* exceptions is suitable.
|
17 |
-
*
|
18 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
19 |
-
*/
|
20 |
-
class InvalidConfigurationException extends Exception
|
21 |
-
{
|
22 |
-
private $path;
|
23 |
-
|
24 |
-
public function setPath($path)
|
25 |
-
{
|
26 |
-
$this->path = $path;
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getPath()
|
30 |
-
{
|
31 |
-
return $this->path;
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/InvalidDefinitionException.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Thrown when an error is detected in a node Definition.
|
16 |
-
*
|
17 |
-
* @author Victor Berchet <victor.berchet@suumit.com>
|
18 |
-
*/
|
19 |
-
class InvalidDefinitionException extends Exception
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/InvalidTypeException.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown if an invalid type is encountered.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class InvalidTypeException extends InvalidConfigurationException
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Exception/UnsetKeyException.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is usually not encountered by the end-user, but only used
|
16 |
-
* internally to signal the parent scope to unset a key.
|
17 |
-
*
|
18 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
19 |
-
*/
|
20 |
-
class UnsetKeyException extends Exception
|
21 |
-
{
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/FloatNode.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents a float value in the config tree.
|
18 |
-
*
|
19 |
-
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
20 |
-
*/
|
21 |
-
class FloatNode extends NumericNode
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* {@inheritdoc}
|
25 |
-
*/
|
26 |
-
protected function validateType($value)
|
27 |
-
{
|
28 |
-
// Integers are also accepted, we just cast them
|
29 |
-
if (is_int($value)) {
|
30 |
-
$value = (float) $value;
|
31 |
-
}
|
32 |
-
|
33 |
-
if (!is_float($value)) {
|
34 |
-
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value)));
|
35 |
-
$ex->setPath($this->getPath());
|
36 |
-
|
37 |
-
throw $ex;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/IntegerNode.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents an integer value in the config tree.
|
18 |
-
*
|
19 |
-
* @author Jeanmonod David <david.jeanmonod@gmail.com>
|
20 |
-
*/
|
21 |
-
class IntegerNode extends NumericNode
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* {@inheritdoc}
|
25 |
-
*/
|
26 |
-
protected function validateType($value)
|
27 |
-
{
|
28 |
-
if (!is_int($value)) {
|
29 |
-
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), gettype($value)));
|
30 |
-
$ex->setPath($this->getPath());
|
31 |
-
|
32 |
-
throw $ex;
|
33 |
-
}
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/NodeInterface.php
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Common Interface among all nodes.
|
16 |
-
*
|
17 |
-
* In most cases, it is better to inherit from BaseNode instead of implementing
|
18 |
-
* this interface yourself.
|
19 |
-
*
|
20 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
21 |
-
*/
|
22 |
-
interface NodeInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Returns the name of the node.
|
26 |
-
*
|
27 |
-
* @return string The name of the node
|
28 |
-
*/
|
29 |
-
public function getName();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns the path of the node.
|
33 |
-
*
|
34 |
-
* @return string The node path
|
35 |
-
*/
|
36 |
-
public function getPath();
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Returns true when the node is required.
|
40 |
-
*
|
41 |
-
* @return bool If the node is required
|
42 |
-
*/
|
43 |
-
public function isRequired();
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Returns true when the node has a default value.
|
47 |
-
*
|
48 |
-
* @return bool If the node has a default value
|
49 |
-
*/
|
50 |
-
public function hasDefaultValue();
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Returns the default value of the node.
|
54 |
-
*
|
55 |
-
* @return mixed The default value
|
56 |
-
*
|
57 |
-
* @throws \RuntimeException if the node has no default value
|
58 |
-
*/
|
59 |
-
public function getDefaultValue();
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Normalizes the supplied value.
|
63 |
-
*
|
64 |
-
* @param mixed $value The value to normalize
|
65 |
-
*
|
66 |
-
* @return mixed The normalized value
|
67 |
-
*/
|
68 |
-
public function normalize($value);
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Merges two values together.
|
72 |
-
*
|
73 |
-
* @param mixed $leftSide
|
74 |
-
* @param mixed $rightSide
|
75 |
-
*
|
76 |
-
* @return mixed The merged values
|
77 |
-
*/
|
78 |
-
public function merge($leftSide, $rightSide);
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Finalizes a value.
|
82 |
-
*
|
83 |
-
* @param mixed $value The value to finalize
|
84 |
-
*
|
85 |
-
* @return mixed The finalized value
|
86 |
-
*/
|
87 |
-
public function finalize($value);
|
88 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/NumericNode.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents a numeric value in the config tree.
|
18 |
-
*
|
19 |
-
* @author David Jeanmonod <david.jeanmonod@gmail.com>
|
20 |
-
*/
|
21 |
-
class NumericNode extends ScalarNode
|
22 |
-
{
|
23 |
-
protected $min;
|
24 |
-
protected $max;
|
25 |
-
|
26 |
-
public function __construct($name, NodeInterface $parent = null, $min = null, $max = null)
|
27 |
-
{
|
28 |
-
parent::__construct($name, $parent);
|
29 |
-
$this->min = $min;
|
30 |
-
$this->max = $max;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* {@inheritdoc}
|
35 |
-
*/
|
36 |
-
protected function finalizeValue($value)
|
37 |
-
{
|
38 |
-
$value = parent::finalizeValue($value);
|
39 |
-
|
40 |
-
$errorMsg = null;
|
41 |
-
if (isset($this->min) && $value < $this->min) {
|
42 |
-
$errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
|
43 |
-
}
|
44 |
-
if (isset($this->max) && $value > $this->max) {
|
45 |
-
$errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
|
46 |
-
}
|
47 |
-
if (isset($errorMsg)) {
|
48 |
-
$ex = new InvalidConfigurationException($errorMsg);
|
49 |
-
$ex->setPath($this->getPath());
|
50 |
-
throw $ex;
|
51 |
-
}
|
52 |
-
|
53 |
-
return $value;
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/Processor.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This class is the entry point for config normalization/merging/finalization.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class Processor
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Processes an array of configurations.
|
23 |
-
*
|
24 |
-
* @param NodeInterface $configTree The node tree describing the configuration
|
25 |
-
* @param array $configs An array of configuration items to process
|
26 |
-
*
|
27 |
-
* @return array The processed configuration
|
28 |
-
*/
|
29 |
-
public function process(NodeInterface $configTree, array $configs)
|
30 |
-
{
|
31 |
-
$currentConfig = array();
|
32 |
-
foreach ($configs as $config) {
|
33 |
-
$config = $configTree->normalize($config);
|
34 |
-
$currentConfig = $configTree->merge($currentConfig, $config);
|
35 |
-
}
|
36 |
-
|
37 |
-
return $configTree->finalize($currentConfig);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes an array of configurations.
|
42 |
-
*
|
43 |
-
* @param ConfigurationInterface $configuration The configuration class
|
44 |
-
* @param array $configs An array of configuration items to process
|
45 |
-
*
|
46 |
-
* @return array The processed configuration
|
47 |
-
*/
|
48 |
-
public function processConfiguration(ConfigurationInterface $configuration, array $configs)
|
49 |
-
{
|
50 |
-
return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Normalizes a configuration entry.
|
55 |
-
*
|
56 |
-
* This method returns a normalize configuration array for a given key
|
57 |
-
* to remove the differences due to the original format (YAML and XML mainly).
|
58 |
-
*
|
59 |
-
* Here is an example.
|
60 |
-
*
|
61 |
-
* The configuration in XML:
|
62 |
-
*
|
63 |
-
* <twig:extension>twig.extension.foo</twig:extension>
|
64 |
-
* <twig:extension>twig.extension.bar</twig:extension>
|
65 |
-
*
|
66 |
-
* And the same configuration in YAML:
|
67 |
-
*
|
68 |
-
* extensions: ['twig.extension.foo', 'twig.extension.bar']
|
69 |
-
*
|
70 |
-
* @param array $config A config array
|
71 |
-
* @param string $key The key to normalize
|
72 |
-
* @param string $plural The plural form of the key if it is irregular
|
73 |
-
*
|
74 |
-
* @return array
|
75 |
-
*/
|
76 |
-
public static function normalizeConfig($config, $key, $plural = null)
|
77 |
-
{
|
78 |
-
if (null === $plural) {
|
79 |
-
$plural = $key.'s';
|
80 |
-
}
|
81 |
-
|
82 |
-
if (isset($config[$plural])) {
|
83 |
-
return $config[$plural];
|
84 |
-
}
|
85 |
-
|
86 |
-
if (isset($config[$key])) {
|
87 |
-
if (is_string($config[$key]) || !is_int(key($config[$key]))) {
|
88 |
-
// only one
|
89 |
-
return array($config[$key]);
|
90 |
-
}
|
91 |
-
|
92 |
-
return $config[$key];
|
93 |
-
}
|
94 |
-
|
95 |
-
return array();
|
96 |
-
}
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/PrototypeNodeInterface.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This interface must be implemented by nodes which can be used as prototypes.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
interface PrototypeNodeInterface extends NodeInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Sets the name of the node.
|
23 |
-
*
|
24 |
-
* @param string $name The name of the node
|
25 |
-
*/
|
26 |
-
public function setName($name);
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/PrototypedArrayNode.php
DELETED
@@ -1,331 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
15 |
-
use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;
|
16 |
-
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
17 |
-
use Symfony\Component\Config\Definition\Exception\Exception;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Represents a prototyped Array node in the config tree.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class PrototypedArrayNode extends ArrayNode
|
25 |
-
{
|
26 |
-
protected $prototype;
|
27 |
-
protected $keyAttribute;
|
28 |
-
protected $removeKeyAttribute = false;
|
29 |
-
protected $minNumberOfElements = 0;
|
30 |
-
protected $defaultValue = array();
|
31 |
-
protected $defaultChildren;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Sets the minimum number of elements that a prototype based node must
|
35 |
-
* contain. By default this is zero, meaning no elements.
|
36 |
-
*
|
37 |
-
* @param int $number
|
38 |
-
*/
|
39 |
-
public function setMinNumberOfElements($number)
|
40 |
-
{
|
41 |
-
$this->minNumberOfElements = $number;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Sets the attribute which value is to be used as key.
|
46 |
-
*
|
47 |
-
* This is useful when you have an indexed array that should be an
|
48 |
-
* associative array. You can select an item from within the array
|
49 |
-
* to be the key of the particular item. For example, if "id" is the
|
50 |
-
* "key", then:
|
51 |
-
*
|
52 |
-
* array(
|
53 |
-
* array('id' => 'my_name', 'foo' => 'bar'),
|
54 |
-
* );
|
55 |
-
*
|
56 |
-
* becomes
|
57 |
-
*
|
58 |
-
* array(
|
59 |
-
* 'my_name' => array('foo' => 'bar'),
|
60 |
-
* );
|
61 |
-
*
|
62 |
-
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
63 |
-
* array, then you can set the second argument of this method to false.
|
64 |
-
*
|
65 |
-
* @param string $attribute The name of the attribute which value is to be used as a key
|
66 |
-
* @param bool $remove Whether or not to remove the key
|
67 |
-
*/
|
68 |
-
public function setKeyAttribute($attribute, $remove = true)
|
69 |
-
{
|
70 |
-
$this->keyAttribute = $attribute;
|
71 |
-
$this->removeKeyAttribute = $remove;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Retrieves the name of the attribute which value should be used as key.
|
76 |
-
*
|
77 |
-
* @return string The name of the attribute
|
78 |
-
*/
|
79 |
-
public function getKeyAttribute()
|
80 |
-
{
|
81 |
-
return $this->keyAttribute;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Sets the default value of this node.
|
86 |
-
*
|
87 |
-
* @param string $value
|
88 |
-
*
|
89 |
-
* @throws \InvalidArgumentException if the default value is not an array
|
90 |
-
*/
|
91 |
-
public function setDefaultValue($value)
|
92 |
-
{
|
93 |
-
if (!is_array($value)) {
|
94 |
-
throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.');
|
95 |
-
}
|
96 |
-
|
97 |
-
$this->defaultValue = $value;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Checks if the node has a default value.
|
102 |
-
*
|
103 |
-
* @return bool
|
104 |
-
*/
|
105 |
-
public function hasDefaultValue()
|
106 |
-
{
|
107 |
-
return true;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Adds default children when none are set.
|
112 |
-
*
|
113 |
-
* @param int|string|array|null $children The number of children|The child name|The children names to be added
|
114 |
-
*/
|
115 |
-
public function setAddChildrenIfNoneSet($children = array('defaults'))
|
116 |
-
{
|
117 |
-
if (null === $children) {
|
118 |
-
$this->defaultChildren = array('defaults');
|
119 |
-
} else {
|
120 |
-
$this->defaultChildren = is_integer($children) && $children > 0 ? range(1, $children) : (array) $children;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Retrieves the default value.
|
126 |
-
*
|
127 |
-
* The default value could be either explicited or derived from the prototype
|
128 |
-
* default value.
|
129 |
-
*
|
130 |
-
* @return array The default value
|
131 |
-
*/
|
132 |
-
public function getDefaultValue()
|
133 |
-
{
|
134 |
-
if (null !== $this->defaultChildren) {
|
135 |
-
$default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : array();
|
136 |
-
$defaults = array();
|
137 |
-
foreach (array_values($this->defaultChildren) as $i => $name) {
|
138 |
-
$defaults[null === $this->keyAttribute ? $i : $name] = $default;
|
139 |
-
}
|
140 |
-
|
141 |
-
return $defaults;
|
142 |
-
}
|
143 |
-
|
144 |
-
return $this->defaultValue;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Sets the node prototype.
|
149 |
-
*
|
150 |
-
* @param PrototypeNodeInterface $node
|
151 |
-
*/
|
152 |
-
public function setPrototype(PrototypeNodeInterface $node)
|
153 |
-
{
|
154 |
-
$this->prototype = $node;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Retrieves the prototype.
|
159 |
-
*
|
160 |
-
* @return PrototypeNodeInterface The prototype
|
161 |
-
*/
|
162 |
-
public function getPrototype()
|
163 |
-
{
|
164 |
-
return $this->prototype;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Disable adding concrete children for prototyped nodes.
|
169 |
-
*
|
170 |
-
* @param NodeInterface $node The child node to add
|
171 |
-
*
|
172 |
-
* @throws Exception
|
173 |
-
*/
|
174 |
-
public function addChild(NodeInterface $node)
|
175 |
-
{
|
176 |
-
throw new Exception('A prototyped array node can not have concrete children.');
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Finalizes the value of this node.
|
181 |
-
*
|
182 |
-
* @param mixed $value
|
183 |
-
*
|
184 |
-
* @return mixed The finalized value
|
185 |
-
*
|
186 |
-
* @throws UnsetKeyException
|
187 |
-
* @throws InvalidConfigurationException if the node doesn't have enough children
|
188 |
-
*/
|
189 |
-
protected function finalizeValue($value)
|
190 |
-
{
|
191 |
-
if (false === $value) {
|
192 |
-
$msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value));
|
193 |
-
throw new UnsetKeyException($msg);
|
194 |
-
}
|
195 |
-
|
196 |
-
foreach ($value as $k => $v) {
|
197 |
-
$this->prototype->setName($k);
|
198 |
-
try {
|
199 |
-
$value[$k] = $this->prototype->finalize($v);
|
200 |
-
} catch (UnsetKeyException $unset) {
|
201 |
-
unset($value[$k]);
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
if (count($value) < $this->minNumberOfElements) {
|
206 |
-
$msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements);
|
207 |
-
$ex = new InvalidConfigurationException($msg);
|
208 |
-
$ex->setPath($this->getPath());
|
209 |
-
|
210 |
-
throw $ex;
|
211 |
-
}
|
212 |
-
|
213 |
-
return $value;
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Normalizes the value.
|
218 |
-
*
|
219 |
-
* @param mixed $value The value to normalize
|
220 |
-
*
|
221 |
-
* @return mixed The normalized value
|
222 |
-
*
|
223 |
-
* @throws InvalidConfigurationException
|
224 |
-
* @throws DuplicateKeyException
|
225 |
-
*/
|
226 |
-
protected function normalizeValue($value)
|
227 |
-
{
|
228 |
-
if (false === $value) {
|
229 |
-
return $value;
|
230 |
-
}
|
231 |
-
|
232 |
-
$value = $this->remapXml($value);
|
233 |
-
|
234 |
-
$isAssoc = array_keys($value) !== range(0, count($value) -1);
|
235 |
-
$normalized = array();
|
236 |
-
foreach ($value as $k => $v) {
|
237 |
-
if (null !== $this->keyAttribute && is_array($v)) {
|
238 |
-
if (!isset($v[$this->keyAttribute]) && is_int($k) && !$isAssoc) {
|
239 |
-
$msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath());
|
240 |
-
$ex = new InvalidConfigurationException($msg);
|
241 |
-
$ex->setPath($this->getPath());
|
242 |
-
|
243 |
-
throw $ex;
|
244 |
-
} elseif (isset($v[$this->keyAttribute])) {
|
245 |
-
$k = $v[$this->keyAttribute];
|
246 |
-
|
247 |
-
// remove the key attribute when required
|
248 |
-
if ($this->removeKeyAttribute) {
|
249 |
-
unset($v[$this->keyAttribute]);
|
250 |
-
}
|
251 |
-
|
252 |
-
// if only "value" is left
|
253 |
-
if (1 == count($v) && isset($v['value'])) {
|
254 |
-
$v = $v['value'];
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
if (array_key_exists($k, $normalized)) {
|
259 |
-
$msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath());
|
260 |
-
$ex = new DuplicateKeyException($msg);
|
261 |
-
$ex->setPath($this->getPath());
|
262 |
-
|
263 |
-
throw $ex;
|
264 |
-
}
|
265 |
-
}
|
266 |
-
|
267 |
-
$this->prototype->setName($k);
|
268 |
-
if (null !== $this->keyAttribute || $isAssoc) {
|
269 |
-
$normalized[$k] = $this->prototype->normalize($v);
|
270 |
-
} else {
|
271 |
-
$normalized[] = $this->prototype->normalize($v);
|
272 |
-
}
|
273 |
-
}
|
274 |
-
|
275 |
-
return $normalized;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Merges values together.
|
280 |
-
*
|
281 |
-
* @param mixed $leftSide The left side to merge.
|
282 |
-
* @param mixed $rightSide The right side to merge.
|
283 |
-
*
|
284 |
-
* @return mixed The merged values
|
285 |
-
*
|
286 |
-
* @throws InvalidConfigurationException
|
287 |
-
* @throws \RuntimeException
|
288 |
-
*/
|
289 |
-
protected function mergeValues($leftSide, $rightSide)
|
290 |
-
{
|
291 |
-
if (false === $rightSide) {
|
292 |
-
// if this is still false after the last config has been merged the
|
293 |
-
// finalization pass will take care of removing this key entirely
|
294 |
-
return false;
|
295 |
-
}
|
296 |
-
|
297 |
-
if (false === $leftSide || !$this->performDeepMerging) {
|
298 |
-
return $rightSide;
|
299 |
-
}
|
300 |
-
|
301 |
-
foreach ($rightSide as $k => $v) {
|
302 |
-
// prototype, and key is irrelevant, so simply append the element
|
303 |
-
if (null === $this->keyAttribute) {
|
304 |
-
$leftSide[] = $v;
|
305 |
-
continue;
|
306 |
-
}
|
307 |
-
|
308 |
-
// no conflict
|
309 |
-
if (!array_key_exists($k, $leftSide)) {
|
310 |
-
if (!$this->allowNewKeys) {
|
311 |
-
$ex = new InvalidConfigurationException(sprintf(
|
312 |
-
'You are not allowed to define new elements for path "%s". '.
|
313 |
-
'Please define all elements for this path in one config file.',
|
314 |
-
$this->getPath()
|
315 |
-
));
|
316 |
-
$ex->setPath($this->getPath());
|
317 |
-
|
318 |
-
throw $ex;
|
319 |
-
}
|
320 |
-
|
321 |
-
$leftSide[$k] = $v;
|
322 |
-
continue;
|
323 |
-
}
|
324 |
-
|
325 |
-
$this->prototype->setName($k);
|
326 |
-
$leftSide[$k] = $this->prototype->merge($leftSide[$k], $v);
|
327 |
-
}
|
328 |
-
|
329 |
-
return $leftSide;
|
330 |
-
}
|
331 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/ReferenceDumper.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper instead.
|
18 |
-
*/
|
19 |
-
class ReferenceDumper extends YamlReferenceDumper
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/ScalarNode.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents a scalar value in the config tree.
|
18 |
-
*
|
19 |
-
* The following values are considered scalars:
|
20 |
-
* * booleans
|
21 |
-
* * strings
|
22 |
-
* * null
|
23 |
-
* * integers
|
24 |
-
* * floats
|
25 |
-
*
|
26 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
27 |
-
*/
|
28 |
-
class ScalarNode extends VariableNode
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* {@inheritdoc}
|
32 |
-
*/
|
33 |
-
protected function validateType($value)
|
34 |
-
{
|
35 |
-
if (!is_scalar($value) && null !== $value) {
|
36 |
-
$ex = new InvalidTypeException(sprintf(
|
37 |
-
'Invalid type for path "%s". Expected scalar, but got %s.',
|
38 |
-
$this->getPath(),
|
39 |
-
gettype($value)
|
40 |
-
));
|
41 |
-
$ex->setPath($this->getPath());
|
42 |
-
|
43 |
-
throw $ex;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Definition/VariableNode.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Definition;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This node represents a value of variable type in the config tree.
|
18 |
-
*
|
19 |
-
* This node is intended for values of arbitrary type.
|
20 |
-
* Any PHP type is accepted as a value.
|
21 |
-
*
|
22 |
-
* @author Jeremy Mikola <jmikola@gmail.com>
|
23 |
-
*/
|
24 |
-
class VariableNode extends BaseNode implements PrototypeNodeInterface
|
25 |
-
{
|
26 |
-
protected $defaultValueSet = false;
|
27 |
-
protected $defaultValue;
|
28 |
-
protected $allowEmptyValue = true;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* {@inheritdoc}
|
32 |
-
*/
|
33 |
-
public function setDefaultValue($value)
|
34 |
-
{
|
35 |
-
$this->defaultValueSet = true;
|
36 |
-
$this->defaultValue = $value;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* {@inheritdoc}
|
41 |
-
*/
|
42 |
-
public function hasDefaultValue()
|
43 |
-
{
|
44 |
-
return $this->defaultValueSet;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* {@inheritdoc}
|
49 |
-
*/
|
50 |
-
public function getDefaultValue()
|
51 |
-
{
|
52 |
-
$v = $this->defaultValue;
|
53 |
-
|
54 |
-
return $v instanceof \Closure ? $v() : $v;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Sets if this node is allowed to have an empty value.
|
59 |
-
*
|
60 |
-
* @param bool $boolean True if this entity will accept empty values.
|
61 |
-
*/
|
62 |
-
public function setAllowEmptyValue($boolean)
|
63 |
-
{
|
64 |
-
$this->allowEmptyValue = (bool) $boolean;
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* {@inheritdoc}
|
69 |
-
*/
|
70 |
-
public function setName($name)
|
71 |
-
{
|
72 |
-
$this->name = $name;
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
-
protected function validateType($value)
|
79 |
-
{
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* {@inheritdoc}
|
84 |
-
*/
|
85 |
-
protected function finalizeValue($value)
|
86 |
-
{
|
87 |
-
if (!$this->allowEmptyValue && empty($value)) {
|
88 |
-
$ex = new InvalidConfigurationException(sprintf(
|
89 |
-
'The path "%s" cannot contain an empty value, but got %s.',
|
90 |
-
$this->getPath(),
|
91 |
-
json_encode($value)
|
92 |
-
));
|
93 |
-
$ex->setPath($this->getPath());
|
94 |
-
|
95 |
-
throw $ex;
|
96 |
-
}
|
97 |
-
|
98 |
-
return $value;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* {@inheritdoc}
|
103 |
-
*/
|
104 |
-
protected function normalizeValue($value)
|
105 |
-
{
|
106 |
-
return $value;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* {@inheritdoc}
|
111 |
-
*/
|
112 |
-
protected function mergeValues($leftSide, $rightSide)
|
113 |
-
{
|
114 |
-
return $rightSide;
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception class for when a circular reference is detected when importing resources.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
class FileLoaderImportCircularReferenceException extends FileLoaderLoadException
|
20 |
-
{
|
21 |
-
public function __construct(array $resources, $code = null, $previous = null)
|
22 |
-
{
|
23 |
-
$message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);
|
24 |
-
|
25 |
-
\Exception::__construct($message, $code, $previous);
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Exception/FileLoaderLoadException.php
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception class for when a resource cannot be loaded or imported.
|
16 |
-
*
|
17 |
-
* @author Ryan Weaver <ryan@thatsquality.com>
|
18 |
-
*/
|
19 |
-
class FileLoaderLoadException extends \Exception
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @param string $resource The resource that could not be imported
|
23 |
-
* @param string $sourceResource The original resource importing the new resource
|
24 |
-
* @param int $code The error code
|
25 |
-
* @param \Exception $previous A previous exception
|
26 |
-
*/
|
27 |
-
public function __construct($resource, $sourceResource = null, $code = null, $previous = null)
|
28 |
-
{
|
29 |
-
if (null === $sourceResource) {
|
30 |
-
$message = sprintf('Cannot load resource "%s".', $this->varToString($resource));
|
31 |
-
} else {
|
32 |
-
$message = sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource));
|
33 |
-
}
|
34 |
-
|
35 |
-
// Is the resource located inside a bundle?
|
36 |
-
if ('@' === $resource[0]) {
|
37 |
-
$parts = explode(DIRECTORY_SEPARATOR, $resource);
|
38 |
-
$bundle = substr($parts[0], 1);
|
39 |
-
$message .= ' '.sprintf('Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle);
|
40 |
-
} elseif ($previous) {
|
41 |
-
// include the previous exception, to help the user see what might be the underlying cause
|
42 |
-
$message .= ' '.sprintf('(%s)', $previous->getMessage());
|
43 |
-
}
|
44 |
-
|
45 |
-
parent::__construct($message, $code, $previous);
|
46 |
-
}
|
47 |
-
|
48 |
-
protected function varToString($var)
|
49 |
-
{
|
50 |
-
if (is_object($var)) {
|
51 |
-
return sprintf('Object(%s)', get_class($var));
|
52 |
-
}
|
53 |
-
|
54 |
-
if (is_array($var)) {
|
55 |
-
$a = array();
|
56 |
-
foreach ($var as $k => $v) {
|
57 |
-
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
|
58 |
-
}
|
59 |
-
|
60 |
-
return sprintf("Array(%s)", implode(', ', $a));
|
61 |
-
}
|
62 |
-
|
63 |
-
if (is_resource($var)) {
|
64 |
-
return sprintf('Resource(%s)', get_resource_type($var));
|
65 |
-
}
|
66 |
-
|
67 |
-
if (null === $var) {
|
68 |
-
return 'null';
|
69 |
-
}
|
70 |
-
|
71 |
-
if (false === $var) {
|
72 |
-
return 'false';
|
73 |
-
}
|
74 |
-
|
75 |
-
if (true === $var) {
|
76 |
-
return 'true';
|
77 |
-
}
|
78 |
-
|
79 |
-
return (string) $var;
|
80 |
-
}
|
81 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/FileLocator.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* FileLocator uses an array of pre-defined paths to find files.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
class FileLocator implements FileLocatorInterface
|
20 |
-
{
|
21 |
-
protected $paths;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Constructor.
|
25 |
-
*
|
26 |
-
* @param string|array $paths A path or an array of paths where to look for resources
|
27 |
-
*/
|
28 |
-
public function __construct($paths = array())
|
29 |
-
{
|
30 |
-
$this->paths = (array) $paths;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* {@inheritdoc}
|
35 |
-
*/
|
36 |
-
public function locate($name, $currentPath = null, $first = true)
|
37 |
-
{
|
38 |
-
if ('' == $name) {
|
39 |
-
throw new \InvalidArgumentException('An empty file name is not valid to be located.');
|
40 |
-
}
|
41 |
-
|
42 |
-
if ($this->isAbsolutePath($name)) {
|
43 |
-
if (!file_exists($name)) {
|
44 |
-
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
|
45 |
-
}
|
46 |
-
|
47 |
-
return $name;
|
48 |
-
}
|
49 |
-
|
50 |
-
$filepaths = array();
|
51 |
-
if (null !== $currentPath && file_exists($file = $currentPath.DIRECTORY_SEPARATOR.$name)) {
|
52 |
-
if (true === $first) {
|
53 |
-
return $file;
|
54 |
-
}
|
55 |
-
$filepaths[] = $file;
|
56 |
-
}
|
57 |
-
|
58 |
-
foreach ($this->paths as $path) {
|
59 |
-
if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
|
60 |
-
if (true === $first) {
|
61 |
-
return $file;
|
62 |
-
}
|
63 |
-
$filepaths[] = $file;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
if (!$filepaths) {
|
68 |
-
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s%s).', $name, null !== $currentPath ? $currentPath.', ' : '', implode(', ', $this->paths)));
|
69 |
-
}
|
70 |
-
|
71 |
-
return array_values(array_unique($filepaths));
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Returns whether the file path is an absolute path.
|
76 |
-
*
|
77 |
-
* @param string $file A file path
|
78 |
-
*
|
79 |
-
* @return bool
|
80 |
-
*/
|
81 |
-
private function isAbsolutePath($file)
|
82 |
-
{
|
83 |
-
if ($file[0] === '/' || $file[0] === '\\'
|
84 |
-
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
85 |
-
&& $file[1] === ':'
|
86 |
-
&& ($file[2] === '\\' || $file[2] === '/')
|
87 |
-
)
|
88 |
-
|| null !== parse_url($file, PHP_URL_SCHEME)
|
89 |
-
) {
|
90 |
-
return true;
|
91 |
-
}
|
92 |
-
|
93 |
-
return false;
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/FileLocatorInterface.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
-
*/
|
17 |
-
interface FileLocatorInterface
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Returns a full path for a given file name.
|
21 |
-
*
|
22 |
-
* @param string $name The file name to locate
|
23 |
-
* @param string|null $currentPath The current path
|
24 |
-
* @param bool $first Whether to return the first occurrence or an array of filenames
|
25 |
-
*
|
26 |
-
* @return string|array The full path to the file or an array of file paths
|
27 |
-
*
|
28 |
-
* @throws \InvalidArgumentException When file is not found
|
29 |
-
*/
|
30 |
-
public function locate($name, $currentPath = null, $first = true);
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/DelegatingLoader.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* DelegatingLoader delegates loading to other loaders using a loader resolver.
|
18 |
-
*
|
19 |
-
* This loader acts as an array of LoaderInterface objects - each having
|
20 |
-
* a chance to load a given resource (handled by the resolver)
|
21 |
-
*
|
22 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
-
*/
|
24 |
-
class DelegatingLoader extends Loader
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Constructor.
|
28 |
-
*
|
29 |
-
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
30 |
-
*/
|
31 |
-
public function __construct(LoaderResolverInterface $resolver)
|
32 |
-
{
|
33 |
-
$this->resolver = $resolver;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* {@inheritdoc}
|
38 |
-
*/
|
39 |
-
public function load($resource, $type = null)
|
40 |
-
{
|
41 |
-
if (false === $loader = $this->resolver->resolve($resource, $type)) {
|
42 |
-
throw new FileLoaderLoadException($resource);
|
43 |
-
}
|
44 |
-
|
45 |
-
return $loader->load($resource, $type);
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* {@inheritdoc}
|
50 |
-
*/
|
51 |
-
public function supports($resource, $type = null)
|
52 |
-
{
|
53 |
-
return false !== $this->resolver->resolve($resource, $type);
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/FileLoader.php
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\FileLocatorInterface;
|
15 |
-
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
16 |
-
use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* FileLoader is the abstract class used by all built-in loaders that are file based.
|
20 |
-
*
|
21 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
-
*/
|
23 |
-
abstract class FileLoader extends Loader
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
protected static $loading = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var FileLocatorInterface
|
32 |
-
*/
|
33 |
-
protected $locator;
|
34 |
-
|
35 |
-
private $currentDir;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Constructor.
|
39 |
-
*
|
40 |
-
* @param FileLocatorInterface $locator A FileLocatorInterface instance
|
41 |
-
*/
|
42 |
-
public function __construct(FileLocatorInterface $locator)
|
43 |
-
{
|
44 |
-
$this->locator = $locator;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Sets the current directory.
|
49 |
-
*
|
50 |
-
* @param string $dir
|
51 |
-
*/
|
52 |
-
public function setCurrentDir($dir)
|
53 |
-
{
|
54 |
-
$this->currentDir = $dir;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Returns the file locator used by this loader.
|
59 |
-
*
|
60 |
-
* @return FileLocatorInterface
|
61 |
-
*/
|
62 |
-
public function getLocator()
|
63 |
-
{
|
64 |
-
return $this->locator;
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Imports a resource.
|
69 |
-
*
|
70 |
-
* @param mixed $resource A Resource
|
71 |
-
* @param string|null $type The resource type or null if unknown
|
72 |
-
* @param bool $ignoreErrors Whether to ignore import errors or not
|
73 |
-
* @param string|null $sourceResource The original resource importing the new resource
|
74 |
-
*
|
75 |
-
* @return mixed
|
76 |
-
*
|
77 |
-
* @throws FileLoaderLoadException
|
78 |
-
* @throws FileLoaderImportCircularReferenceException
|
79 |
-
*/
|
80 |
-
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
|
81 |
-
{
|
82 |
-
try {
|
83 |
-
$loader = $this->resolve($resource, $type);
|
84 |
-
|
85 |
-
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
86 |
-
// we fallback to the current locator to keep BC
|
87 |
-
// as some some loaders do not call the parent __construct()
|
88 |
-
// @deprecated should be removed in 3.0
|
89 |
-
$locator = $loader->getLocator() ?: $this->locator;
|
90 |
-
$resource = $locator->locate($resource, $this->currentDir, false);
|
91 |
-
}
|
92 |
-
|
93 |
-
$resources = is_array($resource) ? $resource : array($resource);
|
94 |
-
for ($i = 0; $i < $resourcesCount = count($resources); $i++) {
|
95 |
-
if (isset(self::$loading[$resources[$i]])) {
|
96 |
-
if ($i == $resourcesCount-1) {
|
97 |
-
throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading));
|
98 |
-
}
|
99 |
-
} else {
|
100 |
-
$resource = $resources[$i];
|
101 |
-
break;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
self::$loading[$resource] = true;
|
105 |
-
|
106 |
-
$ret = $loader->load($resource, $type);
|
107 |
-
|
108 |
-
unset(self::$loading[$resource]);
|
109 |
-
|
110 |
-
return $ret;
|
111 |
-
} catch (FileLoaderImportCircularReferenceException $e) {
|
112 |
-
throw $e;
|
113 |
-
} catch (\Exception $e) {
|
114 |
-
if (!$ignoreErrors) {
|
115 |
-
// prevent embedded imports from nesting multiple exceptions
|
116 |
-
if ($e instanceof FileLoaderLoadException) {
|
117 |
-
throw $e;
|
118 |
-
}
|
119 |
-
|
120 |
-
throw new FileLoaderLoadException($resource, $sourceResource, null, $e);
|
121 |
-
}
|
122 |
-
}
|
123 |
-
}
|
124 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/Loader.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Loader is the abstract class used by all built-in loaders.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*/
|
21 |
-
abstract class Loader implements LoaderInterface
|
22 |
-
{
|
23 |
-
protected $resolver;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* {@inheritdoc}
|
27 |
-
*/
|
28 |
-
public function getResolver()
|
29 |
-
{
|
30 |
-
return $this->resolver;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* {@inheritdoc}
|
35 |
-
*/
|
36 |
-
public function setResolver(LoaderResolverInterface $resolver)
|
37 |
-
{
|
38 |
-
$this->resolver = $resolver;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Imports a resource.
|
43 |
-
*
|
44 |
-
* @param mixed $resource A resource
|
45 |
-
* @param string|null $type The resource type or null if unknown
|
46 |
-
*
|
47 |
-
* @return mixed
|
48 |
-
*/
|
49 |
-
public function import($resource, $type = null)
|
50 |
-
{
|
51 |
-
return $this->resolve($resource, $type)->load($resource, $type);
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Finds a loader able to load an imported resource.
|
56 |
-
*
|
57 |
-
* @param mixed $resource A resource
|
58 |
-
* @param string|null $type The resource type or null if unknown
|
59 |
-
*
|
60 |
-
* @return LoaderInterface A LoaderInterface instance
|
61 |
-
*
|
62 |
-
* @throws FileLoaderLoadException If no loader is found
|
63 |
-
*/
|
64 |
-
public function resolve($resource, $type = null)
|
65 |
-
{
|
66 |
-
if ($this->supports($resource, $type)) {
|
67 |
-
return $this;
|
68 |
-
}
|
69 |
-
|
70 |
-
$loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
|
71 |
-
|
72 |
-
if (false === $loader) {
|
73 |
-
throw new FileLoaderLoadException($resource);
|
74 |
-
}
|
75 |
-
|
76 |
-
return $loader;
|
77 |
-
}
|
78 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/LoaderInterface.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* LoaderInterface is the interface implemented by all loader classes.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
interface LoaderInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Loads a resource.
|
23 |
-
*
|
24 |
-
* @param mixed $resource The resource
|
25 |
-
* @param string|null $type The resource type or null if unknown
|
26 |
-
*
|
27 |
-
* @throws \Exception If something went wrong
|
28 |
-
*/
|
29 |
-
public function load($resource, $type = null);
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns whether this class supports the given resource.
|
33 |
-
*
|
34 |
-
* @param mixed $resource A resource
|
35 |
-
* @param string|null $type The resource type or null if unknown
|
36 |
-
*
|
37 |
-
* @return bool True if this class supports the given resource, false otherwise
|
38 |
-
*/
|
39 |
-
public function supports($resource, $type = null);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Gets the loader resolver.
|
43 |
-
*
|
44 |
-
* @return LoaderResolverInterface A LoaderResolverInterface instance
|
45 |
-
*/
|
46 |
-
public function getResolver();
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Sets the loader resolver.
|
50 |
-
*
|
51 |
-
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
52 |
-
*/
|
53 |
-
public function setResolver(LoaderResolverInterface $resolver);
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/LoaderResolver.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* LoaderResolver selects a loader for a given resource.
|
16 |
-
*
|
17 |
-
* A resource can be anything (e.g. a full path to a config file or a Closure).
|
18 |
-
* Each loader determines whether it can load a resource and how.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*/
|
22 |
-
class LoaderResolver implements LoaderResolverInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @var LoaderInterface[] An array of LoaderInterface objects
|
26 |
-
*/
|
27 |
-
private $loaders = array();
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Constructor.
|
31 |
-
*
|
32 |
-
* @param LoaderInterface[] $loaders An array of loaders
|
33 |
-
*/
|
34 |
-
public function __construct(array $loaders = array())
|
35 |
-
{
|
36 |
-
foreach ($loaders as $loader) {
|
37 |
-
$this->addLoader($loader);
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* {@inheritdoc}
|
43 |
-
*/
|
44 |
-
public function resolve($resource, $type = null)
|
45 |
-
{
|
46 |
-
foreach ($this->loaders as $loader) {
|
47 |
-
if ($loader->supports($resource, $type)) {
|
48 |
-
return $loader;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
return false;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Adds a loader.
|
57 |
-
*
|
58 |
-
* @param LoaderInterface $loader A LoaderInterface instance
|
59 |
-
*/
|
60 |
-
public function addLoader(LoaderInterface $loader)
|
61 |
-
{
|
62 |
-
$this->loaders[] = $loader;
|
63 |
-
$loader->setResolver($this);
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Returns the registered loaders.
|
68 |
-
*
|
69 |
-
* @return LoaderInterface[] An array of LoaderInterface instances
|
70 |
-
*/
|
71 |
-
public function getLoaders()
|
72 |
-
{
|
73 |
-
return $this->loaders;
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Loader/LoaderResolverInterface.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Loader;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* LoaderResolverInterface selects a loader for a given resource.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
interface LoaderResolverInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Returns a loader able to load the resource.
|
23 |
-
*
|
24 |
-
* @param mixed $resource A resource
|
25 |
-
* @param string|null $type The resource type or null if unknown
|
26 |
-
*
|
27 |
-
* @return LoaderInterface|false The loader or false if none is able to load the resource
|
28 |
-
*/
|
29 |
-
public function resolve($resource, $type = null);
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/README.md
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
Config Component
|
2 |
-
================
|
3 |
-
|
4 |
-
Config provides the infrastructure for loading configurations from different
|
5 |
-
data sources and optionally monitoring these data sources for changes. There
|
6 |
-
are additional tools for validating, normalizing and handling of defaults that
|
7 |
-
can optionally be used to convert from different formats to arrays.
|
8 |
-
|
9 |
-
Resources
|
10 |
-
---------
|
11 |
-
|
12 |
-
You can run the unit tests with the following command:
|
13 |
-
|
14 |
-
$ cd path/to/Symfony/Component/Config/
|
15 |
-
$ composer.phar install
|
16 |
-
$ phpunit
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Resource/DirectoryResource.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Resource;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* DirectoryResource represents a resources stored in a subdirectory tree.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
class DirectoryResource implements ResourceInterface, \Serializable
|
20 |
-
{
|
21 |
-
private $resource;
|
22 |
-
private $pattern;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor.
|
26 |
-
*
|
27 |
-
* @param string $resource The file path to the resource
|
28 |
-
* @param string|null $pattern A pattern to restrict monitored files
|
29 |
-
*/
|
30 |
-
public function __construct($resource, $pattern = null)
|
31 |
-
{
|
32 |
-
$this->resource = $resource;
|
33 |
-
$this->pattern = $pattern;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* {@inheritdoc}
|
38 |
-
*/
|
39 |
-
public function __toString()
|
40 |
-
{
|
41 |
-
return (string) $this->resource;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* {@inheritdoc}
|
46 |
-
*/
|
47 |
-
public function getResource()
|
48 |
-
{
|
49 |
-
return $this->resource;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Returns the pattern to restrict monitored files.
|
54 |
-
*
|
55 |
-
* @return string|null
|
56 |
-
*/
|
57 |
-
public function getPattern()
|
58 |
-
{
|
59 |
-
return $this->pattern;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* {@inheritdoc}
|
64 |
-
*/
|
65 |
-
public function isFresh($timestamp)
|
66 |
-
{
|
67 |
-
if (!is_dir($this->resource)) {
|
68 |
-
return false;
|
69 |
-
}
|
70 |
-
|
71 |
-
$newestMTime = filemtime($this->resource);
|
72 |
-
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
|
73 |
-
// if regex filtering is enabled only check matching files
|
74 |
-
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
|
75 |
-
continue;
|
76 |
-
}
|
77 |
-
|
78 |
-
// always monitor directories for changes, except the .. entries
|
79 |
-
// (otherwise deleted files wouldn't get detected)
|
80 |
-
if ($file->isDir() && '/..' === substr($file, -3)) {
|
81 |
-
continue;
|
82 |
-
}
|
83 |
-
|
84 |
-
$newestMTime = max($file->getMTime(), $newestMTime);
|
85 |
-
}
|
86 |
-
|
87 |
-
return $newestMTime < $timestamp;
|
88 |
-
}
|
89 |
-
|
90 |
-
public function serialize()
|
91 |
-
{
|
92 |
-
return serialize(array($this->resource, $this->pattern));
|
93 |
-
}
|
94 |
-
|
95 |
-
public function unserialize($serialized)
|
96 |
-
{
|
97 |
-
list($this->resource, $this->pattern) = unserialize($serialized);
|
98 |
-
}
|
99 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Resource/FileResource.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Resource;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* FileResource represents a resource stored on the filesystem.
|
16 |
-
*
|
17 |
-
* The resource can be a file or a directory.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*/
|
21 |
-
class FileResource implements ResourceInterface, \Serializable
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* @var string|false
|
25 |
-
*/
|
26 |
-
private $resource;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Constructor.
|
30 |
-
*
|
31 |
-
* @param string $resource The file path to the resource
|
32 |
-
*/
|
33 |
-
public function __construct($resource)
|
34 |
-
{
|
35 |
-
$this->resource = realpath($resource);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
-
public function __toString()
|
42 |
-
{
|
43 |
-
return (string) $this->resource;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function getResource()
|
50 |
-
{
|
51 |
-
return $this->resource;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* {@inheritdoc}
|
56 |
-
*/
|
57 |
-
public function isFresh($timestamp)
|
58 |
-
{
|
59 |
-
if (false === $this->resource || !file_exists($this->resource)) {
|
60 |
-
return false;
|
61 |
-
}
|
62 |
-
|
63 |
-
return filemtime($this->resource) < $timestamp;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function serialize()
|
67 |
-
{
|
68 |
-
return serialize($this->resource);
|
69 |
-
}
|
70 |
-
|
71 |
-
public function unserialize($serialized)
|
72 |
-
{
|
73 |
-
$this->resource = unserialize($serialized);
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Resource/ResourceInterface.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Resource;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* ResourceInterface is the interface that must be implemented by all Resource classes.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
interface ResourceInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Returns a string representation of the Resource.
|
23 |
-
*
|
24 |
-
* @return string A string representation of the Resource
|
25 |
-
*/
|
26 |
-
public function __toString();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Returns true if the resource has not been updated since the given timestamp.
|
30 |
-
*
|
31 |
-
* @param int $timestamp The last time the resource was loaded
|
32 |
-
*
|
33 |
-
* @return bool True if the resource has not been updated, false otherwise
|
34 |
-
*/
|
35 |
-
public function isFresh($timestamp);
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Returns the tied resource.
|
39 |
-
*
|
40 |
-
* @return mixed The resource
|
41 |
-
*/
|
42 |
-
public function getResource();
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/Util/XmlUtils.php
DELETED
@@ -1,236 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Config\Util;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* XMLUtils is a bunch of utility methods to XML operations.
|
16 |
-
*
|
17 |
-
* This class contains static methods only and is not meant to be instantiated.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
* @author Martin Hasoň <martin.hason@gmail.com>
|
21 |
-
*/
|
22 |
-
class XmlUtils
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* This class should not be instantiated.
|
26 |
-
*/
|
27 |
-
private function __construct()
|
28 |
-
{
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Loads an XML file.
|
33 |
-
*
|
34 |
-
* @param string $file An XML file path
|
35 |
-
* @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation
|
36 |
-
*
|
37 |
-
* @return \DOMDocument
|
38 |
-
*
|
39 |
-
* @throws \InvalidArgumentException When loading of XML file returns error
|
40 |
-
*/
|
41 |
-
public static function loadFile($file, $schemaOrCallable = null)
|
42 |
-
{
|
43 |
-
$content = @file_get_contents($file);
|
44 |
-
if ('' === trim($content)) {
|
45 |
-
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
|
46 |
-
}
|
47 |
-
|
48 |
-
$internalErrors = libxml_use_internal_errors(true);
|
49 |
-
$disableEntities = libxml_disable_entity_loader(true);
|
50 |
-
libxml_clear_errors();
|
51 |
-
|
52 |
-
$dom = new \DOMDocument();
|
53 |
-
$dom->validateOnParse = true;
|
54 |
-
if (!$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
|
55 |
-
libxml_disable_entity_loader($disableEntities);
|
56 |
-
|
57 |
-
throw new \InvalidArgumentException(implode("\n", static::getXmlErrors($internalErrors)));
|
58 |
-
}
|
59 |
-
|
60 |
-
$dom->normalizeDocument();
|
61 |
-
|
62 |
-
libxml_use_internal_errors($internalErrors);
|
63 |
-
libxml_disable_entity_loader($disableEntities);
|
64 |
-
|
65 |
-
foreach ($dom->childNodes as $child) {
|
66 |
-
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
|
67 |
-
throw new \InvalidArgumentException('Document types are not allowed.');
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
if (null !== $schemaOrCallable) {
|
72 |
-
$internalErrors = libxml_use_internal_errors(true);
|
73 |
-
libxml_clear_errors();
|
74 |
-
|
75 |
-
$e = null;
|
76 |
-
if (is_callable($schemaOrCallable)) {
|
77 |
-
try {
|
78 |
-
$valid = call_user_func($schemaOrCallable, $dom, $internalErrors);
|
79 |
-
} catch (\Exception $e) {
|
80 |
-
$valid = false;
|
81 |
-
}
|
82 |
-
} elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
|
83 |
-
$schemaSource = file_get_contents((string) $schemaOrCallable);
|
84 |
-
$valid = @$dom->schemaValidateSource($schemaSource);
|
85 |
-
} else {
|
86 |
-
libxml_use_internal_errors($internalErrors);
|
87 |
-
|
88 |
-
throw new \InvalidArgumentException('The schemaOrCallable argument has to be a valid path to XSD file or callable.');
|
89 |
-
}
|
90 |
-
|
91 |
-
if (!$valid) {
|
92 |
-
$messages = static::getXmlErrors($internalErrors);
|
93 |
-
if (empty($messages)) {
|
94 |
-
$messages = array(sprintf('The XML file "%s" is not valid.', $file));
|
95 |
-
}
|
96 |
-
throw new \InvalidArgumentException(implode("\n", $messages), 0, $e);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
libxml_clear_errors();
|
101 |
-
libxml_use_internal_errors($internalErrors);
|
102 |
-
|
103 |
-
return $dom;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Converts a \DomElement object to a PHP array.
|
108 |
-
*
|
109 |
-
* The following rules applies during the conversion:
|
110 |
-
*
|
111 |
-
* * Each tag is converted to a key value or an array
|
112 |
-
* if there is more than one "value"
|
113 |
-
*
|
114 |
-
* * The content of a tag is set under a "value" key (<foo>bar</foo>)
|
115 |
-
* if the tag also has some nested tags
|
116 |
-
*
|
117 |
-
* * The attributes are converted to keys (<foo foo="bar"/>)
|
118 |
-
*
|
119 |
-
* * The nested-tags are converted to keys (<foo><foo>bar</foo></foo>)
|
120 |
-
*
|
121 |
-
* @param \DomElement $element A \DomElement instance
|
122 |
-
* @param bool $checkPrefix Check prefix in an element or an attribute name
|
123 |
-
*
|
124 |
-
* @return array A PHP array
|
125 |
-
*/
|
126 |
-
public static function convertDomElementToArray(\DomElement $element, $checkPrefix = true)
|
127 |
-
{
|
128 |
-
$prefix = (string) $element->prefix;
|
129 |
-
$empty = true;
|
130 |
-
$config = array();
|
131 |
-
foreach ($element->attributes as $name => $node) {
|
132 |
-
if ($checkPrefix && !in_array((string) $node->prefix, array('', $prefix), true)) {
|
133 |
-
continue;
|
134 |
-
}
|
135 |
-
$config[$name] = static::phpize($node->value);
|
136 |
-
$empty = false;
|
137 |
-
}
|
138 |
-
|
139 |
-
$nodeValue = false;
|
140 |
-
foreach ($element->childNodes as $node) {
|
141 |
-
if ($node instanceof \DOMText) {
|
142 |
-
if ('' !== trim($node->nodeValue)) {
|
143 |
-
$nodeValue = trim($node->nodeValue);
|
144 |
-
$empty = false;
|
145 |
-
}
|
146 |
-
} elseif ($checkPrefix && $prefix != (string) $node->prefix) {
|
147 |
-
continue;
|
148 |
-
} elseif (!$node instanceof \DOMComment) {
|
149 |
-
$value = static::convertDomElementToArray($node, $checkPrefix);
|
150 |
-
|
151 |
-
$key = $node->localName;
|
152 |
-
if (isset($config[$key])) {
|
153 |
-
if (!is_array($config[$key]) || !is_int(key($config[$key]))) {
|
154 |
-
$config[$key] = array($config[$key]);
|
155 |
-
}
|
156 |
-
$config[$key][] = $value;
|
157 |
-
} else {
|
158 |
-
$config[$key] = $value;
|
159 |
-
}
|
160 |
-
|
161 |
-
$empty = false;
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
if (false !== $nodeValue) {
|
166 |
-
$value = static::phpize($nodeValue);
|
167 |
-
if (count($config)) {
|
168 |
-
$config['value'] = $value;
|
169 |
-
} else {
|
170 |
-
$config = $value;
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
return !$empty ? $config : null;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Converts an xml value to a PHP type.
|
179 |
-
*
|
180 |
-
* @param mixed $value
|
181 |
-
*
|
182 |
-
* @return mixed
|
183 |
-
*/
|
184 |
-
public static function phpize($value)
|
185 |
-
{
|
186 |
-
$value = (string) $value;
|
187 |
-
$lowercaseValue = strtolower($value);
|
188 |
-
|
189 |
-
switch (true) {
|
190 |
-
case 'null' === $lowercaseValue:
|
191 |
-
return;
|
192 |
-
case ctype_digit($value):
|
193 |
-
$raw = $value;
|
194 |
-
$cast = intval($value);
|
195 |
-
|
196 |
-
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
197 |
-
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
|
198 |
-
$raw = $value;
|
199 |
-
$cast = intval($value);
|
200 |
-
|
201 |
-
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
202 |
-
case 'true' === $lowercaseValue:
|
203 |
-
return true;
|
204 |
-
case 'false' === $lowercaseValue:
|
205 |
-
return false;
|
206 |
-
case isset($value[1]) && '0b' == $value[0].$value[1]:
|
207 |
-
return bindec($value);
|
208 |
-
case is_numeric($value):
|
209 |
-
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
|
210 |
-
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
|
211 |
-
return floatval($value);
|
212 |
-
default:
|
213 |
-
return $value;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
protected static function getXmlErrors($internalErrors)
|
218 |
-
{
|
219 |
-
$errors = array();
|
220 |
-
foreach (libxml_get_errors() as $error) {
|
221 |
-
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
|
222 |
-
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
|
223 |
-
$error->code,
|
224 |
-
trim($error->message),
|
225 |
-
$error->file ? $error->file : 'n/a',
|
226 |
-
$error->line,
|
227 |
-
$error->column
|
228 |
-
);
|
229 |
-
}
|
230 |
-
|
231 |
-
libxml_clear_errors();
|
232 |
-
libxml_use_internal_errors($internalErrors);
|
233 |
-
|
234 |
-
return $errors;
|
235 |
-
}
|
236 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/composer.json
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "symfony/config",
|
3 |
-
"type": "library",
|
4 |
-
"description": "Symfony Config Component",
|
5 |
-
"keywords": [],
|
6 |
-
"homepage": "http://symfony.com",
|
7 |
-
"license": "MIT",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Fabien Potencier",
|
11 |
-
"email": "fabien@symfony.com"
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"name": "Symfony Community",
|
15 |
-
"homepage": "http://symfony.com/contributors"
|
16 |
-
}
|
17 |
-
],
|
18 |
-
"require": {
|
19 |
-
"php": ">=5.3.3",
|
20 |
-
"symfony/filesystem": "~2.3"
|
21 |
-
},
|
22 |
-
"autoload": {
|
23 |
-
"psr-0": { "Symfony\\Component\\Config\\": "" }
|
24 |
-
},
|
25 |
-
"target-dir": "Symfony/Component/Config",
|
26 |
-
"minimum-stability": "dev",
|
27 |
-
"extra": {
|
28 |
-
"branch-alias": {
|
29 |
-
"dev-master": "2.5-dev"
|
30 |
-
}
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Config/phpunit.xml.dist
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4 |
-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
5 |
-
backupGlobals="false"
|
6 |
-
colors="true"
|
7 |
-
bootstrap="vendor/autoload.php"
|
8 |
-
>
|
9 |
-
<php>
|
10 |
-
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
|
11 |
-
<ini name="error_reporting" value="-16385"/>
|
12 |
-
</php>
|
13 |
-
<testsuites>
|
14 |
-
<testsuite name="Symfony Config Component Test Suite">
|
15 |
-
<directory>./Tests/</directory>
|
16 |
-
</testsuite>
|
17 |
-
</testsuites>
|
18 |
-
|
19 |
-
<filter>
|
20 |
-
<whitelist>
|
21 |
-
<directory>./</directory>
|
22 |
-
<exclude>
|
23 |
-
<directory>./Resources</directory>
|
24 |
-
<directory>./Tests</directory>
|
25 |
-
<directory>./vendor</directory>
|
26 |
-
</exclude>
|
27 |
-
</whitelist>
|
28 |
-
</filter>
|
29 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Alias.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @api
|
16 |
-
*/
|
17 |
-
class Alias
|
18 |
-
{
|
19 |
-
private $id;
|
20 |
-
private $public;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Constructor.
|
24 |
-
*
|
25 |
-
* @param string $id Alias identifier
|
26 |
-
* @param bool $public If this alias is public
|
27 |
-
*
|
28 |
-
* @api
|
29 |
-
*/
|
30 |
-
public function __construct($id, $public = true)
|
31 |
-
{
|
32 |
-
$this->id = strtolower($id);
|
33 |
-
$this->public = $public;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Checks if this DI Alias should be public or not.
|
38 |
-
*
|
39 |
-
* @return bool
|
40 |
-
*
|
41 |
-
* @api
|
42 |
-
*/
|
43 |
-
public function isPublic()
|
44 |
-
{
|
45 |
-
return $this->public;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Sets if this Alias is public.
|
50 |
-
*
|
51 |
-
* @param bool $boolean If this Alias should be public
|
52 |
-
*
|
53 |
-
* @api
|
54 |
-
*/
|
55 |
-
public function setPublic($boolean)
|
56 |
-
{
|
57 |
-
$this->public = (bool) $boolean;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Returns the Id of this alias.
|
62 |
-
*
|
63 |
-
* @return string The alias id
|
64 |
-
*
|
65 |
-
* @api
|
66 |
-
*/
|
67 |
-
public function __toString()
|
68 |
-
{
|
69 |
-
return $this->id;
|
70 |
-
}
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/CHANGELOG.md
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
CHANGELOG
|
2 |
-
=========
|
3 |
-
|
4 |
-
2.5.0
|
5 |
-
-----
|
6 |
-
|
7 |
-
* added DecoratorServicePass and a way to override a service definition (Definition::setDecoratedService())
|
8 |
-
* deprecated SimpleXMLElement class.
|
9 |
-
|
10 |
-
2.4.0
|
11 |
-
-----
|
12 |
-
|
13 |
-
* added support for expressions in service definitions
|
14 |
-
* added ContainerAwareTrait to add default container aware behavior to a class
|
15 |
-
|
16 |
-
2.2.0
|
17 |
-
-----
|
18 |
-
|
19 |
-
* added Extension::isConfigEnabled() to ease working with enableable configurations
|
20 |
-
* added an Extension base class with sensible defaults to be used in conjunction
|
21 |
-
with the Config component.
|
22 |
-
* added PrependExtensionInterface (to be able to allow extensions to prepend
|
23 |
-
application configuration settings for any Bundle)
|
24 |
-
|
25 |
-
2.1.0
|
26 |
-
-----
|
27 |
-
|
28 |
-
* added IntrospectableContainerInterface (to be able to check if a service
|
29 |
-
has been initialized or not)
|
30 |
-
* added ConfigurationExtensionInterface
|
31 |
-
* added Definition::clearTag()
|
32 |
-
* component exceptions that inherit base SPL classes are now used exclusively
|
33 |
-
(this includes dumped containers)
|
34 |
-
* [BC BREAK] fixed unescaping of class arguments, method
|
35 |
-
ParameterBag::unescapeValue() was made public
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\Reference;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Run this pass before passes that need to know more about the relation of
|
20 |
-
* your services.
|
21 |
-
*
|
22 |
-
* This class will populate the ServiceReferenceGraph with information. You can
|
23 |
-
* retrieve the graph in other passes from the compiler.
|
24 |
-
*
|
25 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
26 |
-
*/
|
27 |
-
class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
28 |
-
{
|
29 |
-
private $graph;
|
30 |
-
private $container;
|
31 |
-
private $currentId;
|
32 |
-
private $currentDefinition;
|
33 |
-
private $repeatedPass;
|
34 |
-
private $onlyConstructorArguments;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Constructor.
|
38 |
-
*
|
39 |
-
* @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
40 |
-
*/
|
41 |
-
public function __construct($onlyConstructorArguments = false)
|
42 |
-
{
|
43 |
-
$this->onlyConstructorArguments = (bool) $onlyConstructorArguments;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function setRepeatedPass(RepeatedPass $repeatedPass)
|
50 |
-
{
|
51 |
-
$this->repeatedPass = $repeatedPass;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Processes a ContainerBuilder object to populate the service reference graph.
|
56 |
-
*
|
57 |
-
* @param ContainerBuilder $container
|
58 |
-
*/
|
59 |
-
public function process(ContainerBuilder $container)
|
60 |
-
{
|
61 |
-
$this->container = $container;
|
62 |
-
$this->graph = $container->getCompiler()->getServiceReferenceGraph();
|
63 |
-
$this->graph->clear();
|
64 |
-
|
65 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
66 |
-
if ($definition->isSynthetic() || $definition->isAbstract()) {
|
67 |
-
continue;
|
68 |
-
}
|
69 |
-
|
70 |
-
$this->currentId = $id;
|
71 |
-
$this->currentDefinition = $definition;
|
72 |
-
|
73 |
-
$this->processArguments($definition->getArguments());
|
74 |
-
if ($definition->getFactoryService()) {
|
75 |
-
$this->processArguments(array(new Reference($definition->getFactoryService())));
|
76 |
-
}
|
77 |
-
|
78 |
-
if (!$this->onlyConstructorArguments) {
|
79 |
-
$this->processArguments($definition->getMethodCalls());
|
80 |
-
$this->processArguments($definition->getProperties());
|
81 |
-
if ($definition->getConfigurator()) {
|
82 |
-
$this->processArguments(array($definition->getConfigurator()));
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
foreach ($container->getAliases() as $id => $alias) {
|
88 |
-
$this->graph->connect($id, $alias, (string) $alias, $this->getDefinition((string) $alias), null);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Processes service definitions for arguments to find relationships for the service graph.
|
94 |
-
*
|
95 |
-
* @param array $arguments An array of Reference or Definition objects relating to service definitions
|
96 |
-
*/
|
97 |
-
private function processArguments(array $arguments)
|
98 |
-
{
|
99 |
-
foreach ($arguments as $argument) {
|
100 |
-
if (is_array($argument)) {
|
101 |
-
$this->processArguments($argument);
|
102 |
-
} elseif ($argument instanceof Reference) {
|
103 |
-
$this->graph->connect(
|
104 |
-
$this->currentId,
|
105 |
-
$this->currentDefinition,
|
106 |
-
$this->getDefinitionId((string) $argument),
|
107 |
-
$this->getDefinition((string) $argument),
|
108 |
-
$argument
|
109 |
-
);
|
110 |
-
} elseif ($argument instanceof Definition) {
|
111 |
-
$this->processArguments($argument->getArguments());
|
112 |
-
$this->processArguments($argument->getMethodCalls());
|
113 |
-
$this->processArguments($argument->getProperties());
|
114 |
-
|
115 |
-
if ($argument->getFactoryService()) {
|
116 |
-
$this->processArguments(array(new Reference($argument->getFactoryService())));
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Returns a service definition given the full name or an alias.
|
124 |
-
*
|
125 |
-
* @param string $id A full id or alias for a service definition.
|
126 |
-
*
|
127 |
-
* @return Definition|null The definition related to the supplied id
|
128 |
-
*/
|
129 |
-
private function getDefinition($id)
|
130 |
-
{
|
131 |
-
$id = $this->getDefinitionId($id);
|
132 |
-
|
133 |
-
return null === $id ? null : $this->container->getDefinition($id);
|
134 |
-
}
|
135 |
-
|
136 |
-
private function getDefinitionId($id)
|
137 |
-
{
|
138 |
-
while ($this->container->hasAlias($id)) {
|
139 |
-
$id = (string) $this->container->getAlias($id);
|
140 |
-
}
|
141 |
-
|
142 |
-
if (!$this->container->hasDefinition($id)) {
|
143 |
-
return;
|
144 |
-
}
|
145 |
-
|
146 |
-
return $id;
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
15 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Checks your services for circular references.
|
19 |
-
*
|
20 |
-
* References from method calls are ignored since we might be able to resolve
|
21 |
-
* these references depending on the order in which services are called.
|
22 |
-
*
|
23 |
-
* Circular reference from method calls will only be detected at run-time.
|
24 |
-
*
|
25 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
26 |
-
*/
|
27 |
-
class CheckCircularReferencesPass implements CompilerPassInterface
|
28 |
-
{
|
29 |
-
private $currentId;
|
30 |
-
private $currentPath;
|
31 |
-
private $checkedNodes;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Checks the ContainerBuilder object for circular references.
|
35 |
-
*
|
36 |
-
* @param ContainerBuilder $container The ContainerBuilder instances
|
37 |
-
*/
|
38 |
-
public function process(ContainerBuilder $container)
|
39 |
-
{
|
40 |
-
$graph = $container->getCompiler()->getServiceReferenceGraph();
|
41 |
-
|
42 |
-
$this->checkedNodes = array();
|
43 |
-
foreach ($graph->getNodes() as $id => $node) {
|
44 |
-
$this->currentId = $id;
|
45 |
-
$this->currentPath = array($id);
|
46 |
-
|
47 |
-
$this->checkOutEdges($node->getOutEdges());
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Checks for circular references.
|
53 |
-
*
|
54 |
-
* @param ServiceReferenceGraphEdge[] $edges An array of Edges
|
55 |
-
*
|
56 |
-
* @throws ServiceCircularReferenceException When a circular reference is found.
|
57 |
-
*/
|
58 |
-
private function checkOutEdges(array $edges)
|
59 |
-
{
|
60 |
-
foreach ($edges as $edge) {
|
61 |
-
$node = $edge->getDestNode();
|
62 |
-
$id = $node->getId();
|
63 |
-
|
64 |
-
if (empty($this->checkedNodes[$id])) {
|
65 |
-
$searchKey = array_search($id, $this->currentPath);
|
66 |
-
$this->currentPath[] = $id;
|
67 |
-
|
68 |
-
if (false !== $searchKey) {
|
69 |
-
throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey));
|
70 |
-
}
|
71 |
-
|
72 |
-
$this->checkOutEdges($node->getOutEdges());
|
73 |
-
|
74 |
-
$this->checkedNodes[$id] = true;
|
75 |
-
array_pop($this->currentPath);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
16 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* This pass validates each definition individually only taking the information
|
20 |
-
* into account which is contained in the definition itself.
|
21 |
-
*
|
22 |
-
* Later passes can rely on the following, and specifically do not need to
|
23 |
-
* perform these checks themselves:
|
24 |
-
*
|
25 |
-
* - non synthetic, non abstract services always have a class set
|
26 |
-
* - synthetic services are always public
|
27 |
-
* - synthetic services are always of non-prototype scope
|
28 |
-
*
|
29 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
30 |
-
*/
|
31 |
-
class CheckDefinitionValidityPass implements CompilerPassInterface
|
32 |
-
{
|
33 |
-
/**
|
34 |
-
* Processes the ContainerBuilder to validate the Definition.
|
35 |
-
*
|
36 |
-
* @param ContainerBuilder $container
|
37 |
-
*
|
38 |
-
* @throws RuntimeException When the Definition is invalid
|
39 |
-
*/
|
40 |
-
public function process(ContainerBuilder $container)
|
41 |
-
{
|
42 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
43 |
-
// synthetic service is public
|
44 |
-
if ($definition->isSynthetic() && !$definition->isPublic()) {
|
45 |
-
throw new RuntimeException(sprintf(
|
46 |
-
'A synthetic service ("%s") must be public.',
|
47 |
-
$id
|
48 |
-
));
|
49 |
-
}
|
50 |
-
|
51 |
-
// synthetic service has non-prototype scope
|
52 |
-
if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope()) {
|
53 |
-
throw new RuntimeException(sprintf(
|
54 |
-
'A synthetic service ("%s") cannot be of scope "prototype".',
|
55 |
-
$id
|
56 |
-
));
|
57 |
-
}
|
58 |
-
|
59 |
-
// non-synthetic, non-abstract service has class
|
60 |
-
if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) {
|
61 |
-
if ($definition->getFactoryClass() || $definition->getFactoryService()) {
|
62 |
-
throw new RuntimeException(sprintf(
|
63 |
-
'Please add the class to service "%s" even if it is constructed by a factory '
|
64 |
-
.'since we might need to add method calls based on compile-time checks.',
|
65 |
-
$id
|
66 |
-
));
|
67 |
-
}
|
68 |
-
|
69 |
-
throw new RuntimeException(sprintf(
|
70 |
-
'The definition for "%s" has no class. If you intend to inject '
|
71 |
-
.'this service dynamically at runtime, please mark it as synthetic=true. '
|
72 |
-
.'If this is an abstract definition solely used by child definitions, '
|
73 |
-
.'please add abstract=true, otherwise specify a class to get rid of this error.',
|
74 |
-
$id
|
75 |
-
));
|
76 |
-
}
|
77 |
-
|
78 |
-
// tag attribute values must be scalars
|
79 |
-
foreach ($definition->getTags() as $name => $tags) {
|
80 |
-
foreach ($tags as $attributes) {
|
81 |
-
foreach ($attributes as $attribute => $value) {
|
82 |
-
if (!is_scalar($value) && null !== $value) {
|
83 |
-
throw new RuntimeException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute));
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
88 |
-
}
|
89 |
-
}
|
90 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
17 |
-
use Symfony\Component\DependencyInjection\Reference;
|
18 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Checks that all references are pointing to a valid service.
|
22 |
-
*
|
23 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
24 |
-
*/
|
25 |
-
class CheckExceptionOnInvalidReferenceBehaviorPass implements CompilerPassInterface
|
26 |
-
{
|
27 |
-
private $container;
|
28 |
-
private $sourceId;
|
29 |
-
|
30 |
-
public function process(ContainerBuilder $container)
|
31 |
-
{
|
32 |
-
$this->container = $container;
|
33 |
-
|
34 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
35 |
-
$this->sourceId = $id;
|
36 |
-
$this->processDefinition($definition);
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
private function processDefinition(Definition $definition)
|
41 |
-
{
|
42 |
-
$this->processReferences($definition->getArguments());
|
43 |
-
$this->processReferences($definition->getMethodCalls());
|
44 |
-
$this->processReferences($definition->getProperties());
|
45 |
-
}
|
46 |
-
|
47 |
-
private function processReferences(array $arguments)
|
48 |
-
{
|
49 |
-
foreach ($arguments as $argument) {
|
50 |
-
if (is_array($argument)) {
|
51 |
-
$this->processReferences($argument);
|
52 |
-
} elseif ($argument instanceof Definition) {
|
53 |
-
$this->processDefinition($argument);
|
54 |
-
} elseif ($argument instanceof Reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $argument->getInvalidBehavior()) {
|
55 |
-
$destId = (string) $argument;
|
56 |
-
|
57 |
-
if (!$this->container->has($destId)) {
|
58 |
-
throw new ServiceNotFoundException($destId, $this->sourceId);
|
59 |
-
}
|
60 |
-
}
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
DELETED
@@ -1,167 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
18 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
19 |
-
use Symfony\Component\DependencyInjection\Exception\ScopeCrossingInjectionException;
|
20 |
-
use Symfony\Component\DependencyInjection\Exception\ScopeWideningInjectionException;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Checks the validity of references.
|
24 |
-
*
|
25 |
-
* The following checks are performed by this pass:
|
26 |
-
* - target definitions are not abstract
|
27 |
-
* - target definitions are of equal or wider scope
|
28 |
-
* - target definitions are in the same scope hierarchy
|
29 |
-
*
|
30 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
31 |
-
*/
|
32 |
-
class CheckReferenceValidityPass implements CompilerPassInterface
|
33 |
-
{
|
34 |
-
private $container;
|
35 |
-
private $currentId;
|
36 |
-
private $currentDefinition;
|
37 |
-
private $currentScope;
|
38 |
-
private $currentScopeAncestors;
|
39 |
-
private $currentScopeChildren;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Processes the ContainerBuilder to validate References.
|
43 |
-
*
|
44 |
-
* @param ContainerBuilder $container
|
45 |
-
*/
|
46 |
-
public function process(ContainerBuilder $container)
|
47 |
-
{
|
48 |
-
$this->container = $container;
|
49 |
-
|
50 |
-
$children = $this->container->getScopeChildren();
|
51 |
-
$ancestors = array();
|
52 |
-
|
53 |
-
$scopes = $this->container->getScopes();
|
54 |
-
foreach ($scopes as $name => $parent) {
|
55 |
-
$ancestors[$name] = array($parent);
|
56 |
-
|
57 |
-
while (isset($scopes[$parent])) {
|
58 |
-
$ancestors[$name][] = $parent = $scopes[$parent];
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
63 |
-
if ($definition->isSynthetic() || $definition->isAbstract()) {
|
64 |
-
continue;
|
65 |
-
}
|
66 |
-
|
67 |
-
$this->currentId = $id;
|
68 |
-
$this->currentDefinition = $definition;
|
69 |
-
$this->currentScope = $scope = $definition->getScope();
|
70 |
-
|
71 |
-
if (ContainerInterface::SCOPE_CONTAINER === $scope) {
|
72 |
-
$this->currentScopeChildren = array_keys($scopes);
|
73 |
-
$this->currentScopeAncestors = array();
|
74 |
-
} elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
|
75 |
-
$this->currentScopeChildren = isset($children[$scope]) ? $children[$scope] : array();
|
76 |
-
$this->currentScopeAncestors = isset($ancestors[$scope]) ? $ancestors[$scope] : array();
|
77 |
-
}
|
78 |
-
|
79 |
-
$this->validateReferences($definition->getArguments());
|
80 |
-
$this->validateReferences($definition->getMethodCalls());
|
81 |
-
$this->validateReferences($definition->getProperties());
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Validates an array of References.
|
87 |
-
*
|
88 |
-
* @param array $arguments An array of Reference objects
|
89 |
-
*
|
90 |
-
* @throws RuntimeException when there is a reference to an abstract definition.
|
91 |
-
*/
|
92 |
-
private function validateReferences(array $arguments)
|
93 |
-
{
|
94 |
-
foreach ($arguments as $argument) {
|
95 |
-
if (is_array($argument)) {
|
96 |
-
$this->validateReferences($argument);
|
97 |
-
} elseif ($argument instanceof Reference) {
|
98 |
-
$targetDefinition = $this->getDefinition((string) $argument);
|
99 |
-
|
100 |
-
if (null !== $targetDefinition && $targetDefinition->isAbstract()) {
|
101 |
-
throw new RuntimeException(sprintf(
|
102 |
-
'The definition "%s" has a reference to an abstract definition "%s". '
|
103 |
-
.'Abstract definitions cannot be the target of references.',
|
104 |
-
$this->currentId,
|
105 |
-
$argument
|
106 |
-
));
|
107 |
-
}
|
108 |
-
|
109 |
-
$this->validateScope($argument, $targetDefinition);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Validates the scope of a single Reference.
|
116 |
-
*
|
117 |
-
* @param Reference $reference
|
118 |
-
* @param Definition $definition
|
119 |
-
*
|
120 |
-
* @throws ScopeWideningInjectionException when the definition references a service of a narrower scope
|
121 |
-
* @throws ScopeCrossingInjectionException when the definition references a service of another scope hierarchy
|
122 |
-
*/
|
123 |
-
private function validateScope(Reference $reference, Definition $definition = null)
|
124 |
-
{
|
125 |
-
if (ContainerInterface::SCOPE_PROTOTYPE === $this->currentScope) {
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
if (!$reference->isStrict()) {
|
130 |
-
return;
|
131 |
-
}
|
132 |
-
|
133 |
-
if (null === $definition) {
|
134 |
-
return;
|
135 |
-
}
|
136 |
-
|
137 |
-
if ($this->currentScope === $scope = $definition->getScope()) {
|
138 |
-
return;
|
139 |
-
}
|
140 |
-
|
141 |
-
$id = (string) $reference;
|
142 |
-
|
143 |
-
if (in_array($scope, $this->currentScopeChildren, true)) {
|
144 |
-
throw new ScopeWideningInjectionException($this->currentId, $this->currentScope, $id, $scope);
|
145 |
-
}
|
146 |
-
|
147 |
-
if (!in_array($scope, $this->currentScopeAncestors, true)) {
|
148 |
-
throw new ScopeCrossingInjectionException($this->currentId, $this->currentScope, $id, $scope);
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Returns the Definition given an id.
|
154 |
-
*
|
155 |
-
* @param string $id Definition identifier
|
156 |
-
*
|
157 |
-
* @return Definition
|
158 |
-
*/
|
159 |
-
private function getDefinition($id)
|
160 |
-
{
|
161 |
-
if (!$this->container->hasDefinition($id)) {
|
162 |
-
return;
|
163 |
-
}
|
164 |
-
|
165 |
-
return $this->container->getDefinition($id);
|
166 |
-
}
|
167 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/Compiler.php
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This class is used to remove circular dependencies between individual passes.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
class Compiler
|
24 |
-
{
|
25 |
-
private $passConfig;
|
26 |
-
private $log = array();
|
27 |
-
private $loggingFormatter;
|
28 |
-
private $serviceReferenceGraph;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor.
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
$this->passConfig = new PassConfig();
|
36 |
-
$this->serviceReferenceGraph = new ServiceReferenceGraph();
|
37 |
-
$this->loggingFormatter = new LoggingFormatter();
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Returns the PassConfig.
|
42 |
-
*
|
43 |
-
* @return PassConfig The PassConfig instance
|
44 |
-
*
|
45 |
-
* @api
|
46 |
-
*/
|
47 |
-
public function getPassConfig()
|
48 |
-
{
|
49 |
-
return $this->passConfig;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Returns the ServiceReferenceGraph.
|
54 |
-
*
|
55 |
-
* @return ServiceReferenceGraph The ServiceReferenceGraph instance
|
56 |
-
*
|
57 |
-
* @api
|
58 |
-
*/
|
59 |
-
public function getServiceReferenceGraph()
|
60 |
-
{
|
61 |
-
return $this->serviceReferenceGraph;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Returns the logging formatter which can be used by compilation passes.
|
66 |
-
*
|
67 |
-
* @return LoggingFormatter
|
68 |
-
*/
|
69 |
-
public function getLoggingFormatter()
|
70 |
-
{
|
71 |
-
return $this->loggingFormatter;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Adds a pass to the PassConfig.
|
76 |
-
*
|
77 |
-
* @param CompilerPassInterface $pass A compiler pass
|
78 |
-
* @param string $type The type of the pass
|
79 |
-
*
|
80 |
-
* @api
|
81 |
-
*/
|
82 |
-
public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
|
83 |
-
{
|
84 |
-
$this->passConfig->addPass($pass, $type);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Adds a log message.
|
89 |
-
*
|
90 |
-
* @param string $string The log message
|
91 |
-
*/
|
92 |
-
public function addLogMessage($string)
|
93 |
-
{
|
94 |
-
$this->log[] = $string;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Returns the log.
|
99 |
-
*
|
100 |
-
* @return array Log array
|
101 |
-
*/
|
102 |
-
public function getLog()
|
103 |
-
{
|
104 |
-
return $this->log;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Run the Compiler and process all Passes.
|
109 |
-
*
|
110 |
-
* @param ContainerBuilder $container
|
111 |
-
*
|
112 |
-
* @api
|
113 |
-
*/
|
114 |
-
public function compile(ContainerBuilder $container)
|
115 |
-
{
|
116 |
-
foreach ($this->passConfig->getPasses() as $pass) {
|
117 |
-
$pass->process($container);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/CompilerPassInterface.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Interface that must be implemented by compilation passes.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
interface CompilerPassInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* You can modify the container here before it is dumped to PHP code.
|
27 |
-
*
|
28 |
-
* @param ContainerBuilder $container
|
29 |
-
*
|
30 |
-
* @api
|
31 |
-
*/
|
32 |
-
public function process(ContainerBuilder $container);
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\DependencyInjection\Alias;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Overwrites a service but keeps the overridden one.
|
19 |
-
*
|
20 |
-
* @author Christophe Coevoet <stof@notk.org>
|
21 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
-
*/
|
23 |
-
class DecoratorServicePass implements CompilerPassInterface
|
24 |
-
{
|
25 |
-
public function process(ContainerBuilder $container)
|
26 |
-
{
|
27 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
28 |
-
if (!$decorated = $definition->getDecoratedService()) {
|
29 |
-
continue;
|
30 |
-
}
|
31 |
-
$definition->setDecoratedService(null);
|
32 |
-
|
33 |
-
list($inner, $renamedId) = $decorated;
|
34 |
-
if (!$renamedId) {
|
35 |
-
$renamedId = $id.'.inner';
|
36 |
-
}
|
37 |
-
|
38 |
-
// we create a new alias/service for the service we are replacing
|
39 |
-
// to be able to reference it in the new one
|
40 |
-
if ($container->hasAlias($inner)) {
|
41 |
-
$alias = $container->getAlias($inner);
|
42 |
-
$public = $alias->isPublic();
|
43 |
-
$container->setAlias($renamedId, new Alias((string) $alias, false));
|
44 |
-
} else {
|
45 |
-
$definition = $container->getDefinition($inner);
|
46 |
-
$public = $definition->isPublic();
|
47 |
-
$definition->setPublic(false);
|
48 |
-
$container->setDefinition($renamedId, $definition);
|
49 |
-
}
|
50 |
-
|
51 |
-
$container->setAlias($inner, new Alias($id, $public));
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
DELETED
@@ -1,152 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\Definition;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Inline service definitions where this is possible.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
25 |
-
{
|
26 |
-
private $repeatedPass;
|
27 |
-
private $graph;
|
28 |
-
private $compiler;
|
29 |
-
private $formatter;
|
30 |
-
private $currentId;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* {@inheritdoc}
|
34 |
-
*/
|
35 |
-
public function setRepeatedPass(RepeatedPass $repeatedPass)
|
36 |
-
{
|
37 |
-
$this->repeatedPass = $repeatedPass;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Processes the ContainerBuilder for inline service definitions.
|
42 |
-
*
|
43 |
-
* @param ContainerBuilder $container
|
44 |
-
*/
|
45 |
-
public function process(ContainerBuilder $container)
|
46 |
-
{
|
47 |
-
$this->compiler = $container->getCompiler();
|
48 |
-
$this->formatter = $this->compiler->getLoggingFormatter();
|
49 |
-
$this->graph = $this->compiler->getServiceReferenceGraph();
|
50 |
-
|
51 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
52 |
-
$this->currentId = $id;
|
53 |
-
|
54 |
-
$definition->setArguments(
|
55 |
-
$this->inlineArguments($container, $definition->getArguments())
|
56 |
-
);
|
57 |
-
|
58 |
-
$definition->setMethodCalls(
|
59 |
-
$this->inlineArguments($container, $definition->getMethodCalls())
|
60 |
-
);
|
61 |
-
|
62 |
-
$definition->setProperties(
|
63 |
-
$this->inlineArguments($container, $definition->getProperties())
|
64 |
-
);
|
65 |
-
|
66 |
-
$configurator = $this->inlineArguments($container, array($definition->getConfigurator()));
|
67 |
-
$definition->setConfigurator(
|
68 |
-
$configurator[0]
|
69 |
-
);
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Processes inline arguments.
|
75 |
-
*
|
76 |
-
* @param ContainerBuilder $container The ContainerBuilder
|
77 |
-
* @param array $arguments An array of arguments
|
78 |
-
*
|
79 |
-
* @return array
|
80 |
-
*/
|
81 |
-
private function inlineArguments(ContainerBuilder $container, array $arguments)
|
82 |
-
{
|
83 |
-
foreach ($arguments as $k => $argument) {
|
84 |
-
if (is_array($argument)) {
|
85 |
-
$arguments[$k] = $this->inlineArguments($container, $argument);
|
86 |
-
} elseif ($argument instanceof Reference) {
|
87 |
-
if (!$container->hasDefinition($id = (string) $argument)) {
|
88 |
-
continue;
|
89 |
-
}
|
90 |
-
|
91 |
-
if ($this->isInlineableDefinition($container, $id, $definition = $container->getDefinition($id))) {
|
92 |
-
$this->compiler->addLogMessage($this->formatter->formatInlineService($this, $id, $this->currentId));
|
93 |
-
|
94 |
-
if (ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope()) {
|
95 |
-
$arguments[$k] = $definition;
|
96 |
-
} else {
|
97 |
-
$arguments[$k] = clone $definition;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
} elseif ($argument instanceof Definition) {
|
101 |
-
$argument->setArguments($this->inlineArguments($container, $argument->getArguments()));
|
102 |
-
$argument->setMethodCalls($this->inlineArguments($container, $argument->getMethodCalls()));
|
103 |
-
$argument->setProperties($this->inlineArguments($container, $argument->getProperties()));
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
return $arguments;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Checks if the definition is inlineable.
|
112 |
-
*
|
113 |
-
* @param ContainerBuilder $container
|
114 |
-
* @param string $id
|
115 |
-
* @param Definition $definition
|
116 |
-
*
|
117 |
-
* @return bool If the definition is inlineable
|
118 |
-
*/
|
119 |
-
private function isInlineableDefinition(ContainerBuilder $container, $id, Definition $definition)
|
120 |
-
{
|
121 |
-
if (ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope()) {
|
122 |
-
return true;
|
123 |
-
}
|
124 |
-
|
125 |
-
if ($definition->isPublic() || $definition->isLazy()) {
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
if (!$this->graph->hasNode($id)) {
|
130 |
-
return true;
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($this->currentId == $id) {
|
134 |
-
return false;
|
135 |
-
}
|
136 |
-
|
137 |
-
$ids = array();
|
138 |
-
foreach ($this->graph->getNode($id)->getInEdges() as $edge) {
|
139 |
-
$ids[] = $edge->getSourceNode()->getId();
|
140 |
-
}
|
141 |
-
|
142 |
-
if (count(array_unique($ids)) > 1) {
|
143 |
-
return false;
|
144 |
-
}
|
145 |
-
|
146 |
-
if (count($ids) > 1 && $definition->getFactoryService()) {
|
147 |
-
return false;
|
148 |
-
}
|
149 |
-
|
150 |
-
return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
|
151 |
-
}
|
152 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/LoggingFormatter.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Used to format logging messages during the compilation.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class LoggingFormatter
|
20 |
-
{
|
21 |
-
public function formatRemoveService(CompilerPassInterface $pass, $id, $reason)
|
22 |
-
{
|
23 |
-
return $this->format($pass, sprintf('Removed service "%s"; reason: %s', $id, $reason));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function formatInlineService(CompilerPassInterface $pass, $id, $target)
|
27 |
-
{
|
28 |
-
return $this->format($pass, sprintf('Inlined service "%s" to "%s".', $id, $target));
|
29 |
-
}
|
30 |
-
|
31 |
-
public function formatUpdateReference(CompilerPassInterface $pass, $serviceId, $oldDestId, $newDestId)
|
32 |
-
{
|
33 |
-
return $this->format($pass, sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', $serviceId, $oldDestId, $newDestId));
|
34 |
-
}
|
35 |
-
|
36 |
-
public function formatResolveInheritance(CompilerPassInterface $pass, $childId, $parentId)
|
37 |
-
{
|
38 |
-
return $this->format($pass, sprintf('Resolving inheritance for "%s" (parent: %s).', $childId, $parentId));
|
39 |
-
}
|
40 |
-
|
41 |
-
public function format(CompilerPassInterface $pass, $message)
|
42 |
-
{
|
43 |
-
return sprintf('%s: %s', get_class($pass), $message);
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Merges extension configs into the container builder.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*/
|
22 |
-
class MergeExtensionConfigurationPass implements CompilerPassInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
-
public function process(ContainerBuilder $container)
|
28 |
-
{
|
29 |
-
$parameters = $container->getParameterBag()->all();
|
30 |
-
$definitions = $container->getDefinitions();
|
31 |
-
$aliases = $container->getAliases();
|
32 |
-
|
33 |
-
foreach ($container->getExtensions() as $extension) {
|
34 |
-
if ($extension instanceof PrependExtensionInterface) {
|
35 |
-
$extension->prepend($container);
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
foreach ($container->getExtensions() as $name => $extension) {
|
40 |
-
if (!$config = $container->getExtensionConfig($name)) {
|
41 |
-
// this extension was not called
|
42 |
-
continue;
|
43 |
-
}
|
44 |
-
$config = $container->getParameterBag()->resolveValue($config);
|
45 |
-
|
46 |
-
$tmpContainer = new ContainerBuilder($container->getParameterBag());
|
47 |
-
$tmpContainer->setResourceTracking($container->isTrackingResources());
|
48 |
-
$tmpContainer->addObjectResource($extension);
|
49 |
-
|
50 |
-
$extension->load($config, $tmpContainer);
|
51 |
-
|
52 |
-
$container->merge($tmpContainer);
|
53 |
-
}
|
54 |
-
|
55 |
-
$container->addDefinitions($definitions);
|
56 |
-
$container->addAliases($aliases);
|
57 |
-
$container->getParameterBag()->add($parameters);
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
DELETED
@@ -1,256 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Compiler Pass Configuration.
|
18 |
-
*
|
19 |
-
* This class has a default configuration embedded.
|
20 |
-
*
|
21 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
22 |
-
*
|
23 |
-
* @api
|
24 |
-
*/
|
25 |
-
class PassConfig
|
26 |
-
{
|
27 |
-
const TYPE_AFTER_REMOVING = 'afterRemoving';
|
28 |
-
const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization';
|
29 |
-
const TYPE_BEFORE_REMOVING = 'beforeRemoving';
|
30 |
-
const TYPE_OPTIMIZE = 'optimization';
|
31 |
-
const TYPE_REMOVE = 'removing';
|
32 |
-
|
33 |
-
private $mergePass;
|
34 |
-
private $afterRemovingPasses = array();
|
35 |
-
private $beforeOptimizationPasses = array();
|
36 |
-
private $beforeRemovingPasses = array();
|
37 |
-
private $optimizationPasses;
|
38 |
-
private $removingPasses;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor.
|
42 |
-
*/
|
43 |
-
public function __construct()
|
44 |
-
{
|
45 |
-
$this->mergePass = new MergeExtensionConfigurationPass();
|
46 |
-
|
47 |
-
$this->optimizationPasses = array(
|
48 |
-
new ResolveDefinitionTemplatesPass(),
|
49 |
-
new DecoratorServicePass(),
|
50 |
-
new ResolveParameterPlaceHoldersPass(),
|
51 |
-
new CheckDefinitionValidityPass(),
|
52 |
-
new ResolveReferencesToAliasesPass(),
|
53 |
-
new ResolveInvalidReferencesPass(),
|
54 |
-
new AnalyzeServiceReferencesPass(true),
|
55 |
-
new CheckCircularReferencesPass(),
|
56 |
-
new CheckReferenceValidityPass(),
|
57 |
-
);
|
58 |
-
|
59 |
-
$this->removingPasses = array(
|
60 |
-
new RemovePrivateAliasesPass(),
|
61 |
-
new RemoveAbstractDefinitionsPass(),
|
62 |
-
new ReplaceAliasByActualDefinitionPass(),
|
63 |
-
new RepeatedPass(array(
|
64 |
-
new AnalyzeServiceReferencesPass(),
|
65 |
-
new InlineServiceDefinitionsPass(),
|
66 |
-
new AnalyzeServiceReferencesPass(),
|
67 |
-
new RemoveUnusedDefinitionsPass(),
|
68 |
-
)),
|
69 |
-
new CheckExceptionOnInvalidReferenceBehaviorPass(),
|
70 |
-
);
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Returns all passes in order to be processed.
|
75 |
-
*
|
76 |
-
* @return array An array of all passes to process
|
77 |
-
*
|
78 |
-
* @api
|
79 |
-
*/
|
80 |
-
public function getPasses()
|
81 |
-
{
|
82 |
-
return array_merge(
|
83 |
-
array($this->mergePass),
|
84 |
-
$this->beforeOptimizationPasses,
|
85 |
-
$this->optimizationPasses,
|
86 |
-
$this->beforeRemovingPasses,
|
87 |
-
$this->removingPasses,
|
88 |
-
$this->afterRemovingPasses
|
89 |
-
);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Adds a pass.
|
94 |
-
*
|
95 |
-
* @param CompilerPassInterface $pass A Compiler pass
|
96 |
-
* @param string $type The pass type
|
97 |
-
*
|
98 |
-
* @throws InvalidArgumentException when a pass type doesn't exist
|
99 |
-
*
|
100 |
-
* @api
|
101 |
-
*/
|
102 |
-
public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION)
|
103 |
-
{
|
104 |
-
$property = $type.'Passes';
|
105 |
-
if (!isset($this->$property)) {
|
106 |
-
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
|
107 |
-
}
|
108 |
-
|
109 |
-
$passes = &$this->$property;
|
110 |
-
$passes[] = $pass;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Gets all passes for the AfterRemoving pass.
|
115 |
-
*
|
116 |
-
* @return array An array of passes
|
117 |
-
*
|
118 |
-
* @api
|
119 |
-
*/
|
120 |
-
public function getAfterRemovingPasses()
|
121 |
-
{
|
122 |
-
return $this->afterRemovingPasses;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Gets all passes for the BeforeOptimization pass.
|
127 |
-
*
|
128 |
-
* @return array An array of passes
|
129 |
-
*
|
130 |
-
* @api
|
131 |
-
*/
|
132 |
-
public function getBeforeOptimizationPasses()
|
133 |
-
{
|
134 |
-
return $this->beforeOptimizationPasses;
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Gets all passes for the BeforeRemoving pass.
|
139 |
-
*
|
140 |
-
* @return array An array of passes
|
141 |
-
*
|
142 |
-
* @api
|
143 |
-
*/
|
144 |
-
public function getBeforeRemovingPasses()
|
145 |
-
{
|
146 |
-
return $this->beforeRemovingPasses;
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Gets all passes for the Optimization pass.
|
151 |
-
*
|
152 |
-
* @return array An array of passes
|
153 |
-
*
|
154 |
-
* @api
|
155 |
-
*/
|
156 |
-
public function getOptimizationPasses()
|
157 |
-
{
|
158 |
-
return $this->optimizationPasses;
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Gets all passes for the Removing pass.
|
163 |
-
*
|
164 |
-
* @return array An array of passes
|
165 |
-
*
|
166 |
-
* @api
|
167 |
-
*/
|
168 |
-
public function getRemovingPasses()
|
169 |
-
{
|
170 |
-
return $this->removingPasses;
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Gets all passes for the Merge pass.
|
175 |
-
*
|
176 |
-
* @return array An array of passes
|
177 |
-
*
|
178 |
-
* @api
|
179 |
-
*/
|
180 |
-
public function getMergePass()
|
181 |
-
{
|
182 |
-
return $this->mergePass;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Sets the Merge Pass.
|
187 |
-
*
|
188 |
-
* @param CompilerPassInterface $pass The merge pass
|
189 |
-
*
|
190 |
-
* @api
|
191 |
-
*/
|
192 |
-
public function setMergePass(CompilerPassInterface $pass)
|
193 |
-
{
|
194 |
-
$this->mergePass = $pass;
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Sets the AfterRemoving passes.
|
199 |
-
*
|
200 |
-
* @param array $passes An array of passes
|
201 |
-
*
|
202 |
-
* @api
|
203 |
-
*/
|
204 |
-
public function setAfterRemovingPasses(array $passes)
|
205 |
-
{
|
206 |
-
$this->afterRemovingPasses = $passes;
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Sets the BeforeOptimization passes.
|
211 |
-
*
|
212 |
-
* @param array $passes An array of passes
|
213 |
-
*
|
214 |
-
* @api
|
215 |
-
*/
|
216 |
-
public function setBeforeOptimizationPasses(array $passes)
|
217 |
-
{
|
218 |
-
$this->beforeOptimizationPasses = $passes;
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Sets the BeforeRemoving passes.
|
223 |
-
*
|
224 |
-
* @param array $passes An array of passes
|
225 |
-
*
|
226 |
-
* @api
|
227 |
-
*/
|
228 |
-
public function setBeforeRemovingPasses(array $passes)
|
229 |
-
{
|
230 |
-
$this->beforeRemovingPasses = $passes;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Sets the Optimization passes.
|
235 |
-
*
|
236 |
-
* @param array $passes An array of passes
|
237 |
-
*
|
238 |
-
* @api
|
239 |
-
*/
|
240 |
-
public function setOptimizationPasses(array $passes)
|
241 |
-
{
|
242 |
-
$this->optimizationPasses = $passes;
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Sets the Removing passes.
|
247 |
-
*
|
248 |
-
* @param array $passes An array of passes
|
249 |
-
*
|
250 |
-
* @api
|
251 |
-
*/
|
252 |
-
public function setRemovingPasses(array $passes)
|
253 |
-
{
|
254 |
-
$this->removingPasses = $passes;
|
255 |
-
}
|
256 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/RemoveAbstractDefinitionsPass.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Removes abstract Definitions.
|
18 |
-
*/
|
19 |
-
class RemoveAbstractDefinitionsPass implements CompilerPassInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Removes abstract definitions from the ContainerBuilder.
|
23 |
-
*
|
24 |
-
* @param ContainerBuilder $container
|
25 |
-
*/
|
26 |
-
public function process(ContainerBuilder $container)
|
27 |
-
{
|
28 |
-
$compiler = $container->getCompiler();
|
29 |
-
$formatter = $compiler->getLoggingFormatter();
|
30 |
-
|
31 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
32 |
-
if ($definition->isAbstract()) {
|
33 |
-
$container->removeDefinition($id);
|
34 |
-
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'abstract'));
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Remove private aliases from the container. They were only used to establish
|
18 |
-
* dependencies between services, and these dependencies have been resolved in
|
19 |
-
* one of the previous passes.
|
20 |
-
*
|
21 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
22 |
-
*/
|
23 |
-
class RemovePrivateAliasesPass implements CompilerPassInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Removes private aliases from the ContainerBuilder.
|
27 |
-
*
|
28 |
-
* @param ContainerBuilder $container
|
29 |
-
*/
|
30 |
-
public function process(ContainerBuilder $container)
|
31 |
-
{
|
32 |
-
$compiler = $container->getCompiler();
|
33 |
-
$formatter = $compiler->getLoggingFormatter();
|
34 |
-
|
35 |
-
foreach ($container->getAliases() as $id => $alias) {
|
36 |
-
if ($alias->isPublic()) {
|
37 |
-
continue;
|
38 |
-
}
|
39 |
-
|
40 |
-
$container->removeAlias($id);
|
41 |
-
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'private alias'));
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Removes unused service definitions from the container.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class RemoveUnusedDefinitionsPass implements RepeatablePassInterface
|
22 |
-
{
|
23 |
-
private $repeatedPass;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* {@inheritdoc}
|
27 |
-
*/
|
28 |
-
public function setRepeatedPass(RepeatedPass $repeatedPass)
|
29 |
-
{
|
30 |
-
$this->repeatedPass = $repeatedPass;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Processes the ContainerBuilder to remove unused definitions.
|
35 |
-
*
|
36 |
-
* @param ContainerBuilder $container
|
37 |
-
*/
|
38 |
-
public function process(ContainerBuilder $container)
|
39 |
-
{
|
40 |
-
$compiler = $container->getCompiler();
|
41 |
-
$formatter = $compiler->getLoggingFormatter();
|
42 |
-
$graph = $compiler->getServiceReferenceGraph();
|
43 |
-
|
44 |
-
$hasChanged = false;
|
45 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
46 |
-
if ($definition->isPublic()) {
|
47 |
-
continue;
|
48 |
-
}
|
49 |
-
|
50 |
-
if ($graph->hasNode($id)) {
|
51 |
-
$edges = $graph->getNode($id)->getInEdges();
|
52 |
-
$referencingAliases = array();
|
53 |
-
$sourceIds = array();
|
54 |
-
foreach ($edges as $edge) {
|
55 |
-
$node = $edge->getSourceNode();
|
56 |
-
$sourceIds[] = $node->getId();
|
57 |
-
|
58 |
-
if ($node->isAlias()) {
|
59 |
-
$referencingAliases[] = $node->getValue();
|
60 |
-
}
|
61 |
-
}
|
62 |
-
$isReferenced = (count(array_unique($sourceIds)) - count($referencingAliases)) > 0;
|
63 |
-
} else {
|
64 |
-
$referencingAliases = array();
|
65 |
-
$isReferenced = false;
|
66 |
-
}
|
67 |
-
|
68 |
-
if (1 === count($referencingAliases) && false === $isReferenced) {
|
69 |
-
$container->setDefinition((string) reset($referencingAliases), $definition);
|
70 |
-
$definition->setPublic(true);
|
71 |
-
$container->removeDefinition($id);
|
72 |
-
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'replaces alias '.reset($referencingAliases)));
|
73 |
-
} elseif (0 === count($referencingAliases) && false === $isReferenced) {
|
74 |
-
$container->removeDefinition($id);
|
75 |
-
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'unused'));
|
76 |
-
$hasChanged = true;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
if ($hasChanged) {
|
81 |
-
$this->repeatedPass->setRepeat();
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/RepeatablePassInterface.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Interface that must be implemented by passes that are run as part of an
|
16 |
-
* RepeatedPass.
|
17 |
-
*
|
18 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
19 |
-
*/
|
20 |
-
interface RepeatablePassInterface extends CompilerPassInterface
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Sets the RepeatedPass interface.
|
24 |
-
*
|
25 |
-
* @param RepeatedPass $repeatedPass
|
26 |
-
*/
|
27 |
-
public function setRepeatedPass(RepeatedPass $repeatedPass);
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* A pass that might be run repeatedly.
|
19 |
-
*
|
20 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
21 |
-
*/
|
22 |
-
class RepeatedPass implements CompilerPassInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @var bool
|
26 |
-
*/
|
27 |
-
private $repeat = false;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var RepeatablePassInterface[]
|
31 |
-
*/
|
32 |
-
private $passes;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Constructor.
|
36 |
-
*
|
37 |
-
* @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
|
38 |
-
*
|
39 |
-
* @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
|
40 |
-
*/
|
41 |
-
public function __construct(array $passes)
|
42 |
-
{
|
43 |
-
foreach ($passes as $pass) {
|
44 |
-
if (!$pass instanceof RepeatablePassInterface) {
|
45 |
-
throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
|
46 |
-
}
|
47 |
-
|
48 |
-
$pass->setRepeatedPass($this);
|
49 |
-
}
|
50 |
-
|
51 |
-
$this->passes = $passes;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Process the repeatable passes that run more than once.
|
56 |
-
*
|
57 |
-
* @param ContainerBuilder $container
|
58 |
-
*/
|
59 |
-
public function process(ContainerBuilder $container)
|
60 |
-
{
|
61 |
-
$this->repeat = false;
|
62 |
-
foreach ($this->passes as $pass) {
|
63 |
-
$pass->process($container);
|
64 |
-
}
|
65 |
-
|
66 |
-
if ($this->repeat) {
|
67 |
-
$this->process($container);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Sets if the pass should repeat.
|
73 |
-
*/
|
74 |
-
public function setRepeat()
|
75 |
-
{
|
76 |
-
$this->repeat = true;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Returns the passes.
|
81 |
-
*
|
82 |
-
* @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
|
83 |
-
*/
|
84 |
-
public function getPasses()
|
85 |
-
{
|
86 |
-
return $this->passes;
|
87 |
-
}
|
88 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php
DELETED
@@ -1,125 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Replaces aliases with actual service definitions, effectively removing these
|
20 |
-
* aliases.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
|
25 |
-
{
|
26 |
-
private $compiler;
|
27 |
-
private $formatter;
|
28 |
-
private $sourceId;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Process the Container to replace aliases with service definitions.
|
32 |
-
*
|
33 |
-
* @param ContainerBuilder $container
|
34 |
-
*
|
35 |
-
* @throws InvalidArgumentException if the service definition does not exist
|
36 |
-
*/
|
37 |
-
public function process(ContainerBuilder $container)
|
38 |
-
{
|
39 |
-
$this->compiler = $container->getCompiler();
|
40 |
-
$this->formatter = $this->compiler->getLoggingFormatter();
|
41 |
-
|
42 |
-
foreach ($container->getAliases() as $id => $alias) {
|
43 |
-
$aliasId = (string) $alias;
|
44 |
-
|
45 |
-
try {
|
46 |
-
$definition = $container->getDefinition($aliasId);
|
47 |
-
} catch (InvalidArgumentException $e) {
|
48 |
-
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
|
49 |
-
}
|
50 |
-
|
51 |
-
if ($definition->isPublic()) {
|
52 |
-
continue;
|
53 |
-
}
|
54 |
-
|
55 |
-
$definition->setPublic(true);
|
56 |
-
$container->setDefinition($id, $definition);
|
57 |
-
$container->removeDefinition($aliasId);
|
58 |
-
|
59 |
-
$this->updateReferences($container, $aliasId, $id);
|
60 |
-
|
61 |
-
// we have to restart the process due to concurrent modification of
|
62 |
-
// the container
|
63 |
-
$this->process($container);
|
64 |
-
|
65 |
-
break;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Updates references to remove aliases.
|
71 |
-
*
|
72 |
-
* @param ContainerBuilder $container The container
|
73 |
-
* @param string $currentId The alias identifier being replaced
|
74 |
-
* @param string $newId The id of the service the alias points to
|
75 |
-
*/
|
76 |
-
private function updateReferences($container, $currentId, $newId)
|
77 |
-
{
|
78 |
-
foreach ($container->getAliases() as $id => $alias) {
|
79 |
-
if ($currentId === (string) $alias) {
|
80 |
-
$container->setAlias($id, $newId);
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
85 |
-
$this->sourceId = $id;
|
86 |
-
|
87 |
-
$definition->setArguments(
|
88 |
-
$this->updateArgumentReferences($definition->getArguments(), $currentId, $newId)
|
89 |
-
);
|
90 |
-
|
91 |
-
$definition->setMethodCalls(
|
92 |
-
$this->updateArgumentReferences($definition->getMethodCalls(), $currentId, $newId)
|
93 |
-
);
|
94 |
-
|
95 |
-
$definition->setProperties(
|
96 |
-
$this->updateArgumentReferences($definition->getProperties(), $currentId, $newId)
|
97 |
-
);
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Updates argument references.
|
103 |
-
*
|
104 |
-
* @param array $arguments An array of Arguments
|
105 |
-
* @param string $currentId The alias identifier
|
106 |
-
* @param string $newId The identifier the alias points to
|
107 |
-
*
|
108 |
-
* @return array
|
109 |
-
*/
|
110 |
-
private function updateArgumentReferences(array $arguments, $currentId, $newId)
|
111 |
-
{
|
112 |
-
foreach ($arguments as $k => $argument) {
|
113 |
-
if (is_array($argument)) {
|
114 |
-
$arguments[$k] = $this->updateArgumentReferences($argument, $currentId, $newId);
|
115 |
-
} elseif ($argument instanceof Reference) {
|
116 |
-
if ($currentId === (string) $argument) {
|
117 |
-
$arguments[$k] = new Reference($newId, $argument->getInvalidBehavior());
|
118 |
-
$this->compiler->addLogMessage($this->formatter->formatUpdateReference($this, $this->sourceId, $currentId, $newId));
|
119 |
-
}
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
return $arguments;
|
124 |
-
}
|
125 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* This replaces all DefinitionDecorator instances with their equivalent fully
|
21 |
-
* merged Definition instance.
|
22 |
-
*
|
23 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
24 |
-
*/
|
25 |
-
class ResolveDefinitionTemplatesPass implements CompilerPassInterface
|
26 |
-
{
|
27 |
-
private $container;
|
28 |
-
private $compiler;
|
29 |
-
private $formatter;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Process the ContainerBuilder to replace DefinitionDecorator instances with their real Definition instances.
|
33 |
-
*
|
34 |
-
* @param ContainerBuilder $container
|
35 |
-
*/
|
36 |
-
public function process(ContainerBuilder $container)
|
37 |
-
{
|
38 |
-
$this->container = $container;
|
39 |
-
$this->compiler = $container->getCompiler();
|
40 |
-
$this->formatter = $this->compiler->getLoggingFormatter();
|
41 |
-
|
42 |
-
foreach (array_keys($container->getDefinitions()) as $id) {
|
43 |
-
// yes, we are specifically fetching the definition from the
|
44 |
-
// container to ensure we are not operating on stale data
|
45 |
-
$definition = $container->getDefinition($id);
|
46 |
-
if (!$definition instanceof DefinitionDecorator || $definition->isAbstract()) {
|
47 |
-
continue;
|
48 |
-
}
|
49 |
-
|
50 |
-
$this->resolveDefinition($id, $definition);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Resolves the definition.
|
56 |
-
*
|
57 |
-
* @param string $id The definition identifier
|
58 |
-
* @param DefinitionDecorator $definition
|
59 |
-
*
|
60 |
-
* @return Definition
|
61 |
-
*
|
62 |
-
* @throws \RuntimeException When the definition is invalid
|
63 |
-
*/
|
64 |
-
private function resolveDefinition($id, DefinitionDecorator $definition)
|
65 |
-
{
|
66 |
-
if (!$this->container->hasDefinition($parent = $definition->getParent())) {
|
67 |
-
throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $id));
|
68 |
-
}
|
69 |
-
|
70 |
-
$parentDef = $this->container->getDefinition($parent);
|
71 |
-
if ($parentDef instanceof DefinitionDecorator) {
|
72 |
-
$parentDef = $this->resolveDefinition($parent, $parentDef);
|
73 |
-
}
|
74 |
-
|
75 |
-
$this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $id, $parent));
|
76 |
-
$def = new Definition();
|
77 |
-
|
78 |
-
// merge in parent definition
|
79 |
-
// purposely ignored attributes: scope, abstract, tags
|
80 |
-
$def->setClass($parentDef->getClass());
|
81 |
-
$def->setArguments($parentDef->getArguments());
|
82 |
-
$def->setMethodCalls($parentDef->getMethodCalls());
|
83 |
-
$def->setProperties($parentDef->getProperties());
|
84 |
-
$def->setFactoryClass($parentDef->getFactoryClass());
|
85 |
-
$def->setFactoryMethod($parentDef->getFactoryMethod());
|
86 |
-
$def->setFactoryService($parentDef->getFactoryService());
|
87 |
-
$def->setConfigurator($parentDef->getConfigurator());
|
88 |
-
$def->setFile($parentDef->getFile());
|
89 |
-
$def->setPublic($parentDef->isPublic());
|
90 |
-
$def->setLazy($parentDef->isLazy());
|
91 |
-
|
92 |
-
// overwrite with values specified in the decorator
|
93 |
-
$changes = $definition->getChanges();
|
94 |
-
if (isset($changes['class'])) {
|
95 |
-
$def->setClass($definition->getClass());
|
96 |
-
}
|
97 |
-
if (isset($changes['factory_class'])) {
|
98 |
-
$def->setFactoryClass($definition->getFactoryClass());
|
99 |
-
}
|
100 |
-
if (isset($changes['factory_method'])) {
|
101 |
-
$def->setFactoryMethod($definition->getFactoryMethod());
|
102 |
-
}
|
103 |
-
if (isset($changes['factory_service'])) {
|
104 |
-
$def->setFactoryService($definition->getFactoryService());
|
105 |
-
}
|
106 |
-
if (isset($changes['configurator'])) {
|
107 |
-
$def->setConfigurator($definition->getConfigurator());
|
108 |
-
}
|
109 |
-
if (isset($changes['file'])) {
|
110 |
-
$def->setFile($definition->getFile());
|
111 |
-
}
|
112 |
-
if (isset($changes['public'])) {
|
113 |
-
$def->setPublic($definition->isPublic());
|
114 |
-
}
|
115 |
-
if (isset($changes['lazy'])) {
|
116 |
-
$def->setLazy($definition->isLazy());
|
117 |
-
}
|
118 |
-
|
119 |
-
// merge arguments
|
120 |
-
foreach ($definition->getArguments() as $k => $v) {
|
121 |
-
if (is_numeric($k)) {
|
122 |
-
$def->addArgument($v);
|
123 |
-
continue;
|
124 |
-
}
|
125 |
-
|
126 |
-
if (0 !== strpos($k, 'index_')) {
|
127 |
-
throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
|
128 |
-
}
|
129 |
-
|
130 |
-
$index = (int) substr($k, strlen('index_'));
|
131 |
-
$def->replaceArgument($index, $v);
|
132 |
-
}
|
133 |
-
|
134 |
-
// merge properties
|
135 |
-
foreach ($definition->getProperties() as $k => $v) {
|
136 |
-
$def->setProperty($k, $v);
|
137 |
-
}
|
138 |
-
|
139 |
-
// append method calls
|
140 |
-
if (count($calls = $definition->getMethodCalls()) > 0) {
|
141 |
-
$def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
|
142 |
-
}
|
143 |
-
|
144 |
-
// these attributes are always taken from the child
|
145 |
-
$def->setAbstract($definition->isAbstract());
|
146 |
-
$def->setScope($definition->getScope());
|
147 |
-
$def->setTags($definition->getTags());
|
148 |
-
|
149 |
-
// set new definition on container
|
150 |
-
$this->container->setDefinition($id, $def);
|
151 |
-
|
152 |
-
return $def;
|
153 |
-
}
|
154 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\Reference;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Emulates the invalid behavior if the reference is not found within the
|
21 |
-
* container.
|
22 |
-
*
|
23 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
24 |
-
*/
|
25 |
-
class ResolveInvalidReferencesPass implements CompilerPassInterface
|
26 |
-
{
|
27 |
-
private $container;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Process the ContainerBuilder to resolve invalid references.
|
31 |
-
*
|
32 |
-
* @param ContainerBuilder $container
|
33 |
-
*/
|
34 |
-
public function process(ContainerBuilder $container)
|
35 |
-
{
|
36 |
-
$this->container = $container;
|
37 |
-
foreach ($container->getDefinitions() as $definition) {
|
38 |
-
if ($definition->isSynthetic() || $definition->isAbstract()) {
|
39 |
-
continue;
|
40 |
-
}
|
41 |
-
|
42 |
-
$definition->setArguments(
|
43 |
-
$this->processArguments($definition->getArguments())
|
44 |
-
);
|
45 |
-
|
46 |
-
$calls = array();
|
47 |
-
foreach ($definition->getMethodCalls() as $call) {
|
48 |
-
try {
|
49 |
-
$calls[] = array($call[0], $this->processArguments($call[1], true));
|
50 |
-
} catch (RuntimeException $ignore) {
|
51 |
-
// this call is simply removed
|
52 |
-
}
|
53 |
-
}
|
54 |
-
$definition->setMethodCalls($calls);
|
55 |
-
|
56 |
-
$properties = array();
|
57 |
-
foreach ($definition->getProperties() as $name => $value) {
|
58 |
-
try {
|
59 |
-
$value = $this->processArguments(array($value), true);
|
60 |
-
$properties[$name] = reset($value);
|
61 |
-
} catch (RuntimeException $ignore) {
|
62 |
-
// ignore property
|
63 |
-
}
|
64 |
-
}
|
65 |
-
$definition->setProperties($properties);
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Processes arguments to determine invalid references.
|
71 |
-
*
|
72 |
-
* @param array $arguments An array of Reference objects
|
73 |
-
* @param bool $inMethodCall
|
74 |
-
*
|
75 |
-
* @return array
|
76 |
-
*
|
77 |
-
* @throws RuntimeException When the config is invalid
|
78 |
-
*/
|
79 |
-
private function processArguments(array $arguments, $inMethodCall = false)
|
80 |
-
{
|
81 |
-
foreach ($arguments as $k => $argument) {
|
82 |
-
if (is_array($argument)) {
|
83 |
-
$arguments[$k] = $this->processArguments($argument, $inMethodCall);
|
84 |
-
} elseif ($argument instanceof Reference) {
|
85 |
-
$id = (string) $argument;
|
86 |
-
|
87 |
-
$invalidBehavior = $argument->getInvalidBehavior();
|
88 |
-
$exists = $this->container->has($id);
|
89 |
-
|
90 |
-
// resolve invalid behavior
|
91 |
-
if (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
|
92 |
-
$arguments[$k] = null;
|
93 |
-
} elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
|
94 |
-
if ($inMethodCall) {
|
95 |
-
throw new RuntimeException('Method shouldn\'t be called.');
|
96 |
-
}
|
97 |
-
|
98 |
-
$arguments[$k] = null;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
return $arguments;
|
104 |
-
}
|
105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Resolves all parameter placeholders "%somevalue%" to their real values.
|
19 |
-
*
|
20 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
21 |
-
*/
|
22 |
-
class ResolveParameterPlaceHoldersPass implements CompilerPassInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Processes the ContainerBuilder to resolve parameter placeholders.
|
26 |
-
*
|
27 |
-
* @param ContainerBuilder $container
|
28 |
-
*
|
29 |
-
* @throws ParameterNotFoundException
|
30 |
-
*/
|
31 |
-
public function process(ContainerBuilder $container)
|
32 |
-
{
|
33 |
-
$parameterBag = $container->getParameterBag();
|
34 |
-
|
35 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
36 |
-
try {
|
37 |
-
$definition->setClass($parameterBag->resolveValue($definition->getClass()));
|
38 |
-
$definition->setFile($parameterBag->resolveValue($definition->getFile()));
|
39 |
-
$definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
|
40 |
-
|
41 |
-
$calls = array();
|
42 |
-
foreach ($definition->getMethodCalls() as $name => $arguments) {
|
43 |
-
$calls[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($arguments);
|
44 |
-
}
|
45 |
-
$definition->setMethodCalls($calls);
|
46 |
-
|
47 |
-
$definition->setProperties($parameterBag->resolveValue($definition->getProperties()));
|
48 |
-
} catch (ParameterNotFoundException $e) {
|
49 |
-
$e->setSourceId($id);
|
50 |
-
|
51 |
-
throw $e;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
$aliases = array();
|
56 |
-
foreach ($container->getAliases() as $name => $target) {
|
57 |
-
$aliases[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($target);
|
58 |
-
}
|
59 |
-
$container->setAliases($aliases);
|
60 |
-
|
61 |
-
$parameterBag->resolve();
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Alias;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Replaces all references to aliases with references to the actual service.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class ResolveReferencesToAliasesPass implements CompilerPassInterface
|
25 |
-
{
|
26 |
-
private $container;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Processes the ContainerBuilder to replace references to aliases with actual service references.
|
30 |
-
*
|
31 |
-
* @param ContainerBuilder $container
|
32 |
-
*/
|
33 |
-
public function process(ContainerBuilder $container)
|
34 |
-
{
|
35 |
-
$this->container = $container;
|
36 |
-
|
37 |
-
foreach ($container->getDefinitions() as $definition) {
|
38 |
-
if ($definition->isSynthetic() || $definition->isAbstract()) {
|
39 |
-
continue;
|
40 |
-
}
|
41 |
-
|
42 |
-
$definition->setArguments($this->processArguments($definition->getArguments()));
|
43 |
-
$definition->setMethodCalls($this->processArguments($definition->getMethodCalls()));
|
44 |
-
$definition->setProperties($this->processArguments($definition->getProperties()));
|
45 |
-
}
|
46 |
-
|
47 |
-
foreach ($container->getAliases() as $id => $alias) {
|
48 |
-
$aliasId = (string) $alias;
|
49 |
-
if ($aliasId !== $defId = $this->getDefinitionId($aliasId)) {
|
50 |
-
$container->setAlias($id, new Alias($defId, $alias->isPublic()));
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Processes the arguments to replace aliases.
|
57 |
-
*
|
58 |
-
* @param array $arguments An array of References
|
59 |
-
*
|
60 |
-
* @return array An array of References
|
61 |
-
*/
|
62 |
-
private function processArguments(array $arguments)
|
63 |
-
{
|
64 |
-
foreach ($arguments as $k => $argument) {
|
65 |
-
if (is_array($argument)) {
|
66 |
-
$arguments[$k] = $this->processArguments($argument);
|
67 |
-
} elseif ($argument instanceof Reference) {
|
68 |
-
$defId = $this->getDefinitionId($id = (string) $argument);
|
69 |
-
|
70 |
-
if ($defId !== $id) {
|
71 |
-
$arguments[$k] = new Reference($defId, $argument->getInvalidBehavior(), $argument->isStrict());
|
72 |
-
}
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
return $arguments;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Resolves an alias into a definition id.
|
81 |
-
*
|
82 |
-
* @param string $id The definition or alias id to resolve
|
83 |
-
*
|
84 |
-
* @return string The definition id with aliases resolved
|
85 |
-
*/
|
86 |
-
private function getDefinitionId($id)
|
87 |
-
{
|
88 |
-
$seen = array();
|
89 |
-
while ($this->container->hasAlias($id)) {
|
90 |
-
if (isset($seen[$id])) {
|
91 |
-
throw new ServiceCircularReferenceException($id, array_keys($seen));
|
92 |
-
}
|
93 |
-
$seen[$id] = true;
|
94 |
-
$id = (string) $this->container->getAlias($id);
|
95 |
-
}
|
96 |
-
|
97 |
-
return $id;
|
98 |
-
}
|
99 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* This is a directed graph of your services.
|
18 |
-
*
|
19 |
-
* This information can be used by your compiler passes instead of collecting
|
20 |
-
* it themselves which improves performance quite a lot.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class ServiceReferenceGraph
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* @var ServiceReferenceGraphNode[]
|
28 |
-
*/
|
29 |
-
private $nodes = array();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Checks if the graph has a specific node.
|
33 |
-
*
|
34 |
-
* @param string $id Id to check
|
35 |
-
*
|
36 |
-
* @return bool
|
37 |
-
*/
|
38 |
-
public function hasNode($id)
|
39 |
-
{
|
40 |
-
return isset($this->nodes[$id]);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Gets a node by identifier.
|
45 |
-
*
|
46 |
-
* @param string $id The id to retrieve
|
47 |
-
*
|
48 |
-
* @return ServiceReferenceGraphNode The node matching the supplied identifier
|
49 |
-
*
|
50 |
-
* @throws InvalidArgumentException if no node matches the supplied identifier
|
51 |
-
*/
|
52 |
-
public function getNode($id)
|
53 |
-
{
|
54 |
-
if (!isset($this->nodes[$id])) {
|
55 |
-
throw new InvalidArgumentException(sprintf('There is no node with id "%s".', $id));
|
56 |
-
}
|
57 |
-
|
58 |
-
return $this->nodes[$id];
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Returns all nodes.
|
63 |
-
*
|
64 |
-
* @return ServiceReferenceGraphNode[] An array of all ServiceReferenceGraphNode objects
|
65 |
-
*/
|
66 |
-
public function getNodes()
|
67 |
-
{
|
68 |
-
return $this->nodes;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Clears all nodes.
|
73 |
-
*/
|
74 |
-
public function clear()
|
75 |
-
{
|
76 |
-
$this->nodes = array();
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Connects 2 nodes together in the Graph.
|
81 |
-
*
|
82 |
-
* @param string $sourceId
|
83 |
-
* @param string $sourceValue
|
84 |
-
* @param string $destId
|
85 |
-
* @param string $destValue
|
86 |
-
* @param string $reference
|
87 |
-
*/
|
88 |
-
public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null)
|
89 |
-
{
|
90 |
-
$sourceNode = $this->createNode($sourceId, $sourceValue);
|
91 |
-
$destNode = $this->createNode($destId, $destValue);
|
92 |
-
$edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference);
|
93 |
-
|
94 |
-
$sourceNode->addOutEdge($edge);
|
95 |
-
$destNode->addInEdge($edge);
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Creates a graph node.
|
100 |
-
*
|
101 |
-
* @param string $id
|
102 |
-
* @param string $value
|
103 |
-
*
|
104 |
-
* @return ServiceReferenceGraphNode
|
105 |
-
*/
|
106 |
-
private function createNode($id, $value)
|
107 |
-
{
|
108 |
-
if (isset($this->nodes[$id]) && $this->nodes[$id]->getValue() === $value) {
|
109 |
-
return $this->nodes[$id];
|
110 |
-
}
|
111 |
-
|
112 |
-
return $this->nodes[$id] = new ServiceReferenceGraphNode($id, $value);
|
113 |
-
}
|
114 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Represents an edge in your service graph.
|
16 |
-
*
|
17 |
-
* Value is typically a reference.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class ServiceReferenceGraphEdge
|
22 |
-
{
|
23 |
-
private $sourceNode;
|
24 |
-
private $destNode;
|
25 |
-
private $value;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Constructor.
|
29 |
-
*
|
30 |
-
* @param ServiceReferenceGraphNode $sourceNode
|
31 |
-
* @param ServiceReferenceGraphNode $destNode
|
32 |
-
* @param string $value
|
33 |
-
*/
|
34 |
-
public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null)
|
35 |
-
{
|
36 |
-
$this->sourceNode = $sourceNode;
|
37 |
-
$this->destNode = $destNode;
|
38 |
-
$this->value = $value;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Returns the value of the edge.
|
43 |
-
*
|
44 |
-
* @return ServiceReferenceGraphNode
|
45 |
-
*/
|
46 |
-
public function getValue()
|
47 |
-
{
|
48 |
-
return $this->value;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Returns the source node.
|
53 |
-
*
|
54 |
-
* @return ServiceReferenceGraphNode
|
55 |
-
*/
|
56 |
-
public function getSourceNode()
|
57 |
-
{
|
58 |
-
return $this->sourceNode;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Returns the destination node.
|
63 |
-
*
|
64 |
-
* @return ServiceReferenceGraphNode
|
65 |
-
*/
|
66 |
-
public function getDestNode()
|
67 |
-
{
|
68 |
-
return $this->destNode;
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php
DELETED
@@ -1,122 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Compiler;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\Alias;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Represents a node in your service graph.
|
19 |
-
*
|
20 |
-
* Value is typically a definition, or an alias.
|
21 |
-
*
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*/
|
24 |
-
class ServiceReferenceGraphNode
|
25 |
-
{
|
26 |
-
private $id;
|
27 |
-
private $inEdges = array();
|
28 |
-
private $outEdges = array();
|
29 |
-
private $value;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Constructor.
|
33 |
-
*
|
34 |
-
* @param string $id The node identifier
|
35 |
-
* @param mixed $value The node value
|
36 |
-
*/
|
37 |
-
public function __construct($id, $value)
|
38 |
-
{
|
39 |
-
$this->id = $id;
|
40 |
-
$this->value = $value;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Adds an in edge to this node.
|
45 |
-
*
|
46 |
-
* @param ServiceReferenceGraphEdge $edge
|
47 |
-
*/
|
48 |
-
public function addInEdge(ServiceReferenceGraphEdge $edge)
|
49 |
-
{
|
50 |
-
$this->inEdges[] = $edge;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Adds an out edge to this node.
|
55 |
-
*
|
56 |
-
* @param ServiceReferenceGraphEdge $edge
|
57 |
-
*/
|
58 |
-
public function addOutEdge(ServiceReferenceGraphEdge $edge)
|
59 |
-
{
|
60 |
-
$this->outEdges[] = $edge;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Checks if the value of this node is an Alias.
|
65 |
-
*
|
66 |
-
* @return bool True if the value is an Alias instance
|
67 |
-
*/
|
68 |
-
public function isAlias()
|
69 |
-
{
|
70 |
-
return $this->value instanceof Alias;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Checks if the value of this node is a Definition.
|
75 |
-
*
|
76 |
-
* @return bool True if the value is a Definition instance
|
77 |
-
*/
|
78 |
-
public function isDefinition()
|
79 |
-
{
|
80 |
-
return $this->value instanceof Definition;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Returns the identifier.
|
85 |
-
*
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
public function getId()
|
89 |
-
{
|
90 |
-
return $this->id;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Returns the in edges.
|
95 |
-
*
|
96 |
-
* @return array The in ServiceReferenceGraphEdge array
|
97 |
-
*/
|
98 |
-
public function getInEdges()
|
99 |
-
{
|
100 |
-
return $this->inEdges;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Returns the out edges.
|
105 |
-
*
|
106 |
-
* @return array The out ServiceReferenceGraphEdge array
|
107 |
-
*/
|
108 |
-
public function getOutEdges()
|
109 |
-
{
|
110 |
-
return $this->outEdges;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Returns the value of this Node.
|
115 |
-
*
|
116 |
-
* @return mixed The value
|
117 |
-
*/
|
118 |
-
public function getValue()
|
119 |
-
{
|
120 |
-
return $this->value;
|
121 |
-
}
|
122 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Container.php
DELETED
@@ -1,567 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
16 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
17 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
18 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
19 |
-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
20 |
-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
21 |
-
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Container is a dependency injection container.
|
25 |
-
*
|
26 |
-
* It gives access to object instances (services).
|
27 |
-
*
|
28 |
-
* Services and parameters are simple key/pair stores.
|
29 |
-
*
|
30 |
-
* Parameter and service keys are case insensitive.
|
31 |
-
*
|
32 |
-
* A service id can contain lowercased letters, digits, underscores, and dots.
|
33 |
-
* Underscores are used to separate words, and dots to group services
|
34 |
-
* under namespaces:
|
35 |
-
*
|
36 |
-
* <ul>
|
37 |
-
* <li>request</li>
|
38 |
-
* <li>mysql_session_storage</li>
|
39 |
-
* <li>symfony.mysql_session_storage</li>
|
40 |
-
* </ul>
|
41 |
-
*
|
42 |
-
* A service can also be defined by creating a method named
|
43 |
-
* getXXXService(), where XXX is the camelized version of the id:
|
44 |
-
*
|
45 |
-
* <ul>
|
46 |
-
* <li>request -> getRequestService()</li>
|
47 |
-
* <li>mysql_session_storage -> getMysqlSessionStorageService()</li>
|
48 |
-
* <li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
|
49 |
-
* </ul>
|
50 |
-
*
|
51 |
-
* The container can have three possible behaviors when a service does not exist:
|
52 |
-
*
|
53 |
-
* * EXCEPTION_ON_INVALID_REFERENCE: Throws an exception (the default)
|
54 |
-
* * NULL_ON_INVALID_REFERENCE: Returns null
|
55 |
-
* * IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference
|
56 |
-
* (for instance, ignore a setter if the service does not exist)
|
57 |
-
*
|
58 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
59 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
60 |
-
*
|
61 |
-
* @api
|
62 |
-
*/
|
63 |
-
class Container implements IntrospectableContainerInterface
|
64 |
-
{
|
65 |
-
/**
|
66 |
-
* @var ParameterBagInterface
|
67 |
-
*/
|
68 |
-
protected $parameterBag;
|
69 |
-
|
70 |
-
protected $services = array();
|
71 |
-
protected $methodMap = array();
|
72 |
-
protected $aliases = array();
|
73 |
-
protected $scopes = array();
|
74 |
-
protected $scopeChildren = array();
|
75 |
-
protected $scopedServices = array();
|
76 |
-
protected $scopeStacks = array();
|
77 |
-
protected $loading = array();
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Constructor.
|
81 |
-
*
|
82 |
-
* @param ParameterBagInterface $parameterBag A ParameterBagInterface instance
|
83 |
-
*
|
84 |
-
* @api
|
85 |
-
*/
|
86 |
-
public function __construct(ParameterBagInterface $parameterBag = null)
|
87 |
-
{
|
88 |
-
$this->parameterBag = $parameterBag ?: new ParameterBag();
|
89 |
-
|
90 |
-
$this->set('service_container', $this);
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Compiles the container.
|
95 |
-
*
|
96 |
-
* This method does two things:
|
97 |
-
*
|
98 |
-
* * Parameter values are resolved;
|
99 |
-
* * The parameter bag is frozen.
|
100 |
-
*
|
101 |
-
* @api
|
102 |
-
*/
|
103 |
-
public function compile()
|
104 |
-
{
|
105 |
-
$this->parameterBag->resolve();
|
106 |
-
|
107 |
-
$this->parameterBag = new FrozenParameterBag($this->parameterBag->all());
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Returns true if the container parameter bag are frozen.
|
112 |
-
*
|
113 |
-
* @return bool true if the container parameter bag are frozen, false otherwise
|
114 |
-
*
|
115 |
-
* @api
|
116 |
-
*/
|
117 |
-
public function isFrozen()
|
118 |
-
{
|
119 |
-
return $this->parameterBag instanceof FrozenParameterBag;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Gets the service container parameter bag.
|
124 |
-
*
|
125 |
-
* @return ParameterBagInterface A ParameterBagInterface instance
|
126 |
-
*
|
127 |
-
* @api
|
128 |
-
*/
|
129 |
-
public function getParameterBag()
|
130 |
-
{
|
131 |
-
return $this->parameterBag;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Gets a parameter.
|
136 |
-
*
|
137 |
-
* @param string $name The parameter name
|
138 |
-
*
|
139 |
-
* @return mixed The parameter value
|
140 |
-
*
|
141 |
-
* @throws InvalidArgumentException if the parameter is not defined
|
142 |
-
*
|
143 |
-
* @api
|
144 |
-
*/
|
145 |
-
public function getParameter($name)
|
146 |
-
{
|
147 |
-
return $this->parameterBag->get($name);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Checks if a parameter exists.
|
152 |
-
*
|
153 |
-
* @param string $name The parameter name
|
154 |
-
*
|
155 |
-
* @return bool The presence of parameter in container
|
156 |
-
*
|
157 |
-
* @api
|
158 |
-
*/
|
159 |
-
public function hasParameter($name)
|
160 |
-
{
|
161 |
-
return $this->parameterBag->has($name);
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Sets a parameter.
|
166 |
-
*
|
167 |
-
* @param string $name The parameter name
|
168 |
-
* @param mixed $value The parameter value
|
169 |
-
*
|
170 |
-
* @api
|
171 |
-
*/
|
172 |
-
public function setParameter($name, $value)
|
173 |
-
{
|
174 |
-
$this->parameterBag->set($name, $value);
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Sets a service.
|
179 |
-
*
|
180 |
-
* Setting a service to null resets the service: has() returns false and get()
|
181 |
-
* behaves in the same way as if the service was never created.
|
182 |
-
*
|
183 |
-
* @param string $id The service identifier
|
184 |
-
* @param object $service The service instance
|
185 |
-
* @param string $scope The scope of the service
|
186 |
-
*
|
187 |
-
* @throws RuntimeException When trying to set a service in an inactive scope
|
188 |
-
* @throws InvalidArgumentException When trying to set a service in the prototype scope
|
189 |
-
*
|
190 |
-
* @api
|
191 |
-
*/
|
192 |
-
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
|
193 |
-
{
|
194 |
-
if (self::SCOPE_PROTOTYPE === $scope) {
|
195 |
-
throw new InvalidArgumentException(sprintf('You cannot set service "%s" of scope "prototype".', $id));
|
196 |
-
}
|
197 |
-
|
198 |
-
$id = strtolower($id);
|
199 |
-
|
200 |
-
if ('service_container' === $id) {
|
201 |
-
// BC: 'service_container' is no longer a self-reference but always
|
202 |
-
// $this, so ignore this call.
|
203 |
-
// @todo Throw InvalidArgumentException in next major release.
|
204 |
-
return;
|
205 |
-
}
|
206 |
-
if (self::SCOPE_CONTAINER !== $scope) {
|
207 |
-
if (!isset($this->scopedServices[$scope])) {
|
208 |
-
throw new RuntimeException(sprintf('You cannot set service "%s" of inactive scope.', $id));
|
209 |
-
}
|
210 |
-
|
211 |
-
$this->scopedServices[$scope][$id] = $service;
|
212 |
-
}
|
213 |
-
|
214 |
-
$this->services[$id] = $service;
|
215 |
-
|
216 |
-
if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) {
|
217 |
-
$this->$method();
|
218 |
-
}
|
219 |
-
|
220 |
-
if (self::SCOPE_CONTAINER !== $scope && null === $service) {
|
221 |
-
unset($this->scopedServices[$scope][$id]);
|
222 |
-
}
|
223 |
-
|
224 |
-
if (null === $service) {
|
225 |
-
unset($this->services[$id]);
|
226 |
-
}
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Returns true if the given service is defined.
|
231 |
-
*
|
232 |
-
* @param string $id The service identifier
|
233 |
-
*
|
234 |
-
* @return bool true if the service is defined, false otherwise
|
235 |
-
*
|
236 |
-
* @api
|
237 |
-
*/
|
238 |
-
public function has($id)
|
239 |
-
{
|
240 |
-
$id = strtolower($id);
|
241 |
-
|
242 |
-
if ('service_container' === $id) {
|
243 |
-
return true;
|
244 |
-
}
|
245 |
-
|
246 |
-
return isset($this->services[$id])
|
247 |
-
|| array_key_exists($id, $this->services)
|
248 |
-
|| isset($this->aliases[$id])
|
249 |
-
|| method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')
|
250 |
-
;
|
251 |
-
}
|
252 |
-
|
253 |
-
/**
|
254 |
-
* Gets a service.
|
255 |
-
*
|
256 |
-
* If a service is defined both through a set() method and
|
257 |
-
* with a get{$id}Service() method, the former has always precedence.
|
258 |
-
*
|
259 |
-
* @param string $id The service identifier
|
260 |
-
* @param int $invalidBehavior The behavior when the service does not exist
|
261 |
-
*
|
262 |
-
* @return object The associated service
|
263 |
-
*
|
264 |
-
* @throws InvalidArgumentException if the service is not defined
|
265 |
-
* @throws ServiceCircularReferenceException When a circular reference is detected
|
266 |
-
* @throws ServiceNotFoundException When the service is not defined
|
267 |
-
* @throws \Exception if an exception has been thrown when the service has been resolved
|
268 |
-
*
|
269 |
-
* @see Reference
|
270 |
-
*
|
271 |
-
* @api
|
272 |
-
*/
|
273 |
-
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
|
274 |
-
{
|
275 |
-
// Attempt to retrieve the service by checking first aliases then
|
276 |
-
// available services. Service IDs are case insensitive, however since
|
277 |
-
// this method can be called thousands of times during a request, avoid
|
278 |
-
// calling strtolower() unless necessary.
|
279 |
-
foreach (array(false, true) as $strtolower) {
|
280 |
-
if ($strtolower) {
|
281 |
-
$id = strtolower($id);
|
282 |
-
}
|
283 |
-
if ('service_container' === $id) {
|
284 |
-
return $this;
|
285 |
-
}
|
286 |
-
if (isset($this->aliases[$id])) {
|
287 |
-
$id = $this->aliases[$id];
|
288 |
-
}
|
289 |
-
// Re-use shared service instance if it exists.
|
290 |
-
if (isset($this->services[$id]) || array_key_exists($id, $this->services)) {
|
291 |
-
return $this->services[$id];
|
292 |
-
}
|
293 |
-
}
|
294 |
-
|
295 |
-
if (isset($this->loading[$id])) {
|
296 |
-
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
|
297 |
-
}
|
298 |
-
|
299 |
-
if (isset($this->methodMap[$id])) {
|
300 |
-
$method = $this->methodMap[$id];
|
301 |
-
} elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) {
|
302 |
-
// $method is set to the right value, proceed
|
303 |
-
} else {
|
304 |
-
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
|
305 |
-
if (!$id) {
|
306 |
-
throw new ServiceNotFoundException($id);
|
307 |
-
}
|
308 |
-
|
309 |
-
$alternatives = array();
|
310 |
-
foreach (array_keys($this->services) as $key) {
|
311 |
-
$lev = levenshtein($id, $key);
|
312 |
-
if ($lev <= strlen($id) / 3 || false !== strpos($key, $id)) {
|
313 |
-
$alternatives[] = $key;
|
314 |
-
}
|
315 |
-
}
|
316 |
-
|
317 |
-
throw new ServiceNotFoundException($id, null, null, $alternatives);
|
318 |
-
}
|
319 |
-
|
320 |
-
return;
|
321 |
-
}
|
322 |
-
|
323 |
-
$this->loading[$id] = true;
|
324 |
-
|
325 |
-
try {
|
326 |
-
$service = $this->$method();
|
327 |
-
} catch (\Exception $e) {
|
328 |
-
unset($this->loading[$id]);
|
329 |
-
|
330 |
-
if (array_key_exists($id, $this->services)) {
|
331 |
-
unset($this->services[$id]);
|
332 |
-
}
|
333 |
-
|
334 |
-
if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
|
335 |
-
return;
|
336 |
-
}
|
337 |
-
|
338 |
-
throw $e;
|
339 |
-
}
|
340 |
-
|
341 |
-
unset($this->loading[$id]);
|
342 |
-
|
343 |
-
return $service;
|
344 |
-
}
|
345 |
-
|
346 |
-
/**
|
347 |
-
* Returns true if the given service has actually been initialized.
|
348 |
-
*
|
349 |
-
* @param string $id The service identifier
|
350 |
-
*
|
351 |
-
* @return bool true if service has already been initialized, false otherwise
|
352 |
-
*/
|
353 |
-
public function initialized($id)
|
354 |
-
{
|
355 |
-
$id = strtolower($id);
|
356 |
-
|
357 |
-
if ('service_container' === $id) {
|
358 |
-
// BC: 'service_container' was a synthetic service previously.
|
359 |
-
// @todo Change to false in next major release.
|
360 |
-
return true;
|
361 |
-
}
|
362 |
-
|
363 |
-
if (isset($this->aliases[$id])) {
|
364 |
-
$id = $this->aliases[$id];
|
365 |
-
}
|
366 |
-
|
367 |
-
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Gets all service ids.
|
372 |
-
*
|
373 |
-
* @return array An array of all defined service ids
|
374 |
-
*/
|
375 |
-
public function getServiceIds()
|
376 |
-
{
|
377 |
-
$ids = array();
|
378 |
-
$r = new \ReflectionClass($this);
|
379 |
-
foreach ($r->getMethods() as $method) {
|
380 |
-
if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
|
381 |
-
$ids[] = self::underscore($match[1]);
|
382 |
-
}
|
383 |
-
}
|
384 |
-
$ids[] = 'service_container';
|
385 |
-
|
386 |
-
return array_unique(array_merge($ids, array_keys($this->services)));
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* This is called when you enter a scope.
|
391 |
-
*
|
392 |
-
* @param string $name
|
393 |
-
*
|
394 |
-
* @throws RuntimeException When the parent scope is inactive
|
395 |
-
* @throws InvalidArgumentException When the scope does not exist
|
396 |
-
*
|
397 |
-
* @api
|
398 |
-
*/
|
399 |
-
public function enterScope($name)
|
400 |
-
{
|
401 |
-
if (!isset($this->scopes[$name])) {
|
402 |
-
throw new InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name));
|
403 |
-
}
|
404 |
-
|
405 |
-
if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) {
|
406 |
-
throw new RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name]));
|
407 |
-
}
|
408 |
-
|
409 |
-
// check if a scope of this name is already active, if so we need to
|
410 |
-
// remove all services of this scope, and those of any of its child
|
411 |
-
// scopes from the global services map
|
412 |
-
if (isset($this->scopedServices[$name])) {
|
413 |
-
$services = array($this->services, $name => $this->scopedServices[$name]);
|
414 |
-
unset($this->scopedServices[$name]);
|
415 |
-
|
416 |
-
foreach ($this->scopeChildren[$name] as $child) {
|
417 |
-
if (isset($this->scopedServices[$child])) {
|
418 |
-
$services[$child] = $this->scopedServices[$child];
|
419 |
-
unset($this->scopedServices[$child]);
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
// update global map
|
424 |
-
$this->services = call_user_func_array('array_diff_key', $services);
|
425 |
-
array_shift($services);
|
426 |
-
|
427 |
-
// add stack entry for this scope so we can restore the removed services later
|
428 |
-
if (!isset($this->scopeStacks[$name])) {
|
429 |
-
$this->scopeStacks[$name] = new \SplStack();
|
430 |
-
}
|
431 |
-
$this->scopeStacks[$name]->push($services);
|
432 |
-
}
|
433 |
-
|
434 |
-
$this->scopedServices[$name] = array();
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* This is called to leave the current scope, and move back to the parent
|
439 |
-
* scope.
|
440 |
-
*
|
441 |
-
* @param string $name The name of the scope to leave
|
442 |
-
*
|
443 |
-
* @throws InvalidArgumentException if the scope is not active
|
444 |
-
*
|
445 |
-
* @api
|
446 |
-
*/
|
447 |
-
public function leaveScope($name)
|
448 |
-
{
|
449 |
-
if (!isset($this->scopedServices[$name])) {
|
450 |
-
throw new InvalidArgumentException(sprintf('The scope "%s" is not active.', $name));
|
451 |
-
}
|
452 |
-
|
453 |
-
// remove all services of this scope, or any of its child scopes from
|
454 |
-
// the global service map
|
455 |
-
$services = array($this->services, $this->scopedServices[$name]);
|
456 |
-
unset($this->scopedServices[$name]);
|
457 |
-
foreach ($this->scopeChildren[$name] as $child) {
|
458 |
-
if (!isset($this->scopedServices[$child])) {
|
459 |
-
continue;
|
460 |
-
}
|
461 |
-
|
462 |
-
$services[] = $this->scopedServices[$child];
|
463 |
-
unset($this->scopedServices[$child]);
|
464 |
-
}
|
465 |
-
$this->services = call_user_func_array('array_diff_key', $services);
|
466 |
-
|
467 |
-
// check if we need to restore services of a previous scope of this type
|
468 |
-
if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) {
|
469 |
-
$services = $this->scopeStacks[$name]->pop();
|
470 |
-
$this->scopedServices += $services;
|
471 |
-
|
472 |
-
foreach ($services as $array) {
|
473 |
-
foreach ($array as $id => $service) {
|
474 |
-
$this->set($id, $service, $name);
|
475 |
-
}
|
476 |
-
}
|
477 |
-
}
|
478 |
-
}
|
479 |
-
|
480 |
-
/**
|
481 |
-
* Adds a scope to the container.
|
482 |
-
*
|
483 |
-
* @param ScopeInterface $scope
|
484 |
-
*
|
485 |
-
* @throws InvalidArgumentException
|
486 |
-
*
|
487 |
-
* @api
|
488 |
-
*/
|
489 |
-
public function addScope(ScopeInterface $scope)
|
490 |
-
{
|
491 |
-
$name = $scope->getName();
|
492 |
-
$parentScope = $scope->getParentName();
|
493 |
-
|
494 |
-
if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) {
|
495 |
-
throw new InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name));
|
496 |
-
}
|
497 |
-
if (isset($this->scopes[$name])) {
|
498 |
-
throw new InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name));
|
499 |
-
}
|
500 |
-
if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) {
|
501 |
-
throw new InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope));
|
502 |
-
}
|
503 |
-
|
504 |
-
$this->scopes[$name] = $parentScope;
|
505 |
-
$this->scopeChildren[$name] = array();
|
506 |
-
|
507 |
-
// normalize the child relations
|
508 |
-
while ($parentScope !== self::SCOPE_CONTAINER) {
|
509 |
-
$this->scopeChildren[$parentScope][] = $name;
|
510 |
-
$parentScope = $this->scopes[$parentScope];
|
511 |
-
}
|
512 |
-
}
|
513 |
-
|
514 |
-
/**
|
515 |
-
* Returns whether this container has a certain scope.
|
516 |
-
*
|
517 |
-
* @param string $name The name of the scope
|
518 |
-
*
|
519 |
-
* @return bool
|
520 |
-
*
|
521 |
-
* @api
|
522 |
-
*/
|
523 |
-
public function hasScope($name)
|
524 |
-
{
|
525 |
-
return isset($this->scopes[$name]);
|
526 |
-
}
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Returns whether this scope is currently active.
|
530 |
-
*
|
531 |
-
* This does not actually check if the passed scope actually exists.
|
532 |
-
*
|
533 |
-
* @param string $name
|
534 |
-
*
|
535 |
-
* @return bool
|
536 |
-
*
|
537 |
-
* @api
|
538 |
-
*/
|
539 |
-
public function isScopeActive($name)
|
540 |
-
{
|
541 |
-
return isset($this->scopedServices[$name]);
|
542 |
-
}
|
543 |
-
|
544 |
-
/**
|
545 |
-
* Camelizes a string.
|
546 |
-
*
|
547 |
-
* @param string $id A string to camelize
|
548 |
-
*
|
549 |
-
* @return string The camelized string
|
550 |
-
*/
|
551 |
-
public static function camelize($id)
|
552 |
-
{
|
553 |
-
return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ ', '\\' => '_ '))), array(' ' => ''));
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* A string to underscore.
|
558 |
-
*
|
559 |
-
* @param string $id The string to underscore
|
560 |
-
*
|
561 |
-
* @return string The underscored string
|
562 |
-
*/
|
563 |
-
public static function underscore($id)
|
564 |
-
{
|
565 |
-
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
|
566 |
-
}
|
567 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ContainerAware.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* A simple implementation of ContainerAwareInterface.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
abstract class ContainerAware implements ContainerAwareInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* @var ContainerInterface
|
25 |
-
*
|
26 |
-
* @api
|
27 |
-
*/
|
28 |
-
protected $container;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Sets the Container associated with this Controller.
|
32 |
-
*
|
33 |
-
* @param ContainerInterface $container A ContainerInterface instance
|
34 |
-
*
|
35 |
-
* @api
|
36 |
-
*/
|
37 |
-
public function setContainer(ContainerInterface $container = null)
|
38 |
-
{
|
39 |
-
$this->container = $container;
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ContainerAwareInterface.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* ContainerAwareInterface should be implemented by classes that depends on a Container.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
interface ContainerAwareInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Sets the Container.
|
25 |
-
*
|
26 |
-
* @param ContainerInterface|null $container A ContainerInterface instance or null
|
27 |
-
*
|
28 |
-
* @api
|
29 |
-
*/
|
30 |
-
public function setContainer(ContainerInterface $container = null);
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ContainerAwareTrait.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* ContainerAware trait.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
trait ContainerAwareTrait
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var ContainerInterface
|
23 |
-
*/
|
24 |
-
protected $container;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Sets the Container associated with this Controller.
|
28 |
-
*
|
29 |
-
* @param ContainerInterface $container A ContainerInterface instance
|
30 |
-
*/
|
31 |
-
public function setContainer(ContainerInterface $container = null)
|
32 |
-
{
|
33 |
-
$this->container = $container;
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ContainerBuilder.php
DELETED
@@ -1,1168 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Compiler\Compiler;
|
15 |
-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
16 |
-
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
17 |
-
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
|
18 |
-
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
19 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
20 |
-
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
21 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
22 |
-
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
23 |
-
use Symfony\Component\Config\Resource\FileResource;
|
24 |
-
use Symfony\Component\Config\Resource\ResourceInterface;
|
25 |
-
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
|
26 |
-
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
|
27 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* ContainerBuilder is a DI container that provides an API to easily describe services.
|
31 |
-
*
|
32 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
33 |
-
*
|
34 |
-
* @api
|
35 |
-
*/
|
36 |
-
class ContainerBuilder extends Container implements TaggedContainerInterface
|
37 |
-
{
|
38 |
-
/**
|
39 |
-
* @var ExtensionInterface[]
|
40 |
-
*/
|
41 |
-
private $extensions = array();
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var ExtensionInterface[]
|
45 |
-
*/
|
46 |
-
private $extensionsByNs = array();
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var Definition[]
|
50 |
-
*/
|
51 |
-
private $definitions = array();
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var Definition[]
|
55 |
-
*/
|
56 |
-
private $obsoleteDefinitions = array();
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @var Alias[]
|
60 |
-
*/
|
61 |
-
private $aliasDefinitions = array();
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @var ResourceInterface[]
|
65 |
-
*/
|
66 |
-
private $resources = array();
|
67 |
-
|
68 |
-
private $extensionConfigs = array();
|
69 |
-
|
70 |
-
/**
|
71 |
-
* @var Compiler
|
72 |
-
*/
|
73 |
-
private $compiler;
|
74 |
-
|
75 |
-
private $trackResources = true;
|
76 |
-
|
77 |
-
/**
|
78 |
-
* @var InstantiatorInterface|null
|
79 |
-
*/
|
80 |
-
private $proxyInstantiator;
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @var ExpressionLanguage|null
|
84 |
-
*/
|
85 |
-
private $expressionLanguage;
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Sets the track resources flag.
|
89 |
-
*
|
90 |
-
* If you are not using the loaders and therefore don't want
|
91 |
-
* to depend on the Config component, set this flag to false.
|
92 |
-
*
|
93 |
-
* @param bool $track true if you want to track resources, false otherwise
|
94 |
-
*/
|
95 |
-
public function setResourceTracking($track)
|
96 |
-
{
|
97 |
-
$this->trackResources = (bool) $track;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Checks if resources are tracked.
|
102 |
-
*
|
103 |
-
* @return bool true if resources are tracked, false otherwise
|
104 |
-
*/
|
105 |
-
public function isTrackingResources()
|
106 |
-
{
|
107 |
-
return $this->trackResources;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Sets the instantiator to be used when fetching proxies.
|
112 |
-
*
|
113 |
-
* @param InstantiatorInterface $proxyInstantiator
|
114 |
-
*/
|
115 |
-
public function setProxyInstantiator(InstantiatorInterface $proxyInstantiator)
|
116 |
-
{
|
117 |
-
$this->proxyInstantiator = $proxyInstantiator;
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Registers an extension.
|
122 |
-
*
|
123 |
-
* @param ExtensionInterface $extension An extension instance
|
124 |
-
*
|
125 |
-
* @api
|
126 |
-
*/
|
127 |
-
public function registerExtension(ExtensionInterface $extension)
|
128 |
-
{
|
129 |
-
$this->extensions[$extension->getAlias()] = $extension;
|
130 |
-
|
131 |
-
if (false !== $extension->getNamespace()) {
|
132 |
-
$this->extensionsByNs[$extension->getNamespace()] = $extension;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Returns an extension by alias or namespace.
|
138 |
-
*
|
139 |
-
* @param string $name An alias or a namespace
|
140 |
-
*
|
141 |
-
* @return ExtensionInterface An extension instance
|
142 |
-
*
|
143 |
-
* @throws LogicException if the extension is not registered
|
144 |
-
*
|
145 |
-
* @api
|
146 |
-
*/
|
147 |
-
public function getExtension($name)
|
148 |
-
{
|
149 |
-
if (isset($this->extensions[$name])) {
|
150 |
-
return $this->extensions[$name];
|
151 |
-
}
|
152 |
-
|
153 |
-
if (isset($this->extensionsByNs[$name])) {
|
154 |
-
return $this->extensionsByNs[$name];
|
155 |
-
}
|
156 |
-
|
157 |
-
throw new LogicException(sprintf('Container extension "%s" is not registered', $name));
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Returns all registered extensions.
|
162 |
-
*
|
163 |
-
* @return ExtensionInterface[] An array of ExtensionInterface
|
164 |
-
*
|
165 |
-
* @api
|
166 |
-
*/
|
167 |
-
public function getExtensions()
|
168 |
-
{
|
169 |
-
return $this->extensions;
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Checks if we have an extension.
|
174 |
-
*
|
175 |
-
* @param string $name The name of the extension
|
176 |
-
*
|
177 |
-
* @return bool If the extension exists
|
178 |
-
*
|
179 |
-
* @api
|
180 |
-
*/
|
181 |
-
public function hasExtension($name)
|
182 |
-
{
|
183 |
-
return isset($this->extensions[$name]) || isset($this->extensionsByNs[$name]);
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Returns an array of resources loaded to build this configuration.
|
188 |
-
*
|
189 |
-
* @return ResourceInterface[] An array of resources
|
190 |
-
*
|
191 |
-
* @api
|
192 |
-
*/
|
193 |
-
public function getResources()
|
194 |
-
{
|
195 |
-
return array_unique($this->resources);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Adds a resource for this configuration.
|
200 |
-
*
|
201 |
-
* @param ResourceInterface $resource A resource instance
|
202 |
-
*
|
203 |
-
* @return ContainerBuilder The current instance
|
204 |
-
*
|
205 |
-
* @api
|
206 |
-
*/
|
207 |
-
public function addResource(ResourceInterface $resource)
|
208 |
-
{
|
209 |
-
if (!$this->trackResources) {
|
210 |
-
return $this;
|
211 |
-
}
|
212 |
-
|
213 |
-
$this->resources[] = $resource;
|
214 |
-
|
215 |
-
return $this;
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Sets the resources for this configuration.
|
220 |
-
*
|
221 |
-
* @param ResourceInterface[] $resources An array of resources
|
222 |
-
*
|
223 |
-
* @return ContainerBuilder The current instance
|
224 |
-
*
|
225 |
-
* @api
|
226 |
-
*/
|
227 |
-
public function setResources(array $resources)
|
228 |
-
{
|
229 |
-
if (!$this->trackResources) {
|
230 |
-
return $this;
|
231 |
-
}
|
232 |
-
|
233 |
-
$this->resources = $resources;
|
234 |
-
|
235 |
-
return $this;
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Adds the object class hierarchy as resources.
|
240 |
-
*
|
241 |
-
* @param object $object An object instance
|
242 |
-
*
|
243 |
-
* @return ContainerBuilder The current instance
|
244 |
-
*
|
245 |
-
* @api
|
246 |
-
*/
|
247 |
-
public function addObjectResource($object)
|
248 |
-
{
|
249 |
-
if ($this->trackResources) {
|
250 |
-
$this->addClassResource(new \ReflectionClass($object));
|
251 |
-
}
|
252 |
-
|
253 |
-
return $this;
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Adds the given class hierarchy as resources.
|
258 |
-
*
|
259 |
-
* @param \ReflectionClass $class
|
260 |
-
*
|
261 |
-
* @return ContainerBuilder The current instance
|
262 |
-
*/
|
263 |
-
public function addClassResource(\ReflectionClass $class)
|
264 |
-
{
|
265 |
-
if (!$this->trackResources) {
|
266 |
-
return $this;
|
267 |
-
}
|
268 |
-
|
269 |
-
do {
|
270 |
-
$this->addResource(new FileResource($class->getFileName()));
|
271 |
-
} while ($class = $class->getParentClass());
|
272 |
-
|
273 |
-
return $this;
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Loads the configuration for an extension.
|
278 |
-
*
|
279 |
-
* @param string $extension The extension alias or namespace
|
280 |
-
* @param array $values An array of values that customizes the extension
|
281 |
-
*
|
282 |
-
* @return ContainerBuilder The current instance
|
283 |
-
*
|
284 |
-
* @throws BadMethodCallException When this ContainerBuilder is frozen
|
285 |
-
* @throws \LogicException if the container is frozen
|
286 |
-
*
|
287 |
-
* @api
|
288 |
-
*/
|
289 |
-
public function loadFromExtension($extension, array $values = array())
|
290 |
-
{
|
291 |
-
if ($this->isFrozen()) {
|
292 |
-
throw new BadMethodCallException('Cannot load from an extension on a frozen container.');
|
293 |
-
}
|
294 |
-
|
295 |
-
$namespace = $this->getExtension($extension)->getAlias();
|
296 |
-
|
297 |
-
$this->extensionConfigs[$namespace][] = $values;
|
298 |
-
|
299 |
-
return $this;
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Adds a compiler pass.
|
304 |
-
*
|
305 |
-
* @param CompilerPassInterface $pass A compiler pass
|
306 |
-
* @param string $type The type of compiler pass
|
307 |
-
*
|
308 |
-
* @return ContainerBuilder The current instance
|
309 |
-
*
|
310 |
-
* @api
|
311 |
-
*/
|
312 |
-
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
|
313 |
-
{
|
314 |
-
$this->getCompiler()->addPass($pass, $type);
|
315 |
-
|
316 |
-
$this->addObjectResource($pass);
|
317 |
-
|
318 |
-
return $this;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Returns the compiler pass config which can then be modified.
|
323 |
-
*
|
324 |
-
* @return PassConfig The compiler pass config
|
325 |
-
*
|
326 |
-
* @api
|
327 |
-
*/
|
328 |
-
public function getCompilerPassConfig()
|
329 |
-
{
|
330 |
-
return $this->getCompiler()->getPassConfig();
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Returns the compiler.
|
335 |
-
*
|
336 |
-
* @return Compiler The compiler
|
337 |
-
*
|
338 |
-
* @api
|
339 |
-
*/
|
340 |
-
public function getCompiler()
|
341 |
-
{
|
342 |
-
if (null === $this->compiler) {
|
343 |
-
$this->compiler = new Compiler();
|
344 |
-
}
|
345 |
-
|
346 |
-
return $this->compiler;
|
347 |
-
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* Returns all Scopes.
|
351 |
-
*
|
352 |
-
* @return array An array of scopes
|
353 |
-
*
|
354 |
-
* @api
|
355 |
-
*/
|
356 |
-
public function getScopes()
|
357 |
-
{
|
358 |
-
return $this->scopes;
|
359 |
-
}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Returns all Scope children.
|
363 |
-
*
|
364 |
-
* @return array An array of scope children.
|
365 |
-
*
|
366 |
-
* @api
|
367 |
-
*/
|
368 |
-
public function getScopeChildren()
|
369 |
-
{
|
370 |
-
return $this->scopeChildren;
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Sets a service.
|
375 |
-
*
|
376 |
-
* @param string $id The service identifier
|
377 |
-
* @param object $service The service instance
|
378 |
-
* @param string $scope The scope
|
379 |
-
*
|
380 |
-
* @throws BadMethodCallException When this ContainerBuilder is frozen
|
381 |
-
*
|
382 |
-
* @api
|
383 |
-
*/
|
384 |
-
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
|
385 |
-
{
|
386 |
-
$id = strtolower($id);
|
387 |
-
|
388 |
-
if ($this->isFrozen()) {
|
389 |
-
// setting a synthetic service on a frozen container is alright
|
390 |
-
if (
|
391 |
-
(!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id]))
|
392 |
-
||
|
393 |
-
(isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())
|
394 |
-
||
|
395 |
-
(isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic())
|
396 |
-
) {
|
397 |
-
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
if (isset($this->definitions[$id])) {
|
402 |
-
$this->obsoleteDefinitions[$id] = $this->definitions[$id];
|
403 |
-
}
|
404 |
-
|
405 |
-
unset($this->definitions[$id], $this->aliasDefinitions[$id]);
|
406 |
-
|
407 |
-
parent::set($id, $service, $scope);
|
408 |
-
|
409 |
-
if (isset($this->obsoleteDefinitions[$id]) && $this->obsoleteDefinitions[$id]->isSynchronized()) {
|
410 |
-
$this->synchronize($id);
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Removes a service definition.
|
416 |
-
*
|
417 |
-
* @param string $id The service identifier
|
418 |
-
*
|
419 |
-
* @api
|
420 |
-
*/
|
421 |
-
public function removeDefinition($id)
|
422 |
-
{
|
423 |
-
unset($this->definitions[strtolower($id)]);
|
424 |
-
}
|
425 |
-
|
426 |
-
/**
|
427 |
-
* Returns true if the given service is defined.
|
428 |
-
*
|
429 |
-
* @param string $id The service identifier
|
430 |
-
*
|
431 |
-
* @return bool true if the service is defined, false otherwise
|
432 |
-
*
|
433 |
-
* @api
|
434 |
-
*/
|
435 |
-
public function has($id)
|
436 |
-
{
|
437 |
-
$id = strtolower($id);
|
438 |
-
|
439 |
-
return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || parent::has($id);
|
440 |
-
}
|
441 |
-
|
442 |
-
/**
|
443 |
-
* Gets a service.
|
444 |
-
*
|
445 |
-
* @param string $id The service identifier
|
446 |
-
* @param int $invalidBehavior The behavior when the service does not exist
|
447 |
-
*
|
448 |
-
* @return object The associated service
|
449 |
-
*
|
450 |
-
* @throws InvalidArgumentException when no definitions are available
|
451 |
-
* @throws InactiveScopeException when the current scope is not active
|
452 |
-
* @throws LogicException when a circular dependency is detected
|
453 |
-
* @throws \Exception
|
454 |
-
*
|
455 |
-
* @see Reference
|
456 |
-
*
|
457 |
-
* @api
|
458 |
-
*/
|
459 |
-
public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
460 |
-
{
|
461 |
-
$id = strtolower($id);
|
462 |
-
|
463 |
-
if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
|
464 |
-
return $service;
|
465 |
-
}
|
466 |
-
|
467 |
-
if (isset($this->loading[$id])) {
|
468 |
-
throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e);
|
469 |
-
}
|
470 |
-
|
471 |
-
if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) {
|
472 |
-
return $this->get($this->aliasDefinitions[$id]);
|
473 |
-
}
|
474 |
-
|
475 |
-
try {
|
476 |
-
$definition = $this->getDefinition($id);
|
477 |
-
} catch (InvalidArgumentException $e) {
|
478 |
-
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
|
479 |
-
return;
|
480 |
-
}
|
481 |
-
|
482 |
-
throw $e;
|
483 |
-
}
|
484 |
-
|
485 |
-
$this->loading[$id] = true;
|
486 |
-
|
487 |
-
try {
|
488 |
-
$service = $this->createService($definition, $id);
|
489 |
-
} catch (\Exception $e) {
|
490 |
-
unset($this->loading[$id]);
|
491 |
-
|
492 |
-
if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
|
493 |
-
return;
|
494 |
-
}
|
495 |
-
|
496 |
-
throw $e;
|
497 |
-
}
|
498 |
-
|
499 |
-
unset($this->loading[$id]);
|
500 |
-
|
501 |
-
return $service;
|
502 |
-
}
|
503 |
-
|
504 |
-
/**
|
505 |
-
* Merges a ContainerBuilder with the current ContainerBuilder configuration.
|
506 |
-
*
|
507 |
-
* Service definitions overrides the current defined ones.
|
508 |
-
*
|
509 |
-
* But for parameters, they are overridden by the current ones. It allows
|
510 |
-
* the parameters passed to the container constructor to have precedence
|
511 |
-
* over the loaded ones.
|
512 |
-
*
|
513 |
-
* $container = new ContainerBuilder(array('foo' => 'bar'));
|
514 |
-
* $loader = new LoaderXXX($container);
|
515 |
-
* $loader->load('resource_name');
|
516 |
-
* $container->register('foo', new stdClass());
|
517 |
-
*
|
518 |
-
* In the above example, even if the loaded resource defines a foo
|
519 |
-
* parameter, the value will still be 'bar' as defined in the ContainerBuilder
|
520 |
-
* constructor.
|
521 |
-
*
|
522 |
-
* @param ContainerBuilder $container The ContainerBuilder instance to merge.
|
523 |
-
*
|
524 |
-
* @throws BadMethodCallException When this ContainerBuilder is frozen
|
525 |
-
*
|
526 |
-
* @api
|
527 |
-
*/
|
528 |
-
public function merge(ContainerBuilder $container)
|
529 |
-
{
|
530 |
-
if ($this->isFrozen()) {
|
531 |
-
throw new BadMethodCallException('Cannot merge on a frozen container.');
|
532 |
-
}
|
533 |
-
|
534 |
-
$this->addDefinitions($container->getDefinitions());
|
535 |
-
$this->addAliases($container->getAliases());
|
536 |
-
$this->getParameterBag()->add($container->getParameterBag()->all());
|
537 |
-
|
538 |
-
if ($this->trackResources) {
|
539 |
-
foreach ($container->getResources() as $resource) {
|
540 |
-
$this->addResource($resource);
|
541 |
-
}
|
542 |
-
}
|
543 |
-
|
544 |
-
foreach ($this->extensions as $name => $extension) {
|
545 |
-
if (!isset($this->extensionConfigs[$name])) {
|
546 |
-
$this->extensionConfigs[$name] = array();
|
547 |
-
}
|
548 |
-
|
549 |
-
$this->extensionConfigs[$name] = array_merge($this->extensionConfigs[$name], $container->getExtensionConfig($name));
|
550 |
-
}
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Returns the configuration array for the given extension.
|
555 |
-
*
|
556 |
-
* @param string $name The name of the extension
|
557 |
-
*
|
558 |
-
* @return array An array of configuration
|
559 |
-
*
|
560 |
-
* @api
|
561 |
-
*/
|
562 |
-
public function getExtensionConfig($name)
|
563 |
-
{
|
564 |
-
if (!isset($this->extensionConfigs[$name])) {
|
565 |
-
$this->extensionConfigs[$name] = array();
|
566 |
-
}
|
567 |
-
|
568 |
-
return $this->extensionConfigs[$name];
|
569 |
-
}
|
570 |
-
|
571 |
-
/**
|
572 |
-
* Prepends a config array to the configs of the given extension.
|
573 |
-
*
|
574 |
-
* @param string $name The name of the extension
|
575 |
-
* @param array $config The config to set
|
576 |
-
*/
|
577 |
-
public function prependExtensionConfig($name, array $config)
|
578 |
-
{
|
579 |
-
if (!isset($this->extensionConfigs[$name])) {
|
580 |
-
$this->extensionConfigs[$name] = array();
|
581 |
-
}
|
582 |
-
|
583 |
-
array_unshift($this->extensionConfigs[$name], $config);
|
584 |
-
}
|
585 |
-
|
586 |
-
/**
|
587 |
-
* Compiles the container.
|
588 |
-
*
|
589 |
-
* This method passes the container to compiler
|
590 |
-
* passes whose job is to manipulate and optimize
|
591 |
-
* the container.
|
592 |
-
*
|
593 |
-
* The main compiler passes roughly do four things:
|
594 |
-
*
|
595 |
-
* * The extension configurations are merged;
|
596 |
-
* * Parameter values are resolved;
|
597 |
-
* * The parameter bag is frozen;
|
598 |
-
* * Extension loading is disabled.
|
599 |
-
*
|
600 |
-
* @api
|
601 |
-
*/
|
602 |
-
public function compile()
|
603 |
-
{
|
604 |
-
$compiler = $this->getCompiler();
|
605 |
-
|
606 |
-
if ($this->trackResources) {
|
607 |
-
foreach ($compiler->getPassConfig()->getPasses() as $pass) {
|
608 |
-
$this->addObjectResource($pass);
|
609 |
-
}
|
610 |
-
}
|
611 |
-
|
612 |
-
$compiler->compile($this);
|
613 |
-
|
614 |
-
if ($this->trackResources) {
|
615 |
-
foreach ($this->definitions as $definition) {
|
616 |
-
if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
|
617 |
-
$this->addClassResource(new \ReflectionClass($class));
|
618 |
-
}
|
619 |
-
}
|
620 |
-
}
|
621 |
-
|
622 |
-
$this->extensionConfigs = array();
|
623 |
-
|
624 |
-
parent::compile();
|
625 |
-
}
|
626 |
-
|
627 |
-
/**
|
628 |
-
* Gets all service ids.
|
629 |
-
*
|
630 |
-
* @return array An array of all defined service ids
|
631 |
-
*/
|
632 |
-
public function getServiceIds()
|
633 |
-
{
|
634 |
-
return array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliasDefinitions), parent::getServiceIds()));
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Adds the service aliases.
|
639 |
-
*
|
640 |
-
* @param array $aliases An array of aliases
|
641 |
-
*
|
642 |
-
* @api
|
643 |
-
*/
|
644 |
-
public function addAliases(array $aliases)
|
645 |
-
{
|
646 |
-
foreach ($aliases as $alias => $id) {
|
647 |
-
$this->setAlias($alias, $id);
|
648 |
-
}
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* Sets the service aliases.
|
653 |
-
*
|
654 |
-
* @param array $aliases An array of aliases
|
655 |
-
*
|
656 |
-
* @api
|
657 |
-
*/
|
658 |
-
public function setAliases(array $aliases)
|
659 |
-
{
|
660 |
-
$this->aliasDefinitions = array();
|
661 |
-
$this->addAliases($aliases);
|
662 |
-
}
|
663 |
-
|
664 |
-
/**
|
665 |
-
* Sets an alias for an existing service.
|
666 |
-
*
|
667 |
-
* @param string $alias The alias to create
|
668 |
-
* @param string|Alias $id The service to alias
|
669 |
-
*
|
670 |
-
* @throws InvalidArgumentException if the id is not a string or an Alias
|
671 |
-
* @throws InvalidArgumentException if the alias is for itself
|
672 |
-
*
|
673 |
-
* @api
|
674 |
-
*/
|
675 |
-
public function setAlias($alias, $id)
|
676 |
-
{
|
677 |
-
$alias = strtolower($alias);
|
678 |
-
|
679 |
-
if (is_string($id)) {
|
680 |
-
$id = new Alias($id);
|
681 |
-
} elseif (!$id instanceof Alias) {
|
682 |
-
throw new InvalidArgumentException('$id must be a string, or an Alias object.');
|
683 |
-
}
|
684 |
-
|
685 |
-
if ($alias === strtolower($id)) {
|
686 |
-
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
687 |
-
}
|
688 |
-
|
689 |
-
unset($this->definitions[$alias]);
|
690 |
-
|
691 |
-
$this->aliasDefinitions[$alias] = $id;
|
692 |
-
}
|
693 |
-
|
694 |
-
/**
|
695 |
-
* Removes an alias.
|
696 |
-
*
|
697 |
-
* @param string $alias The alias to remove
|
698 |
-
*
|
699 |
-
* @api
|
700 |
-
*/
|
701 |
-
public function removeAlias($alias)
|
702 |
-
{
|
703 |
-
unset($this->aliasDefinitions[strtolower($alias)]);
|
704 |
-
}
|
705 |
-
|
706 |
-
/**
|
707 |
-
* Returns true if an alias exists under the given identifier.
|
708 |
-
*
|
709 |
-
* @param string $id The service identifier
|
710 |
-
*
|
711 |
-
* @return bool true if the alias exists, false otherwise
|
712 |
-
*
|
713 |
-
* @api
|
714 |
-
*/
|
715 |
-
public function hasAlias($id)
|
716 |
-
{
|
717 |
-
return isset($this->aliasDefinitions[strtolower($id)]);
|
718 |
-
}
|
719 |
-
|
720 |
-
/**
|
721 |
-
* Gets all defined aliases.
|
722 |
-
*
|
723 |
-
* @return Alias[] An array of aliases
|
724 |
-
*
|
725 |
-
* @api
|
726 |
-
*/
|
727 |
-
public function getAliases()
|
728 |
-
{
|
729 |
-
return $this->aliasDefinitions;
|
730 |
-
}
|
731 |
-
|
732 |
-
/**
|
733 |
-
* Gets an alias.
|
734 |
-
*
|
735 |
-
* @param string $id The service identifier
|
736 |
-
*
|
737 |
-
* @return Alias An Alias instance
|
738 |
-
*
|
739 |
-
* @throws InvalidArgumentException if the alias does not exist
|
740 |
-
*
|
741 |
-
* @api
|
742 |
-
*/
|
743 |
-
public function getAlias($id)
|
744 |
-
{
|
745 |
-
$id = strtolower($id);
|
746 |
-
|
747 |
-
if (!$this->hasAlias($id)) {
|
748 |
-
throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id));
|
749 |
-
}
|
750 |
-
|
751 |
-
return $this->aliasDefinitions[$id];
|
752 |
-
}
|
753 |
-
|
754 |
-
/**
|
755 |
-
* Registers a service definition.
|
756 |
-
*
|
757 |
-
* This methods allows for simple registration of service definition
|
758 |
-
* with a fluid interface.
|
759 |
-
*
|
760 |
-
* @param string $id The service identifier
|
761 |
-
* @param string $class The service class
|
762 |
-
*
|
763 |
-
* @return Definition A Definition instance
|
764 |
-
*
|
765 |
-
* @api
|
766 |
-
*/
|
767 |
-
public function register($id, $class = null)
|
768 |
-
{
|
769 |
-
return $this->setDefinition(strtolower($id), new Definition($class));
|
770 |
-
}
|
771 |
-
|
772 |
-
/**
|
773 |
-
* Adds the service definitions.
|
774 |
-
*
|
775 |
-
* @param Definition[] $definitions An array of service definitions
|
776 |
-
*
|
777 |
-
* @api
|
778 |
-
*/
|
779 |
-
public function addDefinitions(array $definitions)
|
780 |
-
{
|
781 |
-
foreach ($definitions as $id => $definition) {
|
782 |
-
$this->setDefinition($id, $definition);
|
783 |
-
}
|
784 |
-
}
|
785 |
-
|
786 |
-
/**
|
787 |
-
* Sets the service definitions.
|
788 |
-
*
|
789 |
-
* @param Definition[] $definitions An array of service definitions
|
790 |
-
*
|
791 |
-
* @api
|
792 |
-
*/
|
793 |
-
public function setDefinitions(array $definitions)
|
794 |
-
{
|
795 |
-
$this->definitions = array();
|
796 |
-
$this->addDefinitions($definitions);
|
797 |
-
}
|
798 |
-
|
799 |
-
/**
|
800 |
-
* Gets all service definitions.
|
801 |
-
*
|
802 |
-
* @return Definition[] An array of Definition instances
|
803 |
-
*
|
804 |
-
* @api
|
805 |
-
*/
|
806 |
-
public function getDefinitions()
|
807 |
-
{
|
808 |
-
return $this->definitions;
|
809 |
-
}
|
810 |
-
|
811 |
-
/**
|
812 |
-
* Sets a service definition.
|
813 |
-
*
|
814 |
-
* @param string $id The service identifier
|
815 |
-
* @param Definition $definition A Definition instance
|
816 |
-
*
|
817 |
-
* @return Definition the service definition
|
818 |
-
*
|
819 |
-
* @throws BadMethodCallException When this ContainerBuilder is frozen
|
820 |
-
*
|
821 |
-
* @api
|
822 |
-
*/
|
823 |
-
public function setDefinition($id, Definition $definition)
|
824 |
-
{
|
825 |
-
if ($this->isFrozen()) {
|
826 |
-
throw new BadMethodCallException('Adding definition to a frozen container is not allowed');
|
827 |
-
}
|
828 |
-
|
829 |
-
$id = strtolower($id);
|
830 |
-
|
831 |
-
unset($this->aliasDefinitions[$id]);
|
832 |
-
|
833 |
-
return $this->definitions[$id] = $definition;
|
834 |
-
}
|
835 |
-
|
836 |
-
/**
|
837 |
-
* Returns true if a service definition exists under the given identifier.
|
838 |
-
*
|
839 |
-
* @param string $id The service identifier
|
840 |
-
*
|
841 |
-
* @return bool true if the service definition exists, false otherwise
|
842 |
-
*
|
843 |
-
* @api
|
844 |
-
*/
|
845 |
-
public function hasDefinition($id)
|
846 |
-
{
|
847 |
-
return array_key_exists(strtolower($id), $this->definitions);
|
848 |
-
}
|
849 |
-
|
850 |
-
/**
|
851 |
-
* Gets a service definition.
|
852 |
-
*
|
853 |
-
* @param string $id The service identifier
|
854 |
-
*
|
855 |
-
* @return Definition A Definition instance
|
856 |
-
*
|
857 |
-
* @throws InvalidArgumentException if the service definition does not exist
|
858 |
-
*
|
859 |
-
* @api
|
860 |
-
*/
|
861 |
-
public function getDefinition($id)
|
862 |
-
{
|
863 |
-
$id = strtolower($id);
|
864 |
-
|
865 |
-
if (!$this->hasDefinition($id)) {
|
866 |
-
throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id));
|
867 |
-
}
|
868 |
-
|
869 |
-
return $this->definitions[$id];
|
870 |
-
}
|
871 |
-
|
872 |
-
/**
|
873 |
-
* Gets a service definition by id or alias.
|
874 |
-
*
|
875 |
-
* The method "unaliases" recursively to return a Definition instance.
|
876 |
-
*
|
877 |
-
* @param string $id The service identifier or alias
|
878 |
-
*
|
879 |
-
* @return Definition A Definition instance
|
880 |
-
*
|
881 |
-
* @throws InvalidArgumentException if the service definition does not exist
|
882 |
-
*
|
883 |
-
* @api
|
884 |
-
*/
|
885 |
-
public function findDefinition($id)
|
886 |
-
{
|
887 |
-
while ($this->hasAlias($id)) {
|
888 |
-
$id = (string) $this->getAlias($id);
|
889 |
-
}
|
890 |
-
|
891 |
-
return $this->getDefinition($id);
|
892 |
-
}
|
893 |
-
|
894 |
-
/**
|
895 |
-
* Creates a service for a service definition.
|
896 |
-
*
|
897 |
-
* @param Definition $definition A service definition instance
|
898 |
-
* @param string $id The service identifier
|
899 |
-
* @param bool $tryProxy Whether to try proxying the service with a lazy proxy
|
900 |
-
*
|
901 |
-
* @return object The service described by the service definition
|
902 |
-
*
|
903 |
-
* @throws RuntimeException When the scope is inactive
|
904 |
-
* @throws RuntimeException When the factory definition is incomplete
|
905 |
-
* @throws RuntimeException When the service is a synthetic service
|
906 |
-
* @throws InvalidArgumentException When configure callable is not callable
|
907 |
-
*
|
908 |
-
* @internal this method is public because of PHP 5.3 limitations, do not use it explicitly in your code
|
909 |
-
*/
|
910 |
-
public function createService(Definition $definition, $id, $tryProxy = true)
|
911 |
-
{
|
912 |
-
if ($definition->isSynthetic()) {
|
913 |
-
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
|
914 |
-
}
|
915 |
-
|
916 |
-
if ($tryProxy && $definition->isLazy()) {
|
917 |
-
$container = $this;
|
918 |
-
|
919 |
-
$proxy = $this
|
920 |
-
->getProxyInstantiator()
|
921 |
-
->instantiateProxy(
|
922 |
-
$container,
|
923 |
-
$definition,
|
924 |
-
$id, function () use ($definition, $id, $container) {
|
925 |
-
return $container->createService($definition, $id, false);
|
926 |
-
}
|
927 |
-
);
|
928 |
-
$this->shareService($definition, $proxy, $id);
|
929 |
-
|
930 |
-
return $proxy;
|
931 |
-
}
|
932 |
-
|
933 |
-
$parameterBag = $this->getParameterBag();
|
934 |
-
|
935 |
-
if (null !== $definition->getFile()) {
|
936 |
-
require_once $parameterBag->resolveValue($definition->getFile());
|
937 |
-
}
|
938 |
-
|
939 |
-
$arguments = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())));
|
940 |
-
|
941 |
-
if (null !== $definition->getFactoryMethod()) {
|
942 |
-
if (null !== $definition->getFactoryClass()) {
|
943 |
-
$factory = $parameterBag->resolveValue($definition->getFactoryClass());
|
944 |
-
} elseif (null !== $definition->getFactoryService()) {
|
945 |
-
$factory = $this->get($parameterBag->resolveValue($definition->getFactoryService()));
|
946 |
-
} else {
|
947 |
-
throw new RuntimeException(sprintf('Cannot create service "%s" from factory method without a factory service or factory class.', $id));
|
948 |
-
}
|
949 |
-
|
950 |
-
$service = call_user_func_array(array($factory, $definition->getFactoryMethod()), $arguments);
|
951 |
-
} else {
|
952 |
-
$r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass()));
|
953 |
-
|
954 |
-
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
|
955 |
-
}
|
956 |
-
|
957 |
-
if ($tryProxy || !$definition->isLazy()) {
|
958 |
-
// share only if proxying failed, or if not a proxy
|
959 |
-
$this->shareService($definition, $service, $id);
|
960 |
-
}
|
961 |
-
|
962 |
-
foreach ($definition->getMethodCalls() as $call) {
|
963 |
-
$this->callMethod($service, $call);
|
964 |
-
}
|
965 |
-
|
966 |
-
$properties = $this->resolveServices($parameterBag->resolveValue($definition->getProperties()));
|
967 |
-
foreach ($properties as $name => $value) {
|
968 |
-
$service->$name = $value;
|
969 |
-
}
|
970 |
-
|
971 |
-
if ($callable = $definition->getConfigurator()) {
|
972 |
-
if (is_array($callable)) {
|
973 |
-
$callable[0] = $callable[0] instanceof Reference ? $this->get((string) $callable[0]) : $parameterBag->resolveValue($callable[0]);
|
974 |
-
}
|
975 |
-
|
976 |
-
if (!is_callable($callable)) {
|
977 |
-
throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', get_class($service)));
|
978 |
-
}
|
979 |
-
|
980 |
-
call_user_func($callable, $service);
|
981 |
-
}
|
982 |
-
|
983 |
-
return $service;
|
984 |
-
}
|
985 |
-
|
986 |
-
/**
|
987 |
-
* Replaces service references by the real service instance and evaluates expressions.
|
988 |
-
*
|
989 |
-
* @param mixed $value A value
|
990 |
-
*
|
991 |
-
* @return mixed The same value with all service references replaced by
|
992 |
-
* the real service instances and all expressions evaluated
|
993 |
-
*/
|
994 |
-
public function resolveServices($value)
|
995 |
-
{
|
996 |
-
if (is_array($value)) {
|
997 |
-
foreach ($value as &$v) {
|
998 |
-
$v = $this->resolveServices($v);
|
999 |
-
}
|
1000 |
-
} elseif ($value instanceof Reference) {
|
1001 |
-
$value = $this->get((string) $value, $value->getInvalidBehavior());
|
1002 |
-
} elseif ($value instanceof Definition) {
|
1003 |
-
$value = $this->createService($value, null);
|
1004 |
-
} elseif ($value instanceof Expression) {
|
1005 |
-
$value = $this->getExpressionLanguage()->evaluate($value, array('container' => $this));
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
return $value;
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
/**
|
1012 |
-
* Returns service ids for a given tag.
|
1013 |
-
*
|
1014 |
-
* Example:
|
1015 |
-
*
|
1016 |
-
* $container->register('foo')->addTag('my.tag', array('hello' => 'world'));
|
1017 |
-
*
|
1018 |
-
* $serviceIds = $container->findTaggedServiceIds('my.tag');
|
1019 |
-
* foreach ($serviceIds as $serviceId => $tags) {
|
1020 |
-
* foreach ($tags as $tag) {
|
1021 |
-
* echo $tag['hello'];
|
1022 |
-
* }
|
1023 |
-
* }
|
1024 |
-
*
|
1025 |
-
* @param string $name The tag name
|
1026 |
-
*
|
1027 |
-
* @return array An array of tags with the tagged service as key, holding a list of attribute arrays.
|
1028 |
-
*
|
1029 |
-
* @api
|
1030 |
-
*/
|
1031 |
-
public function findTaggedServiceIds($name)
|
1032 |
-
{
|
1033 |
-
$tags = array();
|
1034 |
-
foreach ($this->getDefinitions() as $id => $definition) {
|
1035 |
-
if ($definition->hasTag($name)) {
|
1036 |
-
$tags[$id] = $definition->getTag($name);
|
1037 |
-
}
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
return $tags;
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
/**
|
1044 |
-
* Returns all tags the defined services use.
|
1045 |
-
*
|
1046 |
-
* @return array An array of tags
|
1047 |
-
*/
|
1048 |
-
public function findTags()
|
1049 |
-
{
|
1050 |
-
$tags = array();
|
1051 |
-
foreach ($this->getDefinitions() as $id => $definition) {
|
1052 |
-
$tags = array_merge(array_keys($definition->getTags()), $tags);
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
return array_unique($tags);
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
/**
|
1059 |
-
* Returns the Service Conditionals.
|
1060 |
-
*
|
1061 |
-
* @param mixed $value An array of conditionals to return.
|
1062 |
-
*
|
1063 |
-
* @return array An array of Service conditionals
|
1064 |
-
*/
|
1065 |
-
public static function getServiceConditionals($value)
|
1066 |
-
{
|
1067 |
-
$services = array();
|
1068 |
-
|
1069 |
-
if (is_array($value)) {
|
1070 |
-
foreach ($value as $v) {
|
1071 |
-
$services = array_unique(array_merge($services, self::getServiceConditionals($v)));
|
1072 |
-
}
|
1073 |
-
} elseif ($value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
|
1074 |
-
$services[] = (string) $value;
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
return $services;
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* Retrieves the currently set proxy instantiator or instantiates one.
|
1082 |
-
*
|
1083 |
-
* @return InstantiatorInterface
|
1084 |
-
*/
|
1085 |
-
private function getProxyInstantiator()
|
1086 |
-
{
|
1087 |
-
if (!$this->proxyInstantiator) {
|
1088 |
-
$this->proxyInstantiator = new RealServiceInstantiator();
|
1089 |
-
}
|
1090 |
-
|
1091 |
-
return $this->proxyInstantiator;
|
1092 |
-
}
|
1093 |
-
|
1094 |
-
/**
|
1095 |
-
* Synchronizes a service change.
|
1096 |
-
*
|
1097 |
-
* This method updates all services that depend on the given
|
1098 |
-
* service by calling all methods referencing it.
|
1099 |
-
*
|
1100 |
-
* @param string $id A service id
|
1101 |
-
*/
|
1102 |
-
private function synchronize($id)
|
1103 |
-
{
|
1104 |
-
foreach ($this->definitions as $definitionId => $definition) {
|
1105 |
-
// only check initialized services
|
1106 |
-
if (!$this->initialized($definitionId)) {
|
1107 |
-
continue;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
foreach ($definition->getMethodCalls() as $call) {
|
1111 |
-
foreach ($call[1] as $argument) {
|
1112 |
-
if ($argument instanceof Reference && $id == (string) $argument) {
|
1113 |
-
$this->callMethod($this->get($definitionId), $call);
|
1114 |
-
}
|
1115 |
-
}
|
1116 |
-
}
|
1117 |
-
}
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
private function callMethod($service, $call)
|
1121 |
-
{
|
1122 |
-
$services = self::getServiceConditionals($call[1]);
|
1123 |
-
|
1124 |
-
foreach ($services as $s) {
|
1125 |
-
if (!$this->has($s)) {
|
1126 |
-
return;
|
1127 |
-
}
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1])));
|
1131 |
-
}
|
1132 |
-
|
1133 |
-
/**
|
1134 |
-
* Shares a given service in the container.
|
1135 |
-
*
|
1136 |
-
* @param Definition $definition
|
1137 |
-
* @param mixed $service
|
1138 |
-
* @param string $id
|
1139 |
-
*
|
1140 |
-
* @throws InactiveScopeException
|
1141 |
-
*/
|
1142 |
-
private function shareService(Definition $definition, $service, $id)
|
1143 |
-
{
|
1144 |
-
if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
|
1145 |
-
if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) {
|
1146 |
-
throw new InactiveScopeException($id, $scope);
|
1147 |
-
}
|
1148 |
-
|
1149 |
-
$this->services[$lowerId = strtolower($id)] = $service;
|
1150 |
-
|
1151 |
-
if (self::SCOPE_CONTAINER !== $scope) {
|
1152 |
-
$this->scopedServices[$scope][$lowerId] = $service;
|
1153 |
-
}
|
1154 |
-
}
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
private function getExpressionLanguage()
|
1158 |
-
{
|
1159 |
-
if (null === $this->expressionLanguage) {
|
1160 |
-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
|
1161 |
-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
|
1162 |
-
}
|
1163 |
-
$this->expressionLanguage = new ExpressionLanguage();
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
return $this->expressionLanguage;
|
1167 |
-
}
|
1168 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ContainerInterface.php
DELETED
@@ -1,158 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
16 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* ContainerInterface is the interface implemented by service container classes.
|
20 |
-
*
|
21 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
23 |
-
*
|
24 |
-
* @api
|
25 |
-
*/
|
26 |
-
interface ContainerInterface
|
27 |
-
{
|
28 |
-
const EXCEPTION_ON_INVALID_REFERENCE = 1;
|
29 |
-
const NULL_ON_INVALID_REFERENCE = 2;
|
30 |
-
const IGNORE_ON_INVALID_REFERENCE = 3;
|
31 |
-
const SCOPE_CONTAINER = 'container';
|
32 |
-
const SCOPE_PROTOTYPE = 'prototype';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Sets a service.
|
36 |
-
*
|
37 |
-
* @param string $id The service identifier
|
38 |
-
* @param object $service The service instance
|
39 |
-
* @param string $scope The scope of the service
|
40 |
-
*
|
41 |
-
* @api
|
42 |
-
*/
|
43 |
-
public function set($id, $service, $scope = self::SCOPE_CONTAINER);
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Gets a service.
|
47 |
-
*
|
48 |
-
* @param string $id The service identifier
|
49 |
-
* @param int $invalidBehavior The behavior when the service does not exist
|
50 |
-
*
|
51 |
-
* @return object The associated service
|
52 |
-
*
|
53 |
-
* @throws InvalidArgumentException if the service is not defined
|
54 |
-
* @throws ServiceCircularReferenceException When a circular reference is detected
|
55 |
-
* @throws ServiceNotFoundException When the service is not defined
|
56 |
-
*
|
57 |
-
* @see Reference
|
58 |
-
*
|
59 |
-
* @api
|
60 |
-
*/
|
61 |
-
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Returns true if the given service is defined.
|
65 |
-
*
|
66 |
-
* @param string $id The service identifier
|
67 |
-
*
|
68 |
-
* @return bool true if the service is defined, false otherwise
|
69 |
-
*
|
70 |
-
* @api
|
71 |
-
*/
|
72 |
-
public function has($id);
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Gets a parameter.
|
76 |
-
*
|
77 |
-
* @param string $name The parameter name
|
78 |
-
*
|
79 |
-
* @return mixed The parameter value
|
80 |
-
*
|
81 |
-
* @throws InvalidArgumentException if the parameter is not defined
|
82 |
-
*
|
83 |
-
* @api
|
84 |
-
*/
|
85 |
-
public function getParameter($name);
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Checks if a parameter exists.
|
89 |
-
*
|
90 |
-
* @param string $name The parameter name
|
91 |
-
*
|
92 |
-
* @return bool The presence of parameter in container
|
93 |
-
*
|
94 |
-
* @api
|
95 |
-
*/
|
96 |
-
public function hasParameter($name);
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Sets a parameter.
|
100 |
-
*
|
101 |
-
* @param string $name The parameter name
|
102 |
-
* @param mixed $value The parameter value
|
103 |
-
*
|
104 |
-
* @api
|
105 |
-
*/
|
106 |
-
public function setParameter($name, $value);
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Enters the given scope.
|
110 |
-
*
|
111 |
-
* @param string $name
|
112 |
-
*
|
113 |
-
* @api
|
114 |
-
*/
|
115 |
-
public function enterScope($name);
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Leaves the current scope, and re-enters the parent scope.
|
119 |
-
*
|
120 |
-
* @param string $name
|
121 |
-
*
|
122 |
-
* @api
|
123 |
-
*/
|
124 |
-
public function leaveScope($name);
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Adds a scope to the container.
|
128 |
-
*
|
129 |
-
* @param ScopeInterface $scope
|
130 |
-
*
|
131 |
-
* @api
|
132 |
-
*/
|
133 |
-
public function addScope(ScopeInterface $scope);
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Whether this container has the given scope.
|
137 |
-
*
|
138 |
-
* @param string $name
|
139 |
-
*
|
140 |
-
* @return bool
|
141 |
-
*
|
142 |
-
* @api
|
143 |
-
*/
|
144 |
-
public function hasScope($name);
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Determines whether the given scope is currently active.
|
148 |
-
*
|
149 |
-
* It does however not check if the scope actually exists.
|
150 |
-
*
|
151 |
-
* @param string $name
|
152 |
-
*
|
153 |
-
* @return bool
|
154 |
-
*
|
155 |
-
* @api
|
156 |
-
*/
|
157 |
-
public function isScopeActive($name);
|
158 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Definition.php
DELETED
@@ -1,742 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Definition represents a service definition.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*
|
22 |
-
* @api
|
23 |
-
*/
|
24 |
-
class Definition
|
25 |
-
{
|
26 |
-
private $class;
|
27 |
-
private $file;
|
28 |
-
private $factoryClass;
|
29 |
-
private $factoryMethod;
|
30 |
-
private $factoryService;
|
31 |
-
private $scope = ContainerInterface::SCOPE_CONTAINER;
|
32 |
-
private $properties = array();
|
33 |
-
private $calls = array();
|
34 |
-
private $configurator;
|
35 |
-
private $tags = array();
|
36 |
-
private $public = true;
|
37 |
-
private $synthetic = false;
|
38 |
-
private $abstract = false;
|
39 |
-
private $synchronized = false;
|
40 |
-
private $lazy = false;
|
41 |
-
private $decoratedService;
|
42 |
-
|
43 |
-
protected $arguments;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Constructor.
|
47 |
-
*
|
48 |
-
* @param string|null $class The service class
|
49 |
-
* @param array $arguments An array of arguments to pass to the service constructor
|
50 |
-
*
|
51 |
-
* @api
|
52 |
-
*/
|
53 |
-
public function __construct($class = null, array $arguments = array())
|
54 |
-
{
|
55 |
-
$this->class = $class;
|
56 |
-
$this->arguments = $arguments;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Sets the name of the class that acts as a factory using the factory method,
|
61 |
-
* which will be invoked statically.
|
62 |
-
*
|
63 |
-
* @param string $factoryClass The factory class name
|
64 |
-
*
|
65 |
-
* @return Definition The current instance
|
66 |
-
*
|
67 |
-
* @api
|
68 |
-
*/
|
69 |
-
public function setFactoryClass($factoryClass)
|
70 |
-
{
|
71 |
-
$this->factoryClass = $factoryClass;
|
72 |
-
|
73 |
-
return $this;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Gets the factory class.
|
78 |
-
*
|
79 |
-
* @return string|null The factory class name
|
80 |
-
*
|
81 |
-
* @api
|
82 |
-
*/
|
83 |
-
public function getFactoryClass()
|
84 |
-
{
|
85 |
-
return $this->factoryClass;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Sets the factory method able to create an instance of this class.
|
90 |
-
*
|
91 |
-
* @param string $factoryMethod The factory method name
|
92 |
-
*
|
93 |
-
* @return Definition The current instance
|
94 |
-
*
|
95 |
-
* @api
|
96 |
-
*/
|
97 |
-
public function setFactoryMethod($factoryMethod)
|
98 |
-
{
|
99 |
-
$this->factoryMethod = $factoryMethod;
|
100 |
-
|
101 |
-
return $this;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Sets the service that this service is decorating.
|
106 |
-
*
|
107 |
-
* @param null|string $id The decorated service id, use null to remove decoration
|
108 |
-
* @param null|string $renamedId The new decorated service id
|
109 |
-
*
|
110 |
-
* @return Definition The current instance
|
111 |
-
*
|
112 |
-
* @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals.
|
113 |
-
*/
|
114 |
-
public function setDecoratedService($id, $renamedId = null)
|
115 |
-
{
|
116 |
-
if ($renamedId && $id == $renamedId) {
|
117 |
-
throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
|
118 |
-
}
|
119 |
-
|
120 |
-
if (null === $id) {
|
121 |
-
$this->decoratedService = null;
|
122 |
-
} else {
|
123 |
-
$this->decoratedService = array($id, $renamedId);
|
124 |
-
}
|
125 |
-
|
126 |
-
return $this;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Gets the service that decorates this service.
|
131 |
-
*
|
132 |
-
* @return null|array An array composed of the decorated service id and the new id for it, null if no service is decorated
|
133 |
-
*/
|
134 |
-
public function getDecoratedService()
|
135 |
-
{
|
136 |
-
return $this->decoratedService;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Gets the factory method.
|
141 |
-
*
|
142 |
-
* @return string|null The factory method name
|
143 |
-
*
|
144 |
-
* @api
|
145 |
-
*/
|
146 |
-
public function getFactoryMethod()
|
147 |
-
{
|
148 |
-
return $this->factoryMethod;
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Sets the name of the service that acts as a factory using the factory method.
|
153 |
-
*
|
154 |
-
* @param string $factoryService The factory service id
|
155 |
-
*
|
156 |
-
* @return Definition The current instance
|
157 |
-
*
|
158 |
-
* @api
|
159 |
-
*/
|
160 |
-
public function setFactoryService($factoryService)
|
161 |
-
{
|
162 |
-
$this->factoryService = $factoryService;
|
163 |
-
|
164 |
-
return $this;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Gets the factory service id.
|
169 |
-
*
|
170 |
-
* @return string|null The factory service id
|
171 |
-
*
|
172 |
-
* @api
|
173 |
-
*/
|
174 |
-
public function getFactoryService()
|
175 |
-
{
|
176 |
-
return $this->factoryService;
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Sets the service class.
|
181 |
-
*
|
182 |
-
* @param string $class The service class
|
183 |
-
*
|
184 |
-
* @return Definition The current instance
|
185 |
-
*
|
186 |
-
* @api
|
187 |
-
*/
|
188 |
-
public function setClass($class)
|
189 |
-
{
|
190 |
-
$this->class = $class;
|
191 |
-
|
192 |
-
return $this;
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Gets the service class.
|
197 |
-
*
|
198 |
-
* @return string|null The service class
|
199 |
-
*
|
200 |
-
* @api
|
201 |
-
*/
|
202 |
-
public function getClass()
|
203 |
-
{
|
204 |
-
return $this->class;
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Sets the arguments to pass to the service constructor/factory method.
|
209 |
-
*
|
210 |
-
* @param array $arguments An array of arguments
|
211 |
-
*
|
212 |
-
* @return Definition The current instance
|
213 |
-
*
|
214 |
-
* @api
|
215 |
-
*/
|
216 |
-
public function setArguments(array $arguments)
|
217 |
-
{
|
218 |
-
$this->arguments = $arguments;
|
219 |
-
|
220 |
-
return $this;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* @api
|
225 |
-
*/
|
226 |
-
public function setProperties(array $properties)
|
227 |
-
{
|
228 |
-
$this->properties = $properties;
|
229 |
-
|
230 |
-
return $this;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* @api
|
235 |
-
*/
|
236 |
-
public function getProperties()
|
237 |
-
{
|
238 |
-
return $this->properties;
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* @api
|
243 |
-
*/
|
244 |
-
public function setProperty($name, $value)
|
245 |
-
{
|
246 |
-
$this->properties[$name] = $value;
|
247 |
-
|
248 |
-
return $this;
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Adds an argument to pass to the service constructor/factory method.
|
253 |
-
*
|
254 |
-
* @param mixed $argument An argument
|
255 |
-
*
|
256 |
-
* @return Definition The current instance
|
257 |
-
*
|
258 |
-
* @api
|
259 |
-
*/
|
260 |
-
public function addArgument($argument)
|
261 |
-
{
|
262 |
-
$this->arguments[] = $argument;
|
263 |
-
|
264 |
-
return $this;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Sets a specific argument.
|
269 |
-
*
|
270 |
-
* @param int $index
|
271 |
-
* @param mixed $argument
|
272 |
-
*
|
273 |
-
* @return Definition The current instance
|
274 |
-
*
|
275 |
-
* @throws OutOfBoundsException When the replaced argument does not exist
|
276 |
-
*
|
277 |
-
* @api
|
278 |
-
*/
|
279 |
-
public function replaceArgument($index, $argument)
|
280 |
-
{
|
281 |
-
if ($index < 0 || $index > count($this->arguments) - 1) {
|
282 |
-
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
|
283 |
-
}
|
284 |
-
|
285 |
-
$this->arguments[$index] = $argument;
|
286 |
-
|
287 |
-
return $this;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Gets the arguments to pass to the service constructor/factory method.
|
292 |
-
*
|
293 |
-
* @return array The array of arguments
|
294 |
-
*
|
295 |
-
* @api
|
296 |
-
*/
|
297 |
-
public function getArguments()
|
298 |
-
{
|
299 |
-
return $this->arguments;
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Gets an argument to pass to the service constructor/factory method.
|
304 |
-
*
|
305 |
-
* @param int $index
|
306 |
-
*
|
307 |
-
* @return mixed The argument value
|
308 |
-
*
|
309 |
-
* @throws OutOfBoundsException When the argument does not exist
|
310 |
-
*
|
311 |
-
* @api
|
312 |
-
*/
|
313 |
-
public function getArgument($index)
|
314 |
-
{
|
315 |
-
if ($index < 0 || $index > count($this->arguments) - 1) {
|
316 |
-
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
|
317 |
-
}
|
318 |
-
|
319 |
-
return $this->arguments[$index];
|
320 |
-
}
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Sets the methods to call after service initialization.
|
324 |
-
*
|
325 |
-
* @param array $calls An array of method calls
|
326 |
-
*
|
327 |
-
* @return Definition The current instance
|
328 |
-
*
|
329 |
-
* @api
|
330 |
-
*/
|
331 |
-
public function setMethodCalls(array $calls = array())
|
332 |
-
{
|
333 |
-
$this->calls = array();
|
334 |
-
foreach ($calls as $call) {
|
335 |
-
$this->addMethodCall($call[0], $call[1]);
|
336 |
-
}
|
337 |
-
|
338 |
-
return $this;
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Adds a method to call after service initialization.
|
343 |
-
*
|
344 |
-
* @param string $method The method name to call
|
345 |
-
* @param array $arguments An array of arguments to pass to the method call
|
346 |
-
*
|
347 |
-
* @return Definition The current instance
|
348 |
-
*
|
349 |
-
* @throws InvalidArgumentException on empty $method param
|
350 |
-
*
|
351 |
-
* @api
|
352 |
-
*/
|
353 |
-
public function addMethodCall($method, array $arguments = array())
|
354 |
-
{
|
355 |
-
if (empty($method)) {
|
356 |
-
throw new InvalidArgumentException(sprintf('Method name cannot be empty.'));
|
357 |
-
}
|
358 |
-
$this->calls[] = array($method, $arguments);
|
359 |
-
|
360 |
-
return $this;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Removes a method to call after service initialization.
|
365 |
-
*
|
366 |
-
* @param string $method The method name to remove
|
367 |
-
*
|
368 |
-
* @return Definition The current instance
|
369 |
-
*
|
370 |
-
* @api
|
371 |
-
*/
|
372 |
-
public function removeMethodCall($method)
|
373 |
-
{
|
374 |
-
foreach ($this->calls as $i => $call) {
|
375 |
-
if ($call[0] === $method) {
|
376 |
-
unset($this->calls[$i]);
|
377 |
-
break;
|
378 |
-
}
|
379 |
-
}
|
380 |
-
|
381 |
-
return $this;
|
382 |
-
}
|
383 |
-
|
384 |
-
/**
|
385 |
-
* Check if the current definition has a given method to call after service initialization.
|
386 |
-
*
|
387 |
-
* @param string $method The method name to search for
|
388 |
-
*
|
389 |
-
* @return bool
|
390 |
-
*
|
391 |
-
* @api
|
392 |
-
*/
|
393 |
-
public function hasMethodCall($method)
|
394 |
-
{
|
395 |
-
foreach ($this->calls as $call) {
|
396 |
-
if ($call[0] === $method) {
|
397 |
-
return true;
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
return false;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Gets the methods to call after service initialization.
|
406 |
-
*
|
407 |
-
* @return array An array of method calls
|
408 |
-
*
|
409 |
-
* @api
|
410 |
-
*/
|
411 |
-
public function getMethodCalls()
|
412 |
-
{
|
413 |
-
return $this->calls;
|
414 |
-
}
|
415 |
-
|
416 |
-
/**
|
417 |
-
* Sets tags for this definition.
|
418 |
-
*
|
419 |
-
* @param array $tags
|
420 |
-
*
|
421 |
-
* @return Definition the current instance
|
422 |
-
*
|
423 |
-
* @api
|
424 |
-
*/
|
425 |
-
public function setTags(array $tags)
|
426 |
-
{
|
427 |
-
$this->tags = $tags;
|
428 |
-
|
429 |
-
return $this;
|
430 |
-
}
|
431 |
-
|
432 |
-
/**
|
433 |
-
* Returns all tags.
|
434 |
-
*
|
435 |
-
* @return array An array of tags
|
436 |
-
*
|
437 |
-
* @api
|
438 |
-
*/
|
439 |
-
public function getTags()
|
440 |
-
{
|
441 |
-
return $this->tags;
|
442 |
-
}
|
443 |
-
|
444 |
-
/**
|
445 |
-
* Gets a tag by name.
|
446 |
-
*
|
447 |
-
* @param string $name The tag name
|
448 |
-
*
|
449 |
-
* @return array An array of attributes
|
450 |
-
*
|
451 |
-
* @api
|
452 |
-
*/
|
453 |
-
public function getTag($name)
|
454 |
-
{
|
455 |
-
return isset($this->tags[$name]) ? $this->tags[$name] : array();
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Adds a tag for this definition.
|
460 |
-
*
|
461 |
-
* @param string $name The tag name
|
462 |
-
* @param array $attributes An array of attributes
|
463 |
-
*
|
464 |
-
* @return Definition The current instance
|
465 |
-
*
|
466 |
-
* @api
|
467 |
-
*/
|
468 |
-
public function addTag($name, array $attributes = array())
|
469 |
-
{
|
470 |
-
$this->tags[$name][] = $attributes;
|
471 |
-
|
472 |
-
return $this;
|
473 |
-
}
|
474 |
-
|
475 |
-
/**
|
476 |
-
* Whether this definition has a tag with the given name.
|
477 |
-
*
|
478 |
-
* @param string $name
|
479 |
-
*
|
480 |
-
* @return bool
|
481 |
-
*
|
482 |
-
* @api
|
483 |
-
*/
|
484 |
-
public function hasTag($name)
|
485 |
-
{
|
486 |
-
return isset($this->tags[$name]);
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
* Clears all tags for a given name.
|
491 |
-
*
|
492 |
-
* @param string $name The tag name
|
493 |
-
*
|
494 |
-
* @return Definition
|
495 |
-
*/
|
496 |
-
public function clearTag($name)
|
497 |
-
{
|
498 |
-
if (isset($this->tags[$name])) {
|
499 |
-
unset($this->tags[$name]);
|
500 |
-
}
|
501 |
-
|
502 |
-
return $this;
|
503 |
-
}
|
504 |
-
|
505 |
-
/**
|
506 |
-
* Clears the tags for this definition.
|
507 |
-
*
|
508 |
-
* @return Definition The current instance
|
509 |
-
*
|
510 |
-
* @api
|
511 |
-
*/
|
512 |
-
public function clearTags()
|
513 |
-
{
|
514 |
-
$this->tags = array();
|
515 |
-
|
516 |
-
return $this;
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* Sets a file to require before creating the service.
|
521 |
-
*
|
522 |
-
* @param string $file A full pathname to include
|
523 |
-
*
|
524 |
-
* @return Definition The current instance
|
525 |
-
*
|
526 |
-
* @api
|
527 |
-
*/
|
528 |
-
public function setFile($file)
|
529 |
-
{
|
530 |
-
$this->file = $file;
|
531 |
-
|
532 |
-
return $this;
|
533 |
-
}
|
534 |
-
|
535 |
-
/**
|
536 |
-
* Gets the file to require before creating the service.
|
537 |
-
*
|
538 |
-
* @return string|null The full pathname to include
|
539 |
-
*
|
540 |
-
* @api
|
541 |
-
*/
|
542 |
-
public function getFile()
|
543 |
-
{
|
544 |
-
return $this->file;
|
545 |
-
}
|
546 |
-
|
547 |
-
/**
|
548 |
-
* Sets the scope of the service.
|
549 |
-
*
|
550 |
-
* @param string $scope Whether the service must be shared or not
|
551 |
-
*
|
552 |
-
* @return Definition The current instance
|
553 |
-
*
|
554 |
-
* @api
|
555 |
-
*/
|
556 |
-
public function setScope($scope)
|
557 |
-
{
|
558 |
-
$this->scope = $scope;
|
559 |
-
|
560 |
-
return $this;
|
561 |
-
}
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Returns the scope of the service.
|
565 |
-
*
|
566 |
-
* @return string
|
567 |
-
*
|
568 |
-
* @api
|
569 |
-
*/
|
570 |
-
public function getScope()
|
571 |
-
{
|
572 |
-
return $this->scope;
|
573 |
-
}
|
574 |
-
|
575 |
-
/**
|
576 |
-
* Sets the visibility of this service.
|
577 |
-
*
|
578 |
-
* @param bool $boolean
|
579 |
-
*
|
580 |
-
* @return Definition The current instance
|
581 |
-
*
|
582 |
-
* @api
|
583 |
-
*/
|
584 |
-
public function setPublic($boolean)
|
585 |
-
{
|
586 |
-
$this->public = (bool) $boolean;
|
587 |
-
|
588 |
-
return $this;
|
589 |
-
}
|
590 |
-
|
591 |
-
/**
|
592 |
-
* Whether this service is public facing.
|
593 |
-
*
|
594 |
-
* @return bool
|
595 |
-
*
|
596 |
-
* @api
|
597 |
-
*/
|
598 |
-
public function isPublic()
|
599 |
-
{
|
600 |
-
return $this->public;
|
601 |
-
}
|
602 |
-
|
603 |
-
/**
|
604 |
-
* Sets the synchronized flag of this service.
|
605 |
-
*
|
606 |
-
* @param bool $boolean
|
607 |
-
*
|
608 |
-
* @return Definition The current instance
|
609 |
-
*
|
610 |
-
* @api
|
611 |
-
*/
|
612 |
-
public function setSynchronized($boolean)
|
613 |
-
{
|
614 |
-
$this->synchronized = (bool) $boolean;
|
615 |
-
|
616 |
-
return $this;
|
617 |
-
}
|
618 |
-
|
619 |
-
/**
|
620 |
-
* Whether this service is synchronized.
|
621 |
-
*
|
622 |
-
* @return bool
|
623 |
-
*
|
624 |
-
* @api
|
625 |
-
*/
|
626 |
-
public function isSynchronized()
|
627 |
-
{
|
628 |
-
return $this->synchronized;
|
629 |
-
}
|
630 |
-
|
631 |
-
/**
|
632 |
-
* Sets the lazy flag of this service.
|
633 |
-
*
|
634 |
-
* @param bool $lazy
|
635 |
-
*
|
636 |
-
* @return Definition The current instance
|
637 |
-
*/
|
638 |
-
public function setLazy($lazy)
|
639 |
-
{
|
640 |
-
$this->lazy = (bool) $lazy;
|
641 |
-
|
642 |
-
return $this;
|
643 |
-
}
|
644 |
-
|
645 |
-
/**
|
646 |
-
* Whether this service is lazy.
|
647 |
-
*
|
648 |
-
* @return bool
|
649 |
-
*/
|
650 |
-
public function isLazy()
|
651 |
-
{
|
652 |
-
return $this->lazy;
|
653 |
-
}
|
654 |
-
|
655 |
-
/**
|
656 |
-
* Sets whether this definition is synthetic, that is not constructed by the
|
657 |
-
* container, but dynamically injected.
|
658 |
-
*
|
659 |
-
* @param bool $boolean
|
660 |
-
*
|
661 |
-
* @return Definition the current instance
|
662 |
-
*
|
663 |
-
* @api
|
664 |
-
*/
|
665 |
-
public function setSynthetic($boolean)
|
666 |
-
{
|
667 |
-
$this->synthetic = (bool) $boolean;
|
668 |
-
|
669 |
-
return $this;
|
670 |
-
}
|
671 |
-
|
672 |
-
/**
|
673 |
-
* Whether this definition is synthetic, that is not constructed by the
|
674 |
-
* container, but dynamically injected.
|
675 |
-
*
|
676 |
-
* @return bool
|
677 |
-
*
|
678 |
-
* @api
|
679 |
-
*/
|
680 |
-
public function isSynthetic()
|
681 |
-
{
|
682 |
-
return $this->synthetic;
|
683 |
-
}
|
684 |
-
|
685 |
-
/**
|
686 |
-
* Whether this definition is abstract, that means it merely serves as a
|
687 |
-
* template for other definitions.
|
688 |
-
*
|
689 |
-
* @param bool $boolean
|
690 |
-
*
|
691 |
-
* @return Definition the current instance
|
692 |
-
*
|
693 |
-
* @api
|
694 |
-
*/
|
695 |
-
public function setAbstract($boolean)
|
696 |
-
{
|
697 |
-
$this->abstract = (bool) $boolean;
|
698 |
-
|
699 |
-
return $this;
|
700 |
-
}
|
701 |
-
|
702 |
-
/**
|
703 |
-
* Whether this definition is abstract, that means it merely serves as a
|
704 |
-
* template for other definitions.
|
705 |
-
*
|
706 |
-
* @return bool
|
707 |
-
*
|
708 |
-
* @api
|
709 |
-
*/
|
710 |
-
public function isAbstract()
|
711 |
-
{
|
712 |
-
return $this->abstract;
|
713 |
-
}
|
714 |
-
|
715 |
-
/**
|
716 |
-
* Sets a configurator to call after the service is fully initialized.
|
717 |
-
*
|
718 |
-
* @param callable $callable A PHP callable
|
719 |
-
*
|
720 |
-
* @return Definition The current instance
|
721 |
-
*
|
722 |
-
* @api
|
723 |
-
*/
|
724 |
-
public function setConfigurator($callable)
|
725 |
-
{
|
726 |
-
$this->configurator = $callable;
|
727 |
-
|
728 |
-
return $this;
|
729 |
-
}
|
730 |
-
|
731 |
-
/**
|
732 |
-
* Gets the configurator to call after the service is fully initialized.
|
733 |
-
*
|
734 |
-
* @return callable|null The PHP callable to call
|
735 |
-
*
|
736 |
-
* @api
|
737 |
-
*/
|
738 |
-
public function getConfigurator()
|
739 |
-
{
|
740 |
-
return $this->configurator;
|
741 |
-
}
|
742 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/DefinitionDecorator.php
DELETED
@@ -1,219 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* This definition decorates another definition.
|
19 |
-
*
|
20 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
21 |
-
*
|
22 |
-
* @api
|
23 |
-
*/
|
24 |
-
class DefinitionDecorator extends Definition
|
25 |
-
{
|
26 |
-
private $parent;
|
27 |
-
private $changes = array();
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Constructor.
|
31 |
-
*
|
32 |
-
* @param string $parent The id of Definition instance to decorate.
|
33 |
-
*
|
34 |
-
* @api
|
35 |
-
*/
|
36 |
-
public function __construct($parent)
|
37 |
-
{
|
38 |
-
parent::__construct();
|
39 |
-
|
40 |
-
$this->parent = $parent;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Returns the Definition being decorated.
|
45 |
-
*
|
46 |
-
* @return string
|
47 |
-
*
|
48 |
-
* @api
|
49 |
-
*/
|
50 |
-
public function getParent()
|
51 |
-
{
|
52 |
-
return $this->parent;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Returns all changes tracked for the Definition object.
|
57 |
-
*
|
58 |
-
* @return array An array of changes for this Definition
|
59 |
-
*
|
60 |
-
* @api
|
61 |
-
*/
|
62 |
-
public function getChanges()
|
63 |
-
{
|
64 |
-
return $this->changes;
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* {@inheritdoc}
|
69 |
-
*
|
70 |
-
* @api
|
71 |
-
*/
|
72 |
-
public function setClass($class)
|
73 |
-
{
|
74 |
-
$this->changes['class'] = true;
|
75 |
-
|
76 |
-
return parent::setClass($class);
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* {@inheritdoc}
|
81 |
-
*
|
82 |
-
* @api
|
83 |
-
*/
|
84 |
-
public function setFactoryClass($class)
|
85 |
-
{
|
86 |
-
$this->changes['factory_class'] = true;
|
87 |
-
|
88 |
-
return parent::setFactoryClass($class);
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* {@inheritdoc}
|
93 |
-
*
|
94 |
-
* @api
|
95 |
-
*/
|
96 |
-
public function setFactoryMethod($method)
|
97 |
-
{
|
98 |
-
$this->changes['factory_method'] = true;
|
99 |
-
|
100 |
-
return parent::setFactoryMethod($method);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* {@inheritdoc}
|
105 |
-
*
|
106 |
-
* @api
|
107 |
-
*/
|
108 |
-
public function setFactoryService($service)
|
109 |
-
{
|
110 |
-
$this->changes['factory_service'] = true;
|
111 |
-
|
112 |
-
return parent::setFactoryService($service);
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* {@inheritdoc}
|
117 |
-
*
|
118 |
-
* @api
|
119 |
-
*/
|
120 |
-
public function setConfigurator($callable)
|
121 |
-
{
|
122 |
-
$this->changes['configurator'] = true;
|
123 |
-
|
124 |
-
return parent::setConfigurator($callable);
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* {@inheritdoc}
|
129 |
-
*
|
130 |
-
* @api
|
131 |
-
*/
|
132 |
-
public function setFile($file)
|
133 |
-
{
|
134 |
-
$this->changes['file'] = true;
|
135 |
-
|
136 |
-
return parent::setFile($file);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* {@inheritdoc}
|
141 |
-
*
|
142 |
-
* @api
|
143 |
-
*/
|
144 |
-
public function setPublic($boolean)
|
145 |
-
{
|
146 |
-
$this->changes['public'] = true;
|
147 |
-
|
148 |
-
return parent::setPublic($boolean);
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* {@inheritdoc}
|
153 |
-
*
|
154 |
-
* @api
|
155 |
-
*/
|
156 |
-
public function setLazy($boolean)
|
157 |
-
{
|
158 |
-
$this->changes['lazy'] = true;
|
159 |
-
|
160 |
-
return parent::setLazy($boolean);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Gets an argument to pass to the service constructor/factory method.
|
165 |
-
*
|
166 |
-
* If replaceArgument() has been used to replace an argument, this method
|
167 |
-
* will return the replacement value.
|
168 |
-
*
|
169 |
-
* @param int $index
|
170 |
-
*
|
171 |
-
* @return mixed The argument value
|
172 |
-
*
|
173 |
-
* @throws OutOfBoundsException When the argument does not exist
|
174 |
-
*
|
175 |
-
* @api
|
176 |
-
*/
|
177 |
-
public function getArgument($index)
|
178 |
-
{
|
179 |
-
if (array_key_exists('index_'.$index, $this->arguments)) {
|
180 |
-
return $this->arguments['index_'.$index];
|
181 |
-
}
|
182 |
-
|
183 |
-
$lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1;
|
184 |
-
|
185 |
-
if ($index < 0 || $index > $lastIndex) {
|
186 |
-
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex));
|
187 |
-
}
|
188 |
-
|
189 |
-
return $this->arguments[$index];
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* You should always use this method when overwriting existing arguments
|
194 |
-
* of the parent definition.
|
195 |
-
*
|
196 |
-
* If you directly call setArguments() keep in mind that you must follow
|
197 |
-
* certain conventions when you want to overwrite the arguments of the
|
198 |
-
* parent definition, otherwise your arguments will only be appended.
|
199 |
-
*
|
200 |
-
* @param int $index
|
201 |
-
* @param mixed $value
|
202 |
-
*
|
203 |
-
* @return DefinitionDecorator the current instance
|
204 |
-
*
|
205 |
-
* @throws InvalidArgumentException when $index isn't an integer
|
206 |
-
*
|
207 |
-
* @api
|
208 |
-
*/
|
209 |
-
public function replaceArgument($index, $value)
|
210 |
-
{
|
211 |
-
if (!is_int($index)) {
|
212 |
-
throw new InvalidArgumentException('$index must be an integer.');
|
213 |
-
}
|
214 |
-
|
215 |
-
$this->arguments['index_'.$index] = $value;
|
216 |
-
|
217 |
-
return $this;
|
218 |
-
}
|
219 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/Dumper.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Dumper is the abstract class for all built-in dumpers.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
abstract class Dumper implements DumperInterface
|
24 |
-
{
|
25 |
-
protected $container;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Constructor.
|
29 |
-
*
|
30 |
-
* @param ContainerBuilder $container The service container to dump
|
31 |
-
*
|
32 |
-
* @api
|
33 |
-
*/
|
34 |
-
public function __construct(ContainerBuilder $container)
|
35 |
-
{
|
36 |
-
$this->container = $container;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* DumperInterface is the interface implemented by service container dumper classes.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
interface DumperInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Dumps the service container.
|
25 |
-
*
|
26 |
-
* @param array $options An array of options
|
27 |
-
*
|
28 |
-
* @return string The representation of the service container
|
29 |
-
*
|
30 |
-
* @api
|
31 |
-
*/
|
32 |
-
public function dump(array $options = array());
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
DELETED
@@ -1,302 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
use Symfony\Component\DependencyInjection\Parameter;
|
18 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
19 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
20 |
-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
21 |
-
use Symfony\Component\DependencyInjection\Scope;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* GraphvizDumper dumps a service container as a graphviz file.
|
25 |
-
*
|
26 |
-
* You can convert the generated dot file with the dot utility (http://www.graphviz.org/):
|
27 |
-
*
|
28 |
-
* dot -Tpng container.dot > foo.png
|
29 |
-
*
|
30 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
31 |
-
*/
|
32 |
-
class GraphvizDumper extends Dumper
|
33 |
-
{
|
34 |
-
private $nodes;
|
35 |
-
private $edges;
|
36 |
-
private $options = array(
|
37 |
-
'graph' => array('ratio' => 'compress'),
|
38 |
-
'node' => array('fontsize' => 11, 'fontname' => 'Arial', 'shape' => 'record'),
|
39 |
-
'edge' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => 0.5),
|
40 |
-
'node.instance' => array('fillcolor' => '#9999ff', 'style' => 'filled'),
|
41 |
-
'node.definition' => array('fillcolor' => '#eeeeee'),
|
42 |
-
'node.missing' => array('fillcolor' => '#ff9999', 'style' => 'filled'),
|
43 |
-
);
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Dumps the service container as a graphviz graph.
|
47 |
-
*
|
48 |
-
* Available options:
|
49 |
-
*
|
50 |
-
* * graph: The default options for the whole graph
|
51 |
-
* * node: The default options for nodes
|
52 |
-
* * edge: The default options for edges
|
53 |
-
* * node.instance: The default options for services that are defined directly by object instances
|
54 |
-
* * node.definition: The default options for services that are defined via service definition instances
|
55 |
-
* * node.missing: The default options for missing services
|
56 |
-
*
|
57 |
-
* @param array $options An array of options
|
58 |
-
*
|
59 |
-
* @return string The dot representation of the service container
|
60 |
-
*/
|
61 |
-
public function dump(array $options = array())
|
62 |
-
{
|
63 |
-
foreach (array('graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing') as $key) {
|
64 |
-
if (isset($options[$key])) {
|
65 |
-
$this->options[$key] = array_merge($this->options[$key], $options[$key]);
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
$this->nodes = $this->findNodes();
|
70 |
-
|
71 |
-
$this->edges = array();
|
72 |
-
foreach ($this->container->getDefinitions() as $id => $definition) {
|
73 |
-
$this->edges[$id] = array_merge(
|
74 |
-
$this->findEdges($id, $definition->getArguments(), true, ''),
|
75 |
-
$this->findEdges($id, $definition->getProperties(), false, '')
|
76 |
-
);
|
77 |
-
|
78 |
-
foreach ($definition->getMethodCalls() as $call) {
|
79 |
-
$this->edges[$id] = array_merge(
|
80 |
-
$this->edges[$id],
|
81 |
-
$this->findEdges($id, $call[1], false, $call[0].'()')
|
82 |
-
);
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
return $this->startDot().$this->addNodes().$this->addEdges().$this->endDot();
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Returns all nodes.
|
91 |
-
*
|
92 |
-
* @return string A string representation of all nodes
|
93 |
-
*/
|
94 |
-
private function addNodes()
|
95 |
-
{
|
96 |
-
$code = '';
|
97 |
-
foreach ($this->nodes as $id => $node) {
|
98 |
-
$aliases = $this->getAliases($id);
|
99 |
-
|
100 |
-
$code .= sprintf(" node_%s [label=\"%s\\n%s\\n\", shape=%s%s];\n", $this->dotize($id), $id.($aliases ? ' ('.implode(', ', $aliases).')' : ''), $node['class'], $this->options['node']['shape'], $this->addAttributes($node['attributes']));
|
101 |
-
}
|
102 |
-
|
103 |
-
return $code;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Returns all edges.
|
108 |
-
*
|
109 |
-
* @return string A string representation of all edges
|
110 |
-
*/
|
111 |
-
private function addEdges()
|
112 |
-
{
|
113 |
-
$code = '';
|
114 |
-
foreach ($this->edges as $id => $edges) {
|
115 |
-
foreach ($edges as $edge) {
|
116 |
-
$code .= sprintf(" node_%s -> node_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], $edge['required'] ? 'filled' : 'dashed');
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
return $code;
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Finds all edges belonging to a specific service id.
|
125 |
-
*
|
126 |
-
* @param string $id The service id used to find edges
|
127 |
-
* @param array $arguments An array of arguments
|
128 |
-
* @param bool $required
|
129 |
-
* @param string $name
|
130 |
-
*
|
131 |
-
* @return array An array of edges
|
132 |
-
*/
|
133 |
-
private function findEdges($id, $arguments, $required, $name)
|
134 |
-
{
|
135 |
-
$edges = array();
|
136 |
-
foreach ($arguments as $argument) {
|
137 |
-
if ($argument instanceof Parameter) {
|
138 |
-
$argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null;
|
139 |
-
} elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) {
|
140 |
-
$argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null;
|
141 |
-
}
|
142 |
-
|
143 |
-
if ($argument instanceof Reference) {
|
144 |
-
if (!$this->container->has((string) $argument)) {
|
145 |
-
$this->nodes[(string) $argument] = array('name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']);
|
146 |
-
}
|
147 |
-
|
148 |
-
$edges[] = array('name' => $name, 'required' => $required, 'to' => $argument);
|
149 |
-
} elseif (is_array($argument)) {
|
150 |
-
$edges = array_merge($edges, $this->findEdges($id, $argument, $required, $name));
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
return $edges;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Finds all nodes.
|
159 |
-
*
|
160 |
-
* @return array An array of all nodes
|
161 |
-
*/
|
162 |
-
private function findNodes()
|
163 |
-
{
|
164 |
-
$nodes = array();
|
165 |
-
|
166 |
-
$container = $this->cloneContainer();
|
167 |
-
|
168 |
-
foreach ($container->getDefinitions() as $id => $definition) {
|
169 |
-
$className = $definition->getClass();
|
170 |
-
|
171 |
-
try {
|
172 |
-
$className = $this->container->getParameterBag()->resolveValue($className);
|
173 |
-
} catch (ParameterNotFoundException $e) {
|
174 |
-
}
|
175 |
-
|
176 |
-
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
|
177 |
-
$container->setDefinition($id, new Definition('stdClass'));
|
178 |
-
}
|
179 |
-
|
180 |
-
foreach ($container->getServiceIds() as $id) {
|
181 |
-
$service = $container->get($id);
|
182 |
-
|
183 |
-
if (in_array($id, array_keys($container->getAliases()))) {
|
184 |
-
continue;
|
185 |
-
}
|
186 |
-
|
187 |
-
if (!$container->hasDefinition($id)) {
|
188 |
-
$class = ('service_container' === $id) ? get_class($this->container) : get_class($service);
|
189 |
-
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => $this->options['node.instance']);
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
return $nodes;
|
194 |
-
}
|
195 |
-
|
196 |
-
private function cloneContainer()
|
197 |
-
{
|
198 |
-
$parameterBag = new ParameterBag($this->container->getParameterBag()->all());
|
199 |
-
|
200 |
-
$container = new ContainerBuilder($parameterBag);
|
201 |
-
$container->setDefinitions($this->container->getDefinitions());
|
202 |
-
$container->setAliases($this->container->getAliases());
|
203 |
-
$container->setResources($this->container->getResources());
|
204 |
-
foreach ($this->container->getScopes() as $scope => $parentScope) {
|
205 |
-
$container->addScope(new Scope($scope, $parentScope));
|
206 |
-
}
|
207 |
-
foreach ($this->container->getExtensions() as $extension) {
|
208 |
-
$container->registerExtension($extension);
|
209 |
-
}
|
210 |
-
|
211 |
-
return $container;
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Returns the start dot.
|
216 |
-
*
|
217 |
-
* @return string The string representation of a start dot
|
218 |
-
*/
|
219 |
-
private function startDot()
|
220 |
-
{
|
221 |
-
return sprintf("digraph sc {\n %s\n node [%s];\n edge [%s];\n\n",
|
222 |
-
$this->addOptions($this->options['graph']),
|
223 |
-
$this->addOptions($this->options['node']),
|
224 |
-
$this->addOptions($this->options['edge'])
|
225 |
-
);
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Returns the end dot.
|
230 |
-
*
|
231 |
-
* @return string
|
232 |
-
*/
|
233 |
-
private function endDot()
|
234 |
-
{
|
235 |
-
return "}\n";
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Adds attributes.
|
240 |
-
*
|
241 |
-
* @param array $attributes An array of attributes
|
242 |
-
*
|
243 |
-
* @return string A comma separated list of attributes
|
244 |
-
*/
|
245 |
-
private function addAttributes($attributes)
|
246 |
-
{
|
247 |
-
$code = array();
|
248 |
-
foreach ($attributes as $k => $v) {
|
249 |
-
$code[] = sprintf('%s="%s"', $k, $v);
|
250 |
-
}
|
251 |
-
|
252 |
-
return $code ? ', '.implode(', ', $code) : '';
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Adds options.
|
257 |
-
*
|
258 |
-
* @param array $options An array of options
|
259 |
-
*
|
260 |
-
* @return string A space separated list of options
|
261 |
-
*/
|
262 |
-
private function addOptions($options)
|
263 |
-
{
|
264 |
-
$code = array();
|
265 |
-
foreach ($options as $k => $v) {
|
266 |
-
$code[] = sprintf('%s="%s"', $k, $v);
|
267 |
-
}
|
268 |
-
|
269 |
-
return implode(' ', $code);
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Dotizes an identifier.
|
274 |
-
*
|
275 |
-
* @param string $id The identifier to dotize
|
276 |
-
*
|
277 |
-
* @return string A dotized string
|
278 |
-
*/
|
279 |
-
private function dotize($id)
|
280 |
-
{
|
281 |
-
return strtolower(preg_replace('/[^\w]/i', '_', $id));
|
282 |
-
}
|
283 |
-
|
284 |
-
/**
|
285 |
-
* Compiles an array of aliases for a specified service id.
|
286 |
-
*
|
287 |
-
* @param string $id A service id
|
288 |
-
*
|
289 |
-
* @return array An array of aliases
|
290 |
-
*/
|
291 |
-
private function getAliases($id)
|
292 |
-
{
|
293 |
-
$aliases = array();
|
294 |
-
foreach ($this->container->getAliases() as $alias => $origin) {
|
295 |
-
if ($id == $origin) {
|
296 |
-
$aliases[] = $alias;
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
return $aliases;
|
301 |
-
}
|
302 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
DELETED
@@ -1,1448 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Variable;
|
15 |
-
use Symfony\Component\DependencyInjection\Definition;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 |
-
use Symfony\Component\DependencyInjection\Container;
|
18 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
19 |
-
use Symfony\Component\DependencyInjection\Reference;
|
20 |
-
use Symfony\Component\DependencyInjection\Parameter;
|
21 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
22 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
23 |
-
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
24 |
-
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper;
|
25 |
-
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
|
26 |
-
use Symfony\Component\DependencyInjection\ExpressionLanguage;
|
27 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* PhpDumper dumps a service container as a PHP class.
|
31 |
-
*
|
32 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
33 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
34 |
-
*
|
35 |
-
* @api
|
36 |
-
*/
|
37 |
-
class PhpDumper extends Dumper
|
38 |
-
{
|
39 |
-
/**
|
40 |
-
* Characters that might appear in the generated variable name as first character.
|
41 |
-
*
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
const FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Characters that might appear in the generated variable name as any but the first character.
|
48 |
-
*
|
49 |
-
* @var string
|
50 |
-
*/
|
51 |
-
const NON_FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_';
|
52 |
-
|
53 |
-
private $inlinedDefinitions;
|
54 |
-
private $definitionVariables;
|
55 |
-
private $referenceVariables;
|
56 |
-
private $variableCount;
|
57 |
-
private $reservedVariables = array('instance', 'class');
|
58 |
-
private $expressionLanguage;
|
59 |
-
private $targetDirRegex;
|
60 |
-
private $targetDirMaxMatches;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
|
64 |
-
*/
|
65 |
-
private $proxyDumper;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* {@inheritdoc}
|
69 |
-
*
|
70 |
-
* @api
|
71 |
-
*/
|
72 |
-
public function __construct(ContainerBuilder $container)
|
73 |
-
{
|
74 |
-
parent::__construct($container);
|
75 |
-
|
76 |
-
$this->inlinedDefinitions = new \SplObjectStorage();
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Sets the dumper to be used when dumping proxies in the generated container.
|
81 |
-
*
|
82 |
-
* @param ProxyDumper $proxyDumper
|
83 |
-
*/
|
84 |
-
public function setProxyDumper(ProxyDumper $proxyDumper)
|
85 |
-
{
|
86 |
-
$this->proxyDumper = $proxyDumper;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Dumps the service container as a PHP class.
|
91 |
-
*
|
92 |
-
* Available options:
|
93 |
-
*
|
94 |
-
* * class: The class name
|
95 |
-
* * base_class: The base class name
|
96 |
-
* * namespace: The class namespace
|
97 |
-
*
|
98 |
-
* @param array $options An array of options
|
99 |
-
*
|
100 |
-
* @return string A PHP class representing of the service container
|
101 |
-
*
|
102 |
-
* @api
|
103 |
-
*/
|
104 |
-
public function dump(array $options = array())
|
105 |
-
{
|
106 |
-
$this->targetDirRegex = null;
|
107 |
-
$options = array_merge(array(
|
108 |
-
'class' => 'ProjectServiceContainer',
|
109 |
-
'base_class' => 'Container',
|
110 |
-
'namespace' => '',
|
111 |
-
), $options);
|
112 |
-
|
113 |
-
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
|
114 |
-
// Build a regexp where the first root dirs are mandatory,
|
115 |
-
// but every other sub-dir is optional up to the full path in $dir
|
116 |
-
// Mandate at least 2 root dirs and not more that 5 optional dirs.
|
117 |
-
|
118 |
-
$dir = explode(DIRECTORY_SEPARATOR, realpath($dir));
|
119 |
-
$i = count($dir);
|
120 |
-
|
121 |
-
if (3 <= $i) {
|
122 |
-
$regex = '';
|
123 |
-
$lastOptionalDir = $i > 8 ? $i - 5 : 3;
|
124 |
-
$this->targetDirMaxMatches = $i - $lastOptionalDir;
|
125 |
-
|
126 |
-
while (--$i >= $lastOptionalDir) {
|
127 |
-
$regex = sprintf('(%s%s)?', preg_quote(DIRECTORY_SEPARATOR.$dir[$i], '#'), $regex);
|
128 |
-
}
|
129 |
-
|
130 |
-
do {
|
131 |
-
$regex = preg_quote(DIRECTORY_SEPARATOR.$dir[$i], '#').$regex;
|
132 |
-
} while (0 < --$i);
|
133 |
-
|
134 |
-
$this->targetDirRegex = '#'.preg_quote($dir[0], '#').$regex.'#';
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
$code = $this->startClass($options['class'], $options['base_class'], $options['namespace']);
|
139 |
-
|
140 |
-
if ($this->container->isFrozen()) {
|
141 |
-
$code .= $this->addFrozenConstructor();
|
142 |
-
} else {
|
143 |
-
$code .= $this->addConstructor();
|
144 |
-
}
|
145 |
-
|
146 |
-
$code .=
|
147 |
-
$this->addServices().
|
148 |
-
$this->addDefaultParametersMethod().
|
149 |
-
$this->endClass().
|
150 |
-
$this->addProxyClasses()
|
151 |
-
;
|
152 |
-
$this->targetDirRegex = null;
|
153 |
-
|
154 |
-
return $code;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Retrieves the currently set proxy dumper or instantiates one.
|
159 |
-
*
|
160 |
-
* @return ProxyDumper
|
161 |
-
*/
|
162 |
-
private function getProxyDumper()
|
163 |
-
{
|
164 |
-
if (!$this->proxyDumper) {
|
165 |
-
$this->proxyDumper = new NullDumper();
|
166 |
-
}
|
167 |
-
|
168 |
-
return $this->proxyDumper;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Generates Service local temp variables.
|
173 |
-
*
|
174 |
-
* @param string $cId
|
175 |
-
* @param string $definition
|
176 |
-
*
|
177 |
-
* @return string
|
178 |
-
*/
|
179 |
-
private function addServiceLocalTempVariables($cId, $definition)
|
180 |
-
{
|
181 |
-
static $template = " \$%s = %s;\n";
|
182 |
-
|
183 |
-
$localDefinitions = array_merge(
|
184 |
-
array($definition),
|
185 |
-
$this->getInlinedDefinitions($definition)
|
186 |
-
);
|
187 |
-
|
188 |
-
$calls = $behavior = array();
|
189 |
-
foreach ($localDefinitions as $iDefinition) {
|
190 |
-
$this->getServiceCallsFromArguments($iDefinition->getArguments(), $calls, $behavior);
|
191 |
-
$this->getServiceCallsFromArguments($iDefinition->getMethodCalls(), $calls, $behavior);
|
192 |
-
$this->getServiceCallsFromArguments($iDefinition->getProperties(), $calls, $behavior);
|
193 |
-
$this->getServiceCallsFromArguments(array($iDefinition->getConfigurator()), $calls, $behavior);
|
194 |
-
}
|
195 |
-
|
196 |
-
$code = '';
|
197 |
-
foreach ($calls as $id => $callCount) {
|
198 |
-
if ('service_container' === $id || $id === $cId) {
|
199 |
-
continue;
|
200 |
-
}
|
201 |
-
|
202 |
-
if ($callCount > 1) {
|
203 |
-
$name = $this->getNextVariableName();
|
204 |
-
$this->referenceVariables[$id] = new Variable($name);
|
205 |
-
|
206 |
-
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $behavior[$id]) {
|
207 |
-
$code .= sprintf($template, $name, $this->getServiceCall($id));
|
208 |
-
} else {
|
209 |
-
$code .= sprintf($template, $name, $this->getServiceCall($id, new Reference($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)));
|
210 |
-
}
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
if ('' !== $code) {
|
215 |
-
$code .= "\n";
|
216 |
-
}
|
217 |
-
|
218 |
-
return $code;
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Generates code for the proxies to be attached after the container class.
|
223 |
-
*
|
224 |
-
* @return string
|
225 |
-
*/
|
226 |
-
private function addProxyClasses()
|
227 |
-
{
|
228 |
-
/* @var $definitions Definition[] */
|
229 |
-
$definitions = array_filter(
|
230 |
-
$this->container->getDefinitions(),
|
231 |
-
array($this->getProxyDumper(), 'isProxyCandidate')
|
232 |
-
);
|
233 |
-
$code = '';
|
234 |
-
|
235 |
-
foreach ($definitions as $definition) {
|
236 |
-
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
|
237 |
-
}
|
238 |
-
|
239 |
-
return $code;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Generates the require_once statement for service includes.
|
244 |
-
*
|
245 |
-
* @param string $id The service id
|
246 |
-
* @param Definition $definition
|
247 |
-
*
|
248 |
-
* @return string
|
249 |
-
*/
|
250 |
-
private function addServiceInclude($id, $definition)
|
251 |
-
{
|
252 |
-
$template = " require_once %s;\n";
|
253 |
-
$code = '';
|
254 |
-
|
255 |
-
if (null !== $file = $definition->getFile()) {
|
256 |
-
$code .= sprintf($template, $this->dumpValue($file));
|
257 |
-
}
|
258 |
-
|
259 |
-
foreach ($this->getInlinedDefinitions($definition) as $definition) {
|
260 |
-
if (null !== $file = $definition->getFile()) {
|
261 |
-
$code .= sprintf($template, $this->dumpValue($file));
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
if ('' !== $code) {
|
266 |
-
$code .= "\n";
|
267 |
-
}
|
268 |
-
|
269 |
-
return $code;
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Generates the inline definition of a service.
|
274 |
-
*
|
275 |
-
* @param string $id
|
276 |
-
* @param Definition $definition
|
277 |
-
*
|
278 |
-
* @return string
|
279 |
-
*
|
280 |
-
* @throws RuntimeException When the factory definition is incomplete
|
281 |
-
* @throws ServiceCircularReferenceException When a circular reference is detected
|
282 |
-
*/
|
283 |
-
private function addServiceInlinedDefinitions($id, $definition)
|
284 |
-
{
|
285 |
-
$code = '';
|
286 |
-
$variableMap = $this->definitionVariables;
|
287 |
-
$nbOccurrences = new \SplObjectStorage();
|
288 |
-
$processed = new \SplObjectStorage();
|
289 |
-
$inlinedDefinitions = $this->getInlinedDefinitions($definition);
|
290 |
-
|
291 |
-
foreach ($inlinedDefinitions as $definition) {
|
292 |
-
if (false === $nbOccurrences->contains($definition)) {
|
293 |
-
$nbOccurrences->offsetSet($definition, 1);
|
294 |
-
} else {
|
295 |
-
$i = $nbOccurrences->offsetGet($definition);
|
296 |
-
$nbOccurrences->offsetSet($definition, $i + 1);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
foreach ($inlinedDefinitions as $sDefinition) {
|
301 |
-
if ($processed->contains($sDefinition)) {
|
302 |
-
continue;
|
303 |
-
}
|
304 |
-
$processed->offsetSet($sDefinition);
|
305 |
-
|
306 |
-
$class = $this->dumpValue($sDefinition->getClass());
|
307 |
-
if ($nbOccurrences->offsetGet($sDefinition) > 1 || $sDefinition->getMethodCalls() || $sDefinition->getProperties() || null !== $sDefinition->getConfigurator() || false !== strpos($class, '$')) {
|
308 |
-
$name = $this->getNextVariableName();
|
309 |
-
$variableMap->offsetSet($sDefinition, new Variable($name));
|
310 |
-
|
311 |
-
// a construct like:
|
312 |
-
// $a = new ServiceA(ServiceB $b); $b = new ServiceB(ServiceA $a);
|
313 |
-
// this is an indication for a wrong implementation, you can circumvent this problem
|
314 |
-
// by setting up your service structure like this:
|
315 |
-
// $b = new ServiceB();
|
316 |
-
// $a = new ServiceA(ServiceB $b);
|
317 |
-
// $b->setServiceA(ServiceA $a);
|
318 |
-
if ($this->hasReference($id, $sDefinition->getArguments())) {
|
319 |
-
throw new ServiceCircularReferenceException($id, array($id));
|
320 |
-
}
|
321 |
-
|
322 |
-
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');
|
323 |
-
|
324 |
-
if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
|
325 |
-
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
|
326 |
-
$code .= $this->addServiceProperties(null, $sDefinition, $name);
|
327 |
-
$code .= $this->addServiceConfigurator(null, $sDefinition, $name);
|
328 |
-
}
|
329 |
-
|
330 |
-
$code .= "\n";
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
return $code;
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Adds the service return statement.
|
339 |
-
*
|
340 |
-
* @param string $id Service id
|
341 |
-
* @param Definition $definition
|
342 |
-
*
|
343 |
-
* @return string
|
344 |
-
*/
|
345 |
-
private function addServiceReturn($id, $definition)
|
346 |
-
{
|
347 |
-
if ($this->isSimpleInstance($id, $definition)) {
|
348 |
-
return " }\n";
|
349 |
-
}
|
350 |
-
|
351 |
-
return "\n return \$instance;\n }\n";
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Generates the service instance.
|
356 |
-
*
|
357 |
-
* @param string $id
|
358 |
-
* @param Definition $definition
|
359 |
-
*
|
360 |
-
* @return string
|
361 |
-
*
|
362 |
-
* @throws InvalidArgumentException
|
363 |
-
* @throws RuntimeException
|
364 |
-
*/
|
365 |
-
private function addServiceInstance($id, $definition)
|
366 |
-
{
|
367 |
-
$class = $this->dumpValue($definition->getClass());
|
368 |
-
|
369 |
-
if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
|
370 |
-
throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
|
371 |
-
}
|
372 |
-
|
373 |
-
$simple = $this->isSimpleInstance($id, $definition);
|
374 |
-
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
|
375 |
-
$instantiation = '';
|
376 |
-
|
377 |
-
if (!$isProxyCandidate && ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
|
378 |
-
$instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance');
|
379 |
-
} elseif (!$isProxyCandidate && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
|
380 |
-
$instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance');
|
381 |
-
} elseif (!$simple) {
|
382 |
-
$instantiation = '$instance';
|
383 |
-
}
|
384 |
-
|
385 |
-
$return = '';
|
386 |
-
if ($simple) {
|
387 |
-
$return = 'return ';
|
388 |
-
} else {
|
389 |
-
$instantiation .= ' = ';
|
390 |
-
}
|
391 |
-
|
392 |
-
$code = $this->addNewInstance($id, $definition, $return, $instantiation);
|
393 |
-
|
394 |
-
if (!$simple) {
|
395 |
-
$code .= "\n";
|
396 |
-
}
|
397 |
-
|
398 |
-
return $code;
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Checks if the definition is a simple instance.
|
403 |
-
*
|
404 |
-
* @param string $id
|
405 |
-
* @param Definition $definition
|
406 |
-
*
|
407 |
-
* @return bool
|
408 |
-
*/
|
409 |
-
private function isSimpleInstance($id, $definition)
|
410 |
-
{
|
411 |
-
foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) {
|
412 |
-
if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) {
|
413 |
-
continue;
|
414 |
-
}
|
415 |
-
|
416 |
-
if ($sDefinition->getMethodCalls() || $sDefinition->getProperties() || $sDefinition->getConfigurator()) {
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
}
|
420 |
-
|
421 |
-
return true;
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* Adds method calls to a service definition.
|
426 |
-
*
|
427 |
-
* @param string $id
|
428 |
-
* @param Definition $definition
|
429 |
-
* @param string $variableName
|
430 |
-
*
|
431 |
-
* @return string
|
432 |
-
*/
|
433 |
-
private function addServiceMethodCalls($id, $definition, $variableName = 'instance')
|
434 |
-
{
|
435 |
-
$calls = '';
|
436 |
-
foreach ($definition->getMethodCalls() as $call) {
|
437 |
-
$arguments = array();
|
438 |
-
foreach ($call[1] as $value) {
|
439 |
-
$arguments[] = $this->dumpValue($value);
|
440 |
-
}
|
441 |
-
|
442 |
-
$calls .= $this->wrapServiceConditionals($call[1], sprintf(" \$%s->%s(%s);\n", $variableName, $call[0], implode(', ', $arguments)));
|
443 |
-
}
|
444 |
-
|
445 |
-
return $calls;
|
446 |
-
}
|
447 |
-
|
448 |
-
private function addServiceProperties($id, $definition, $variableName = 'instance')
|
449 |
-
{
|
450 |
-
$code = '';
|
451 |
-
foreach ($definition->getProperties() as $name => $value) {
|
452 |
-
$code .= sprintf(" \$%s->%s = %s;\n", $variableName, $name, $this->dumpValue($value));
|
453 |
-
}
|
454 |
-
|
455 |
-
return $code;
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Generates the inline definition setup.
|
460 |
-
*
|
461 |
-
* @param string $id
|
462 |
-
* @param Definition $definition
|
463 |
-
*
|
464 |
-
* @return string
|
465 |
-
*
|
466 |
-
* @throws ServiceCircularReferenceException when the container contains a circular reference
|
467 |
-
*/
|
468 |
-
private function addServiceInlinedDefinitionsSetup($id, $definition)
|
469 |
-
{
|
470 |
-
$this->referenceVariables[$id] = new Variable('instance');
|
471 |
-
|
472 |
-
$code = '';
|
473 |
-
$processed = new \SplObjectStorage();
|
474 |
-
foreach ($this->getInlinedDefinitions($definition) as $iDefinition) {
|
475 |
-
if ($processed->contains($iDefinition)) {
|
476 |
-
continue;
|
477 |
-
}
|
478 |
-
$processed->offsetSet($iDefinition);
|
479 |
-
|
480 |
-
if (!$this->hasReference($id, $iDefinition->getMethodCalls(), true) && !$this->hasReference($id, $iDefinition->getProperties(), true)) {
|
481 |
-
continue;
|
482 |
-
}
|
483 |
-
|
484 |
-
// if the instance is simple, the return statement has already been generated
|
485 |
-
// so, the only possible way to get there is because of a circular reference
|
486 |
-
if ($this->isSimpleInstance($id, $definition)) {
|
487 |
-
throw new ServiceCircularReferenceException($id, array($id));
|
488 |
-
}
|
489 |
-
|
490 |
-
$name = (string) $this->definitionVariables->offsetGet($iDefinition);
|
491 |
-
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
|
492 |
-
$code .= $this->addServiceProperties(null, $iDefinition, $name);
|
493 |
-
$code .= $this->addServiceConfigurator(null, $iDefinition, $name);
|
494 |
-
}
|
495 |
-
|
496 |
-
if ('' !== $code) {
|
497 |
-
$code .= "\n";
|
498 |
-
}
|
499 |
-
|
500 |
-
return $code;
|
501 |
-
}
|
502 |
-
|
503 |
-
/**
|
504 |
-
* Adds configurator definition.
|
505 |
-
*
|
506 |
-
* @param string $id
|
507 |
-
* @param Definition $definition
|
508 |
-
* @param string $variableName
|
509 |
-
*
|
510 |
-
* @return string
|
511 |
-
*/
|
512 |
-
private function addServiceConfigurator($id, $definition, $variableName = 'instance')
|
513 |
-
{
|
514 |
-
if (!$callable = $definition->getConfigurator()) {
|
515 |
-
return '';
|
516 |
-
}
|
517 |
-
|
518 |
-
if (is_array($callable)) {
|
519 |
-
if ($callable[0] instanceof Reference
|
520 |
-
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
|
521 |
-
return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
|
522 |
-
}
|
523 |
-
|
524 |
-
$class = $this->dumpValue($callable[0]);
|
525 |
-
// If the class is a string we can optimize call_user_func away
|
526 |
-
if (strpos($class, "'") === 0) {
|
527 |
-
return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
|
528 |
-
}
|
529 |
-
|
530 |
-
return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
|
531 |
-
}
|
532 |
-
|
533 |
-
return sprintf(" %s(\$%s);\n", $callable, $variableName);
|
534 |
-
}
|
535 |
-
|
536 |
-
/**
|
537 |
-
* Adds a service.
|
538 |
-
*
|
539 |
-
* @param string $id
|
540 |
-
* @param Definition $definition
|
541 |
-
*
|
542 |
-
* @return string
|
543 |
-
*/
|
544 |
-
private function addService($id, $definition)
|
545 |
-
{
|
546 |
-
$this->definitionVariables = new \SplObjectStorage();
|
547 |
-
$this->referenceVariables = array();
|
548 |
-
$this->variableCount = 0;
|
549 |
-
|
550 |
-
$return = array();
|
551 |
-
|
552 |
-
if ($definition->isSynthetic()) {
|
553 |
-
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
|
554 |
-
} elseif ($class = $definition->getClass()) {
|
555 |
-
$return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
|
556 |
-
} elseif ($definition->getFactoryClass()) {
|
557 |
-
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod());
|
558 |
-
} elseif ($definition->getFactoryService()) {
|
559 |
-
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryService(), $definition->getFactoryMethod());
|
560 |
-
}
|
561 |
-
|
562 |
-
$scope = $definition->getScope();
|
563 |
-
if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) {
|
564 |
-
if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
|
565 |
-
$return[] = '';
|
566 |
-
}
|
567 |
-
$return[] = sprintf("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active", $id, $scope);
|
568 |
-
}
|
569 |
-
|
570 |
-
$return = implode("\n * ", $return);
|
571 |
-
|
572 |
-
$doc = '';
|
573 |
-
if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
|
574 |
-
$doc .= <<<EOF
|
575 |
-
|
576 |
-
*
|
577 |
-
* This service is shared.
|
578 |
-
* This method always returns the same instance of the service.
|
579 |
-
EOF;
|
580 |
-
}
|
581 |
-
|
582 |
-
if (!$definition->isPublic()) {
|
583 |
-
$doc .= <<<EOF
|
584 |
-
|
585 |
-
*
|
586 |
-
* This service is private.
|
587 |
-
* If you want to be able to request this service from the container directly,
|
588 |
-
* make it public, otherwise you might end up with broken code.
|
589 |
-
EOF;
|
590 |
-
}
|
591 |
-
|
592 |
-
if ($definition->isLazy()) {
|
593 |
-
$lazyInitialization = '$lazyLoad = true';
|
594 |
-
$lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *";
|
595 |
-
} else {
|
596 |
-
$lazyInitialization = '';
|
597 |
-
$lazyInitializationDoc = '';
|
598 |
-
}
|
599 |
-
|
600 |
-
// with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
|
601 |
-
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
|
602 |
-
$visibility = $isProxyCandidate ? 'public' : 'protected';
|
603 |
-
$code = <<<EOF
|
604 |
-
|
605 |
-
/**
|
606 |
-
* Gets the '$id' service.$doc
|
607 |
-
*$lazyInitializationDoc
|
608 |
-
* $return
|
609 |
-
*/
|
610 |
-
{$visibility} function get{$this->camelize($id)}Service($lazyInitialization)
|
611 |
-
{
|
612 |
-
|
613 |
-
EOF;
|
614 |
-
|
615 |
-
$code .= $isProxyCandidate ? $this->getProxyDumper()->getProxyFactoryCode($definition, $id) : '';
|
616 |
-
|
617 |
-
if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) {
|
618 |
-
$code .= <<<EOF
|
619 |
-
if (!isset(\$this->scopedServices['$scope'])) {
|
620 |
-
throw new InactiveScopeException('$id', '$scope');
|
621 |
-
}
|
622 |
-
|
623 |
-
|
624 |
-
EOF;
|
625 |
-
}
|
626 |
-
|
627 |
-
if ($definition->isSynthetic()) {
|
628 |
-
$code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id);
|
629 |
-
} else {
|
630 |
-
$code .=
|
631 |
-
$this->addServiceInclude($id, $definition).
|
632 |
-
$this->addServiceLocalTempVariables($id, $definition).
|
633 |
-
$this->addServiceInlinedDefinitions($id, $definition).
|
634 |
-
$this->addServiceInstance($id, $definition).
|
635 |
-
$this->addServiceInlinedDefinitionsSetup($id, $definition).
|
636 |
-
$this->addServiceMethodCalls($id, $definition).
|
637 |
-
$this->addServiceProperties($id, $definition).
|
638 |
-
$this->addServiceConfigurator($id, $definition).
|
639 |
-
$this->addServiceReturn($id, $definition)
|
640 |
-
;
|
641 |
-
}
|
642 |
-
|
643 |
-
$this->definitionVariables = null;
|
644 |
-
$this->referenceVariables = null;
|
645 |
-
|
646 |
-
return $code;
|
647 |
-
}
|
648 |
-
|
649 |
-
/**
|
650 |
-
* Adds multiple services.
|
651 |
-
*
|
652 |
-
* @return string
|
653 |
-
*/
|
654 |
-
private function addServices()
|
655 |
-
{
|
656 |
-
$publicServices = $privateServices = $synchronizers = '';
|
657 |
-
$definitions = $this->container->getDefinitions();
|
658 |
-
ksort($definitions);
|
659 |
-
foreach ($definitions as $id => $definition) {
|
660 |
-
if ($definition->isPublic()) {
|
661 |
-
$publicServices .= $this->addService($id, $definition);
|
662 |
-
} else {
|
663 |
-
$privateServices .= $this->addService($id, $definition);
|
664 |
-
}
|
665 |
-
|
666 |
-
$synchronizers .= $this->addServiceSynchronizer($id, $definition);
|
667 |
-
}
|
668 |
-
|
669 |
-
return $publicServices.$synchronizers.$privateServices;
|
670 |
-
}
|
671 |
-
|
672 |
-
/**
|
673 |
-
* Adds synchronizer methods.
|
674 |
-
*
|
675 |
-
* @param string $id A service identifier
|
676 |
-
* @param Definition $definition A Definition instance
|
677 |
-
*
|
678 |
-
* @return string|null
|
679 |
-
*/
|
680 |
-
private function addServiceSynchronizer($id, Definition $definition)
|
681 |
-
{
|
682 |
-
if (!$definition->isSynchronized()) {
|
683 |
-
return;
|
684 |
-
}
|
685 |
-
|
686 |
-
$code = '';
|
687 |
-
foreach ($this->container->getDefinitions() as $definitionId => $definition) {
|
688 |
-
foreach ($definition->getMethodCalls() as $call) {
|
689 |
-
foreach ($call[1] as $argument) {
|
690 |
-
if ($argument instanceof Reference && $id == (string) $argument) {
|
691 |
-
$arguments = array();
|
692 |
-
foreach ($call[1] as $value) {
|
693 |
-
$arguments[] = $this->dumpValue($value);
|
694 |
-
}
|
695 |
-
|
696 |
-
$call = $this->wrapServiceConditionals($call[1], sprintf("\$this->get('%s')->%s(%s);", $definitionId, $call[0], implode(', ', $arguments)));
|
697 |
-
|
698 |
-
$code .= <<<EOF
|
699 |
-
if (\$this->initialized('$definitionId')) {
|
700 |
-
$call
|
701 |
-
}
|
702 |
-
|
703 |
-
EOF;
|
704 |
-
}
|
705 |
-
}
|
706 |
-
}
|
707 |
-
}
|
708 |
-
|
709 |
-
if (!$code) {
|
710 |
-
return;
|
711 |
-
}
|
712 |
-
|
713 |
-
return <<<EOF
|
714 |
-
|
715 |
-
/**
|
716 |
-
* Updates the '$id' service.
|
717 |
-
*/
|
718 |
-
protected function synchronize{$this->camelize($id)}Service()
|
719 |
-
{
|
720 |
-
$code }
|
721 |
-
|
722 |
-
EOF;
|
723 |
-
}
|
724 |
-
|
725 |
-
private function addNewInstance($id, Definition $definition, $return, $instantiation)
|
726 |
-
{
|
727 |
-
$class = $this->dumpValue($definition->getClass());
|
728 |
-
|
729 |
-
$arguments = array();
|
730 |
-
foreach ($definition->getArguments() as $value) {
|
731 |
-
$arguments[] = $this->dumpValue($value);
|
732 |
-
}
|
733 |
-
|
734 |
-
if (null !== $definition->getFactoryMethod()) {
|
735 |
-
if (null !== $definition->getFactoryClass()) {
|
736 |
-
$class = $this->dumpValue($definition->getFactoryClass());
|
737 |
-
|
738 |
-
// If the class is a string we can optimize call_user_func away
|
739 |
-
if (strpos($class, "'") === 0) {
|
740 |
-
return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(), $arguments ? implode(', ', $arguments) : '');
|
741 |
-
}
|
742 |
-
|
743 |
-
return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : '');
|
744 |
-
}
|
745 |
-
|
746 |
-
if (null !== $definition->getFactoryService()) {
|
747 |
-
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments));
|
748 |
-
}
|
749 |
-
|
750 |
-
throw new RuntimeException(sprintf('Factory method requires a factory service or factory class in service definition for %s', $id));
|
751 |
-
}
|
752 |
-
|
753 |
-
if (false !== strpos($class, '$')) {
|
754 |
-
return sprintf(" \$class = %s;\n\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
|
755 |
-
}
|
756 |
-
|
757 |
-
return sprintf(" $return{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments));
|
758 |
-
}
|
759 |
-
|
760 |
-
/**
|
761 |
-
* Adds the class headers.
|
762 |
-
*
|
763 |
-
* @param string $class Class name
|
764 |
-
* @param string $baseClass The name of the base class
|
765 |
-
* @param string $namespace The class namespace
|
766 |
-
*
|
767 |
-
* @return string
|
768 |
-
*/
|
769 |
-
private function startClass($class, $baseClass, $namespace)
|
770 |
-
{
|
771 |
-
$bagClass = $this->container->isFrozen() ? 'use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;' : 'use Symfony\Component\DependencyInjection\ParameterBag\\ParameterBag;';
|
772 |
-
$namespaceLine = $namespace ? "namespace $namespace;\n" : '';
|
773 |
-
|
774 |
-
return <<<EOF
|
775 |
-
<?php
|
776 |
-
$namespaceLine
|
777 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
778 |
-
use Symfony\Component\DependencyInjection\Container;
|
779 |
-
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
780 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
781 |
-
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
782 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
783 |
-
$bagClass
|
784 |
-
|
785 |
-
/**
|
786 |
-
* $class
|
787 |
-
*
|
788 |
-
* This class has been auto-generated
|
789 |
-
* by the Symfony Dependency Injection Component.
|
790 |
-
*/
|
791 |
-
class $class extends $baseClass
|
792 |
-
{
|
793 |
-
private \$parameters;
|
794 |
-
private \$targetDirs = array();
|
795 |
-
|
796 |
-
EOF;
|
797 |
-
}
|
798 |
-
|
799 |
-
/**
|
800 |
-
* Adds the constructor.
|
801 |
-
*
|
802 |
-
* @return string
|
803 |
-
*/
|
804 |
-
private function addConstructor()
|
805 |
-
{
|
806 |
-
$targetDirs = $this->exportTargetDirs();
|
807 |
-
$arguments = $this->container->getParameterBag()->all() ? 'new ParameterBag($this->getDefaultParameters())' : null;
|
808 |
-
|
809 |
-
$code = <<<EOF
|
810 |
-
|
811 |
-
/**
|
812 |
-
* Constructor.
|
813 |
-
*/
|
814 |
-
public function __construct()
|
815 |
-
{{$targetDirs}
|
816 |
-
parent::__construct($arguments);
|
817 |
-
|
818 |
-
EOF;
|
819 |
-
|
820 |
-
if (count($scopes = $this->container->getScopes()) > 0) {
|
821 |
-
$code .= "\n";
|
822 |
-
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
|
823 |
-
$code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
|
824 |
-
}
|
825 |
-
|
826 |
-
$code .= $this->addMethodMap();
|
827 |
-
$code .= $this->addAliases();
|
828 |
-
|
829 |
-
$code .= <<<EOF
|
830 |
-
}
|
831 |
-
|
832 |
-
EOF;
|
833 |
-
|
834 |
-
return $code;
|
835 |
-
}
|
836 |
-
|
837 |
-
/**
|
838 |
-
* Adds the constructor for a frozen container.
|
839 |
-
*
|
840 |
-
* @return string
|
841 |
-
*/
|
842 |
-
private function addFrozenConstructor()
|
843 |
-
{
|
844 |
-
$targetDirs = $this->exportTargetDirs();
|
845 |
-
|
846 |
-
$code = <<<EOF
|
847 |
-
|
848 |
-
/**
|
849 |
-
* Constructor.
|
850 |
-
*/
|
851 |
-
public function __construct()
|
852 |
-
{{$targetDirs}
|
853 |
-
EOF;
|
854 |
-
|
855 |
-
if ($this->container->getParameterBag()->all()) {
|
856 |
-
$code .= "\n \$this->parameters = \$this->getDefaultParameters();\n";
|
857 |
-
}
|
858 |
-
|
859 |
-
$code .= <<<EOF
|
860 |
-
|
861 |
-
\$this->services =
|
862 |
-
\$this->scopedServices =
|
863 |
-
\$this->scopeStacks = array();
|
864 |
-
|
865 |
-
\$this->set('service_container', \$this);
|
866 |
-
|
867 |
-
EOF;
|
868 |
-
|
869 |
-
$code .= "\n";
|
870 |
-
if (count($scopes = $this->container->getScopes()) > 0) {
|
871 |
-
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
|
872 |
-
$code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
|
873 |
-
} else {
|
874 |
-
$code .= " \$this->scopes = array();\n";
|
875 |
-
$code .= " \$this->scopeChildren = array();\n";
|
876 |
-
}
|
877 |
-
|
878 |
-
$code .= $this->addMethodMap();
|
879 |
-
$code .= $this->addAliases();
|
880 |
-
|
881 |
-
$code .= <<<EOF
|
882 |
-
}
|
883 |
-
|
884 |
-
EOF;
|
885 |
-
|
886 |
-
return $code;
|
887 |
-
}
|
888 |
-
|
889 |
-
/**
|
890 |
-
* Adds the methodMap property definition.
|
891 |
-
*
|
892 |
-
* @return string
|
893 |
-
*/
|
894 |
-
private function addMethodMap()
|
895 |
-
{
|
896 |
-
if (!$definitions = $this->container->getDefinitions()) {
|
897 |
-
return '';
|
898 |
-
}
|
899 |
-
|
900 |
-
$code = " \$this->methodMap = array(\n";
|
901 |
-
ksort($definitions);
|
902 |
-
foreach ($definitions as $id => $definition) {
|
903 |
-
$code .= ' '.var_export($id, true).' => '.var_export('get'.$this->camelize($id).'Service', true).",\n";
|
904 |
-
}
|
905 |
-
|
906 |
-
return $code." );\n";
|
907 |
-
}
|
908 |
-
|
909 |
-
/**
|
910 |
-
* Adds the aliases property definition.
|
911 |
-
*
|
912 |
-
* @return string
|
913 |
-
*/
|
914 |
-
private function addAliases()
|
915 |
-
{
|
916 |
-
if (!$aliases = $this->container->getAliases()) {
|
917 |
-
if ($this->container->isFrozen()) {
|
918 |
-
return "\n \$this->aliases = array();\n";
|
919 |
-
} else {
|
920 |
-
return '';
|
921 |
-
}
|
922 |
-
}
|
923 |
-
|
924 |
-
$code = " \$this->aliases = array(\n";
|
925 |
-
ksort($aliases);
|
926 |
-
foreach ($aliases as $alias => $id) {
|
927 |
-
$id = (string) $id;
|
928 |
-
while (isset($aliases[$id])) {
|
929 |
-
$id = (string) $aliases[$id];
|
930 |
-
}
|
931 |
-
$code .= ' '.var_export($alias, true).' => '.var_export($id, true).",\n";
|
932 |
-
}
|
933 |
-
|
934 |
-
return $code." );\n";
|
935 |
-
}
|
936 |
-
|
937 |
-
/**
|
938 |
-
* Adds default parameters method.
|
939 |
-
*
|
940 |
-
* @return string
|
941 |
-
*/
|
942 |
-
private function addDefaultParametersMethod()
|
943 |
-
{
|
944 |
-
if (!$this->container->getParameterBag()->all()) {
|
945 |
-
return '';
|
946 |
-
}
|
947 |
-
|
948 |
-
$parameters = $this->exportParameters($this->container->getParameterBag()->all());
|
949 |
-
|
950 |
-
$code = '';
|
951 |
-
if ($this->container->isFrozen()) {
|
952 |
-
$code .= <<<EOF
|
953 |
-
|
954 |
-
/**
|
955 |
-
* {@inheritdoc}
|
956 |
-
*/
|
957 |
-
public function getParameter(\$name)
|
958 |
-
{
|
959 |
-
\$name = strtolower(\$name);
|
960 |
-
|
961 |
-
if (!(isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) {
|
962 |
-
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name));
|
963 |
-
}
|
964 |
-
|
965 |
-
return \$this->parameters[\$name];
|
966 |
-
}
|
967 |
-
|
968 |
-
/**
|
969 |
-
* {@inheritdoc}
|
970 |
-
*/
|
971 |
-
public function hasParameter(\$name)
|
972 |
-
{
|
973 |
-
\$name = strtolower(\$name);
|
974 |
-
|
975 |
-
return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters);
|
976 |
-
}
|
977 |
-
|
978 |
-
/**
|
979 |
-
* {@inheritdoc}
|
980 |
-
*/
|
981 |
-
public function setParameter(\$name, \$value)
|
982 |
-
{
|
983 |
-
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
984 |
-
}
|
985 |
-
|
986 |
-
/**
|
987 |
-
* {@inheritdoc}
|
988 |
-
*/
|
989 |
-
public function getParameterBag()
|
990 |
-
{
|
991 |
-
if (null === \$this->parameterBag) {
|
992 |
-
\$this->parameterBag = new FrozenParameterBag(\$this->parameters);
|
993 |
-
}
|
994 |
-
|
995 |
-
return \$this->parameterBag;
|
996 |
-
}
|
997 |
-
EOF;
|
998 |
-
}
|
999 |
-
|
1000 |
-
$code .= <<<EOF
|
1001 |
-
|
1002 |
-
/**
|
1003 |
-
* Gets the default parameters.
|
1004 |
-
*
|
1005 |
-
* @return array An array of the default parameters
|
1006 |
-
*/
|
1007 |
-
protected function getDefaultParameters()
|
1008 |
-
{
|
1009 |
-
return $parameters;
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
EOF;
|
1013 |
-
|
1014 |
-
return $code;
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
/**
|
1018 |
-
* Exports parameters.
|
1019 |
-
*
|
1020 |
-
* @param array $parameters
|
1021 |
-
* @param string $path
|
1022 |
-
* @param int $indent
|
1023 |
-
*
|
1024 |
-
* @return string
|
1025 |
-
*
|
1026 |
-
* @throws InvalidArgumentException
|
1027 |
-
*/
|
1028 |
-
private function exportParameters($parameters, $path = '', $indent = 12)
|
1029 |
-
{
|
1030 |
-
$php = array();
|
1031 |
-
foreach ($parameters as $key => $value) {
|
1032 |
-
if (is_array($value)) {
|
1033 |
-
$value = $this->exportParameters($value, $path.'/'.$key, $indent + 4);
|
1034 |
-
} elseif ($value instanceof Variable) {
|
1035 |
-
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path.'/'.$key));
|
1036 |
-
} elseif ($value instanceof Definition) {
|
1037 |
-
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->getClass(), $path.'/'.$key));
|
1038 |
-
} elseif ($value instanceof Reference) {
|
1039 |
-
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path.'/'.$key));
|
1040 |
-
} elseif ($value instanceof Expression) {
|
1041 |
-
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path.'/'.$key));
|
1042 |
-
} else {
|
1043 |
-
$value = $this->export($value);
|
1044 |
-
}
|
1045 |
-
|
1046 |
-
$php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), var_export($key, true), $value);
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
/**
|
1053 |
-
* Ends the class definition.
|
1054 |
-
*
|
1055 |
-
* @return string
|
1056 |
-
*/
|
1057 |
-
private function endClass()
|
1058 |
-
{
|
1059 |
-
return <<<EOF
|
1060 |
-
}
|
1061 |
-
|
1062 |
-
EOF;
|
1063 |
-
}
|
1064 |
-
|
1065 |
-
/**
|
1066 |
-
* Wraps the service conditionals.
|
1067 |
-
*
|
1068 |
-
* @param string $value
|
1069 |
-
* @param string $code
|
1070 |
-
*
|
1071 |
-
* @return string
|
1072 |
-
*/
|
1073 |
-
private function wrapServiceConditionals($value, $code)
|
1074 |
-
{
|
1075 |
-
if (!$services = ContainerBuilder::getServiceConditionals($value)) {
|
1076 |
-
return $code;
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
$conditions = array();
|
1080 |
-
foreach ($services as $service) {
|
1081 |
-
$conditions[] = sprintf("\$this->has('%s')", $service);
|
1082 |
-
}
|
1083 |
-
|
1084 |
-
// re-indent the wrapped code
|
1085 |
-
$code = implode("\n", array_map(function ($line) { return $line ? ' '.$line : $line; }, explode("\n", $code)));
|
1086 |
-
|
1087 |
-
return sprintf(" if (%s) {\n%s }\n", implode(' && ', $conditions), $code);
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
/**
|
1091 |
-
* Builds service calls from arguments.
|
1092 |
-
*
|
1093 |
-
* @param array $arguments
|
1094 |
-
* @param array &$calls By reference
|
1095 |
-
* @param array &$behavior By reference
|
1096 |
-
*/
|
1097 |
-
private function getServiceCallsFromArguments(array $arguments, array &$calls, array &$behavior)
|
1098 |
-
{
|
1099 |
-
foreach ($arguments as $argument) {
|
1100 |
-
if (is_array($argument)) {
|
1101 |
-
$this->getServiceCallsFromArguments($argument, $calls, $behavior);
|
1102 |
-
} elseif ($argument instanceof Reference) {
|
1103 |
-
$id = (string) $argument;
|
1104 |
-
|
1105 |
-
if (!isset($calls[$id])) {
|
1106 |
-
$calls[$id] = 0;
|
1107 |
-
}
|
1108 |
-
if (!isset($behavior[$id])) {
|
1109 |
-
$behavior[$id] = $argument->getInvalidBehavior();
|
1110 |
-
} elseif (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $behavior[$id]) {
|
1111 |
-
$behavior[$id] = $argument->getInvalidBehavior();
|
1112 |
-
}
|
1113 |
-
|
1114 |
-
$calls[$id] += 1;
|
1115 |
-
}
|
1116 |
-
}
|
1117 |
-
}
|
1118 |
-
|
1119 |
-
/**
|
1120 |
-
* Returns the inline definition.
|
1121 |
-
*
|
1122 |
-
* @param Definition $definition
|
1123 |
-
*
|
1124 |
-
* @return array
|
1125 |
-
*/
|
1126 |
-
private function getInlinedDefinitions(Definition $definition)
|
1127 |
-
{
|
1128 |
-
if (false === $this->inlinedDefinitions->contains($definition)) {
|
1129 |
-
$definitions = array_merge(
|
1130 |
-
$this->getDefinitionsFromArguments($definition->getArguments()),
|
1131 |
-
$this->getDefinitionsFromArguments($definition->getMethodCalls()),
|
1132 |
-
$this->getDefinitionsFromArguments($definition->getProperties()),
|
1133 |
-
$this->getDefinitionsFromArguments(array($definition->getConfigurator()))
|
1134 |
-
);
|
1135 |
-
|
1136 |
-
$this->inlinedDefinitions->offsetSet($definition, $definitions);
|
1137 |
-
|
1138 |
-
return $definitions;
|
1139 |
-
}
|
1140 |
-
|
1141 |
-
return $this->inlinedDefinitions->offsetGet($definition);
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
/**
|
1145 |
-
* Gets the definition from arguments.
|
1146 |
-
*
|
1147 |
-
* @param array $arguments
|
1148 |
-
*
|
1149 |
-
* @return array
|
1150 |
-
*/
|
1151 |
-
private function getDefinitionsFromArguments(array $arguments)
|
1152 |
-
{
|
1153 |
-
$definitions = array();
|
1154 |
-
foreach ($arguments as $argument) {
|
1155 |
-
if (is_array($argument)) {
|
1156 |
-
$definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument));
|
1157 |
-
} elseif ($argument instanceof Definition) {
|
1158 |
-
$definitions = array_merge(
|
1159 |
-
$definitions,
|
1160 |
-
$this->getInlinedDefinitions($argument),
|
1161 |
-
array($argument)
|
1162 |
-
);
|
1163 |
-
}
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
return $definitions;
|
1167 |
-
}
|
1168 |
-
|
1169 |
-
/**
|
1170 |
-
* Checks if a service id has a reference.
|
1171 |
-
*
|
1172 |
-
* @param string $id
|
1173 |
-
* @param array $arguments
|
1174 |
-
* @param bool $deep
|
1175 |
-
* @param array $visited
|
1176 |
-
*
|
1177 |
-
* @return bool
|
1178 |
-
*/
|
1179 |
-
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
|
1180 |
-
{
|
1181 |
-
foreach ($arguments as $argument) {
|
1182 |
-
if (is_array($argument)) {
|
1183 |
-
if ($this->hasReference($id, $argument, $deep, $visited)) {
|
1184 |
-
return true;
|
1185 |
-
}
|
1186 |
-
} elseif ($argument instanceof Reference) {
|
1187 |
-
$argumentId = (string) $argument;
|
1188 |
-
if ($id === $argumentId) {
|
1189 |
-
return true;
|
1190 |
-
}
|
1191 |
-
|
1192 |
-
if ($deep && !isset($visited[$argumentId])) {
|
1193 |
-
$visited[$argumentId] = true;
|
1194 |
-
|
1195 |
-
$service = $this->container->getDefinition($argumentId);
|
1196 |
-
$arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties());
|
1197 |
-
|
1198 |
-
if ($this->hasReference($id, $arguments, $deep, $visited)) {
|
1199 |
-
return true;
|
1200 |
-
}
|
1201 |
-
}
|
1202 |
-
}
|
1203 |
-
}
|
1204 |
-
|
1205 |
-
return false;
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
/**
|
1209 |
-
* Dumps values.
|
1210 |
-
*
|
1211 |
-
* @param array $value
|
1212 |
-
* @param bool $interpolate
|
1213 |
-
*
|
1214 |
-
* @return string
|
1215 |
-
*
|
1216 |
-
* @throws RuntimeException
|
1217 |
-
*/
|
1218 |
-
private function dumpValue($value, $interpolate = true)
|
1219 |
-
{
|
1220 |
-
if (is_array($value)) {
|
1221 |
-
$code = array();
|
1222 |
-
foreach ($value as $k => $v) {
|
1223 |
-
$code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
|
1224 |
-
}
|
1225 |
-
|
1226 |
-
return sprintf('array(%s)', implode(', ', $code));
|
1227 |
-
} elseif ($value instanceof Definition) {
|
1228 |
-
if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) {
|
1229 |
-
return $this->dumpValue($this->definitionVariables->offsetGet($value), $interpolate);
|
1230 |
-
}
|
1231 |
-
if (count($value->getMethodCalls()) > 0) {
|
1232 |
-
throw new RuntimeException('Cannot dump definitions which have method calls.');
|
1233 |
-
}
|
1234 |
-
if (null !== $value->getConfigurator()) {
|
1235 |
-
throw new RuntimeException('Cannot dump definitions which have a configurator.');
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
$arguments = array();
|
1239 |
-
foreach ($value->getArguments() as $argument) {
|
1240 |
-
$arguments[] = $this->dumpValue($argument);
|
1241 |
-
}
|
1242 |
-
$class = $this->dumpValue($value->getClass());
|
1243 |
-
|
1244 |
-
if (false !== strpos($class, '$')) {
|
1245 |
-
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
if (null !== $value->getFactoryMethod()) {
|
1249 |
-
if (null !== $value->getFactoryClass()) {
|
1250 |
-
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass()), $value->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
|
1251 |
-
} elseif (null !== $value->getFactoryService()) {
|
1252 |
-
return sprintf("%s->%s(%s)", $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
|
1253 |
-
} else {
|
1254 |
-
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
|
1255 |
-
}
|
1256 |
-
}
|
1257 |
-
|
1258 |
-
return sprintf("new \\%s(%s)", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
|
1259 |
-
} elseif ($value instanceof Variable) {
|
1260 |
-
return '$'.$value;
|
1261 |
-
} elseif ($value instanceof Reference) {
|
1262 |
-
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) {
|
1263 |
-
return $this->dumpValue($this->referenceVariables[$id], $interpolate);
|
1264 |
-
}
|
1265 |
-
|
1266 |
-
return $this->getServiceCall((string) $value, $value);
|
1267 |
-
} elseif ($value instanceof Expression) {
|
1268 |
-
return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
|
1269 |
-
} elseif ($value instanceof Parameter) {
|
1270 |
-
return $this->dumpParameter($value);
|
1271 |
-
} elseif (true === $interpolate && is_string($value)) {
|
1272 |
-
if (preg_match('/^%([^%]+)%$/', $value, $match)) {
|
1273 |
-
// we do this to deal with non string values (Boolean, integer, ...)
|
1274 |
-
// the preg_replace_callback converts them to strings
|
1275 |
-
return $this->dumpParameter(strtolower($match[1]));
|
1276 |
-
} else {
|
1277 |
-
$that = $this;
|
1278 |
-
$replaceParameters = function ($match) use ($that) {
|
1279 |
-
return "'.".$that->dumpParameter(strtolower($match[2])).".'";
|
1280 |
-
};
|
1281 |
-
|
1282 |
-
$code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters, $this->export($value)));
|
1283 |
-
|
1284 |
-
return $code;
|
1285 |
-
}
|
1286 |
-
} elseif (is_object($value) || is_resource($value)) {
|
1287 |
-
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
|
1288 |
-
} else {
|
1289 |
-
return $this->export($value);
|
1290 |
-
}
|
1291 |
-
}
|
1292 |
-
|
1293 |
-
/**
|
1294 |
-
* Dumps a string to a literal (aka PHP Code) class value.
|
1295 |
-
*
|
1296 |
-
* @param string $class
|
1297 |
-
*
|
1298 |
-
* @return string
|
1299 |
-
*/
|
1300 |
-
private function dumpLiteralClass($class)
|
1301 |
-
{
|
1302 |
-
return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
|
1303 |
-
}
|
1304 |
-
|
1305 |
-
/**
|
1306 |
-
* Dumps a parameter.
|
1307 |
-
*
|
1308 |
-
* @param string $name
|
1309 |
-
*
|
1310 |
-
* @return string
|
1311 |
-
*/
|
1312 |
-
public function dumpParameter($name)
|
1313 |
-
{
|
1314 |
-
if ($this->container->isFrozen() && $this->container->hasParameter($name)) {
|
1315 |
-
return $this->dumpValue($this->container->getParameter($name), false);
|
1316 |
-
}
|
1317 |
-
|
1318 |
-
return sprintf("\$this->getParameter('%s')", strtolower($name));
|
1319 |
-
}
|
1320 |
-
|
1321 |
-
/**
|
1322 |
-
* Gets a service call.
|
1323 |
-
*
|
1324 |
-
* @param string $id
|
1325 |
-
* @param Reference $reference
|
1326 |
-
*
|
1327 |
-
* @return string
|
1328 |
-
*/
|
1329 |
-
private function getServiceCall($id, Reference $reference = null)
|
1330 |
-
{
|
1331 |
-
if ('service_container' === $id) {
|
1332 |
-
return '$this';
|
1333 |
-
}
|
1334 |
-
|
1335 |
-
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
1336 |
-
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
|
1337 |
-
} else {
|
1338 |
-
if ($this->container->hasAlias($id)) {
|
1339 |
-
$id = (string) $this->container->getAlias($id);
|
1340 |
-
}
|
1341 |
-
|
1342 |
-
return sprintf('$this->get(\'%s\')', $id);
|
1343 |
-
}
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
/**
|
1347 |
-
* Convert a service id to a valid PHP method name.
|
1348 |
-
*
|
1349 |
-
* @param string $id
|
1350 |
-
*
|
1351 |
-
* @return string
|
1352 |
-
*
|
1353 |
-
* @throws InvalidArgumentException
|
1354 |
-
*/
|
1355 |
-
private function camelize($id)
|
1356 |
-
{
|
1357 |
-
$name = Container::camelize($id);
|
1358 |
-
|
1359 |
-
if (!preg_match('/^[a-zA-Z0-9_\x7f-\xff]+$/', $name)) {
|
1360 |
-
throw new InvalidArgumentException(sprintf('Service id "%s" cannot be converted to a valid PHP method name.', $id));
|
1361 |
-
}
|
1362 |
-
|
1363 |
-
return $name;
|
1364 |
-
}
|
1365 |
-
|
1366 |
-
/**
|
1367 |
-
* Returns the next name to use.
|
1368 |
-
*
|
1369 |
-
* @return string
|
1370 |
-
*/
|
1371 |
-
private function getNextVariableName()
|
1372 |
-
{
|
1373 |
-
$firstChars = self::FIRST_CHARS;
|
1374 |
-
$firstCharsLength = strlen($firstChars);
|
1375 |
-
$nonFirstChars = self::NON_FIRST_CHARS;
|
1376 |
-
$nonFirstCharsLength = strlen($nonFirstChars);
|
1377 |
-
|
1378 |
-
while (true) {
|
1379 |
-
$name = '';
|
1380 |
-
$i = $this->variableCount;
|
1381 |
-
|
1382 |
-
if ('' === $name) {
|
1383 |
-
$name .= $firstChars[$i%$firstCharsLength];
|
1384 |
-
$i = intval($i/$firstCharsLength);
|
1385 |
-
}
|
1386 |
-
|
1387 |
-
while ($i > 0) {
|
1388 |
-
$i -= 1;
|
1389 |
-
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
|
1390 |
-
$i = intval($i/$nonFirstCharsLength);
|
1391 |
-
}
|
1392 |
-
|
1393 |
-
$this->variableCount += 1;
|
1394 |
-
|
1395 |
-
// check that the name is not reserved
|
1396 |
-
if (in_array($name, $this->reservedVariables, true)) {
|
1397 |
-
continue;
|
1398 |
-
}
|
1399 |
-
|
1400 |
-
return $name;
|
1401 |
-
}
|
1402 |
-
}
|
1403 |
-
|
1404 |
-
private function getExpressionLanguage()
|
1405 |
-
{
|
1406 |
-
if (null === $this->expressionLanguage) {
|
1407 |
-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
|
1408 |
-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
|
1409 |
-
}
|
1410 |
-
$this->expressionLanguage = new ExpressionLanguage();
|
1411 |
-
}
|
1412 |
-
|
1413 |
-
return $this->expressionLanguage;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
private function exportTargetDirs()
|
1417 |
-
{
|
1418 |
-
return null === $this->targetDirRegex ? '' : <<<EOF
|
1419 |
-
|
1420 |
-
\$dir = __DIR__;
|
1421 |
-
for (\$i = 1; \$i <= {$this->targetDirMaxMatches}; ++\$i) {
|
1422 |
-
\$this->targetDirs[\$i] = \$dir = dirname(\$dir);
|
1423 |
-
}
|
1424 |
-
EOF;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
private function export($value)
|
1428 |
-
{
|
1429 |
-
if (null !== $this->targetDirRegex && is_string($value) && preg_match($this->targetDirRegex, $value, $matches, PREG_OFFSET_CAPTURE)) {
|
1430 |
-
$prefix = $matches[0][1] ? var_export(substr($value, 0, $matches[0][1]), true).'.' : '';
|
1431 |
-
$suffix = $matches[0][1] + strlen($matches[0][0]);
|
1432 |
-
$suffix = isset($value[$suffix]) ? '.'.var_export(substr($value, $suffix), true) : '';
|
1433 |
-
$dirname = '__DIR__';
|
1434 |
-
|
1435 |
-
if (0 < $offset = 1 + $this->targetDirMaxMatches - count($matches)) {
|
1436 |
-
$dirname = sprintf('$this->targetDirs[%d]', $offset);
|
1437 |
-
}
|
1438 |
-
|
1439 |
-
if ($prefix || $suffix) {
|
1440 |
-
return sprintf('(%s%s%s)', $prefix, $dirname, $suffix);
|
1441 |
-
}
|
1442 |
-
|
1443 |
-
return $dirname;
|
1444 |
-
}
|
1445 |
-
|
1446 |
-
return var_export($value, true);
|
1447 |
-
}
|
1448 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
DELETED
@@ -1,337 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\Parameter;
|
16 |
-
use Symfony\Component\DependencyInjection\Reference;
|
17 |
-
use Symfony\Component\DependencyInjection\Definition;
|
18 |
-
use Symfony\Component\DependencyInjection\Alias;
|
19 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
20 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* XmlDumper dumps a service container as an XML string.
|
24 |
-
*
|
25 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
-
* @author Martin Hasoň <martin.hason@gmail.com>
|
27 |
-
*
|
28 |
-
* @api
|
29 |
-
*/
|
30 |
-
class XmlDumper extends Dumper
|
31 |
-
{
|
32 |
-
/**
|
33 |
-
* @var \DOMDocument
|
34 |
-
*/
|
35 |
-
private $document;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Dumps the service container as an XML string.
|
39 |
-
*
|
40 |
-
* @param array $options An array of options
|
41 |
-
*
|
42 |
-
* @return string An xml string representing of the service container
|
43 |
-
*
|
44 |
-
* @api
|
45 |
-
*/
|
46 |
-
public function dump(array $options = array())
|
47 |
-
{
|
48 |
-
$this->document = new \DOMDocument('1.0', 'utf-8');
|
49 |
-
$this->document->formatOutput = true;
|
50 |
-
|
51 |
-
$container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container');
|
52 |
-
$container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
53 |
-
$container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd');
|
54 |
-
|
55 |
-
$this->addParameters($container);
|
56 |
-
$this->addServices($container);
|
57 |
-
|
58 |
-
$this->document->appendChild($container);
|
59 |
-
$xml = $this->document->saveXML();
|
60 |
-
$this->document = null;
|
61 |
-
|
62 |
-
return $xml;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Adds parameters.
|
67 |
-
*
|
68 |
-
* @param \DOMElement $parent
|
69 |
-
*/
|
70 |
-
private function addParameters(\DOMElement $parent)
|
71 |
-
{
|
72 |
-
$data = $this->container->getParameterBag()->all();
|
73 |
-
if (!$data) {
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
|
77 |
-
if ($this->container->isFrozen()) {
|
78 |
-
$data = $this->escape($data);
|
79 |
-
}
|
80 |
-
|
81 |
-
$parameters = $this->document->createElement('parameters');
|
82 |
-
$parent->appendChild($parameters);
|
83 |
-
$this->convertParameters($data, 'parameter', $parameters);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Adds method calls.
|
88 |
-
*
|
89 |
-
* @param array $methodcalls
|
90 |
-
* @param \DOMElement $parent
|
91 |
-
*/
|
92 |
-
private function addMethodCalls(array $methodcalls, \DOMElement $parent)
|
93 |
-
{
|
94 |
-
foreach ($methodcalls as $methodcall) {
|
95 |
-
$call = $this->document->createElement('call');
|
96 |
-
$call->setAttribute('method', $methodcall[0]);
|
97 |
-
if (count($methodcall[1])) {
|
98 |
-
$this->convertParameters($methodcall[1], 'argument', $call);
|
99 |
-
}
|
100 |
-
$parent->appendChild($call);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Adds a service.
|
106 |
-
*
|
107 |
-
* @param Definition $definition
|
108 |
-
* @param string $id
|
109 |
-
* @param \DOMElement $parent
|
110 |
-
*/
|
111 |
-
private function addService($definition, $id, \DOMElement $parent)
|
112 |
-
{
|
113 |
-
$service = $this->document->createElement('service');
|
114 |
-
if (null !== $id) {
|
115 |
-
$service->setAttribute('id', $id);
|
116 |
-
}
|
117 |
-
if ($definition->getClass()) {
|
118 |
-
$service->setAttribute('class', $definition->getClass());
|
119 |
-
}
|
120 |
-
if ($definition->getFactoryMethod()) {
|
121 |
-
$service->setAttribute('factory-method', $definition->getFactoryMethod());
|
122 |
-
}
|
123 |
-
if ($definition->getFactoryClass()) {
|
124 |
-
$service->setAttribute('factory-class', $definition->getFactoryClass());
|
125 |
-
}
|
126 |
-
if ($definition->getFactoryService()) {
|
127 |
-
$service->setAttribute('factory-service', $definition->getFactoryService());
|
128 |
-
}
|
129 |
-
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
|
130 |
-
$service->setAttribute('scope', $scope);
|
131 |
-
}
|
132 |
-
if (!$definition->isPublic()) {
|
133 |
-
$service->setAttribute('public', 'false');
|
134 |
-
}
|
135 |
-
if ($definition->isSynthetic()) {
|
136 |
-
$service->setAttribute('synthetic', 'true');
|
137 |
-
}
|
138 |
-
if ($definition->isSynchronized()) {
|
139 |
-
$service->setAttribute('synchronized', 'true');
|
140 |
-
}
|
141 |
-
if ($definition->isLazy()) {
|
142 |
-
$service->setAttribute('lazy', 'true');
|
143 |
-
}
|
144 |
-
if (null !== $decorated = $definition->getDecoratedService()) {
|
145 |
-
list($decorated, $renamedId) = $decorated;
|
146 |
-
$service->setAttribute('decorates', $decorated);
|
147 |
-
if (null !== $renamedId) {
|
148 |
-
$service->setAttribute('decoration-inner-name', $renamedId);
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
foreach ($definition->getTags() as $name => $tags) {
|
153 |
-
foreach ($tags as $attributes) {
|
154 |
-
$tag = $this->document->createElement('tag');
|
155 |
-
$tag->setAttribute('name', $name);
|
156 |
-
foreach ($attributes as $key => $value) {
|
157 |
-
$tag->setAttribute($key, $value);
|
158 |
-
}
|
159 |
-
$service->appendChild($tag);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
if ($definition->getFile()) {
|
164 |
-
$file = $this->document->createElement('file');
|
165 |
-
$file->appendChild($this->document->createTextNode($definition->getFile()));
|
166 |
-
$service->appendChild($file);
|
167 |
-
}
|
168 |
-
|
169 |
-
if ($parameters = $definition->getArguments()) {
|
170 |
-
$this->convertParameters($parameters, 'argument', $service);
|
171 |
-
}
|
172 |
-
|
173 |
-
if ($parameters = $definition->getProperties()) {
|
174 |
-
$this->convertParameters($parameters, 'property', $service, 'name');
|
175 |
-
}
|
176 |
-
|
177 |
-
$this->addMethodCalls($definition->getMethodCalls(), $service);
|
178 |
-
|
179 |
-
if ($callable = $definition->getConfigurator()) {
|
180 |
-
$configurator = $this->document->createElement('configurator');
|
181 |
-
if (is_array($callable)) {
|
182 |
-
$configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
|
183 |
-
$configurator->setAttribute('method', $callable[1]);
|
184 |
-
} else {
|
185 |
-
$configurator->setAttribute('function', $callable);
|
186 |
-
}
|
187 |
-
$service->appendChild($configurator);
|
188 |
-
}
|
189 |
-
|
190 |
-
$parent->appendChild($service);
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Adds a service alias.
|
195 |
-
*
|
196 |
-
* @param string $alias
|
197 |
-
* @param Alias $id
|
198 |
-
* @param \DOMElement $parent
|
199 |
-
*/
|
200 |
-
private function addServiceAlias($alias, Alias $id, \DOMElement $parent)
|
201 |
-
{
|
202 |
-
$service = $this->document->createElement('service');
|
203 |
-
$service->setAttribute('id', $alias);
|
204 |
-
$service->setAttribute('alias', $id);
|
205 |
-
if (!$id->isPublic()) {
|
206 |
-
$service->setAttribute('public', 'false');
|
207 |
-
}
|
208 |
-
$parent->appendChild($service);
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Adds services.
|
213 |
-
*
|
214 |
-
* @param \DOMElement $parent
|
215 |
-
*/
|
216 |
-
private function addServices(\DOMElement $parent)
|
217 |
-
{
|
218 |
-
$definitions = $this->container->getDefinitions();
|
219 |
-
if (!$definitions) {
|
220 |
-
return;
|
221 |
-
}
|
222 |
-
|
223 |
-
$services = $this->document->createElement('services');
|
224 |
-
foreach ($definitions as $id => $definition) {
|
225 |
-
$this->addService($definition, $id, $services);
|
226 |
-
}
|
227 |
-
|
228 |
-
$aliases = $this->container->getAliases();
|
229 |
-
foreach ($aliases as $alias => $id) {
|
230 |
-
while (isset($aliases[(string) $id])) {
|
231 |
-
$id = $aliases[(string) $id];
|
232 |
-
}
|
233 |
-
$this->addServiceAlias($alias, $id, $services);
|
234 |
-
}
|
235 |
-
$parent->appendChild($services);
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Converts parameters.
|
240 |
-
*
|
241 |
-
* @param array $parameters
|
242 |
-
* @param string $type
|
243 |
-
* @param \DOMElement $parent
|
244 |
-
* @param string $keyAttribute
|
245 |
-
*/
|
246 |
-
private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
|
247 |
-
{
|
248 |
-
$withKeys = array_keys($parameters) !== range(0, count($parameters) - 1);
|
249 |
-
foreach ($parameters as $key => $value) {
|
250 |
-
$element = $this->document->createElement($type);
|
251 |
-
if ($withKeys) {
|
252 |
-
$element->setAttribute($keyAttribute, $key);
|
253 |
-
}
|
254 |
-
|
255 |
-
if (is_array($value)) {
|
256 |
-
$element->setAttribute('type', 'collection');
|
257 |
-
$this->convertParameters($value, $type, $element, 'key');
|
258 |
-
} elseif ($value instanceof Reference) {
|
259 |
-
$element->setAttribute('type', 'service');
|
260 |
-
$element->setAttribute('id', (string) $value);
|
261 |
-
$behaviour = $value->getInvalidBehavior();
|
262 |
-
if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) {
|
263 |
-
$element->setAttribute('on-invalid', 'null');
|
264 |
-
} elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
|
265 |
-
$element->setAttribute('on-invalid', 'ignore');
|
266 |
-
}
|
267 |
-
if (!$value->isStrict()) {
|
268 |
-
$element->setAttribute('strict', 'false');
|
269 |
-
}
|
270 |
-
} elseif ($value instanceof Definition) {
|
271 |
-
$element->setAttribute('type', 'service');
|
272 |
-
$this->addService($value, null, $element);
|
273 |
-
} elseif ($value instanceof Expression) {
|
274 |
-
$element->setAttribute('type', 'expression');
|
275 |
-
$text = $this->document->createTextNode(self::phpToXml((string) $value));
|
276 |
-
$element->appendChild($text);
|
277 |
-
} else {
|
278 |
-
if (in_array($value, array('null', 'true', 'false'), true)) {
|
279 |
-
$element->setAttribute('type', 'string');
|
280 |
-
}
|
281 |
-
$text = $this->document->createTextNode(self::phpToXml($value));
|
282 |
-
$element->appendChild($text);
|
283 |
-
}
|
284 |
-
$parent->appendChild($element);
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Escapes arguments.
|
290 |
-
*
|
291 |
-
* @param array $arguments
|
292 |
-
*
|
293 |
-
* @return array
|
294 |
-
*/
|
295 |
-
private function escape($arguments)
|
296 |
-
{
|
297 |
-
$args = array();
|
298 |
-
foreach ($arguments as $k => $v) {
|
299 |
-
if (is_array($v)) {
|
300 |
-
$args[$k] = $this->escape($v);
|
301 |
-
} elseif (is_string($v)) {
|
302 |
-
$args[$k] = str_replace('%', '%%', $v);
|
303 |
-
} else {
|
304 |
-
$args[$k] = $v;
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
return $args;
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Converts php types to xml types.
|
313 |
-
*
|
314 |
-
* @param mixed $value Value to convert
|
315 |
-
*
|
316 |
-
* @return string
|
317 |
-
*
|
318 |
-
* @throws RuntimeException When trying to dump object or resource
|
319 |
-
*/
|
320 |
-
public static function phpToXml($value)
|
321 |
-
{
|
322 |
-
switch (true) {
|
323 |
-
case null === $value:
|
324 |
-
return 'null';
|
325 |
-
case true === $value:
|
326 |
-
return 'true';
|
327 |
-
case false === $value:
|
328 |
-
return 'false';
|
329 |
-
case $value instanceof Parameter:
|
330 |
-
return '%'.$value.'%';
|
331 |
-
case is_object($value) || is_resource($value):
|
332 |
-
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
|
333 |
-
default:
|
334 |
-
return (string) $value;
|
335 |
-
}
|
336 |
-
}
|
337 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
DELETED
@@ -1,336 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Dumper;
|
13 |
-
|
14 |
-
use Symfony\Component\Yaml\Dumper as YmlDumper;
|
15 |
-
use Symfony\Component\DependencyInjection\Alias;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
17 |
-
use Symfony\Component\DependencyInjection\Definition;
|
18 |
-
use Symfony\Component\DependencyInjection\Parameter;
|
19 |
-
use Symfony\Component\DependencyInjection\Reference;
|
20 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
21 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
22 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* YamlDumper dumps a service container as a YAML string.
|
26 |
-
*
|
27 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
28 |
-
*
|
29 |
-
* @api
|
30 |
-
*/
|
31 |
-
class YamlDumper extends Dumper
|
32 |
-
{
|
33 |
-
private $dumper;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Constructor.
|
37 |
-
*
|
38 |
-
* @param ContainerBuilder $container The service container to dump
|
39 |
-
*
|
40 |
-
* @api
|
41 |
-
*/
|
42 |
-
public function __construct(ContainerBuilder $container)
|
43 |
-
{
|
44 |
-
parent::__construct($container);
|
45 |
-
|
46 |
-
$this->dumper = new YmlDumper();
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Dumps the service container as an YAML string.
|
51 |
-
*
|
52 |
-
* @param array $options An array of options
|
53 |
-
*
|
54 |
-
* @return string A YAML string representing of the service container
|
55 |
-
*
|
56 |
-
* @api
|
57 |
-
*/
|
58 |
-
public function dump(array $options = array())
|
59 |
-
{
|
60 |
-
return $this->addParameters()."\n".$this->addServices();
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Adds a service.
|
65 |
-
*
|
66 |
-
* @param string $id
|
67 |
-
* @param Definition $definition
|
68 |
-
*
|
69 |
-
* @return string
|
70 |
-
*/
|
71 |
-
private function addService($id, $definition)
|
72 |
-
{
|
73 |
-
$code = " $id:\n";
|
74 |
-
if ($definition->getClass()) {
|
75 |
-
$code .= sprintf(" class: %s\n", $definition->getClass());
|
76 |
-
}
|
77 |
-
|
78 |
-
if (!$definition->isPublic()) {
|
79 |
-
$code .= " public: false\n";
|
80 |
-
}
|
81 |
-
|
82 |
-
$tagsCode = '';
|
83 |
-
foreach ($definition->getTags() as $name => $tags) {
|
84 |
-
foreach ($tags as $attributes) {
|
85 |
-
$att = array();
|
86 |
-
foreach ($attributes as $key => $value) {
|
87 |
-
$att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
|
88 |
-
}
|
89 |
-
$att = $att ? ', '.implode(' ', $att) : '';
|
90 |
-
|
91 |
-
$tagsCode .= sprintf(" - { name: %s%s }\n", $this->dumper->dump($name), $att);
|
92 |
-
}
|
93 |
-
}
|
94 |
-
if ($tagsCode) {
|
95 |
-
$code .= " tags:\n".$tagsCode;
|
96 |
-
}
|
97 |
-
|
98 |
-
if ($definition->getFile()) {
|
99 |
-
$code .= sprintf(" file: %s\n", $definition->getFile());
|
100 |
-
}
|
101 |
-
|
102 |
-
if ($definition->isSynthetic()) {
|
103 |
-
$code .= sprintf(" synthetic: true\n");
|
104 |
-
}
|
105 |
-
|
106 |
-
if ($definition->isSynchronized()) {
|
107 |
-
$code .= sprintf(" synchronized: true\n");
|
108 |
-
}
|
109 |
-
|
110 |
-
if ($definition->getFactoryClass()) {
|
111 |
-
$code .= sprintf(" factory_class: %s\n", $definition->getFactoryClass());
|
112 |
-
}
|
113 |
-
|
114 |
-
if ($definition->isLazy()) {
|
115 |
-
$code .= sprintf(" lazy: true\n");
|
116 |
-
}
|
117 |
-
|
118 |
-
if ($definition->getFactoryMethod()) {
|
119 |
-
$code .= sprintf(" factory_method: %s\n", $definition->getFactoryMethod());
|
120 |
-
}
|
121 |
-
|
122 |
-
if ($definition->getFactoryService()) {
|
123 |
-
$code .= sprintf(" factory_service: %s\n", $definition->getFactoryService());
|
124 |
-
}
|
125 |
-
|
126 |
-
if ($definition->getArguments()) {
|
127 |
-
$code .= sprintf(" arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
|
128 |
-
}
|
129 |
-
|
130 |
-
if ($definition->getProperties()) {
|
131 |
-
$code .= sprintf(" properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
|
132 |
-
}
|
133 |
-
|
134 |
-
if ($definition->getMethodCalls()) {
|
135 |
-
$code .= sprintf(" calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
|
136 |
-
}
|
137 |
-
|
138 |
-
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
|
139 |
-
$code .= sprintf(" scope: %s\n", $scope);
|
140 |
-
}
|
141 |
-
|
142 |
-
if (null !== $decorated = $definition->getDecoratedService()) {
|
143 |
-
list($decorated, $renamedId) = $decorated;
|
144 |
-
$code .= sprintf(" decorates: %s\n", $decorated);
|
145 |
-
if (null !== $renamedId) {
|
146 |
-
$code .= sprintf(" decoration_inner_name: %s\n", $renamedId);
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
if ($callable = $definition->getConfigurator()) {
|
151 |
-
if (is_array($callable)) {
|
152 |
-
if ($callable[0] instanceof Reference) {
|
153 |
-
$callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]);
|
154 |
-
} else {
|
155 |
-
$callable = array($callable[0], $callable[1]);
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
$code .= sprintf(" configurator: %s\n", $this->dumper->dump($callable, 0));
|
160 |
-
}
|
161 |
-
|
162 |
-
return $code;
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Adds a service alias.
|
167 |
-
*
|
168 |
-
* @param string $alias
|
169 |
-
* @param Alias $id
|
170 |
-
*
|
171 |
-
* @return string
|
172 |
-
*/
|
173 |
-
private function addServiceAlias($alias, $id)
|
174 |
-
{
|
175 |
-
if ($id->isPublic()) {
|
176 |
-
return sprintf(" %s: @%s\n", $alias, $id);
|
177 |
-
} else {
|
178 |
-
return sprintf(" %s:\n alias: %s\n public: false", $alias, $id);
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Adds services.
|
184 |
-
*
|
185 |
-
* @return string
|
186 |
-
*/
|
187 |
-
private function addServices()
|
188 |
-
{
|
189 |
-
if (!$this->container->getDefinitions()) {
|
190 |
-
return '';
|
191 |
-
}
|
192 |
-
|
193 |
-
$code = "services:\n";
|
194 |
-
foreach ($this->container->getDefinitions() as $id => $definition) {
|
195 |
-
$code .= $this->addService($id, $definition);
|
196 |
-
}
|
197 |
-
|
198 |
-
$aliases = $this->container->getAliases();
|
199 |
-
foreach ($aliases as $alias => $id) {
|
200 |
-
while (isset($aliases[(string) $id])) {
|
201 |
-
$id = $aliases[(string) $id];
|
202 |
-
}
|
203 |
-
$code .= $this->addServiceAlias($alias, $id);
|
204 |
-
}
|
205 |
-
|
206 |
-
return $code;
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Adds parameters.
|
211 |
-
*
|
212 |
-
* @return string
|
213 |
-
*/
|
214 |
-
private function addParameters()
|
215 |
-
{
|
216 |
-
if (!$this->container->getParameterBag()->all()) {
|
217 |
-
return '';
|
218 |
-
}
|
219 |
-
|
220 |
-
$parameters = $this->prepareParameters($this->container->getParameterBag()->all(), $this->container->isFrozen());
|
221 |
-
|
222 |
-
return $this->dumper->dump(array('parameters' => $parameters), 2);
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Dumps the value to YAML format.
|
227 |
-
*
|
228 |
-
* @param mixed $value
|
229 |
-
*
|
230 |
-
* @return mixed
|
231 |
-
*
|
232 |
-
* @throws RuntimeException When trying to dump object or resource
|
233 |
-
*/
|
234 |
-
private function dumpValue($value)
|
235 |
-
{
|
236 |
-
if (is_array($value)) {
|
237 |
-
$code = array();
|
238 |
-
foreach ($value as $k => $v) {
|
239 |
-
$code[$k] = $this->dumpValue($v);
|
240 |
-
}
|
241 |
-
|
242 |
-
return $code;
|
243 |
-
} elseif ($value instanceof Reference) {
|
244 |
-
return $this->getServiceCall((string) $value, $value);
|
245 |
-
} elseif ($value instanceof Parameter) {
|
246 |
-
return $this->getParameterCall((string) $value);
|
247 |
-
} elseif ($value instanceof Expression) {
|
248 |
-
return $this->getExpressionCall((string) $value);
|
249 |
-
} elseif (is_object($value) || is_resource($value)) {
|
250 |
-
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
|
251 |
-
}
|
252 |
-
|
253 |
-
return $value;
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Gets the service call.
|
258 |
-
*
|
259 |
-
* @param string $id
|
260 |
-
* @param Reference $reference
|
261 |
-
*
|
262 |
-
* @return string
|
263 |
-
*/
|
264 |
-
private function getServiceCall($id, Reference $reference = null)
|
265 |
-
{
|
266 |
-
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
267 |
-
return sprintf('@?%s', $id);
|
268 |
-
}
|
269 |
-
|
270 |
-
return sprintf('@%s', $id);
|
271 |
-
}
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Gets parameter call.
|
275 |
-
*
|
276 |
-
* @param string $id
|
277 |
-
*
|
278 |
-
* @return string
|
279 |
-
*/
|
280 |
-
private function getParameterCall($id)
|
281 |
-
{
|
282 |
-
return sprintf('%%%s%%', $id);
|
283 |
-
}
|
284 |
-
|
285 |
-
private function getExpressionCall($expression)
|
286 |
-
{
|
287 |
-
return sprintf('@=%s', $expression);
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Prepares parameters.
|
292 |
-
*
|
293 |
-
* @param array $parameters
|
294 |
-
* @param bool $escape
|
295 |
-
*
|
296 |
-
* @return array
|
297 |
-
*/
|
298 |
-
private function prepareParameters($parameters, $escape = true)
|
299 |
-
{
|
300 |
-
$filtered = array();
|
301 |
-
foreach ($parameters as $key => $value) {
|
302 |
-
if (is_array($value)) {
|
303 |
-
$value = $this->prepareParameters($value, $escape);
|
304 |
-
} elseif ($value instanceof Reference || is_string($value) && 0 === strpos($value, '@')) {
|
305 |
-
$value = '@'.$value;
|
306 |
-
}
|
307 |
-
|
308 |
-
$filtered[$key] = $value;
|
309 |
-
}
|
310 |
-
|
311 |
-
return $escape ? $this->escape($filtered) : $filtered;
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Escapes arguments.
|
316 |
-
*
|
317 |
-
* @param array $arguments
|
318 |
-
*
|
319 |
-
* @return array
|
320 |
-
*/
|
321 |
-
private function escape($arguments)
|
322 |
-
{
|
323 |
-
$args = array();
|
324 |
-
foreach ($arguments as $k => $v) {
|
325 |
-
if (is_array($v)) {
|
326 |
-
$args[$k] = $this->escape($v);
|
327 |
-
} elseif (is_string($v)) {
|
328 |
-
$args[$k] = str_replace('%', '%%', $v);
|
329 |
-
} else {
|
330 |
-
$args[$k] = $v;
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
return $args;
|
335 |
-
}
|
336 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/BadMethodCallException.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base BadMethodCallException for Dependency Injection component.
|
16 |
-
*/
|
17 |
-
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
|
18 |
-
{
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ExceptionInterface.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base ExceptionInterface for Dependency Injection component.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
|
19 |
-
*/
|
20 |
-
interface ExceptionInterface
|
21 |
-
{
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when you try to create a service of an inactive scope.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class InactiveScopeException extends RuntimeException
|
20 |
-
{
|
21 |
-
private $serviceId;
|
22 |
-
private $scope;
|
23 |
-
|
24 |
-
public function __construct($serviceId, $scope, \Exception $previous = null)
|
25 |
-
{
|
26 |
-
parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous);
|
27 |
-
|
28 |
-
$this->serviceId = $serviceId;
|
29 |
-
$this->scope = $scope;
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getServiceId()
|
33 |
-
{
|
34 |
-
return $this->serviceId;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getScope()
|
38 |
-
{
|
39 |
-
return $this->scope;
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/InvalidArgumentException.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base InvalidArgumentException for Dependency Injection component.
|
16 |
-
*
|
17 |
-
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
|
18 |
-
*/
|
19 |
-
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/LogicException.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base LogicException for Dependency Injection component.
|
16 |
-
*/
|
17 |
-
class LogicException extends \LogicException implements ExceptionInterface
|
18 |
-
{
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/OutOfBoundsException.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base OutOfBoundsException for Dependency Injection component.
|
16 |
-
*/
|
17 |
-
class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface
|
18 |
-
{
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when a circular reference in a parameter is detected.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
class ParameterCircularReferenceException extends RuntimeException
|
20 |
-
{
|
21 |
-
private $parameters;
|
22 |
-
|
23 |
-
public function __construct($parameters, \Exception $previous = null)
|
24 |
-
{
|
25 |
-
parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous);
|
26 |
-
|
27 |
-
$this->parameters = $parameters;
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getParameters()
|
31 |
-
{
|
32 |
-
return $this->parameters;
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when a non-existent parameter is used.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*/
|
19 |
-
class ParameterNotFoundException extends InvalidArgumentException
|
20 |
-
{
|
21 |
-
private $key;
|
22 |
-
private $sourceId;
|
23 |
-
private $sourceKey;
|
24 |
-
private $alternatives;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Constructor.
|
28 |
-
*
|
29 |
-
* @param string $key The requested parameter key
|
30 |
-
* @param string $sourceId The service id that references the non-existent parameter
|
31 |
-
* @param string $sourceKey The parameter key that references the non-existent parameter
|
32 |
-
* @param \Exception $previous The previous exception
|
33 |
-
* @param string[] $alternatives Some parameter name alternatives
|
34 |
-
*/
|
35 |
-
public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null, array $alternatives = array())
|
36 |
-
{
|
37 |
-
$this->key = $key;
|
38 |
-
$this->sourceId = $sourceId;
|
39 |
-
$this->sourceKey = $sourceKey;
|
40 |
-
$this->alternatives = $alternatives;
|
41 |
-
|
42 |
-
parent::__construct('', 0, $previous);
|
43 |
-
|
44 |
-
$this->updateRepr();
|
45 |
-
}
|
46 |
-
|
47 |
-
public function updateRepr()
|
48 |
-
{
|
49 |
-
if (null !== $this->sourceId) {
|
50 |
-
$this->message = sprintf('The service "%s" has a dependency on a non-existent parameter "%s".', $this->sourceId, $this->key);
|
51 |
-
} elseif (null !== $this->sourceKey) {
|
52 |
-
$this->message = sprintf('The parameter "%s" has a dependency on a non-existent parameter "%s".', $this->sourceKey, $this->key);
|
53 |
-
} else {
|
54 |
-
$this->message = sprintf('You have requested a non-existent parameter "%s".', $this->key);
|
55 |
-
}
|
56 |
-
|
57 |
-
if ($this->alternatives) {
|
58 |
-
if (1 == count($this->alternatives)) {
|
59 |
-
$this->message .= ' Did you mean this: "';
|
60 |
-
} else {
|
61 |
-
$this->message .= ' Did you mean one of these: "';
|
62 |
-
}
|
63 |
-
$this->message .= implode('", "', $this->alternatives).'"?';
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
public function getKey()
|
68 |
-
{
|
69 |
-
return $this->key;
|
70 |
-
}
|
71 |
-
|
72 |
-
public function getSourceId()
|
73 |
-
{
|
74 |
-
return $this->sourceId;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getSourceKey()
|
78 |
-
{
|
79 |
-
return $this->sourceKey;
|
80 |
-
}
|
81 |
-
|
82 |
-
public function setSourceId($sourceId)
|
83 |
-
{
|
84 |
-
$this->sourceId = $sourceId;
|
85 |
-
|
86 |
-
$this->updateRepr();
|
87 |
-
}
|
88 |
-
|
89 |
-
public function setSourceKey($sourceKey)
|
90 |
-
{
|
91 |
-
$this->sourceKey = $sourceKey;
|
92 |
-
|
93 |
-
$this->updateRepr();
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/RuntimeException.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base RuntimeException for Dependency Injection component.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when the a scope crossing injection is detected.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class ScopeCrossingInjectionException extends RuntimeException
|
20 |
-
{
|
21 |
-
private $sourceServiceId;
|
22 |
-
private $sourceScope;
|
23 |
-
private $destServiceId;
|
24 |
-
private $destScope;
|
25 |
-
|
26 |
-
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
|
27 |
-
{
|
28 |
-
parent::__construct(sprintf(
|
29 |
-
'Scope Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. '
|
30 |
-
.'This service might not be available consistently. Generally, it is safer to either move the definition "%s" to scope "%s", or '
|
31 |
-
.'declare "%s" as a child scope of "%s". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.',
|
32 |
-
$sourceServiceId,
|
33 |
-
$destServiceId,
|
34 |
-
$sourceServiceId,
|
35 |
-
$destScope,
|
36 |
-
$sourceScope,
|
37 |
-
$destScope
|
38 |
-
), 0, $previous);
|
39 |
-
|
40 |
-
$this->sourceServiceId = $sourceServiceId;
|
41 |
-
$this->sourceScope = $sourceScope;
|
42 |
-
$this->destServiceId = $destServiceId;
|
43 |
-
$this->destScope = $destScope;
|
44 |
-
}
|
45 |
-
|
46 |
-
public function getSourceServiceId()
|
47 |
-
{
|
48 |
-
return $this->sourceServiceId;
|
49 |
-
}
|
50 |
-
|
51 |
-
public function getSourceScope()
|
52 |
-
{
|
53 |
-
return $this->sourceScope;
|
54 |
-
}
|
55 |
-
|
56 |
-
public function getDestServiceId()
|
57 |
-
{
|
58 |
-
return $this->destServiceId;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function getDestScope()
|
62 |
-
{
|
63 |
-
return $this->destScope;
|
64 |
-
}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Thrown when a scope widening injection is detected.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class ScopeWideningInjectionException extends RuntimeException
|
20 |
-
{
|
21 |
-
private $sourceServiceId;
|
22 |
-
private $sourceScope;
|
23 |
-
private $destServiceId;
|
24 |
-
private $destScope;
|
25 |
-
|
26 |
-
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
|
27 |
-
{
|
28 |
-
parent::__construct(sprintf(
|
29 |
-
'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. '
|
30 |
-
.'Generally, it is safer to either move "%s" to scope "%s" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "%s" each time it is needed. '
|
31 |
-
.'In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.',
|
32 |
-
$sourceServiceId,
|
33 |
-
$destServiceId,
|
34 |
-
$sourceServiceId,
|
35 |
-
$destScope,
|
36 |
-
$destServiceId
|
37 |
-
), 0, $previous);
|
38 |
-
|
39 |
-
$this->sourceServiceId = $sourceServiceId;
|
40 |
-
$this->sourceScope = $sourceScope;
|
41 |
-
$this->destServiceId = $destServiceId;
|
42 |
-
$this->destScope = $destScope;
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getSourceServiceId()
|
46 |
-
{
|
47 |
-
return $this->sourceServiceId;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getSourceScope()
|
51 |
-
{
|
52 |
-
return $this->sourceScope;
|
53 |
-
}
|
54 |
-
|
55 |
-
public function getDestServiceId()
|
56 |
-
{
|
57 |
-
return $this->destServiceId;
|
58 |
-
}
|
59 |
-
|
60 |
-
public function getDestScope()
|
61 |
-
{
|
62 |
-
return $this->destScope;
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when a circular reference is detected.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class ServiceCircularReferenceException extends RuntimeException
|
20 |
-
{
|
21 |
-
private $serviceId;
|
22 |
-
private $path;
|
23 |
-
|
24 |
-
public function __construct($serviceId, array $path, \Exception $previous = null)
|
25 |
-
{
|
26 |
-
parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous);
|
27 |
-
|
28 |
-
$this->serviceId = $serviceId;
|
29 |
-
$this->path = $path;
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getServiceId()
|
33 |
-
{
|
34 |
-
return $this->serviceId;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getPath()
|
38 |
-
{
|
39 |
-
return $this->path;
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* This exception is thrown when a non-existent service is requested.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
class ServiceNotFoundException extends InvalidArgumentException
|
20 |
-
{
|
21 |
-
private $id;
|
22 |
-
private $sourceId;
|
23 |
-
|
24 |
-
public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array())
|
25 |
-
{
|
26 |
-
if (null === $sourceId) {
|
27 |
-
$msg = sprintf('You have requested a non-existent service "%s".', $id);
|
28 |
-
} else {
|
29 |
-
$msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
|
30 |
-
}
|
31 |
-
|
32 |
-
if ($alternatives) {
|
33 |
-
if (1 == count($alternatives)) {
|
34 |
-
$msg .= ' Did you mean this: "';
|
35 |
-
} else {
|
36 |
-
$msg .= ' Did you mean one of these: "';
|
37 |
-
}
|
38 |
-
$msg .= implode('", "', $alternatives).'"?';
|
39 |
-
}
|
40 |
-
|
41 |
-
parent::__construct($msg, 0, $previous);
|
42 |
-
|
43 |
-
$this->id = $id;
|
44 |
-
$this->sourceId = $sourceId;
|
45 |
-
}
|
46 |
-
|
47 |
-
public function getId()
|
48 |
-
{
|
49 |
-
return $this->id;
|
50 |
-
}
|
51 |
-
|
52 |
-
public function getSourceId()
|
53 |
-
{
|
54 |
-
return $this->sourceId;
|
55 |
-
}
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ExpressionLanguage.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Adds some function to the default ExpressionLanguage.
|
18 |
-
*
|
19 |
-
* To get a service, use service('request').
|
20 |
-
* To get a parameter, use parameter('kernel.debug').
|
21 |
-
*
|
22 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
-
*/
|
24 |
-
class ExpressionLanguage extends BaseExpressionLanguage
|
25 |
-
{
|
26 |
-
protected function registerFunctions()
|
27 |
-
{
|
28 |
-
parent::registerFunctions();
|
29 |
-
|
30 |
-
$this->register('service', function ($arg) {
|
31 |
-
return sprintf('$this->get(%s)', $arg);
|
32 |
-
}, function (array $variables, $value) {
|
33 |
-
return $variables['container']->get($value);
|
34 |
-
});
|
35 |
-
|
36 |
-
$this->register('parameter', function ($arg) {
|
37 |
-
return sprintf('$this->getParameter(%s)', $arg);
|
38 |
-
}, function (array $variables, $value) {
|
39 |
-
return $variables['container']->getParameter($value);
|
40 |
-
});
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Extension;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* ConfigurationExtensionInterface is the interface implemented by container extension classes.
|
19 |
-
*
|
20 |
-
* @author Kevin Bond <kevinbond@gmail.com>
|
21 |
-
*/
|
22 |
-
interface ConfigurationExtensionInterface
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Returns extension configuration.
|
26 |
-
*
|
27 |
-
* @param array $config An array of configuration values
|
28 |
-
* @param ContainerBuilder $container A ContainerBuilder instance
|
29 |
-
*
|
30 |
-
* @return ConfigurationInterface|null The configuration or null
|
31 |
-
*/
|
32 |
-
public function getConfiguration(array $config, ContainerBuilder $container);
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Extension/Extension.php
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Extension;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Container;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
|
16 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
17 |
-
use Symfony\Component\Config\Resource\FileResource;
|
18 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
19 |
-
use Symfony\Component\Config\Definition\Processor;
|
20 |
-
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Provides useful features shared by many extensions.
|
24 |
-
*
|
25 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
-
*/
|
27 |
-
abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Returns the base path for the XSD files.
|
31 |
-
*
|
32 |
-
* @return string The XSD base path
|
33 |
-
*/
|
34 |
-
public function getXsdValidationBasePath()
|
35 |
-
{
|
36 |
-
return false;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Returns the namespace to be used for this extension (XML namespace).
|
41 |
-
*
|
42 |
-
* @return string The XML namespace
|
43 |
-
*/
|
44 |
-
public function getNamespace()
|
45 |
-
{
|
46 |
-
return 'http://example.org/schema/dic/'.$this->getAlias();
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Returns the recommended alias to use in XML.
|
51 |
-
*
|
52 |
-
* This alias is also the mandatory prefix to use when using YAML.
|
53 |
-
*
|
54 |
-
* This convention is to remove the "Extension" postfix from the class
|
55 |
-
* name and then lowercase and underscore the result. So:
|
56 |
-
*
|
57 |
-
* AcmeHelloExtension
|
58 |
-
*
|
59 |
-
* becomes
|
60 |
-
*
|
61 |
-
* acme_hello
|
62 |
-
*
|
63 |
-
* This can be overridden in a sub-class to specify the alias manually.
|
64 |
-
*
|
65 |
-
* @return string The alias
|
66 |
-
*
|
67 |
-
* @throws BadMethodCallException When the extension name does not follow conventions
|
68 |
-
*/
|
69 |
-
public function getAlias()
|
70 |
-
{
|
71 |
-
$className = get_class($this);
|
72 |
-
if (substr($className, -9) != 'Extension') {
|
73 |
-
throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
|
74 |
-
}
|
75 |
-
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
|
76 |
-
|
77 |
-
return Container::underscore($classBaseName);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* {@inheritdoc}
|
82 |
-
*/
|
83 |
-
public function getConfiguration(array $config, ContainerBuilder $container)
|
84 |
-
{
|
85 |
-
$reflected = new \ReflectionClass($this);
|
86 |
-
$namespace = $reflected->getNamespaceName();
|
87 |
-
|
88 |
-
$class = $namespace.'\\Configuration';
|
89 |
-
if (class_exists($class)) {
|
90 |
-
$r = new \ReflectionClass($class);
|
91 |
-
$container->addResource(new FileResource($r->getFileName()));
|
92 |
-
|
93 |
-
if (!method_exists($class, '__construct')) {
|
94 |
-
$configuration = new $class();
|
95 |
-
|
96 |
-
return $configuration;
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
|
102 |
-
{
|
103 |
-
$processor = new Processor();
|
104 |
-
|
105 |
-
return $processor->processConfiguration($configuration, $configs);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @param ContainerBuilder $container
|
110 |
-
* @param array $config
|
111 |
-
*
|
112 |
-
* @return bool Whether the configuration is enabled
|
113 |
-
*
|
114 |
-
* @throws InvalidArgumentException When the config is not enableable
|
115 |
-
*/
|
116 |
-
protected function isConfigEnabled(ContainerBuilder $container, array $config)
|
117 |
-
{
|
118 |
-
if (!array_key_exists('enabled', $config)) {
|
119 |
-
throw new InvalidArgumentException("The config array has no 'enabled' key.");
|
120 |
-
}
|
121 |
-
|
122 |
-
return (bool) $container->getParameterBag()->resolveValue($config['enabled']);
|
123 |
-
}
|
124 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Extension;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* ExtensionInterface is the interface implemented by container extension classes.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
interface ExtensionInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Loads a specific configuration.
|
27 |
-
*
|
28 |
-
* @param array $config An array of configuration values
|
29 |
-
* @param ContainerBuilder $container A ContainerBuilder instance
|
30 |
-
*
|
31 |
-
* @throws \InvalidArgumentException When provided tag is not defined in this extension
|
32 |
-
*
|
33 |
-
* @api
|
34 |
-
*/
|
35 |
-
public function load(array $config, ContainerBuilder $container);
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Returns the namespace to be used for this extension (XML namespace).
|
39 |
-
*
|
40 |
-
* @return string The XML namespace
|
41 |
-
*
|
42 |
-
* @api
|
43 |
-
*/
|
44 |
-
public function getNamespace();
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Returns the base path for the XSD files.
|
48 |
-
*
|
49 |
-
* @return string The XSD base path
|
50 |
-
*
|
51 |
-
* @api
|
52 |
-
*/
|
53 |
-
public function getXsdValidationBasePath();
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Returns the recommended alias to use in XML.
|
57 |
-
*
|
58 |
-
* This alias is also the mandatory prefix to use when using YAML.
|
59 |
-
*
|
60 |
-
* @return string The alias
|
61 |
-
*
|
62 |
-
* @api
|
63 |
-
*/
|
64 |
-
public function getAlias();
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Extension/PrependExtensionInterface.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Extension;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
|
16 |
-
interface PrependExtensionInterface
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* Allow an extension to prepend the extension configurations.
|
20 |
-
*
|
21 |
-
* @param ContainerBuilder $container
|
22 |
-
*/
|
23 |
-
public function prepend(ContainerBuilder $container);
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* IntrospectableContainerInterface defines additional introspection functionality
|
16 |
-
* for containers, allowing logic to be implemented based on a Container's state.
|
17 |
-
*
|
18 |
-
* @author Evan Villemez <evillemez@gmail.com>
|
19 |
-
*/
|
20 |
-
interface IntrospectableContainerInterface extends ContainerInterface
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Check for whether or not a service has been initialized.
|
24 |
-
*
|
25 |
-
* @param string $id
|
26 |
-
*
|
27 |
-
* @return bool true if the service has been initialized, false otherwise
|
28 |
-
*/
|
29 |
-
public function initialized($id);
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2004-2015 Fabien Potencier
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
-
to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in all
|
11 |
-
copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\LazyProxy\Instantiator;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\Definition;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Lazy proxy instantiator, capable of instantiating a proxy given a container, the
|
19 |
-
* service definitions and a callback that produces the real service instance.
|
20 |
-
*
|
21 |
-
* @author Marco Pivetta <ocramius@gmail.com>
|
22 |
-
*/
|
23 |
-
interface InstantiatorInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Instantiates a proxy object.
|
27 |
-
*
|
28 |
-
* @param ContainerInterface $container the container from which the service is being requested
|
29 |
-
* @param Definition $definition the definition of the requested service
|
30 |
-
* @param string $id identifier of the requested service
|
31 |
-
* @param callable $realInstantiator zero-argument callback that is capable of producing the real
|
32 |
-
* service instance
|
33 |
-
*
|
34 |
-
* @return object
|
35 |
-
*/
|
36 |
-
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator);
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\LazyProxy\Instantiator;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
15 |
-
use Symfony\Component\DependencyInjection\Definition;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* {@inheritdoc}
|
19 |
-
*
|
20 |
-
* Noop proxy instantiator - simply produces the real service instead of a proxy instance.
|
21 |
-
*
|
22 |
-
* @author Marco Pivetta <ocramius@gmail.com>
|
23 |
-
*/
|
24 |
-
class RealServiceInstantiator implements InstantiatorInterface
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* {@inheritdoc}
|
28 |
-
*/
|
29 |
-
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator)
|
30 |
-
{
|
31 |
-
return call_user_func($realInstantiator);
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Lazy proxy dumper capable of generating the instantiation logic PHP code for proxied services.
|
18 |
-
*
|
19 |
-
* @author Marco Pivetta <ocramius@gmail.com>
|
20 |
-
*/
|
21 |
-
interface DumperInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Inspects whether the given definitions should produce proxy instantiation logic in the dumped container.
|
25 |
-
*
|
26 |
-
* @param Definition $definition
|
27 |
-
*
|
28 |
-
* @return bool
|
29 |
-
*/
|
30 |
-
public function isProxyCandidate(Definition $definition);
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Generates the code to be used to instantiate a proxy in the dumped factory code.
|
34 |
-
*
|
35 |
-
* @param Definition $definition
|
36 |
-
* @param string $id service identifier
|
37 |
-
*
|
38 |
-
* @return string
|
39 |
-
*/
|
40 |
-
public function getProxyFactoryCode(Definition $definition, $id);
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Generates the code for the lazy proxy.
|
44 |
-
*
|
45 |
-
* @param Definition $definition
|
46 |
-
*
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
public function getProxyCode(Definition $definition);
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Definition;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Null dumper, negates any proxy code generation for any given service definition.
|
18 |
-
*
|
19 |
-
* @author Marco Pivetta <ocramius@gmail.com>
|
20 |
-
*/
|
21 |
-
class NullDumper implements DumperInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* {@inheritdoc}
|
25 |
-
*/
|
26 |
-
public function isProxyCandidate(Definition $definition)
|
27 |
-
{
|
28 |
-
return false;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* {@inheritdoc}
|
33 |
-
*/
|
34 |
-
public function getProxyFactoryCode(Definition $definition, $id)
|
35 |
-
{
|
36 |
-
return '';
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* {@inheritdoc}
|
41 |
-
*/
|
42 |
-
public function getProxyCode(Definition $definition)
|
43 |
-
{
|
44 |
-
return '';
|
45 |
-
}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\Config\Loader\Loader;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* ClosureLoader loads service definitions from a PHP closure.
|
19 |
-
*
|
20 |
-
* The Closure has access to the container as its first argument.
|
21 |
-
*
|
22 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
-
*/
|
24 |
-
class ClosureLoader extends Loader
|
25 |
-
{
|
26 |
-
private $container;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Constructor.
|
30 |
-
*
|
31 |
-
* @param ContainerBuilder $container A ContainerBuilder instance
|
32 |
-
*/
|
33 |
-
public function __construct(ContainerBuilder $container)
|
34 |
-
{
|
35 |
-
$this->container = $container;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
-
public function load($resource, $type = null)
|
42 |
-
{
|
43 |
-
call_user_func($resource, $this->container);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function supports($resource, $type = null)
|
50 |
-
{
|
51 |
-
return $resource instanceof \Closure;
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/FileLoader.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 |
-
use Symfony\Component\Config\Loader\FileLoader as BaseFileLoader;
|
16 |
-
use Symfony\Component\Config\FileLocatorInterface;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* FileLoader is the abstract class used by all built-in loaders that are file based.
|
20 |
-
*
|
21 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
-
*/
|
23 |
-
abstract class FileLoader extends BaseFileLoader
|
24 |
-
{
|
25 |
-
protected $container;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Constructor.
|
29 |
-
*
|
30 |
-
* @param ContainerBuilder $container A ContainerBuilder instance
|
31 |
-
* @param FileLocatorInterface $locator A FileLocator instance
|
32 |
-
*/
|
33 |
-
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator)
|
34 |
-
{
|
35 |
-
$this->container = $container;
|
36 |
-
|
37 |
-
parent::__construct($locator);
|
38 |
-
}
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Resource\FileResource;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* IniFileLoader loads parameters from INI files.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*/
|
22 |
-
class IniFileLoader extends FileLoader
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
-
public function load($resource, $type = null)
|
28 |
-
{
|
29 |
-
$path = $this->locator->locate($resource);
|
30 |
-
|
31 |
-
$this->container->addResource(new FileResource($path));
|
32 |
-
|
33 |
-
$result = parse_ini_file($path, true);
|
34 |
-
if (false === $result || array() === $result) {
|
35 |
-
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
|
36 |
-
}
|
37 |
-
|
38 |
-
if (isset($result['parameters']) && is_array($result['parameters'])) {
|
39 |
-
foreach ($result['parameters'] as $key => $value) {
|
40 |
-
$this->container->setParameter($key, $value);
|
41 |
-
}
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* {@inheritdoc}
|
47 |
-
*/
|
48 |
-
public function supports($resource, $type = null)
|
49 |
-
{
|
50 |
-
return is_string($resource) && 'ini' === pathinfo($resource, PATHINFO_EXTENSION);
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Resource\FileResource;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* PhpFileLoader loads service definitions from a PHP file.
|
18 |
-
*
|
19 |
-
* The PHP file is required and the $container variable can be
|
20 |
-
* used within the file to change the container.
|
21 |
-
*
|
22 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
-
*/
|
24 |
-
class PhpFileLoader extends FileLoader
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* {@inheritdoc}
|
28 |
-
*/
|
29 |
-
public function load($resource, $type = null)
|
30 |
-
{
|
31 |
-
// the container and loader variables are exposed to the included file below
|
32 |
-
$container = $this->container;
|
33 |
-
$loader = $this;
|
34 |
-
|
35 |
-
$path = $this->locator->locate($resource);
|
36 |
-
$this->setCurrentDir(dirname($path));
|
37 |
-
$this->container->addResource(new FileResource($path));
|
38 |
-
|
39 |
-
include $path;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
-
public function supports($resource, $type = null)
|
46 |
-
{
|
47 |
-
return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION);
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
DELETED
@@ -1,528 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Resource\FileResource;
|
15 |
-
use Symfony\Component\Config\Util\XmlUtils;
|
16 |
-
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
17 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
18 |
-
use Symfony\Component\DependencyInjection\Alias;
|
19 |
-
use Symfony\Component\DependencyInjection\Definition;
|
20 |
-
use Symfony\Component\DependencyInjection\Reference;
|
21 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
22 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
23 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* XmlFileLoader loads XML files service definitions.
|
27 |
-
*
|
28 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
-
*/
|
30 |
-
class XmlFileLoader extends FileLoader
|
31 |
-
{
|
32 |
-
const NS = 'http://symfony.com/schema/dic/services';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
-
public function load($resource, $type = null)
|
38 |
-
{
|
39 |
-
$path = $this->locator->locate($resource);
|
40 |
-
|
41 |
-
$xml = $this->parseFileToDOM($path);
|
42 |
-
|
43 |
-
$this->container->addResource(new FileResource($path));
|
44 |
-
|
45 |
-
// anonymous services
|
46 |
-
$this->processAnonymousServices($xml, $path);
|
47 |
-
|
48 |
-
// imports
|
49 |
-
$this->parseImports($xml, $path);
|
50 |
-
|
51 |
-
// parameters
|
52 |
-
$this->parseParameters($xml, $path);
|
53 |
-
|
54 |
-
// extensions
|
55 |
-
$this->loadFromExtensions($xml);
|
56 |
-
|
57 |
-
// services
|
58 |
-
$this->parseDefinitions($xml, $path);
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* {@inheritdoc}
|
63 |
-
*/
|
64 |
-
public function supports($resource, $type = null)
|
65 |
-
{
|
66 |
-
return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Parses parameters.
|
71 |
-
*
|
72 |
-
* @param \DOMDocument $xml
|
73 |
-
* @param string $file
|
74 |
-
*/
|
75 |
-
private function parseParameters(\DOMDocument $xml, $file)
|
76 |
-
{
|
77 |
-
if ($parameters = $this->getChildren($xml->documentElement, 'parameters')) {
|
78 |
-
$this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter'));
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Parses imports.
|
84 |
-
*
|
85 |
-
* @param \DOMDocument $xml
|
86 |
-
* @param string $file
|
87 |
-
*/
|
88 |
-
private function parseImports(\DOMDocument $xml, $file)
|
89 |
-
{
|
90 |
-
$xpath = new \DOMXPath($xml);
|
91 |
-
$xpath->registerNamespace('container', self::NS);
|
92 |
-
|
93 |
-
if (false === $imports = $xpath->query('//container:imports/container:import')) {
|
94 |
-
return;
|
95 |
-
}
|
96 |
-
|
97 |
-
foreach ($imports as $import) {
|
98 |
-
$this->setCurrentDir(dirname($file));
|
99 |
-
$this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Parses multiple definitions.
|
105 |
-
*
|
106 |
-
* @param \DOMDocument $xml
|
107 |
-
* @param string $file
|
108 |
-
*/
|
109 |
-
private function parseDefinitions(\DOMDocument $xml, $file)
|
110 |
-
{
|
111 |
-
$xpath = new \DOMXPath($xml);
|
112 |
-
$xpath->registerNamespace('container', self::NS);
|
113 |
-
|
114 |
-
if (false === $services = $xpath->query('//container:services/container:service')) {
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
|
118 |
-
foreach ($services as $service) {
|
119 |
-
$this->parseDefinition((string) $service->getAttribute('id'), $service, $file);
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Parses an individual Definition.
|
125 |
-
*
|
126 |
-
* @param string $id
|
127 |
-
* @param \DOMElement $service
|
128 |
-
* @param string $file
|
129 |
-
*/
|
130 |
-
private function parseDefinition($id, \DOMElement $service, $file)
|
131 |
-
{
|
132 |
-
if ($alias = $service->getAttribute('alias')) {
|
133 |
-
$public = true;
|
134 |
-
if ($publicAttr = $service->getAttribute('public')) {
|
135 |
-
$public = XmlUtils::phpize($publicAttr);
|
136 |
-
}
|
137 |
-
$this->container->setAlias($id, new Alias($alias, $public));
|
138 |
-
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
|
142 |
-
if ($parent = $service->getAttribute('parent')) {
|
143 |
-
$definition = new DefinitionDecorator($parent);
|
144 |
-
} else {
|
145 |
-
$definition = new Definition();
|
146 |
-
}
|
147 |
-
|
148 |
-
foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'synchronized', 'lazy', 'abstract') as $key) {
|
149 |
-
if ($value = $service->getAttribute($key)) {
|
150 |
-
$method = 'set'.str_replace('-', '', $key);
|
151 |
-
$definition->$method(XmlUtils::phpize($value));
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
if ($files = $this->getChildren($service, 'file')) {
|
156 |
-
$definition->setFile($files[0]->nodeValue);
|
157 |
-
}
|
158 |
-
|
159 |
-
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
|
160 |
-
$definition->setProperties($this->getArgumentsAsPhp($service, 'property'));
|
161 |
-
|
162 |
-
if ($configurators = $this->getChildren($service, 'configurator')) {
|
163 |
-
$configurator = $configurators[0];
|
164 |
-
if ($function = $configurator->getAttribute('function')) {
|
165 |
-
$definition->setConfigurator($function);
|
166 |
-
} else {
|
167 |
-
if ($childService = $configurator->getAttribute('service')) {
|
168 |
-
$class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
|
169 |
-
} else {
|
170 |
-
$class = $configurator->getAttribute('class');
|
171 |
-
}
|
172 |
-
|
173 |
-
$definition->setConfigurator(array($class, $configurator->getAttribute('method')));
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
foreach ($this->getChildren($service, 'call') as $call) {
|
178 |
-
$definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument'));
|
179 |
-
}
|
180 |
-
|
181 |
-
foreach ($this->getChildren($service, 'tag') as $tag) {
|
182 |
-
$parameters = array();
|
183 |
-
foreach ($tag->attributes as $name => $node) {
|
184 |
-
if ('name' === $name) {
|
185 |
-
continue;
|
186 |
-
}
|
187 |
-
|
188 |
-
if (false !== strpos($name, '-') && false === strpos($name, '_') && !array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) {
|
189 |
-
$parameters[$normalizedName] = XmlUtils::phpize($node->nodeValue);
|
190 |
-
}
|
191 |
-
// keep not normalized key for BC too
|
192 |
-
$parameters[$name] = XmlUtils::phpize($node->nodeValue);
|
193 |
-
}
|
194 |
-
|
195 |
-
$definition->addTag($tag->getAttribute('name'), $parameters);
|
196 |
-
}
|
197 |
-
|
198 |
-
if ($value = $service->getAttribute('decorates')) {
|
199 |
-
$renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null;
|
200 |
-
$definition->setDecoratedService($value, $renameId);
|
201 |
-
}
|
202 |
-
|
203 |
-
$this->container->setDefinition($id, $definition);
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Parses a XML file to a \DOMDocument
|
208 |
-
*
|
209 |
-
* @param string $file Path to a file
|
210 |
-
*
|
211 |
-
* @return \DOMDocument
|
212 |
-
*
|
213 |
-
* @throws InvalidArgumentException When loading of XML file returns error
|
214 |
-
*/
|
215 |
-
private function parseFileToDOM($file)
|
216 |
-
{
|
217 |
-
try {
|
218 |
-
$dom = XmlUtils::loadFile($file, array($this, 'validateSchema'));
|
219 |
-
} catch (\InvalidArgumentException $e) {
|
220 |
-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
|
221 |
-
}
|
222 |
-
|
223 |
-
$this->validateExtensions($dom, $file);
|
224 |
-
|
225 |
-
return $dom;
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Processes anonymous services.
|
230 |
-
*
|
231 |
-
* @param \DOMDocument $xml
|
232 |
-
* @param string $file
|
233 |
-
*/
|
234 |
-
private function processAnonymousServices(\DOMDocument $xml, $file)
|
235 |
-
{
|
236 |
-
$definitions = array();
|
237 |
-
$count = 0;
|
238 |
-
|
239 |
-
$xpath = new \DOMXPath($xml);
|
240 |
-
$xpath->registerNamespace('container', self::NS);
|
241 |
-
|
242 |
-
// anonymous services as arguments/properties
|
243 |
-
if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]')) {
|
244 |
-
foreach ($nodes as $node) {
|
245 |
-
// give it a unique name
|
246 |
-
$id = sprintf('%s_%d', hash('sha256', $file), ++$count);
|
247 |
-
$node->setAttribute('id', $id);
|
248 |
-
|
249 |
-
if ($services = $this->getChildren($node, 'service')) {
|
250 |
-
$definitions[$id] = array($services[0], $file, false);
|
251 |
-
$services[0]->setAttribute('id', $id);
|
252 |
-
}
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
// anonymous services "in the wild"
|
257 |
-
if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {
|
258 |
-
foreach ($nodes as $node) {
|
259 |
-
// give it a unique name
|
260 |
-
$id = sprintf('%s_%d', hash('sha256', $file), ++$count);
|
261 |
-
$node->setAttribute('id', $id);
|
262 |
-
|
263 |
-
if ($services = $this->getChildren($node, 'service')) {
|
264 |
-
$definitions[$id] = array($node, $file, true);
|
265 |
-
$services[0]->setAttribute('id', $id);
|
266 |
-
}
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
// resolve definitions
|
271 |
-
krsort($definitions);
|
272 |
-
foreach ($definitions as $id => $def) {
|
273 |
-
list($domElement, $file, $wild) = $def;
|
274 |
-
|
275 |
-
// anonymous services are always private
|
276 |
-
// we could not use the constant false here, because of XML parsing
|
277 |
-
$domElement->setAttribute('public', 'false');
|
278 |
-
|
279 |
-
$this->parseDefinition($id, $domElement, $file);
|
280 |
-
|
281 |
-
if (true === $wild) {
|
282 |
-
$tmpDomElement = new \DOMElement('_services', null, self::NS);
|
283 |
-
$domElement->parentNode->replaceChild($tmpDomElement, $domElement);
|
284 |
-
$tmpDomElement->setAttribute('id', $id);
|
285 |
-
} else {
|
286 |
-
$domElement->parentNode->removeChild($domElement);
|
287 |
-
}
|
288 |
-
}
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Returns arguments as valid php types.
|
293 |
-
*
|
294 |
-
* @param \DOMElement $node
|
295 |
-
* @param string $name
|
296 |
-
* @param bool $lowercase
|
297 |
-
*
|
298 |
-
* @return mixed
|
299 |
-
*/
|
300 |
-
private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
|
301 |
-
{
|
302 |
-
$arguments = array();
|
303 |
-
foreach ($this->getChildren($node, $name) as $arg) {
|
304 |
-
if ($arg->hasAttribute('name')) {
|
305 |
-
$arg->setAttribute('key', $arg->getAttribute('name'));
|
306 |
-
}
|
307 |
-
|
308 |
-
if (!$arg->hasAttribute('key')) {
|
309 |
-
$key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
|
310 |
-
} else {
|
311 |
-
$key = $arg->getAttribute('key');
|
312 |
-
}
|
313 |
-
|
314 |
-
// parameter keys are case insensitive
|
315 |
-
if ('parameter' == $name && $lowercase) {
|
316 |
-
$key = strtolower($key);
|
317 |
-
}
|
318 |
-
|
319 |
-
// this is used by DefinitionDecorator to overwrite a specific
|
320 |
-
// argument of the parent definition
|
321 |
-
if ($arg->hasAttribute('index')) {
|
322 |
-
$key = 'index_'.$arg->getAttribute('index');
|
323 |
-
}
|
324 |
-
|
325 |
-
switch ($arg->getAttribute('type')) {
|
326 |
-
case 'service':
|
327 |
-
$onInvalid = $arg->getAttribute('on-invalid');
|
328 |
-
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
329 |
-
if ('ignore' == $onInvalid) {
|
330 |
-
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
331 |
-
} elseif ('null' == $onInvalid) {
|
332 |
-
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
|
333 |
-
}
|
334 |
-
|
335 |
-
if ($strict = $arg->getAttribute('strict')) {
|
336 |
-
$strict = XmlUtils::phpize($strict);
|
337 |
-
} else {
|
338 |
-
$strict = true;
|
339 |
-
}
|
340 |
-
|
341 |
-
$arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior, $strict);
|
342 |
-
break;
|
343 |
-
case 'expression':
|
344 |
-
$arguments[$key] = new Expression($arg->nodeValue);
|
345 |
-
break;
|
346 |
-
case 'collection':
|
347 |
-
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
|
348 |
-
break;
|
349 |
-
case 'string':
|
350 |
-
$arguments[$key] = $arg->nodeValue;
|
351 |
-
break;
|
352 |
-
case 'constant':
|
353 |
-
$arguments[$key] = constant($arg->nodeValue);
|
354 |
-
break;
|
355 |
-
default:
|
356 |
-
$arguments[$key] = XmlUtils::phpize($arg->nodeValue);
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
return $arguments;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Get child elements by name
|
365 |
-
*
|
366 |
-
* @param \DOMNode $node
|
367 |
-
* @param mixed $name
|
368 |
-
*
|
369 |
-
* @return array
|
370 |
-
*/
|
371 |
-
private function getChildren(\DOMNode $node, $name)
|
372 |
-
{
|
373 |
-
$children = array();
|
374 |
-
foreach ($node->childNodes as $child) {
|
375 |
-
if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) {
|
376 |
-
$children[] = $child;
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
return $children;
|
381 |
-
}
|
382 |
-
|
383 |
-
/**
|
384 |
-
* Validates a documents XML schema.
|
385 |
-
*
|
386 |
-
* @param \DOMDocument $dom
|
387 |
-
*
|
388 |
-
* @return bool
|
389 |
-
*
|
390 |
-
* @throws RuntimeException When extension references a non-existent XSD file
|
391 |
-
*/
|
392 |
-
public function validateSchema(\DOMDocument $dom)
|
393 |
-
{
|
394 |
-
$schemaLocations = array('http://symfony.com/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd'));
|
395 |
-
|
396 |
-
if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) {
|
397 |
-
$items = preg_split('/\s+/', $element);
|
398 |
-
for ($i = 0, $nb = count($items); $i < $nb; $i += 2) {
|
399 |
-
if (!$this->container->hasExtension($items[$i])) {
|
400 |
-
continue;
|
401 |
-
}
|
402 |
-
|
403 |
-
if (($extension = $this->container->getExtension($items[$i])) && false !== $extension->getXsdValidationBasePath()) {
|
404 |
-
$path = str_replace($extension->getNamespace(), str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);
|
405 |
-
|
406 |
-
if (!is_file($path)) {
|
407 |
-
throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s"', get_class($extension), $path));
|
408 |
-
}
|
409 |
-
|
410 |
-
$schemaLocations[$items[$i]] = $path;
|
411 |
-
}
|
412 |
-
}
|
413 |
-
}
|
414 |
-
|
415 |
-
$tmpfiles = array();
|
416 |
-
$imports = '';
|
417 |
-
foreach ($schemaLocations as $namespace => $location) {
|
418 |
-
$parts = explode('/', $location);
|
419 |
-
if (0 === stripos($location, 'phar://')) {
|
420 |
-
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
|
421 |
-
if ($tmpfile) {
|
422 |
-
copy($location, $tmpfile);
|
423 |
-
$tmpfiles[] = $tmpfile;
|
424 |
-
$parts = explode('/', str_replace('\\', '/', $tmpfile));
|
425 |
-
}
|
426 |
-
}
|
427 |
-
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
|
428 |
-
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
|
429 |
-
|
430 |
-
$imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
|
431 |
-
}
|
432 |
-
|
433 |
-
$source = <<<EOF
|
434 |
-
<?xml version="1.0" encoding="utf-8" ?>
|
435 |
-
<xsd:schema xmlns="http://symfony.com/schema"
|
436 |
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
437 |
-
targetNamespace="http://symfony.com/schema"
|
438 |
-
elementFormDefault="qualified">
|
439 |
-
|
440 |
-
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
|
441 |
-
$imports
|
442 |
-
</xsd:schema>
|
443 |
-
EOF
|
444 |
-
;
|
445 |
-
|
446 |
-
$valid = @$dom->schemaValidateSource($source);
|
447 |
-
|
448 |
-
foreach ($tmpfiles as $tmpfile) {
|
449 |
-
@unlink($tmpfile);
|
450 |
-
}
|
451 |
-
|
452 |
-
return $valid;
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Validates an extension.
|
457 |
-
*
|
458 |
-
* @param \DOMDocument $dom
|
459 |
-
* @param string $file
|
460 |
-
*
|
461 |
-
* @throws InvalidArgumentException When no extension is found corresponding to a tag
|
462 |
-
*/
|
463 |
-
private function validateExtensions(\DOMDocument $dom, $file)
|
464 |
-
{
|
465 |
-
foreach ($dom->documentElement->childNodes as $node) {
|
466 |
-
if (!$node instanceof \DOMElement || 'http://symfony.com/schema/dic/services' === $node->namespaceURI) {
|
467 |
-
continue;
|
468 |
-
}
|
469 |
-
|
470 |
-
// can it be handled by an extension?
|
471 |
-
if (!$this->container->hasExtension($node->namespaceURI)) {
|
472 |
-
$extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions()));
|
473 |
-
throw new InvalidArgumentException(sprintf(
|
474 |
-
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
|
475 |
-
$node->tagName,
|
476 |
-
$file,
|
477 |
-
$node->namespaceURI,
|
478 |
-
$extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
|
479 |
-
));
|
480 |
-
}
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Loads from an extension.
|
486 |
-
*
|
487 |
-
* @param \DOMDocument $xml
|
488 |
-
*/
|
489 |
-
private function loadFromExtensions(\DOMDocument $xml)
|
490 |
-
{
|
491 |
-
foreach ($xml->documentElement->childNodes as $node) {
|
492 |
-
if (!$node instanceof \DOMElement || $node->namespaceURI === self::NS) {
|
493 |
-
continue;
|
494 |
-
}
|
495 |
-
|
496 |
-
$values = static::convertDomElementToArray($node);
|
497 |
-
if (!is_array($values)) {
|
498 |
-
$values = array();
|
499 |
-
}
|
500 |
-
|
501 |
-
$this->container->loadFromExtension($node->namespaceURI, $values);
|
502 |
-
}
|
503 |
-
}
|
504 |
-
|
505 |
-
/**
|
506 |
-
* Converts a \DomElement object to a PHP array.
|
507 |
-
*
|
508 |
-
* The following rules applies during the conversion:
|
509 |
-
*
|
510 |
-
* * Each tag is converted to a key value or an array
|
511 |
-
* if there is more than one "value"
|
512 |
-
*
|
513 |
-
* * The content of a tag is set under a "value" key (<foo>bar</foo>)
|
514 |
-
* if the tag also has some nested tags
|
515 |
-
*
|
516 |
-
* * The attributes are converted to keys (<foo foo="bar"/>)
|
517 |
-
*
|
518 |
-
* * The nested-tags are converted to keys (<foo><foo>bar</foo></foo>)
|
519 |
-
*
|
520 |
-
* @param \DomElement $element A \DomElement instance
|
521 |
-
*
|
522 |
-
* @return array A PHP array
|
523 |
-
*/
|
524 |
-
public static function convertDomElementToArray(\DomElement $element)
|
525 |
-
{
|
526 |
-
return XmlUtils::convertDomElementToArray($element);
|
527 |
-
}
|
528 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
DELETED
@@ -1,392 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\Loader;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
15 |
-
use Symfony\Component\DependencyInjection\Alias;
|
16 |
-
use Symfony\Component\DependencyInjection\ContainerInterface;
|
17 |
-
use Symfony\Component\DependencyInjection\Definition;
|
18 |
-
use Symfony\Component\DependencyInjection\Reference;
|
19 |
-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
20 |
-
use Symfony\Component\Config\Resource\FileResource;
|
21 |
-
use Symfony\Component\Yaml\Parser as YamlParser;
|
22 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* YamlFileLoader loads YAML files service definitions.
|
26 |
-
*
|
27 |
-
* The YAML format does not support anonymous services (cf. the XML loader).
|
28 |
-
*
|
29 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
30 |
-
*/
|
31 |
-
class YamlFileLoader extends FileLoader
|
32 |
-
{
|
33 |
-
private $yamlParser;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* {@inheritdoc}
|
37 |
-
*/
|
38 |
-
public function load($resource, $type = null)
|
39 |
-
{
|
40 |
-
$path = $this->locator->locate($resource);
|
41 |
-
|
42 |
-
$content = $this->loadFile($path);
|
43 |
-
|
44 |
-
$this->container->addResource(new FileResource($path));
|
45 |
-
|
46 |
-
// empty file
|
47 |
-
if (null === $content) {
|
48 |
-
return;
|
49 |
-
}
|
50 |
-
|
51 |
-
// imports
|
52 |
-
$this->parseImports($content, $path);
|
53 |
-
|
54 |
-
// parameters
|
55 |
-
if (isset($content['parameters'])) {
|
56 |
-
if (!is_array($content['parameters'])) {
|
57 |
-
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $resource));
|
58 |
-
}
|
59 |
-
|
60 |
-
foreach ($content['parameters'] as $key => $value) {
|
61 |
-
$this->container->setParameter($key, $this->resolveServices($value));
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
// extensions
|
66 |
-
$this->loadFromExtensions($content);
|
67 |
-
|
68 |
-
// services
|
69 |
-
$this->parseDefinitions($content, $resource);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* {@inheritdoc}
|
74 |
-
*/
|
75 |
-
public function supports($resource, $type = null)
|
76 |
-
{
|
77 |
-
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Parses all imports.
|
82 |
-
*
|
83 |
-
* @param array $content
|
84 |
-
* @param string $file
|
85 |
-
*/
|
86 |
-
private function parseImports($content, $file)
|
87 |
-
{
|
88 |
-
if (!isset($content['imports'])) {
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
|
92 |
-
if (!is_array($content['imports'])) {
|
93 |
-
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
|
94 |
-
}
|
95 |
-
|
96 |
-
foreach ($content['imports'] as $import) {
|
97 |
-
if (!is_array($import)) {
|
98 |
-
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
|
99 |
-
}
|
100 |
-
|
101 |
-
$this->setCurrentDir(dirname($file));
|
102 |
-
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Parses definitions.
|
108 |
-
*
|
109 |
-
* @param array $content
|
110 |
-
* @param string $file
|
111 |
-
*/
|
112 |
-
private function parseDefinitions($content, $file)
|
113 |
-
{
|
114 |
-
if (!isset($content['services'])) {
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
|
118 |
-
if (!is_array($content['services'])) {
|
119 |
-
throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
|
120 |
-
}
|
121 |
-
|
122 |
-
foreach ($content['services'] as $id => $service) {
|
123 |
-
$this->parseDefinition($id, $service, $file);
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Parses a definition.
|
129 |
-
*
|
130 |
-
* @param string $id
|
131 |
-
* @param array $service
|
132 |
-
* @param string $file
|
133 |
-
*
|
134 |
-
* @throws InvalidArgumentException When tags are invalid
|
135 |
-
*/
|
136 |
-
private function parseDefinition($id, $service, $file)
|
137 |
-
{
|
138 |
-
if (is_string($service) && 0 === strpos($service, '@')) {
|
139 |
-
$this->container->setAlias($id, substr($service, 1));
|
140 |
-
|
141 |
-
return;
|
142 |
-
}
|
143 |
-
|
144 |
-
if (!is_array($service)) {
|
145 |
-
throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', gettype($service), $id, $file));
|
146 |
-
}
|
147 |
-
|
148 |
-
if (isset($service['alias'])) {
|
149 |
-
$public = !array_key_exists('public', $service) || (bool) $service['public'];
|
150 |
-
$this->container->setAlias($id, new Alias($service['alias'], $public));
|
151 |
-
|
152 |
-
return;
|
153 |
-
}
|
154 |
-
|
155 |
-
if (isset($service['parent'])) {
|
156 |
-
$definition = new DefinitionDecorator($service['parent']);
|
157 |
-
} else {
|
158 |
-
$definition = new Definition();
|
159 |
-
}
|
160 |
-
|
161 |
-
if (isset($service['class'])) {
|
162 |
-
$definition->setClass($service['class']);
|
163 |
-
}
|
164 |
-
|
165 |
-
if (isset($service['scope'])) {
|
166 |
-
$definition->setScope($service['scope']);
|
167 |
-
}
|
168 |
-
|
169 |
-
if (isset($service['synthetic'])) {
|
170 |
-
$definition->setSynthetic($service['synthetic']);
|
171 |
-
}
|
172 |
-
|
173 |
-
if (isset($service['synchronized'])) {
|
174 |
-
$definition->setSynchronized($service['synchronized']);
|
175 |
-
}
|
176 |
-
|
177 |
-
if (isset($service['lazy'])) {
|
178 |
-
$definition->setLazy($service['lazy']);
|
179 |
-
}
|
180 |
-
|
181 |
-
if (isset($service['public'])) {
|
182 |
-
$definition->setPublic($service['public']);
|
183 |
-
}
|
184 |
-
|
185 |
-
if (isset($service['abstract'])) {
|
186 |
-
$definition->setAbstract($service['abstract']);
|
187 |
-
}
|
188 |
-
|
189 |
-
if (isset($service['factory_class'])) {
|
190 |
-
$definition->setFactoryClass($service['factory_class']);
|
191 |
-
}
|
192 |
-
|
193 |
-
if (isset($service['factory_method'])) {
|
194 |
-
$definition->setFactoryMethod($service['factory_method']);
|
195 |
-
}
|
196 |
-
|
197 |
-
if (isset($service['factory_service'])) {
|
198 |
-
$definition->setFactoryService($service['factory_service']);
|
199 |
-
}
|
200 |
-
|
201 |
-
if (isset($service['file'])) {
|
202 |
-
$definition->setFile($service['file']);
|
203 |
-
}
|
204 |
-
|
205 |
-
if (isset($service['arguments'])) {
|
206 |
-
$definition->setArguments($this->resolveServices($service['arguments']));
|
207 |
-
}
|
208 |
-
|
209 |
-
if (isset($service['properties'])) {
|
210 |
-
$definition->setProperties($this->resolveServices($service['properties']));
|
211 |
-
}
|
212 |
-
|
213 |
-
if (isset($service['configurator'])) {
|
214 |
-
if (is_string($service['configurator'])) {
|
215 |
-
$definition->setConfigurator($service['configurator']);
|
216 |
-
} else {
|
217 |
-
$definition->setConfigurator(array($this->resolveServices($service['configurator'][0]), $service['configurator'][1]));
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
if (isset($service['calls'])) {
|
222 |
-
if (!is_array($service['calls'])) {
|
223 |
-
throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
|
224 |
-
}
|
225 |
-
|
226 |
-
foreach ($service['calls'] as $call) {
|
227 |
-
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
|
228 |
-
$definition->addMethodCall($call[0], $args);
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
if (isset($service['tags'])) {
|
233 |
-
if (!is_array($service['tags'])) {
|
234 |
-
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
|
235 |
-
}
|
236 |
-
|
237 |
-
foreach ($service['tags'] as $tag) {
|
238 |
-
if (!is_array($tag)) {
|
239 |
-
throw new InvalidArgumentException(sprintf('A "tags" entry must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
|
240 |
-
}
|
241 |
-
|
242 |
-
if (!isset($tag['name'])) {
|
243 |
-
throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file));
|
244 |
-
}
|
245 |
-
|
246 |
-
$name = $tag['name'];
|
247 |
-
unset($tag['name']);
|
248 |
-
|
249 |
-
foreach ($tag as $attribute => $value) {
|
250 |
-
if (!is_scalar($value) && null !== $value) {
|
251 |
-
throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s. Check your YAML syntax.', $id, $name, $attribute, $file));
|
252 |
-
}
|
253 |
-
}
|
254 |
-
|
255 |
-
$definition->addTag($name, $tag);
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
if (isset($service['decorates'])) {
|
260 |
-
$renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null;
|
261 |
-
$definition->setDecoratedService($service['decorates'], $renameId);
|
262 |
-
}
|
263 |
-
|
264 |
-
$this->container->setDefinition($id, $definition);
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Loads a YAML file.
|
269 |
-
*
|
270 |
-
* @param string $file
|
271 |
-
*
|
272 |
-
* @return array The file content
|
273 |
-
*
|
274 |
-
* @throws InvalidArgumentException when the given file is not a local file or when it does not exist
|
275 |
-
*/
|
276 |
-
protected function loadFile($file)
|
277 |
-
{
|
278 |
-
if (!stream_is_local($file)) {
|
279 |
-
throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
|
280 |
-
}
|
281 |
-
|
282 |
-
if (!file_exists($file)) {
|
283 |
-
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
|
284 |
-
}
|
285 |
-
|
286 |
-
if (null === $this->yamlParser) {
|
287 |
-
$this->yamlParser = new YamlParser();
|
288 |
-
}
|
289 |
-
|
290 |
-
return $this->validate($this->yamlParser->parse(file_get_contents($file)), $file);
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Validates a YAML file.
|
295 |
-
*
|
296 |
-
* @param mixed $content
|
297 |
-
* @param string $file
|
298 |
-
*
|
299 |
-
* @return array
|
300 |
-
*
|
301 |
-
* @throws InvalidArgumentException When service file is not valid
|
302 |
-
*/
|
303 |
-
private function validate($content, $file)
|
304 |
-
{
|
305 |
-
if (null === $content) {
|
306 |
-
return $content;
|
307 |
-
}
|
308 |
-
|
309 |
-
if (!is_array($content)) {
|
310 |
-
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file));
|
311 |
-
}
|
312 |
-
|
313 |
-
foreach (array_keys($content) as $namespace) {
|
314 |
-
if (in_array($namespace, array('imports', 'parameters', 'services'))) {
|
315 |
-
continue;
|
316 |
-
}
|
317 |
-
|
318 |
-
if (!$this->container->hasExtension($namespace)) {
|
319 |
-
$extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
|
320 |
-
throw new InvalidArgumentException(sprintf(
|
321 |
-
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
|
322 |
-
$namespace,
|
323 |
-
$file,
|
324 |
-
$namespace,
|
325 |
-
$extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
|
326 |
-
));
|
327 |
-
}
|
328 |
-
}
|
329 |
-
|
330 |
-
return $content;
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Resolves services.
|
335 |
-
*
|
336 |
-
* @param string|array $value
|
337 |
-
*
|
338 |
-
* @return array|string|Reference
|
339 |
-
*/
|
340 |
-
private function resolveServices($value)
|
341 |
-
{
|
342 |
-
if (is_array($value)) {
|
343 |
-
$value = array_map(array($this, 'resolveServices'), $value);
|
344 |
-
} elseif (is_string($value) && 0 === strpos($value, '@=')) {
|
345 |
-
return new Expression(substr($value, 2));
|
346 |
-
} elseif (is_string($value) && 0 === strpos($value, '@')) {
|
347 |
-
if (0 === strpos($value, '@@')) {
|
348 |
-
$value = substr($value, 1);
|
349 |
-
$invalidBehavior = null;
|
350 |
-
} elseif (0 === strpos($value, '@?')) {
|
351 |
-
$value = substr($value, 2);
|
352 |
-
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
353 |
-
} else {
|
354 |
-
$value = substr($value, 1);
|
355 |
-
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
356 |
-
}
|
357 |
-
|
358 |
-
if ('=' === substr($value, -1)) {
|
359 |
-
$value = substr($value, 0, -1);
|
360 |
-
$strict = false;
|
361 |
-
} else {
|
362 |
-
$strict = true;
|
363 |
-
}
|
364 |
-
|
365 |
-
if (null !== $invalidBehavior) {
|
366 |
-
$value = new Reference($value, $invalidBehavior, $strict);
|
367 |
-
}
|
368 |
-
}
|
369 |
-
|
370 |
-
return $value;
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Loads from Extensions.
|
375 |
-
*
|
376 |
-
* @param array $content
|
377 |
-
*/
|
378 |
-
private function loadFromExtensions($content)
|
379 |
-
{
|
380 |
-
foreach ($content as $namespace => $values) {
|
381 |
-
if (in_array($namespace, array('imports', 'parameters', 'services'))) {
|
382 |
-
continue;
|
383 |
-
}
|
384 |
-
|
385 |
-
if (!is_array($values)) {
|
386 |
-
$values = array();
|
387 |
-
}
|
388 |
-
|
389 |
-
$this->container->loadFromExtension($namespace, $values);
|
390 |
-
}
|
391 |
-
}
|
392 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
-
|
3 |
-
<xsd:schema xmlns="http://symfony.com/schema/dic/services"
|
4 |
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
5 |
-
targetNamespace="http://symfony.com/schema/dic/services"
|
6 |
-
elementFormDefault="qualified">
|
7 |
-
|
8 |
-
<xsd:annotation>
|
9 |
-
<xsd:documentation><![CDATA[
|
10 |
-
Symfony XML Services Schema, version 1.0
|
11 |
-
Authors: Fabien Potencier
|
12 |
-
|
13 |
-
This defines a way to describe PHP objects (services) and their
|
14 |
-
dependencies.
|
15 |
-
]]></xsd:documentation>
|
16 |
-
</xsd:annotation>
|
17 |
-
|
18 |
-
<xsd:element name="container" type="container" />
|
19 |
-
|
20 |
-
<xsd:complexType name="container">
|
21 |
-
<xsd:annotation>
|
22 |
-
<xsd:documentation><![CDATA[
|
23 |
-
The root element of a service file.
|
24 |
-
]]></xsd:documentation>
|
25 |
-
</xsd:annotation>
|
26 |
-
<xsd:sequence>
|
27 |
-
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
|
28 |
-
<xsd:element name="imports" type="imports" minOccurs="0" maxOccurs="1" />
|
29 |
-
<xsd:element name="parameters" type="parameters" minOccurs="0" maxOccurs="1" />
|
30 |
-
<xsd:element name="services" type="services" minOccurs="0" maxOccurs="1" />
|
31 |
-
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
|
32 |
-
</xsd:sequence>
|
33 |
-
</xsd:complexType>
|
34 |
-
|
35 |
-
<xsd:complexType name="services">
|
36 |
-
<xsd:annotation>
|
37 |
-
<xsd:documentation><![CDATA[
|
38 |
-
Enclosing element for the definition of all services
|
39 |
-
]]></xsd:documentation>
|
40 |
-
</xsd:annotation>
|
41 |
-
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
42 |
-
<xsd:element name="service" type="service" />
|
43 |
-
</xsd:choice>
|
44 |
-
</xsd:complexType>
|
45 |
-
|
46 |
-
<xsd:complexType name="imports">
|
47 |
-
<xsd:annotation>
|
48 |
-
<xsd:documentation><![CDATA[
|
49 |
-
Enclosing element for the import elements
|
50 |
-
]]></xsd:documentation>
|
51 |
-
</xsd:annotation>
|
52 |
-
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
53 |
-
<xsd:element name="import" type="import" />
|
54 |
-
</xsd:choice>
|
55 |
-
</xsd:complexType>
|
56 |
-
|
57 |
-
<xsd:complexType name="import">
|
58 |
-
<xsd:annotation>
|
59 |
-
<xsd:documentation><![CDATA[
|
60 |
-
Import an external resource defining other services or parameters
|
61 |
-
]]></xsd:documentation>
|
62 |
-
</xsd:annotation>
|
63 |
-
<xsd:attribute name="resource" type="xsd:string" use="required" />
|
64 |
-
<xsd:attribute name="ignore-errors" type="boolean" />
|
65 |
-
</xsd:complexType>
|
66 |
-
|
67 |
-
<xsd:complexType name="configurator">
|
68 |
-
<xsd:attribute name="id" type="xsd:string" />
|
69 |
-
<xsd:attribute name="service" type="xsd:string" />
|
70 |
-
<xsd:attribute name="class" type="xsd:string" />
|
71 |
-
<xsd:attribute name="method" type="xsd:string" />
|
72 |
-
<xsd:attribute name="function" type="xsd:string" />
|
73 |
-
</xsd:complexType>
|
74 |
-
|
75 |
-
<xsd:complexType name="service">
|
76 |
-
<xsd:choice maxOccurs="unbounded">
|
77 |
-
<xsd:element name="file" type="xsd:string" minOccurs="0" maxOccurs="1" />
|
78 |
-
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
79 |
-
<xsd:element name="configurator" type="configurator" minOccurs="0" maxOccurs="1" />
|
80 |
-
<xsd:element name="call" type="call" minOccurs="0" maxOccurs="unbounded" />
|
81 |
-
<xsd:element name="tag" type="tag" minOccurs="0" maxOccurs="unbounded" />
|
82 |
-
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
83 |
-
</xsd:choice>
|
84 |
-
<xsd:attribute name="id" type="xsd:string" />
|
85 |
-
<xsd:attribute name="class" type="xsd:string" />
|
86 |
-
<xsd:attribute name="scope" type="xsd:string" />
|
87 |
-
<xsd:attribute name="public" type="boolean" />
|
88 |
-
<xsd:attribute name="synthetic" type="boolean" />
|
89 |
-
<xsd:attribute name="synchronized" type="boolean" />
|
90 |
-
<xsd:attribute name="lazy" type="boolean" />
|
91 |
-
<xsd:attribute name="abstract" type="boolean" />
|
92 |
-
<xsd:attribute name="factory-class" type="xsd:string" />
|
93 |
-
<xsd:attribute name="factory-method" type="xsd:string" />
|
94 |
-
<xsd:attribute name="factory-service" type="xsd:string" />
|
95 |
-
<xsd:attribute name="alias" type="xsd:string" />
|
96 |
-
<xsd:attribute name="parent" type="xsd:string" />
|
97 |
-
<xsd:attribute name="decorates" type="xsd:string" />
|
98 |
-
<xsd:attribute name="decoration-inner-name" type="xsd:string" />
|
99 |
-
</xsd:complexType>
|
100 |
-
|
101 |
-
<xsd:complexType name="tag">
|
102 |
-
<xsd:attribute name="name" type="xsd:string" />
|
103 |
-
<xsd:anyAttribute namespace="##any" processContents="lax" />
|
104 |
-
</xsd:complexType>
|
105 |
-
|
106 |
-
<xsd:complexType name="parameters">
|
107 |
-
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
108 |
-
<xsd:element name="parameter" type="parameter" />
|
109 |
-
</xsd:choice>
|
110 |
-
<xsd:attribute name="type" type="parameter_type" />
|
111 |
-
<xsd:attribute name="key" type="xsd:string" />
|
112 |
-
</xsd:complexType>
|
113 |
-
|
114 |
-
<xsd:complexType name="parameter" mixed="true">
|
115 |
-
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
116 |
-
<xsd:element name="parameter" type="parameter" />
|
117 |
-
</xsd:choice>
|
118 |
-
<xsd:attribute name="type" type="parameter_type" />
|
119 |
-
<xsd:attribute name="id" type="xsd:string" />
|
120 |
-
<xsd:attribute name="key" type="xsd:string" />
|
121 |
-
<xsd:attribute name="on-invalid" type="invalid_sequence" />
|
122 |
-
</xsd:complexType>
|
123 |
-
|
124 |
-
<xsd:complexType name="property" mixed="true">
|
125 |
-
<xsd:choice minOccurs="0" maxOccurs="1">
|
126 |
-
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
127 |
-
<xsd:element name="service" type="service" />
|
128 |
-
</xsd:choice>
|
129 |
-
<xsd:attribute name="type" type="argument_type" />
|
130 |
-
<xsd:attribute name="id" type="xsd:string" />
|
131 |
-
<xsd:attribute name="key" type="xsd:string" />
|
132 |
-
<xsd:attribute name="name" type="xsd:string" />
|
133 |
-
<xsd:attribute name="on-invalid" type="xsd:string" />
|
134 |
-
<xsd:attribute name="strict" type="boolean" />
|
135 |
-
</xsd:complexType>
|
136 |
-
|
137 |
-
<xsd:complexType name="argument" mixed="true">
|
138 |
-
<xsd:choice maxOccurs="unbounded">
|
139 |
-
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
140 |
-
<xsd:element name="service" type="service" />
|
141 |
-
</xsd:choice>
|
142 |
-
<xsd:attribute name="type" type="argument_type" />
|
143 |
-
<xsd:attribute name="id" type="xsd:string" />
|
144 |
-
<xsd:attribute name="key" type="xsd:string" />
|
145 |
-
<xsd:attribute name="index" type="xsd:integer" />
|
146 |
-
<xsd:attribute name="on-invalid" type="xsd:string" />
|
147 |
-
<xsd:attribute name="strict" type="boolean" />
|
148 |
-
</xsd:complexType>
|
149 |
-
|
150 |
-
<xsd:complexType name="call" mixed="true">
|
151 |
-
<xsd:choice maxOccurs="unbounded">
|
152 |
-
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
153 |
-
<xsd:element name="service" type="service" />
|
154 |
-
</xsd:choice>
|
155 |
-
<xsd:attribute name="method" type="xsd:string" />
|
156 |
-
</xsd:complexType>
|
157 |
-
|
158 |
-
<xsd:simpleType name="parameter_type">
|
159 |
-
<xsd:restriction base="xsd:string">
|
160 |
-
<xsd:enumeration value="collection" />
|
161 |
-
<xsd:enumeration value="string" />
|
162 |
-
<xsd:enumeration value="constant" />
|
163 |
-
</xsd:restriction>
|
164 |
-
</xsd:simpleType>
|
165 |
-
|
166 |
-
<xsd:simpleType name="argument_type">
|
167 |
-
<xsd:restriction base="xsd:string">
|
168 |
-
<xsd:enumeration value="collection" />
|
169 |
-
<xsd:enumeration value="service" />
|
170 |
-
<xsd:enumeration value="expression" />
|
171 |
-
<xsd:enumeration value="string" />
|
172 |
-
<xsd:enumeration value="constant" />
|
173 |
-
</xsd:restriction>
|
174 |
-
</xsd:simpleType>
|
175 |
-
|
176 |
-
<xsd:simpleType name="invalid_sequence">
|
177 |
-
<xsd:restriction base="xsd:string">
|
178 |
-
<xsd:enumeration value="null" />
|
179 |
-
<xsd:enumeration value="ignore" />
|
180 |
-
<xsd:enumeration value="exception" />
|
181 |
-
</xsd:restriction>
|
182 |
-
</xsd:simpleType>
|
183 |
-
|
184 |
-
<xsd:simpleType name="boolean">
|
185 |
-
<xsd:restriction base="xsd:string">
|
186 |
-
<xsd:pattern value="(%.+%|true|false)" />
|
187 |
-
</xsd:restriction>
|
188 |
-
</xsd:simpleType>
|
189 |
-
</xsd:schema>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Parameter.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Parameter represents a parameter reference.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
class Parameter
|
22 |
-
{
|
23 |
-
private $id;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Constructor.
|
27 |
-
*
|
28 |
-
* @param string $id The parameter key
|
29 |
-
*/
|
30 |
-
public function __construct($id)
|
31 |
-
{
|
32 |
-
$this->id = $id;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* __toString.
|
37 |
-
*
|
38 |
-
* @return string The parameter key
|
39 |
-
*/
|
40 |
-
public function __toString()
|
41 |
-
{
|
42 |
-
return (string) $this->id;
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\ParameterBag;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Holds read-only parameters.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
class FrozenParameterBag extends ParameterBag
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Constructor.
|
27 |
-
*
|
28 |
-
* For performance reasons, the constructor assumes that
|
29 |
-
* all keys are already lowercased.
|
30 |
-
*
|
31 |
-
* This is always the case when used internally.
|
32 |
-
*
|
33 |
-
* @param array $parameters An array of parameters
|
34 |
-
*
|
35 |
-
* @api
|
36 |
-
*/
|
37 |
-
public function __construct(array $parameters = array())
|
38 |
-
{
|
39 |
-
$this->parameters = $parameters;
|
40 |
-
$this->resolved = true;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* {@inheritdoc}
|
45 |
-
*
|
46 |
-
* @api
|
47 |
-
*/
|
48 |
-
public function clear()
|
49 |
-
{
|
50 |
-
throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* {@inheritdoc}
|
55 |
-
*
|
56 |
-
* @api
|
57 |
-
*/
|
58 |
-
public function add(array $parameters)
|
59 |
-
{
|
60 |
-
throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* {@inheritdoc}
|
65 |
-
*
|
66 |
-
* @api
|
67 |
-
*/
|
68 |
-
public function set($name, $value)
|
69 |
-
{
|
70 |
-
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
DELETED
@@ -1,304 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\ParameterBag;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
15 |
-
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
|
16 |
-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Holds parameters.
|
20 |
-
*
|
21 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
-
*
|
23 |
-
* @api
|
24 |
-
*/
|
25 |
-
class ParameterBag implements ParameterBagInterface
|
26 |
-
{
|
27 |
-
protected $parameters = array();
|
28 |
-
protected $resolved = false;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor.
|
32 |
-
*
|
33 |
-
* @param array $parameters An array of parameters
|
34 |
-
*
|
35 |
-
* @api
|
36 |
-
*/
|
37 |
-
public function __construct(array $parameters = array())
|
38 |
-
{
|
39 |
-
$this->add($parameters);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Clears all parameters.
|
44 |
-
*
|
45 |
-
* @api
|
46 |
-
*/
|
47 |
-
public function clear()
|
48 |
-
{
|
49 |
-
$this->parameters = array();
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Adds parameters to the service container parameters.
|
54 |
-
*
|
55 |
-
* @param array $parameters An array of parameters
|
56 |
-
*
|
57 |
-
* @api
|
58 |
-
*/
|
59 |
-
public function add(array $parameters)
|
60 |
-
{
|
61 |
-
foreach ($parameters as $key => $value) {
|
62 |
-
$this->parameters[strtolower($key)] = $value;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Gets the service container parameters.
|
68 |
-
*
|
69 |
-
* @return array An array of parameters
|
70 |
-
*
|
71 |
-
* @api
|
72 |
-
*/
|
73 |
-
public function all()
|
74 |
-
{
|
75 |
-
return $this->parameters;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Gets a service container parameter.
|
80 |
-
*
|
81 |
-
* @param string $name The parameter name
|
82 |
-
*
|
83 |
-
* @return mixed The parameter value
|
84 |
-
*
|
85 |
-
* @throws ParameterNotFoundException if the parameter is not defined
|
86 |
-
*
|
87 |
-
* @api
|
88 |
-
*/
|
89 |
-
public function get($name)
|
90 |
-
{
|
91 |
-
$name = strtolower($name);
|
92 |
-
|
93 |
-
if (!array_key_exists($name, $this->parameters)) {
|
94 |
-
if (!$name) {
|
95 |
-
throw new ParameterNotFoundException($name);
|
96 |
-
}
|
97 |
-
|
98 |
-
$alternatives = array();
|
99 |
-
foreach (array_keys($this->parameters) as $key) {
|
100 |
-
$lev = levenshtein($name, $key);
|
101 |
-
if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) {
|
102 |
-
$alternatives[] = $key;
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
throw new ParameterNotFoundException($name, null, null, null, $alternatives);
|
107 |
-
}
|
108 |
-
|
109 |
-
return $this->parameters[$name];
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Sets a service container parameter.
|
114 |
-
*
|
115 |
-
* @param string $name The parameter name
|
116 |
-
* @param mixed $value The parameter value
|
117 |
-
*
|
118 |
-
* @api
|
119 |
-
*/
|
120 |
-
public function set($name, $value)
|
121 |
-
{
|
122 |
-
$this->parameters[strtolower($name)] = $value;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Returns true if a parameter name is defined.
|
127 |
-
*
|
128 |
-
* @param string $name The parameter name
|
129 |
-
*
|
130 |
-
* @return bool true if the parameter name is defined, false otherwise
|
131 |
-
*
|
132 |
-
* @api
|
133 |
-
*/
|
134 |
-
public function has($name)
|
135 |
-
{
|
136 |
-
return array_key_exists(strtolower($name), $this->parameters);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Removes a parameter.
|
141 |
-
*
|
142 |
-
* @param string $name The parameter name
|
143 |
-
*
|
144 |
-
* @api
|
145 |
-
*/
|
146 |
-
public function remove($name)
|
147 |
-
{
|
148 |
-
unset($this->parameters[strtolower($name)]);
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Replaces parameter placeholders (%name%) by their values for all parameters.
|
153 |
-
*/
|
154 |
-
public function resolve()
|
155 |
-
{
|
156 |
-
if ($this->resolved) {
|
157 |
-
return;
|
158 |
-
}
|
159 |
-
|
160 |
-
$parameters = array();
|
161 |
-
foreach ($this->parameters as $key => $value) {
|
162 |
-
try {
|
163 |
-
$value = $this->resolveValue($value);
|
164 |
-
$parameters[$key] = $this->unescapeValue($value);
|
165 |
-
} catch (ParameterNotFoundException $e) {
|
166 |
-
$e->setSourceKey($key);
|
167 |
-
|
168 |
-
throw $e;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
$this->parameters = $parameters;
|
173 |
-
$this->resolved = true;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Replaces parameter placeholders (%name%) by their values.
|
178 |
-
*
|
179 |
-
* @param mixed $value A value
|
180 |
-
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
|
181 |
-
*
|
182 |
-
* @return mixed The resolved value
|
183 |
-
*
|
184 |
-
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
|
185 |
-
* @throws ParameterCircularReferenceException if a circular reference if detected
|
186 |
-
* @throws RuntimeException when a given parameter has a type problem.
|
187 |
-
*/
|
188 |
-
public function resolveValue($value, array $resolving = array())
|
189 |
-
{
|
190 |
-
if (is_array($value)) {
|
191 |
-
$args = array();
|
192 |
-
foreach ($value as $k => $v) {
|
193 |
-
$args[$this->resolveValue($k, $resolving)] = $this->resolveValue($v, $resolving);
|
194 |
-
}
|
195 |
-
|
196 |
-
return $args;
|
197 |
-
}
|
198 |
-
|
199 |
-
if (!is_string($value)) {
|
200 |
-
return $value;
|
201 |
-
}
|
202 |
-
|
203 |
-
return $this->resolveString($value, $resolving);
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Resolves parameters inside a string.
|
208 |
-
*
|
209 |
-
* @param string $value The string to resolve
|
210 |
-
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
|
211 |
-
*
|
212 |
-
* @return string The resolved string
|
213 |
-
*
|
214 |
-
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
|
215 |
-
* @throws ParameterCircularReferenceException if a circular reference if detected
|
216 |
-
* @throws RuntimeException when a given parameter has a type problem.
|
217 |
-
*/
|
218 |
-
public function resolveString($value, array $resolving = array())
|
219 |
-
{
|
220 |
-
// we do this to deal with non string values (Boolean, integer, ...)
|
221 |
-
// as the preg_replace_callback throw an exception when trying
|
222 |
-
// a non-string in a parameter value
|
223 |
-
if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
|
224 |
-
$key = strtolower($match[1]);
|
225 |
-
|
226 |
-
if (isset($resolving[$key])) {
|
227 |
-
throw new ParameterCircularReferenceException(array_keys($resolving));
|
228 |
-
}
|
229 |
-
|
230 |
-
$resolving[$key] = true;
|
231 |
-
|
232 |
-
return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
|
233 |
-
}
|
234 |
-
|
235 |
-
$self = $this;
|
236 |
-
|
237 |
-
return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($self, $resolving, $value) {
|
238 |
-
// skip %%
|
239 |
-
if (!isset($match[1])) {
|
240 |
-
return '%%';
|
241 |
-
}
|
242 |
-
|
243 |
-
$key = strtolower($match[1]);
|
244 |
-
if (isset($resolving[$key])) {
|
245 |
-
throw new ParameterCircularReferenceException(array_keys($resolving));
|
246 |
-
}
|
247 |
-
|
248 |
-
$resolved = $self->get($key);
|
249 |
-
|
250 |
-
if (!is_string($resolved) && !is_numeric($resolved)) {
|
251 |
-
throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value));
|
252 |
-
}
|
253 |
-
|
254 |
-
$resolved = (string) $resolved;
|
255 |
-
$resolving[$key] = true;
|
256 |
-
|
257 |
-
return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving);
|
258 |
-
}, $value);
|
259 |
-
}
|
260 |
-
|
261 |
-
public function isResolved()
|
262 |
-
{
|
263 |
-
return $this->resolved;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* {@inheritdoc}
|
268 |
-
*/
|
269 |
-
public function escapeValue($value)
|
270 |
-
{
|
271 |
-
if (is_string($value)) {
|
272 |
-
return str_replace('%', '%%', $value);
|
273 |
-
}
|
274 |
-
|
275 |
-
if (is_array($value)) {
|
276 |
-
$result = array();
|
277 |
-
foreach ($value as $k => $v) {
|
278 |
-
$result[$k] = $this->escapeValue($v);
|
279 |
-
}
|
280 |
-
|
281 |
-
return $result;
|
282 |
-
}
|
283 |
-
|
284 |
-
return $value;
|
285 |
-
}
|
286 |
-
|
287 |
-
public function unescapeValue($value)
|
288 |
-
{
|
289 |
-
if (is_string($value)) {
|
290 |
-
return str_replace('%%', '%', $value);
|
291 |
-
}
|
292 |
-
|
293 |
-
if (is_array($value)) {
|
294 |
-
$result = array();
|
295 |
-
foreach ($value as $k => $v) {
|
296 |
-
$result[$k] = $this->unescapeValue($v);
|
297 |
-
}
|
298 |
-
|
299 |
-
return $result;
|
300 |
-
}
|
301 |
-
|
302 |
-
return $value;
|
303 |
-
}
|
304 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection\ParameterBag;
|
13 |
-
|
14 |
-
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* ParameterBagInterface.
|
18 |
-
*
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
interface ParameterBagInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Clears all parameters.
|
27 |
-
*
|
28 |
-
* @api
|
29 |
-
*/
|
30 |
-
public function clear();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Adds parameters to the service container parameters.
|
34 |
-
*
|
35 |
-
* @param array $parameters An array of parameters
|
36 |
-
*
|
37 |
-
* @api
|
38 |
-
*/
|
39 |
-
public function add(array $parameters);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Gets the service container parameters.
|
43 |
-
*
|
44 |
-
* @return array An array of parameters
|
45 |
-
*
|
46 |
-
* @api
|
47 |
-
*/
|
48 |
-
public function all();
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Gets a service container parameter.
|
52 |
-
*
|
53 |
-
* @param string $name The parameter name
|
54 |
-
*
|
55 |
-
* @return mixed The parameter value
|
56 |
-
*
|
57 |
-
* @throws ParameterNotFoundException if the parameter is not defined
|
58 |
-
*
|
59 |
-
* @api
|
60 |
-
*/
|
61 |
-
public function get($name);
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Sets a service container parameter.
|
65 |
-
*
|
66 |
-
* @param string $name The parameter name
|
67 |
-
* @param mixed $value The parameter value
|
68 |
-
*
|
69 |
-
* @api
|
70 |
-
*/
|
71 |
-
public function set($name, $value);
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Returns true if a parameter name is defined.
|
75 |
-
*
|
76 |
-
* @param string $name The parameter name
|
77 |
-
*
|
78 |
-
* @return bool true if the parameter name is defined, false otherwise
|
79 |
-
*
|
80 |
-
* @api
|
81 |
-
*/
|
82 |
-
public function has($name);
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Replaces parameter placeholders (%name%) by their values for all parameters.
|
86 |
-
*/
|
87 |
-
public function resolve();
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Replaces parameter placeholders (%name%) by their values.
|
91 |
-
*
|
92 |
-
* @param mixed $value A value
|
93 |
-
*
|
94 |
-
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
|
95 |
-
*/
|
96 |
-
public function resolveValue($value);
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Escape parameter placeholders %.
|
100 |
-
*
|
101 |
-
* @param mixed $value
|
102 |
-
*
|
103 |
-
* @return mixed
|
104 |
-
*/
|
105 |
-
public function escapeValue($value);
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Unescape parameter placeholders %.
|
109 |
-
*
|
110 |
-
* @param mixed $value
|
111 |
-
*
|
112 |
-
* @return mixed
|
113 |
-
*/
|
114 |
-
public function unescapeValue($value);
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/README.md
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
DependencyInjection Component
|
2 |
-
=============================
|
3 |
-
|
4 |
-
DependencyInjection manages your services via a robust and flexible Dependency
|
5 |
-
Injection Container.
|
6 |
-
|
7 |
-
Here is a simple example that shows how to register services and parameters:
|
8 |
-
|
9 |
-
```php
|
10 |
-
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
11 |
-
use Symfony\Component\DependencyInjection\Reference;
|
12 |
-
|
13 |
-
$sc = new ContainerBuilder();
|
14 |
-
$sc
|
15 |
-
->register('foo', '%foo.class%')
|
16 |
-
->addArgument(new Reference('bar'))
|
17 |
-
;
|
18 |
-
$sc->setParameter('foo.class', 'Foo');
|
19 |
-
|
20 |
-
$sc->get('foo');
|
21 |
-
```
|
22 |
-
|
23 |
-
Method Calls (Setter Injection):
|
24 |
-
|
25 |
-
```php
|
26 |
-
$sc = new ContainerBuilder();
|
27 |
-
|
28 |
-
$sc
|
29 |
-
->register('bar', '%bar.class%')
|
30 |
-
->addMethodCall('setFoo', array(new Reference('foo')))
|
31 |
-
;
|
32 |
-
$sc->setParameter('bar.class', 'Bar');
|
33 |
-
|
34 |
-
$sc->get('bar');
|
35 |
-
```
|
36 |
-
|
37 |
-
Factory Class:
|
38 |
-
|
39 |
-
If your service is retrieved by calling a static method:
|
40 |
-
|
41 |
-
```php
|
42 |
-
$sc = new ContainerBuilder();
|
43 |
-
|
44 |
-
$sc
|
45 |
-
->register('bar', '%bar.class%')
|
46 |
-
->setFactoryClass('%bar.class%')
|
47 |
-
->setFactoryMethod('getInstance')
|
48 |
-
->addArgument('Aarrg!!!')
|
49 |
-
;
|
50 |
-
$sc->setParameter('bar.class', 'Bar');
|
51 |
-
|
52 |
-
$sc->get('bar');
|
53 |
-
```
|
54 |
-
|
55 |
-
File Include:
|
56 |
-
|
57 |
-
For some services, especially those that are difficult or impossible to
|
58 |
-
autoload, you may need the container to include a file before
|
59 |
-
instantiating your class.
|
60 |
-
|
61 |
-
```php
|
62 |
-
$sc = new ContainerBuilder();
|
63 |
-
|
64 |
-
$sc
|
65 |
-
->register('bar', '%bar.class%')
|
66 |
-
->setFile('/path/to/file')
|
67 |
-
->addArgument('Aarrg!!!')
|
68 |
-
;
|
69 |
-
$sc->setParameter('bar.class', 'Bar');
|
70 |
-
|
71 |
-
$sc->get('bar');
|
72 |
-
```
|
73 |
-
|
74 |
-
Resources
|
75 |
-
---------
|
76 |
-
|
77 |
-
You can run the unit tests with the following command:
|
78 |
-
|
79 |
-
$ cd path/to/Symfony/Component/DependencyInjection/
|
80 |
-
$ composer.phar install
|
81 |
-
$ phpunit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Reference.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Reference represents a service reference.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
class Reference
|
22 |
-
{
|
23 |
-
private $id;
|
24 |
-
private $invalidBehavior;
|
25 |
-
private $strict;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Constructor.
|
29 |
-
*
|
30 |
-
* @param string $id The service identifier
|
31 |
-
* @param int $invalidBehavior The behavior when the service does not exist
|
32 |
-
* @param bool $strict Sets how this reference is validated
|
33 |
-
*
|
34 |
-
* @see Container
|
35 |
-
*/
|
36 |
-
public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $strict = true)
|
37 |
-
{
|
38 |
-
$this->id = strtolower($id);
|
39 |
-
$this->invalidBehavior = $invalidBehavior;
|
40 |
-
$this->strict = $strict;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* __toString.
|
45 |
-
*
|
46 |
-
* @return string The service identifier
|
47 |
-
*/
|
48 |
-
public function __toString()
|
49 |
-
{
|
50 |
-
return $this->id;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Returns the behavior to be used when the service does not exist.
|
55 |
-
*
|
56 |
-
* @return int
|
57 |
-
*/
|
58 |
-
public function getInvalidBehavior()
|
59 |
-
{
|
60 |
-
return $this->invalidBehavior;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Returns true when this Reference is strict.
|
65 |
-
*
|
66 |
-
* @return bool
|
67 |
-
*/
|
68 |
-
public function isStrict()
|
69 |
-
{
|
70 |
-
return $this->strict;
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Scope.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Scope class.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
class Scope implements ScopeInterface
|
22 |
-
{
|
23 |
-
private $name;
|
24 |
-
private $parentName;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @api
|
28 |
-
*/
|
29 |
-
public function __construct($name, $parentName = ContainerInterface::SCOPE_CONTAINER)
|
30 |
-
{
|
31 |
-
$this->name = $name;
|
32 |
-
$this->parentName = $parentName;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @api
|
37 |
-
*/
|
38 |
-
public function getName()
|
39 |
-
{
|
40 |
-
return $this->name;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @api
|
45 |
-
*/
|
46 |
-
public function getParentName()
|
47 |
-
{
|
48 |
-
return $this->parentName;
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/ScopeInterface.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Scope Interface.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
interface ScopeInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* @api
|
25 |
-
*/
|
26 |
-
public function getName();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @api
|
30 |
-
*/
|
31 |
-
public function getParentName();
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/SimpleXMLElement.php
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
use Symfony\Component\Config\Util\XmlUtils;
|
15 |
-
use Symfony\Component\ExpressionLanguage\Expression;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* SimpleXMLElement class.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*
|
22 |
-
* @deprecated Deprecated since version 2.5, to be removed in 3.0.
|
23 |
-
*/
|
24 |
-
class SimpleXMLElement extends \SimpleXMLElement
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Converts an attribute as a PHP type.
|
28 |
-
*
|
29 |
-
* @param string $name
|
30 |
-
*
|
31 |
-
* @return mixed
|
32 |
-
*/
|
33 |
-
public function getAttributeAsPhp($name)
|
34 |
-
{
|
35 |
-
return self::phpize($this[$name]);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Returns arguments as valid PHP types.
|
40 |
-
*
|
41 |
-
* @param string $name
|
42 |
-
* @param bool $lowercase
|
43 |
-
*
|
44 |
-
* @return mixed
|
45 |
-
*/
|
46 |
-
public function getArgumentsAsPhp($name, $lowercase = true)
|
47 |
-
{
|
48 |
-
$arguments = array();
|
49 |
-
foreach ($this->$name as $arg) {
|
50 |
-
if (isset($arg['name'])) {
|
51 |
-
$arg['key'] = (string) $arg['name'];
|
52 |
-
}
|
53 |
-
$key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
|
54 |
-
|
55 |
-
// parameter keys are case insensitive
|
56 |
-
if ('parameter' == $name && $lowercase) {
|
57 |
-
$key = strtolower($key);
|
58 |
-
}
|
59 |
-
|
60 |
-
// this is used by DefinitionDecorator to overwrite a specific
|
61 |
-
// argument of the parent definition
|
62 |
-
if (isset($arg['index'])) {
|
63 |
-
$key = 'index_'.$arg['index'];
|
64 |
-
}
|
65 |
-
|
66 |
-
switch ($arg['type']) {
|
67 |
-
case 'service':
|
68 |
-
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
69 |
-
if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
|
70 |
-
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
71 |
-
} elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
|
72 |
-
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
|
73 |
-
}
|
74 |
-
|
75 |
-
if (isset($arg['strict'])) {
|
76 |
-
$strict = self::phpize($arg['strict']);
|
77 |
-
} else {
|
78 |
-
$strict = true;
|
79 |
-
}
|
80 |
-
|
81 |
-
$arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
|
82 |
-
break;
|
83 |
-
case 'expression':
|
84 |
-
$arguments[$key] = new Expression((string) $arg);
|
85 |
-
break;
|
86 |
-
case 'collection':
|
87 |
-
$arguments[$key] = $arg->getArgumentsAsPhp($name, false);
|
88 |
-
break;
|
89 |
-
case 'string':
|
90 |
-
$arguments[$key] = (string) $arg;
|
91 |
-
break;
|
92 |
-
case 'constant':
|
93 |
-
$arguments[$key] = constant((string) $arg);
|
94 |
-
break;
|
95 |
-
default:
|
96 |
-
$arguments[$key] = self::phpize($arg);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
return $arguments;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Converts an xml value to a PHP type.
|
105 |
-
*
|
106 |
-
* @param mixed $value
|
107 |
-
*
|
108 |
-
* @return mixed
|
109 |
-
*/
|
110 |
-
public static function phpize($value)
|
111 |
-
{
|
112 |
-
return XmlUtils::phpize($value);
|
113 |
-
}
|
114 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/TaggedContainerInterface.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* TaggedContainerInterface is the interface implemented when a container knows how to deals with tags.
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
interface TaggedContainerInterface extends ContainerInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Returns service ids for a given tag.
|
25 |
-
*
|
26 |
-
* @param string $name The tag name
|
27 |
-
*
|
28 |
-
* @return array An array of tags
|
29 |
-
*
|
30 |
-
* @api
|
31 |
-
*/
|
32 |
-
public function findTaggedServiceIds($name);
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/Variable.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\DependencyInjection;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Represents a variable.
|
16 |
-
*
|
17 |
-
* $var = new Variable('a');
|
18 |
-
*
|
19 |
-
* will be dumped as
|
20 |
-
*
|
21 |
-
* $a
|
22 |
-
*
|
23 |
-
* by the PHP dumper.
|
24 |
-
*
|
25 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
26 |
-
*/
|
27 |
-
class Variable
|
28 |
-
{
|
29 |
-
private $name;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Constructor.
|
33 |
-
*
|
34 |
-
* @param string $name
|
35 |
-
*/
|
36 |
-
public function __construct($name)
|
37 |
-
{
|
38 |
-
$this->name = $name;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Converts the object to a string.
|
43 |
-
*
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function __toString()
|
47 |
-
{
|
48 |
-
return $this->name;
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/composer.json
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "symfony/dependency-injection",
|
3 |
-
"type": "library",
|
4 |
-
"description": "Symfony DependencyInjection Component",
|
5 |
-
"keywords": [],
|
6 |
-
"homepage": "http://symfony.com",
|
7 |
-
"license": "MIT",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Fabien Potencier",
|
11 |
-
"email": "fabien@symfony.com"
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"name": "Symfony Community",
|
15 |
-
"homepage": "http://symfony.com/contributors"
|
16 |
-
}
|
17 |
-
],
|
18 |
-
"require": {
|
19 |
-
"php": ">=5.3.3"
|
20 |
-
},
|
21 |
-
"require-dev": {
|
22 |
-
"symfony/yaml": "~2.1",
|
23 |
-
"symfony/config": "~2.2",
|
24 |
-
"symfony/expression-language": "~2.4,>=2.4.10"
|
25 |
-
},
|
26 |
-
"suggest": {
|
27 |
-
"symfony/yaml": "",
|
28 |
-
"symfony/config": "",
|
29 |
-
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them"
|
30 |
-
},
|
31 |
-
"autoload": {
|
32 |
-
"psr-0": { "Symfony\\Component\\DependencyInjection\\": "" }
|
33 |
-
},
|
34 |
-
"target-dir": "Symfony/Component/DependencyInjection",
|
35 |
-
"minimum-stability": "dev",
|
36 |
-
"extra": {
|
37 |
-
"branch-alias": {
|
38 |
-
"dev-master": "2.5-dev"
|
39 |
-
}
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/DependencyInjection/phpunit.xml.dist
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4 |
-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
5 |
-
backupGlobals="false"
|
6 |
-
colors="true"
|
7 |
-
bootstrap="vendor/autoload.php"
|
8 |
-
>
|
9 |
-
<php>
|
10 |
-
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
|
11 |
-
<ini name="error_reporting" value="-16385"/>
|
12 |
-
</php>
|
13 |
-
<testsuites>
|
14 |
-
<testsuite name="Symfony DependencyInjection Component Test Suite">
|
15 |
-
<directory>./Tests/</directory>
|
16 |
-
</testsuite>
|
17 |
-
</testsuites>
|
18 |
-
|
19 |
-
<filter>
|
20 |
-
<whitelist>
|
21 |
-
<directory>./</directory>
|
22 |
-
<exclude>
|
23 |
-
<directory>./Resources</directory>
|
24 |
-
<directory>./Tests</directory>
|
25 |
-
<directory>./vendor</directory>
|
26 |
-
</exclude>
|
27 |
-
</whitelist>
|
28 |
-
</filter>
|
29 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/CHANGELOG.md
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
CHANGELOG
|
2 |
-
=========
|
3 |
-
|
4 |
-
2.3.12
|
5 |
-
------
|
6 |
-
|
7 |
-
* deprecated dumpFile() file mode argument.
|
8 |
-
|
9 |
-
2.3.0
|
10 |
-
-----
|
11 |
-
|
12 |
-
* added the dumpFile() method to atomically write files
|
13 |
-
|
14 |
-
2.2.0
|
15 |
-
-----
|
16 |
-
|
17 |
-
* added a delete option for the mirror() method
|
18 |
-
|
19 |
-
2.1.0
|
20 |
-
-----
|
21 |
-
|
22 |
-
* 24eb396 : BC Break : mkdir() function now throws exception in case of failure instead of returning Boolean value
|
23 |
-
* created the component
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/Exception/ExceptionInterface.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Filesystem\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception interface for all exceptions thrown by the component.
|
16 |
-
*
|
17 |
-
* @author Romain Neutron <imprec@gmail.com>
|
18 |
-
*
|
19 |
-
* @api
|
20 |
-
*/
|
21 |
-
interface ExceptionInterface
|
22 |
-
{
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/Exception/FileNotFoundException.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Filesystem\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception class thrown when a file couldn't be found
|
16 |
-
*
|
17 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
-
* @author Christian Gärtner <christiangaertner.film@googlemail.com>
|
19 |
-
*/
|
20 |
-
class FileNotFoundException extends IOException
|
21 |
-
{
|
22 |
-
public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
|
23 |
-
{
|
24 |
-
if (null === $message) {
|
25 |
-
if (null === $path) {
|
26 |
-
$message = 'File could not be found.';
|
27 |
-
} else {
|
28 |
-
$message = sprintf('File "%s" could not be found.', $path);
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
parent::__construct($message, $code, $previous, $path);
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/Exception/IOException.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Filesystem\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception class thrown when a filesystem operation failure happens.
|
16 |
-
*
|
17 |
-
* @author Romain Neutron <imprec@gmail.com>
|
18 |
-
* @author Christian Gärtner <christiangaertner.film@googlemail.com>
|
19 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
-
*
|
21 |
-
* @api
|
22 |
-
*/
|
23 |
-
class IOException extends \RuntimeException implements IOExceptionInterface
|
24 |
-
{
|
25 |
-
private $path;
|
26 |
-
|
27 |
-
public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
|
28 |
-
{
|
29 |
-
$this->path = $path;
|
30 |
-
|
31 |
-
parent::__construct($message, $code, $previous);
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
-
public function getPath()
|
38 |
-
{
|
39 |
-
return $this->path;
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Filesystem\Exception;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* IOException interface for file and input/output stream related exceptions thrown by the component.
|
16 |
-
*
|
17 |
-
* @author Christian Gärtner <christiangaertner.film@googlemail.com>
|
18 |
-
*/
|
19 |
-
interface IOExceptionInterface extends ExceptionInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Returns the associated path for the exception
|
23 |
-
*
|
24 |
-
* @return string The path.
|
25 |
-
*/
|
26 |
-
public function getPath();
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/Filesystem.php
DELETED
@@ -1,490 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Filesystem;
|
13 |
-
|
14 |
-
use Symfony\Component\Filesystem\Exception\IOException;
|
15 |
-
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Provides basic utility to manipulate the file system.
|
19 |
-
*
|
20 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
-
*/
|
22 |
-
class Filesystem
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Copies a file.
|
26 |
-
*
|
27 |
-
* This method only copies the file if the origin file is newer than the target file.
|
28 |
-
*
|
29 |
-
* By default, if the target already exists, it is not overridden.
|
30 |
-
*
|
31 |
-
* @param string $originFile The original filename
|
32 |
-
* @param string $targetFile The target filename
|
33 |
-
* @param bool $override Whether to override an existing file or not
|
34 |
-
*
|
35 |
-
* @throws FileNotFoundException When originFile doesn't exist
|
36 |
-
* @throws IOException When copy fails
|
37 |
-
*/
|
38 |
-
public function copy($originFile, $targetFile, $override = false)
|
39 |
-
{
|
40 |
-
if (stream_is_local($originFile) && !is_file($originFile)) {
|
41 |
-
throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
|
42 |
-
}
|
43 |
-
|
44 |
-
$this->mkdir(dirname($targetFile));
|
45 |
-
|
46 |
-
if (!$override && is_file($targetFile) && null === parse_url($originFile, PHP_URL_HOST)) {
|
47 |
-
$doCopy = filemtime($originFile) > filemtime($targetFile);
|
48 |
-
} else {
|
49 |
-
$doCopy = true;
|
50 |
-
}
|
51 |
-
|
52 |
-
if ($doCopy) {
|
53 |
-
// https://bugs.php.net/bug.php?id=64634
|
54 |
-
$source = fopen($originFile, 'r');
|
55 |
-
// Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
|
56 |
-
$target = fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))));
|
57 |
-
stream_copy_to_stream($source, $target);
|
58 |
-
fclose($source);
|
59 |
-
fclose($target);
|
60 |
-
unset($source, $target);
|
61 |
-
|
62 |
-
if (!is_file($targetFile)) {
|
63 |
-
throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Creates a directory recursively.
|
70 |
-
*
|
71 |
-
* @param string|array|\Traversable $dirs The directory path
|
72 |
-
* @param int $mode The directory mode
|
73 |
-
*
|
74 |
-
* @throws IOException On any directory creation failure
|
75 |
-
*/
|
76 |
-
public function mkdir($dirs, $mode = 0777)
|
77 |
-
{
|
78 |
-
foreach ($this->toIterator($dirs) as $dir) {
|
79 |
-
if (is_dir($dir)) {
|
80 |
-
continue;
|
81 |
-
}
|
82 |
-
|
83 |
-
if (true !== @mkdir($dir, $mode, true)) {
|
84 |
-
$error = error_get_last();
|
85 |
-
if (!is_dir($dir)) {
|
86 |
-
// The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one
|
87 |
-
if ($error) {
|
88 |
-
throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message']), 0, null, $dir);
|
89 |
-
}
|
90 |
-
throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
|
91 |
-
}
|
92 |
-
}
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Checks the existence of files or directories.
|
98 |
-
*
|
99 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to check
|
100 |
-
*
|
101 |
-
* @return bool true if the file exists, false otherwise
|
102 |
-
*/
|
103 |
-
public function exists($files)
|
104 |
-
{
|
105 |
-
foreach ($this->toIterator($files) as $file) {
|
106 |
-
if (!file_exists($file)) {
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
return true;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Sets access and modification time of file.
|
116 |
-
*
|
117 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to create
|
118 |
-
* @param int $time The touch time as a Unix timestamp
|
119 |
-
* @param int $atime The access time as a Unix timestamp
|
120 |
-
*
|
121 |
-
* @throws IOException When touch fails
|
122 |
-
*/
|
123 |
-
public function touch($files, $time = null, $atime = null)
|
124 |
-
{
|
125 |
-
foreach ($this->toIterator($files) as $file) {
|
126 |
-
$touch = $time ? @touch($file, $time, $atime) : @touch($file);
|
127 |
-
if (true !== $touch) {
|
128 |
-
throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Removes files or directories.
|
135 |
-
*
|
136 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove
|
137 |
-
*
|
138 |
-
* @throws IOException When removal fails
|
139 |
-
*/
|
140 |
-
public function remove($files)
|
141 |
-
{
|
142 |
-
$files = iterator_to_array($this->toIterator($files));
|
143 |
-
$files = array_reverse($files);
|
144 |
-
foreach ($files as $file) {
|
145 |
-
if (!file_exists($file) && !is_link($file)) {
|
146 |
-
continue;
|
147 |
-
}
|
148 |
-
|
149 |
-
if (is_dir($file) && !is_link($file)) {
|
150 |
-
$this->remove(new \FilesystemIterator($file));
|
151 |
-
|
152 |
-
if (true !== @rmdir($file)) {
|
153 |
-
throw new IOException(sprintf('Failed to remove directory "%s".', $file), 0, null, $file);
|
154 |
-
}
|
155 |
-
} else {
|
156 |
-
// https://bugs.php.net/bug.php?id=52176
|
157 |
-
if ('\\' === DIRECTORY_SEPARATOR && is_dir($file)) {
|
158 |
-
if (true !== @rmdir($file)) {
|
159 |
-
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
|
160 |
-
}
|
161 |
-
} else {
|
162 |
-
if (true !== @unlink($file)) {
|
163 |
-
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Change mode for an array of files or directories.
|
172 |
-
*
|
173 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change mode
|
174 |
-
* @param int $mode The new mode (octal)
|
175 |
-
* @param int $umask The mode mask (octal)
|
176 |
-
* @param bool $recursive Whether change the mod recursively or not
|
177 |
-
*
|
178 |
-
* @throws IOException When the change fail
|
179 |
-
*/
|
180 |
-
public function chmod($files, $mode, $umask = 0000, $recursive = false)
|
181 |
-
{
|
182 |
-
foreach ($this->toIterator($files) as $file) {
|
183 |
-
if ($recursive && is_dir($file) && !is_link($file)) {
|
184 |
-
$this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
|
185 |
-
}
|
186 |
-
if (true !== @chmod($file, $mode & ~$umask)) {
|
187 |
-
throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
|
188 |
-
}
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Change the owner of an array of files or directories.
|
194 |
-
*
|
195 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change owner
|
196 |
-
* @param string $user The new owner user name
|
197 |
-
* @param bool $recursive Whether change the owner recursively or not
|
198 |
-
*
|
199 |
-
* @throws IOException When the change fail
|
200 |
-
*/
|
201 |
-
public function chown($files, $user, $recursive = false)
|
202 |
-
{
|
203 |
-
foreach ($this->toIterator($files) as $file) {
|
204 |
-
if ($recursive && is_dir($file) && !is_link($file)) {
|
205 |
-
$this->chown(new \FilesystemIterator($file), $user, true);
|
206 |
-
}
|
207 |
-
if (is_link($file) && function_exists('lchown')) {
|
208 |
-
if (true !== @lchown($file, $user)) {
|
209 |
-
throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
|
210 |
-
}
|
211 |
-
} else {
|
212 |
-
if (true !== @chown($file, $user)) {
|
213 |
-
throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Change the group of an array of files or directories.
|
221 |
-
*
|
222 |
-
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change group
|
223 |
-
* @param string $group The group name
|
224 |
-
* @param bool $recursive Whether change the group recursively or not
|
225 |
-
*
|
226 |
-
* @throws IOException When the change fail
|
227 |
-
*/
|
228 |
-
public function chgrp($files, $group, $recursive = false)
|
229 |
-
{
|
230 |
-
foreach ($this->toIterator($files) as $file) {
|
231 |
-
if ($recursive && is_dir($file) && !is_link($file)) {
|
232 |
-
$this->chgrp(new \FilesystemIterator($file), $group, true);
|
233 |
-
}
|
234 |
-
if (is_link($file) && function_exists('lchgrp')) {
|
235 |
-
if (true !== @lchgrp($file, $group)) {
|
236 |
-
throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
|
237 |
-
}
|
238 |
-
} else {
|
239 |
-
if (true !== @chgrp($file, $group)) {
|
240 |
-
throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Renames a file or a directory.
|
248 |
-
*
|
249 |
-
* @param string $origin The origin filename or directory
|
250 |
-
* @param string $target The new filename or directory
|
251 |
-
* @param bool $overwrite Whether to overwrite the target if it already exists
|
252 |
-
*
|
253 |
-
* @throws IOException When target file or directory already exists
|
254 |
-
* @throws IOException When origin cannot be renamed
|
255 |
-
*/
|
256 |
-
public function rename($origin, $target, $overwrite = false)
|
257 |
-
{
|
258 |
-
// we check that target does not exist
|
259 |
-
if (!$overwrite && is_readable($target)) {
|
260 |
-
throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
|
261 |
-
}
|
262 |
-
|
263 |
-
if (true !== @rename($origin, $target)) {
|
264 |
-
throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
|
265 |
-
}
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Creates a symbolic link or copy a directory.
|
270 |
-
*
|
271 |
-
* @param string $originDir The origin directory path
|
272 |
-
* @param string $targetDir The symbolic link name
|
273 |
-
* @param bool $copyOnWindows Whether to copy files if on Windows
|
274 |
-
*
|
275 |
-
* @throws IOException When symlink fails
|
276 |
-
*/
|
277 |
-
public function symlink($originDir, $targetDir, $copyOnWindows = false)
|
278 |
-
{
|
279 |
-
if (!function_exists('symlink') && $copyOnWindows) {
|
280 |
-
$this->mirror($originDir, $targetDir);
|
281 |
-
|
282 |
-
return;
|
283 |
-
}
|
284 |
-
|
285 |
-
$this->mkdir(dirname($targetDir));
|
286 |
-
|
287 |
-
$ok = false;
|
288 |
-
if (is_link($targetDir)) {
|
289 |
-
if (readlink($targetDir) != $originDir) {
|
290 |
-
$this->remove($targetDir);
|
291 |
-
} else {
|
292 |
-
$ok = true;
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
if (!$ok) {
|
297 |
-
if (true !== @symlink($originDir, $targetDir)) {
|
298 |
-
$report = error_get_last();
|
299 |
-
if (is_array($report)) {
|
300 |
-
if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) {
|
301 |
-
throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
|
302 |
-
}
|
303 |
-
}
|
304 |
-
|
305 |
-
throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
/**
|
311 |
-
* Given an existing path, convert it to a path relative to a given starting path.
|
312 |
-
*
|
313 |
-
* @param string $endPath Absolute path of target
|
314 |
-
* @param string $startPath Absolute path where traversal begins
|
315 |
-
*
|
316 |
-
* @return string Path of target relative to starting path
|
317 |
-
*/
|
318 |
-
public function makePathRelative($endPath, $startPath)
|
319 |
-
{
|
320 |
-
// Normalize separators on Windows
|
321 |
-
if ('\\' === DIRECTORY_SEPARATOR) {
|
322 |
-
$endPath = strtr($endPath, '\\', '/');
|
323 |
-
$startPath = strtr($startPath, '\\', '/');
|
324 |
-
}
|
325 |
-
|
326 |
-
// Split the paths into arrays
|
327 |
-
$startPathArr = explode('/', trim($startPath, '/'));
|
328 |
-
$endPathArr = explode('/', trim($endPath, '/'));
|
329 |
-
|
330 |
-
// Find for which directory the common path stops
|
331 |
-
$index = 0;
|
332 |
-
while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
|
333 |
-
$index++;
|
334 |
-
}
|
335 |
-
|
336 |
-
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
337 |
-
$depth = count($startPathArr) - $index;
|
338 |
-
|
339 |
-
// Repeated "../" for each level need to reach the common path
|
340 |
-
$traverser = str_repeat('../', $depth);
|
341 |
-
|
342 |
-
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
|
343 |
-
|
344 |
-
// Construct $endPath from traversing to the common path, then to the remaining $endPath
|
345 |
-
$relativePath = $traverser.(strlen($endPathRemainder) > 0 ? $endPathRemainder.'/' : '');
|
346 |
-
|
347 |
-
return (strlen($relativePath) === 0) ? './' : $relativePath;
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Mirrors a directory to another.
|
352 |
-
*
|
353 |
-
* @param string $originDir The origin directory
|
354 |
-
* @param string $targetDir The target directory
|
355 |
-
* @param \Traversable $iterator A Traversable instance
|
356 |
-
* @param array $options An array of boolean options
|
357 |
-
* Valid options are:
|
358 |
-
* - $options['override'] Whether to override an existing file on copy or not (see copy())
|
359 |
-
* - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink())
|
360 |
-
* - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
|
361 |
-
*
|
362 |
-
* @throws IOException When file type is unknown
|
363 |
-
*/
|
364 |
-
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
|
365 |
-
{
|
366 |
-
$targetDir = rtrim($targetDir, '/\\');
|
367 |
-
$originDir = rtrim($originDir, '/\\');
|
368 |
-
|
369 |
-
// Iterate in destination folder to remove obsolete entries
|
370 |
-
if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
|
371 |
-
$deleteIterator = $iterator;
|
372 |
-
if (null === $deleteIterator) {
|
373 |
-
$flags = \FilesystemIterator::SKIP_DOTS;
|
374 |
-
$deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
|
375 |
-
}
|
376 |
-
foreach ($deleteIterator as $file) {
|
377 |
-
$origin = str_replace($targetDir, $originDir, $file->getPathname());
|
378 |
-
if (!$this->exists($origin)) {
|
379 |
-
$this->remove($file);
|
380 |
-
}
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
$copyOnWindows = false;
|
385 |
-
if (isset($options['copy_on_windows']) && !function_exists('symlink')) {
|
386 |
-
$copyOnWindows = $options['copy_on_windows'];
|
387 |
-
}
|
388 |
-
|
389 |
-
if (null === $iterator) {
|
390 |
-
$flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
391 |
-
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
|
392 |
-
}
|
393 |
-
|
394 |
-
if ($this->exists($originDir)) {
|
395 |
-
$this->mkdir($targetDir);
|
396 |
-
}
|
397 |
-
|
398 |
-
foreach ($iterator as $file) {
|
399 |
-
$target = str_replace($originDir, $targetDir, $file->getPathname());
|
400 |
-
|
401 |
-
if ($copyOnWindows) {
|
402 |
-
if (is_link($file) || is_file($file)) {
|
403 |
-
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
|
404 |
-
} elseif (is_dir($file)) {
|
405 |
-
$this->mkdir($target);
|
406 |
-
} else {
|
407 |
-
throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
|
408 |
-
}
|
409 |
-
} else {
|
410 |
-
if (is_link($file)) {
|
411 |
-
$this->symlink($file->getRealPath(), $target);
|
412 |
-
} elseif (is_dir($file)) {
|
413 |
-
$this->mkdir($target);
|
414 |
-
} elseif (is_file($file)) {
|
415 |
-
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
|
416 |
-
} else {
|
417 |
-
throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
|
418 |
-
}
|
419 |
-
}
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
/**
|
424 |
-
* Returns whether the file path is an absolute path.
|
425 |
-
*
|
426 |
-
* @param string $file A file path
|
427 |
-
*
|
428 |
-
* @return bool
|
429 |
-
*/
|
430 |
-
public function isAbsolutePath($file)
|
431 |
-
{
|
432 |
-
if (strspn($file, '/\\', 0, 1)
|
433 |
-
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
434 |
-
&& substr($file, 1, 1) === ':'
|
435 |
-
&& (strspn($file, '/\\', 2, 1))
|
436 |
-
)
|
437 |
-
|| null !== parse_url($file, PHP_URL_SCHEME)
|
438 |
-
) {
|
439 |
-
return true;
|
440 |
-
}
|
441 |
-
|
442 |
-
return false;
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
* Atomically dumps content into a file.
|
447 |
-
*
|
448 |
-
* @param string $filename The file to be written to.
|
449 |
-
* @param string $content The data to write into the file.
|
450 |
-
* @param null|int $mode The file mode (octal). If null, file permissions are not modified
|
451 |
-
* Deprecated since version 2.3.12, to be removed in 3.0.
|
452 |
-
*
|
453 |
-
* @throws IOException If the file cannot be written to.
|
454 |
-
*/
|
455 |
-
public function dumpFile($filename, $content, $mode = 0666)
|
456 |
-
{
|
457 |
-
$dir = dirname($filename);
|
458 |
-
|
459 |
-
if (!is_dir($dir)) {
|
460 |
-
$this->mkdir($dir);
|
461 |
-
} elseif (!is_writable($dir)) {
|
462 |
-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
|
463 |
-
}
|
464 |
-
|
465 |
-
$tmpFile = tempnam($dir, basename($filename));
|
466 |
-
|
467 |
-
if (false === @file_put_contents($tmpFile, $content)) {
|
468 |
-
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
|
469 |
-
}
|
470 |
-
|
471 |
-
$this->rename($tmpFile, $filename, true);
|
472 |
-
if (null !== $mode) {
|
473 |
-
$this->chmod($filename, $mode);
|
474 |
-
}
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* @param mixed $files
|
479 |
-
*
|
480 |
-
* @return \Traversable
|
481 |
-
*/
|
482 |
-
private function toIterator($files)
|
483 |
-
{
|
484 |
-
if (!$files instanceof \Traversable) {
|
485 |
-
$files = new \ArrayObject(is_array($files) ? $files : array($files));
|
486 |
-
}
|
487 |
-
|
488 |
-
return $files;
|
489 |
-
}
|
490 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2004-2015 Fabien Potencier
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
-
to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in all
|
11 |
-
copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/README.md
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
Filesystem Component
|
2 |
-
====================
|
3 |
-
|
4 |
-
Filesystem provides basic utility to manipulate the file system:
|
5 |
-
|
6 |
-
```php
|
7 |
-
<?php
|
8 |
-
|
9 |
-
use Symfony\Component\Filesystem\Filesystem;
|
10 |
-
|
11 |
-
$filesystem = new Filesystem();
|
12 |
-
|
13 |
-
$filesystem->copy($originFile, $targetFile, $override = false);
|
14 |
-
|
15 |
-
$filesystem->mkdir($dirs, $mode = 0777);
|
16 |
-
|
17 |
-
$filesystem->touch($files, $time = null, $atime = null);
|
18 |
-
|
19 |
-
$filesystem->remove($files);
|
20 |
-
|
21 |
-
$filesystem->exists($files);
|
22 |
-
|
23 |
-
$filesystem->chmod($files, $mode, $umask = 0000, $recursive = false);
|
24 |
-
|
25 |
-
$filesystem->chown($files, $user, $recursive = false);
|
26 |
-
|
27 |
-
$filesystem->chgrp($files, $group, $recursive = false);
|
28 |
-
|
29 |
-
$filesystem->rename($origin, $target);
|
30 |
-
|
31 |
-
$filesystem->symlink($originDir, $targetDir, $copyOnWindows = false);
|
32 |
-
|
33 |
-
$filesystem->makePathRelative($endPath, $startPath);
|
34 |
-
|
35 |
-
$filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array());
|
36 |
-
|
37 |
-
$filesystem->isAbsolutePath($file);
|
38 |
-
```
|
39 |
-
|
40 |
-
Resources
|
41 |
-
---------
|
42 |
-
|
43 |
-
You can run the unit tests with the following command:
|
44 |
-
|
45 |
-
$ cd path/to/Symfony/Component/Filesystem/
|
46 |
-
$ composer.phar install
|
47 |
-
$ phpunit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/composer.json
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "symfony/filesystem",
|
3 |
-
"type": "library",
|
4 |
-
"description": "Symfony Filesystem Component",
|
5 |
-
"keywords": [],
|
6 |
-
"homepage": "http://symfony.com",
|
7 |
-
"license": "MIT",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Fabien Potencier",
|
11 |
-
"email": "fabien@symfony.com"
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"name": "Symfony Community",
|
15 |
-
"homepage": "http://symfony.com/contributors"
|
16 |
-
}
|
17 |
-
],
|
18 |
-
"require": {
|
19 |
-
"php": ">=5.3.3"
|
20 |
-
},
|
21 |
-
"autoload": {
|
22 |
-
"psr-0": { "Symfony\\Component\\Filesystem\\": "" }
|
23 |
-
},
|
24 |
-
"target-dir": "Symfony/Component/Filesystem",
|
25 |
-
"minimum-stability": "dev",
|
26 |
-
"extra": {
|
27 |
-
"branch-alias": {
|
28 |
-
"dev-master": "2.5-dev"
|
29 |
-
}
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Symfony/Component/Filesystem/phpunit.xml.dist
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4 |
-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
5 |
-
backupGlobals="false"
|
6 |
-
colors="true"
|
7 |
-
bootstrap="vendor/autoload.php"
|
8 |
-
>
|
9 |
-
<php>
|
10 |
-
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
|
11 |
-
<ini name="error_reporting" value="-16385"/>
|
12 |
-
</php>
|
13 |
-
<testsuites>
|
14 |
-
<testsuite name="Symfony Filesystem Component Test Suite">
|
15 |
-
<directory>./Tests/</directory>
|
16 |
-
</testsuite>
|
17 |
-
</testsuites>
|
18 |
-
|
19 |
-
<filter>
|
20 |
-
<whitelist>
|
21 |
-
<directory>./</directory>
|
22 |
-
<exclude>
|
23 |
-
<directory>./Tests</directory>
|
24 |
-
</exclude>
|
25 |
-
</whitelist>
|
26 |
-
</filter>
|
27 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<package><name>Bitpay_Core</name><version>2.1.2</version><stability>stable</stability><license uri="https://github.com/bitpay/magento-plugin/blob/master/LICENSE">MIT</license><channel>community</channel><extends/><summary/><description/><notes/><authors><author><name>Integrations Team</name><user>BitPayInc</user><email>support@bitpay.com</email></author></authors><date>2015-01-14</date><time>14:39:06</time><compatible/><dependencies/><required php_min="5.4.0" php_max="6.0.0">php</required><extensions><name>openssl<min/><max/></name><name>mcrypt<min/><max/></name></extensions><contents><target name="mage"><dir name="app"><dir name="locale"><dir name="en_US"><file name="Bitpay_Core.csv" hash="1f6198bdeee3f77f87c36b4e09b45be2"/></dir></dir><dir name="code"><dir name="community"><dir name="Bitpay"><dir name="Core"><dir name="controllers"><file name="IndexController.php" hash="cccb8e613c6ddbc102c3f194d10bc17b"/><file name="IpnController.php" hash="1b24021e7cefc71fa3bd4211155ac1b2"/></dir><dir name="Helper"><file name="Data.php" hash="a3ec244ea664da05b7c4ad84f29c1be8"/></dir><dir name="Block"><file name="Iframe.php" hash="4e30275678e7f53ee474ec4beeaa23c9"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extension.php" hash="ce9dd3c24d090a4f3ecd10f0488eb635"/><file name="Header.php" hash="a1a0f427bfacfda6375acd345696262a"/></dir></dir></dir></dir></dir><file name="Info.php" hash="3c8ca079710e5b8e5d176a0c15383400"/><dir name="Form"><file name="Bitpay.php" hash="c071d4a4f56b2c5cebaad25d21ad0645"/></dir></dir><dir name="Model"><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="b7bb6c723c948626da6a2af91ca6ce1b"/></dir></dir><file name="Observer.php" hash="7aff74761b0df271cb42c38be29316b5"/><file name="Network.php" hash="b9e46a0a056d758d37d50b6e078b7f8a"/><dir name="Method"><file name="Bitcoin.php" hash="090244442578d5eee1949de4e1a28d8e"/></dir><file name="TransactionSpeed.php" hash="7c3f5dd65fdc4838224c14bf050b4d0d"/><dir name="Config"><file name="PairingCode.php" hash="10c5ed0378e7ca8f0a46dd0529898830"/></dir><file name="Invoice.php" hash="39336ff3cb1e4478c13bdf8a4f50b895"/><dir name="Mysql4"><dir name="Ipn"><file name="Collection.php" hash="5731cf9f07a7542a5fb7c357713b1415"/></dir><file name="Invoice.php" hash="09eef9e9eb8fd73a0e0991f0b06ed8f7"/><dir name="Invoice"><file name="Collection.php" hash="9f133b3a850ed81ee2b10afddaa8f192"/></dir><file name="Ipn.php" hash="c4d06de91130340c90e2b823d3221e98"/></dir><file name="Status.php" hash="f54b852c353206667262d11a1ca419a8"/><file name="Ipn.php" hash="10cdfe78efea3eb9e6776b35f48acc9d"/></dir><dir name="etc"><file name="config.xml" hash="5d131d785a389615421b279796ac2aa3"/><file name="system.xml" hash="292e163d31c53b3586f9f319f236ff47"/><file name="adminhtml.xml" hash="a3d6e1c3fb81e271a85260aba4f9f797"/></dir><dir name="sql"><dir name="bitpay_setup"><file name="mysql4-install-2.0.0.php" hash="dbc4ded8c37cf1fdc798fe24f259ae1e"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bitpay.xml" hash="c7e3886904c20f44b58409968c4209f0"/></dir><dir name="template"><dir name="bitpay"><dir name="info"><file name="default.phtml" hash="7e31f22f964ccbbbdcd71504c60e0393"/></dir><dir name="system"><dir name="config"><dir name="field"><file name="header.phtml" hash="971ec034699d110f7842a2c8befb4c55"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bitpay.xml" hash="c7e3886904c20f44b58409968c4209f0"/></dir><dir name="template"><dir name="bitpay"><dir name="form"><file name="bitpay.phtml" hash="c12ef983014d5a73906502d2031108e2"/></dir><dir name="info"><file name="default.phtml" hash="a3bd6e183052b9d9181aaf96accfa42e"/></dir><file name="iframe.phtml" hash="84892655b0e807e905251b8763850bae"/><file name="json.phtml" hash="cc43e25d0445d5ba15b448ba946dabfd"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Bitpay_Core.xml" hash="122aa83102518a01122aaddcafa8ea7f"/></dir></dir></dir><dir name="lib"><dir name="Symfony"><dir name="Component"><dir name="DependencyInjection"><file name="ContainerBuilder.php" hash="81ff255a4f4c85f2ccd1733e6597e0a9"/><file name="SimpleXMLElement.php" hash="41fe9a267150ceee2ac80c11156b863b"/><dir name="Extension"><file name="ExtensionInterface.php" hash="d9f5df364b37addf087305ce17842de9"/><file name="Extension.php" hash="ae958d857ad986bfa7ac7280f93309f4"/><file name="PrependExtensionInterface.php" hash="0eea6361b5960d4ff58646b75864898f"/><file name="ConfigurationExtensionInterface.php" hash="a1cbab69d6a97cd38a1e4e705779f905"/></dir><file name="Alias.php" hash="08d0c245ef3762be097338102e96debf"/><file name="TaggedContainerInterface.php" hash="3c47bde46b89617dcd69f4ebf5056865"/><file name="ScopeInterface.php" hash="b990c20640f9a64135bcf0369f4e22a6"/><file name="phpunit.xml.dist" hash="65fadd262f9e2cc93a3aad45d1f341e1"/><dir name="LazyProxy"><dir name="Instantiator"><file name="InstantiatorInterface.php" hash="2195bb770e5851fa1ebd680906ae112b"/><file name="RealServiceInstantiator.php" hash="f89b9132dd5853375551eb8347e8e51f"/></dir><dir name="PhpDumper"><file name="DumperInterface.php" hash="0ff96280df12f153aee121649615763f"/><file name="NullDumper.php" hash="55c3aaf28d4107dd40fb2905ce91c692"/></dir></dir><file name="ExpressionLanguage.php" hash="3eebc81d79682bdbfe5ce43980d2ab92"/><file name="ContainerInterface.php" hash="8028901dbade81edc95d8e9a1f922478"/><file name="Scope.php" hash="d464293058a891542cef77f9e14e18b4"/><file name="IntrospectableContainerInterface.php" hash="3b4b46eeef76d72b9d356385d6576830"/><file name="Container.php" hash="7f09cfb0a513941003e3de7b16e70c09"/><file name="Parameter.php" hash="7b2faf5e73ce778720b67e94cf6d2bba"/><file name="ContainerAwareTrait.php" hash="304f3c4322c235b332992d829d68e50b"/><file name="Reference.php" hash="e16a543b515f15d9c0b1ef505c50b95c"/><dir name="Exception"><file name="ScopeWideningInjectionException.php" hash="719ca3a89890fcb941cca1b16a0fafef"/><file name="InactiveScopeException.php" hash="9022cb0f19ecaf1198318f0c178c5264"/><file name="BadMethodCallException.php" hash="7881aa76d06f7b9e4bd45dc85ae0d52e"/><file name="ServiceNotFoundException.php" hash="9785d054cb75a079dcecc97fc77a8ebb"/><file name="RuntimeException.php" hash="4e4d9c135fec917ae3fa78f25fbd7f85"/><file name="LogicException.php" hash="5b78b4f59982df23deaf0242aec3d4a9"/><file name="OutOfBoundsException.php" hash="792b235a45e9f4c0c7a7280580b1a2a3"/><file name="ExceptionInterface.php" hash="d79633abb224cffc0597be170aca74ea"/><file name="ServiceCircularReferenceException.php" hash="8ac40af4863b3c6cd9311cc1a29cf802"/><file name="ParameterNotFoundException.php" hash="6d83c2934f82a5ef7992b7081eaeffd7"/><file name="InvalidArgumentException.php" hash="f1b09121e6850f5271d8bd3a6837efd3"/><file name="ParameterCircularReferenceException.php" hash="7b059f59730003361cceadd8965ad7c5"/><file name="ScopeCrossingInjectionException.php" hash="0d73336fcf6534c59887f8b5687d1bd6"/></dir><file name="CHANGELOG.md" hash="0316942313ddf17e8db0729defedc187"/><file name="LICENSE" hash="56dedd4bd25ecd034ac4e1c17ebba0cc"/><file name="Definition.php" hash="b21fa974c7447f00b8444316abe9204f"/><file name="Variable.php" hash="0709a98930af173c2089f972b050ee1b"/><dir name="Compiler"><file name="Compiler.php" hash="14bcd46172f5ac3e022e1d8f4fe1b08c"/><file name="ResolveParameterPlaceHoldersPass.php" hash="f33dfb27625ccb59d575de3fd0e3862f"/><file name="RepeatedPass.php" hash="466e5e4ae231a2231d122823e5d16915"/><file name="ReplaceAliasByActualDefinitionPass.php" hash="0ece3d877daaabc8be38509d97752e2c"/><file name="ServiceReferenceGraphEdge.php" hash="4656ff2d6ccca2540a440d4bdecc2347"/><file name="DecoratorServicePass.php" hash="c42f097de100864a185ef1c021a510f6"/><file name="CheckExceptionOnInvalidReferenceBehaviorPass.php" hash="0a061122dcf50fc4b8da961e04400b9d"/><file name="PassConfig.php" hash="b9d66fce6ec1e4357d0d4e945aa3f93c"/><file name="AnalyzeServiceReferencesPass.php" hash="77d48a44db3ac5428d50ec8ebf228cb3"/><file name="RepeatablePassInterface.php" hash="bee7b2336c610435c89fdc854101b604"/><file name="ResolveInvalidReferencesPass.php" hash="499e4e7357d1e565d334b146f3e05863"/><file name="ServiceReferenceGraph.php" hash="ee56e0a4fcdc016088e61c2d9afbfa80"/><file name="CheckDefinitionValidityPass.php" hash="2b373903ccf9d566a6927aed6c3c6650"/><file name="CompilerPassInterface.php" hash="853eace86233ce23e4d0f8b89736d173"/><file name="CheckReferenceValidityPass.php" hash="2ec0cc8f8f771e30708d83b66405290b"/><file name="RemoveUnusedDefinitionsPass.php" hash="e8e05577d6086ebe2b4251e665919489"/><file name="ServiceReferenceGraphNode.php" hash="730f73ae4d86383fafa160264a474dfe"/><file name="LoggingFormatter.php" hash="d18aa0d044d4725eaacd006c55b8e366"/><file name="RemoveAbstractDefinitionsPass.php" hash="50373c5ff2ab6b3b540bd76036b8a3aa"/><file name="MergeExtensionConfigurationPass.php" hash="4252a3ea826e1423e66377c81dd12ae9"/><file name="InlineServiceDefinitionsPass.php" hash="eab7d43cb04a3252d731a5e8527eefc5"/><file name="ResolveDefinitionTemplatesPass.php" hash="30cabb0ccd2b9569d3ded2b4ebeb93a8"/><file name="CheckCircularReferencesPass.php" hash="529a03d3c6ac37bf5f37d2f05984353a"/><file name="ResolveReferencesToAliasesPass.php" hash="29d8ba719ae7c1b2286083201664b4c5"/><file name="RemovePrivateAliasesPass.php" hash="3ab8d8e151db2b5fd88819fa57f2308a"/></dir><file name="ContainerAwareInterface.php" hash="b4bbd2a21e9afe2cd25d26c37c54bfa9"/><dir name="Loader"><file name="PhpFileLoader.php" hash="2cd10bb9323270c20e818347691d13d0"/><file name="IniFileLoader.php" hash="7ea10963772ecf6f0c18fb04faead289"/><file name="YamlFileLoader.php" hash="fa1b8024ce6d9867fbf7f5135a0dbce6"/><file name="FileLoader.php" hash="4327841db6a3761ad17e54553178cf28"/><file name="XmlFileLoader.php" hash="e921b5607467cb4719e8e2bcb0349c66"/><file name="ClosureLoader.php" hash="e435524e4fe5c3bb374a9d89dcc4abcc"/><dir name="schema"><dir name="dic"><dir name="services"><file name="services-1.0.xsd" hash="8fdc942dfd53dfae77fef5e6fe565dd8"/></dir></dir></dir></dir><file name="DefinitionDecorator.php" hash="088ef975cd93b71b1118f29a4894bc3a"/><file name="ContainerAware.php" hash="4318c2ce4d160e6d183edce4928db696"/><dir name="ParameterBag"><file name="ParameterBag.php" hash="fb6f40da7f38cc4a3d636dc09ff7fd07"/><file name="ParameterBagInterface.php" hash="9c29ec4f6769f64eacd57633b62605ff"/><file name="FrozenParameterBag.php" hash="7a5a470e2d4ae055483c4370995ed030"/></dir><dir name="Dumper"><file name="DumperInterface.php" hash="b9dd1589f9ffac4366fd4148d9e78ade"/><file name="Dumper.php" hash="3b295c276bb774433a45f1ee0339a299"/><file name="GraphvizDumper.php" hash="95e156fafea46747f4a4a38b85faf943"/><file name="XmlDumper.php" hash="0834804e82bbba5658b4f3cb0294c5af"/><file name="YamlDumper.php" hash="5940848c7422f7ff0ece71f91bf9ec1a"/><file name="PhpDumper.php" hash="7b1e05faeeb6c013b4a2647439a4679a"/></dir><file name="composer.json" hash="134f706fbc63147624e46136a8fa0213"/><file name="README.md" hash="4a37dd76abb0d970c3c58030be21a993"/></dir><dir name="Config"><dir name="Resource"><file name="ResourceInterface.php" hash="8f062b489e002da9b8c9fedde7686f53"/><file name="DirectoryResource.php" hash="0dd51e1fce277a9dac05d77eb98553dc"/><file name="FileResource.php" hash="67e90b9f2144af1021feef854ed138f4"/></dir><file name="phpunit.xml.dist" hash="c794a91aae05def17fb44431cb4fca84"/><dir name="Exception"><file name="FileLoaderLoadException.php" hash="c72ffdb8bb37fc40fb9c45d5bb7fea6c"/><file name="FileLoaderImportCircularReferenceException.php" hash="59c5c886c2d0230703a6a8ebc47541af"/></dir><file name="ConfigCache.php" hash="42fe66cd64cd32ea55cefd056c7a1b67"/><file name="CHANGELOG.md" hash="2e855ecea3b2fd176fcde9dcbee078b4"/><file name="LICENSE" hash="56dedd4bd25ecd034ac4e1c17ebba0cc"/><dir name="Definition"><file name="PrototypedArrayNode.php" hash="4ea0d7cac936058397a02b4d1b24abd6"/><file name="BooleanNode.php" hash="35e38c75b51cdff67f3098103a791e44"/><file name="VariableNode.php" hash="f11fea9a1fe9fe3ebf5aaaad541faca8"/><file name="BaseNode.php" hash="4e1c72481d5d85f9347494885976831a"/><file name="Processor.php" hash="4d853174c3a8b201b3684fd8cdc5b768"/><file name="ScalarNode.php" hash="f132a3acf024a2e7fdbcf311900ac6cf"/><file name="ConfigurationInterface.php" hash="2715dbdacacd877e377fbdbd4ad1ec90"/><file name="EnumNode.php" hash="4718c796e11ef0403e41dce26b7224ea"/><dir name="Exception"><file name="InvalidConfigurationException.php" hash="df898eea27890a50cb912e1dbb88f1b2"/><file name="UnsetKeyException.php" hash="55c97aa4e81643f04c3abd943cc29a24"/><file name="InvalidDefinitionException.php" hash="aeb2ca3c7e035486a4ccebeac363125c"/><file name="Exception.php" hash="663baaeb8e61e07fa5a9ad4274686d53"/><file name="ForbiddenOverwriteException.php" hash="e2a12d6760feb9f7c96d61e502f68b2c"/><file name="InvalidTypeException.php" hash="4dc25832f90b656b88da8ac50789784a"/><file name="DuplicateKeyException.php" hash="ede2ab4177afff995069bc54c4517f9e"/></dir><file name="NodeInterface.php" hash="6f9786dc687247c82fe66f20030d3045"/><file name="IntegerNode.php" hash="9ccc83daaba13a6119645846977462c1"/><file name="PrototypeNodeInterface.php" hash="ef44def01e8a4abfa4eaabdab44a3e1e"/><file name="FloatNode.php" hash="7dfded8c4692130fc554b4078fb50f60"/><file name="ReferenceDumper.php" hash="52e870bf26dfc67c5cc508f35728877d"/><file name="NumericNode.php" hash="75d9c7fc5aa9188383c41a3b9db09ba9"/><file name="ArrayNode.php" hash="410683e3bc07db7398694b96d919c878"/><dir name="Dumper"><file name="XmlReferenceDumper.php" hash="ff8ec25bb68fe90df74a0ad5ce81acf6"/><file name="YamlReferenceDumper.php" hash="b3872d7001d6e2720a867a2bf09af371"/></dir><dir name="Builder"><file name="NumericNodeDefinition.php" hash="5432ea41087e28803130a9cbe74e4356"/><file name="ExprBuilder.php" hash="00801f867f745d41e276e503fcc91422"/><file name="NodeBuilder.php" hash="7693aa48110f594cf10b5cff5961fe1c"/><file name="FloatNodeDefinition.php" hash="ea6a82bed9a7bfe2f7c7e4bded4ba25e"/><file name="NormalizationBuilder.php" hash="46bebb98028e9769c8cf3831ba00eac1"/><file name="NodeParentInterface.php" hash="8857cb48e2ba81f9ac87d906cdff6828"/><file name="BooleanNodeDefinition.php" hash="f695e1837c512ef8114328e660bf548b"/><file name="EnumNodeDefinition.php" hash="d24500c7829d10fe297bc51941d9f687"/><file name="ValidationBuilder.php" hash="f3f979aa257bebf13b5eff13cec65f89"/><file name="TreeBuilder.php" hash="48f136a2fe26ef3b84f2f4e785dafdca"/><file name="IntegerNodeDefinition.php" hash="0de24b6c3b0846189e0e7140340e4c20"/><file name="ArrayNodeDefinition.php" hash="22a935981e46b1e93f47671d4eba7a0b"/><file name="NodeDefinition.php" hash="cb35eeaefb91af375748b08cea511624"/><file name="MergeBuilder.php" hash="b11f7c9b66d7b499362eec9cb4bbb1f4"/><file name="ScalarNodeDefinition.php" hash="60cdafbd23a7cfe8082e9a05131ed580"/><file name="VariableNodeDefinition.php" hash="72ec2bf4a8686d8ae753fe91f026b1a6"/><file name="ParentNodeDefinitionInterface.php" hash="2116ee0288a4d682af361f2d472ec242"/></dir></dir><file name="FileLocator.php" hash="026635098bb87b0f3d9aa9db277372ea"/><dir name="Util"><file name="XmlUtils.php" hash="74d9ff921ec1235a84f44b4ff48dccad"/></dir><dir name="Loader"><file name="DelegatingLoader.php" hash="55f0bb12cab11e866f3b8dc990acfe44"/><file name="LoaderResolver.php" hash="fa0e5cf636fcb699349bc383ac1c58e4"/><file name="Loader.php" hash="ee72e1f5134967e385909103288f1f28"/><file name="FileLoader.php" hash="5cf3b0ea85d4ec9c88347f2836e6829a"/><file name="LoaderInterface.php" hash="186d2f94152a27ccec52ef09dee3ff5b"/><file name="LoaderResolverInterface.php" hash="b5b88cd457cd2722513763f34d91181f"/></dir><file name="FileLocatorInterface.php" hash="19f6ce347d97710e6e204f6072080d7f"/><file name="composer.json" hash="f811d1f0df9a5b256c16a7029dae9513"/><file name="README.md" hash="80fb119edb21de39ff671d640fc7f381"/></dir><dir name="Filesystem"><file name="Filesystem.php" hash="42a77b14e5ad6730973a550ef3d1befd"/><file name="phpunit.xml.dist" hash="0b56a69620e3c1e5425a4006506948db"/><dir name="Exception"><file name="ExceptionInterface.php" hash="11a7d451ae71b6aeba9e1236a53865f0"/><file name="IOException.php" hash="86997298817e01fd6a9fad7e9bf9ab7c"/><file name="IOExceptionInterface.php" hash="9ce81ced7d137497a4aa3639b2c445fe"/><file name="FileNotFoundException.php" hash="8a8b119b88f20a5a3078e051a308f741"/></dir><file name="CHANGELOG.md" hash="1537577578897cb0d5702f346fae3c82"/><file name="LICENSE" hash="56dedd4bd25ecd034ac4e1c17ebba0cc"/><file name="composer.json" hash="d685adc2374ea7ec68ebb150e6e69d7c"/><file name="README.md" hash="e499eea57ed2f13503b64641c0890418"/></dir></dir></dir><dir name="Bitpay"><file name="TokenInterface.php" hash="a0da969c86e363b201cc48c0a228ebed"/><file name="AccessToken.php" hash="dd33ed2e4802be42097c3c09e0d12b63"/><file name="Bitpay.php" hash="50120aeed758c3acb3bebfc4b202f168"/><dir name="Storage"><file name="MagentoStorage.php" hash="a2b276b80d0b568b67bd6b1dd1c4af04"/><file name="StorageInterface.php" hash="bb136e52d599fdb59739f32d027a1602"/><file name="MockStorage.php" hash="2570dbf74083bb8a7117595a6c4aefb4"/><file name="EncryptedFilesystemStorage.php" hash="e42a3c81bd19393ae78c10fed77dfb75"/><file name="FilesystemStorage.php" hash="673528691f5b999fc5481ff112140dfe"/></dir><file name="PayoutInstruction.php" hash="ef96db181023671aecac43950b709001"/><file name="Application.php" hash="832324bd621f53ac57d5d4d04ecf4e1c"/><file name="BuyerInterface.php" hash="749f9fc623ff65e5bce296a5b4dfdbbc"/><file name="PointInterface.php" hash="2a8fce4bbc8e84e221563c27ce7b57ce"/><file name="KeyManager.php" hash="ad48cd3f5ddba0c47606659a32e85e7b"/><dir name="Network"><file name="Livenet.php" hash="7107f34a87978e78588482e5b1f868d4"/><file name="NetworkInterface.php" hash="998b026f803b4d99daec03b876d2d132"/><file name="Testnet.php" hash="98b315759b32549c558e143e50a365ad"/><file name="NetworkAware.php" hash="d92aad1b38105078cd5055b295014a11"/><file name="Customnet.php" hash="d2af606a4a63babf0a08d0e8abac72f5"/><file name="NetworkAwareInterface.php" hash="1d1f87d25469a8ce2d0f1f2eaaf03ef1"/></dir><file name="ApplicationInterface.php" hash="8721d3fe85f80dbf71ead7df93eb3f82"/><file name="CurrencyInterface.php" hash="561ff6c529ab29813e751999e70fb166"/><file name="KeyInterface.php" hash="30253c1e42ee7b452bbb0a7451c88685"/><file name="PayoutInstructionInterface.php" hash="5d6c51b0b6a980d84bfad21ecaecf92c"/><dir name="Math"><file name="EngineInterface.php" hash="a0de5260325608e0911d4128fe3e52c2"/><file name="GmpEngine.php" hash="3136a8196599b00f097c15c0aa3a4c49"/><file name="Math.php" hash="98fb61ecc9379c625c9b970df7e0ac54"/><file name="BcEngine.php" hash="2db2b0d7aed63b5641d646f56f196942"/></dir><file name="User.php" hash="061f9f4dcff8d3090cb358ae1b87e259"/><file name="AccessTokenInterface.php" hash="57b7b403c1644dba10474d67b3b781ca"/><file name="ItemInterface.php" hash="94e9fc64fafde84425cb30f73b96dc48"/><file name="SinKey.php" hash="f126c1344247e87aa5c108d57f0ca354"/><dir name="DependencyInjection"><file name="services.xml" hash="cda4e79bf0e6f6821e5b4c2e16c240cb"/><dir name="Loader"><file name="ArrayLoader.php" hash="5176febbc2ff9bf1646f623dccd54cd7"/></dir><file name="BitpayExtension.php" hash="fc361f93a85be0b066dd1a60bb5d4a15"/></dir><dir name="Config"><file name="Configuration.php" hash="7cb0441f0dce52bab9f30f0cc3dee2fa"/></dir><file name="Invoice.php" hash="f93959d593e54c30f01ccae85f521168"/><file name="Buyer.php" hash="aa43ea51f57b00568e3827d1e7ba2025"/><file name="PrivateKey.php" hash="d3e6ec3b5c91eb9627509365b26fb744"/><file name="Bill.php" hash="d41fc149de27e026546cda7db6c060cb"/><file name="Point.php" hash="605d50d4b9890f2e1a3120fb5b0c50d2"/><file name="InvoiceInterface.php" hash="1e280dbf85d96ad462b47c087fbe6d9f"/><file name="Item.php" hash="a4fc84d7309cf44de812612ca2fa6c90"/><file name="PayoutTransaction.php" hash="80ed69aae8134c32caddbfd8e17a85e3"/><file name="Key.php" hash="0c6bdce34e7b3a650914393c9da5c99d"/><dir name="Crypto"><file name="CryptoInterface.php" hash="13ac34aa5f26fe5640c037511c7789f4"/><file name="HashExtension.php" hash="62f5d49ddafbc7e7ca19aaaea76830ba"/><file name="OpenSSLExtension.php" hash="e8393638871fc2605dbd6ec58e7a7564"/><file name="McryptExtension.php" hash="160e7e94e6ec50b255742bb5366dea29"/></dir><file name="PayoutInterface.php" hash="5fe5e08a395d2179e64baa3364ff512c"/><file name="BillInterface.php" hash="4d4f7c1e6b8ea9421a5e6651c7bd0654"/><dir name="Util"><file name="Error.php" hash="d4e4ba021b73f94467793043db14cc93"/><file name="Base58.php" hash="544526f4f89848bfb61f7bfcae348af6"/><file name="Secp256k1.php" hash="84d9a363e0f185200664c712832b8759"/><file name="SecureRandom.php" hash="9e699a6e383cb439a604f6e6e1837833"/><file name="Fingerprint.php" hash="0dde9668583a04391a2faf99d4b72914"/><file name="Util.php" hash="00a6664bc2a77483a01c614054a20e58"/><file name="CurveParameterInterface.php" hash="72ca86056b4abfebbcfec87037478db7"/></dir><file name="Payout.php" hash="ca73c1f0a81a642ed0a6fed6fd1002c1"/><file name="Token.php" hash="8440fcdcbf7d20d8bda3e7ee7e6ad73f"/><file name="PublicKey.php" hash="dca40e9a5e8679f21d143d205cd2c389"/><file name="PayoutTransactionInterface.php" hash="43a42bf47814d44b431328b5e70731a4"/><file name="Autoloader.php" hash="109400039e04ef345ac879a944fe45ba"/><file name="Currency.php" hash="85fad91aae2c896aee7f463c9952d320"/><dir name="Client"><file name="Request.php" hash="fbdd615774ab606df4062b3874c03496"/><file name="RequestInterface.php" hash="1a77530dddf63f24a78ce488c401f499"/><file name="Response.php" hash="195796fb21d235e1348caca2a990910d"/><file name="ConnectionException.php" hash="f5cd06c10cca143d3e7a4f6c24e2727b"/><file name="ClientInterface.php" hash="365b7a595eb15705bd4bd88273d10293"/><file name="BitpayException.php" hash="f8de7190213f0fab975e44f29ffa17f1"/><dir name="Adapter"><file name="CurlAdapter.php" hash="267beddc7821db66f81a113c4d806a20"/><file name="AdapterInterface.php" hash="b85307a1bd110c08141a7eb29b305973"/><file name="ca-bundle.crt" hash="9025ca14554240fc05c4e919ae3f8923"/></dir><file name="ResponseInterface.php" hash="1d53f3b84efc12e370c72ac7be0e8211"/><file name="ArgumentException.php" hash="3dc6e11dfc71116cad8e843255a09d2b"/><file name="Client.php" hash="0338ed97a40491c33d059c66dab39166"/></dir><file name="UserInterface.php" hash="7714dd84ab21eac77736a80d9e19f7c0"/></dir></dir></target></contents></package>
|
1 |
<?xml version="1.0"?>
|
2 |
+
<package><name>Bitpay_Core</name><version>2.1.3</version><stability>stable</stability><license uri="https://github.com/bitpay/magento-plugin/blob/master/LICENSE">MIT</license><channel>community</channel><extends/><summary/><description/><notes/><authors><author><name>Integrations Team</name><user>BitPayInc</user><email>support@bitpay.com</email></author></authors><date>2015-06-08</date><time>14:24:13</time><compatible/><dependencies/><required php_min="5.4.0" php_max="6.0.0">php</required><extensions><name>openssl<min/><max/></name><name>mcrypt<min/><max/></name></extensions><contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Bitpay"><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extension.php" hash="ce9dd3c24d090a4f3ecd10f0488eb635"/><file name="Header.php" hash="a1a0f427bfacfda6375acd345696262a"/></dir></dir></dir></dir></dir><dir name="Form"><file name="Bitpay.php" hash="c071d4a4f56b2c5cebaad25d21ad0645"/></dir><file name="Iframe.php" hash="4e30275678e7f53ee474ec4beeaa23c9"/><file name="Info.php" hash="3c8ca079710e5b8e5d176a0c15383400"/></dir><dir name="controllers"><file name="IndexController.php" hash="cccb8e613c6ddbc102c3f194d10bc17b"/><file name="IpnController.php" hash="0210d2d02ddc3059e8708d8153c76cd6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a3d6e1c3fb81e271a85260aba4f9f797"/><file name="config.xml" hash="9827f19d8dc33f6a2bc5214f3db64424"/><file name="system.xml" hash="292e163d31c53b3586f9f319f236ff47"/></dir><dir name="Helper"><file name="Data.php" hash="fa70c9276b88f86abaec6939b39f1afd"/></dir><file name="LICENSE" hash="c443b0598a4770735bb68838f7d563a3"/><dir name="Model"><dir name="Config"><file name="PairingCode.php" hash="2a5e0ad5ff0713505e0369650e3666b6"/></dir><file name="Invoice.php" hash="aabfe84828f8bb9b5f49ea400987c545"/><file name="Ipn.php" hash="a4fbded43a0afe2285f2d474ae5bfe26"/><dir name="Method"><file name="Bitcoin.php" hash="2255adc27d7f1b3d6af77dddc73f7933"/></dir><dir name="Mysql4"><dir name="Invoice"><file name="Collection.php" hash="22be8a79edc2e1cd5b61f1800c4cfe53"/></dir><file name="Invoice.php" hash="9bbf44a18a28e74528bc68eee4c43832"/><dir name="Ipn"><file name="Collection.php" hash="8c9b4087793d674b47d08d62812cf9f5"/></dir><file name="Ipn.php" hash="428c133bd044253229ac7876aa08acbf"/></dir><file name="Network.php" hash="a02a268fac47fe19fed93828f28285e2"/><file name="Observer.php" hash="c0e6a80ae7cd484ac0221c5621533100"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="285ede9c3abd026784b1b20fff3a1913"/></dir></dir><file name="Status.php" hash="deba733eeb8127395e9f23677627e8c4"/><file name="TransactionSpeed.php" hash="444a8dfce8bdde09efa8daeafcef6cf9"/></dir><file name="README.md" hash="5de7be17a73016fe9c2f27219641c28d"/><dir name="sql"><dir name="bitpay_setup"><file name="install-2.1.3.php" hash="dc0b3c6100e274e7bfd6cedcedf0d38d"/><file name="upgrade-2.0.1-2.1.3.php" hash="4091ce21542aa7e8f4ae2484d165f957"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bitpay.xml" hash="c7e3886904c20f44b58409968c4209f0"/></dir><dir name="template"><dir name="bitpay"><dir name="info"><file name="default.phtml" hash="7e31f22f964ccbbbdcd71504c60e0393"/></dir><dir name="system"><dir name="config"><dir name="field"><file name="header.phtml" hash="971ec034699d110f7842a2c8befb4c55"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bitpay.xml" hash="c7e3886904c20f44b58409968c4209f0"/></dir><dir name="template"><dir name="bitpay"><dir name="form"><file name="bitpay.phtml" hash="c12ef983014d5a73906502d2031108e2"/></dir><file name="iframe.phtml" hash="84892655b0e807e905251b8763850bae"/><dir name="info"><file name="default.phtml" hash="a3bd6e183052b9d9181aaf96accfa42e"/></dir><file name="json.phtml" hash="cc43e25d0445d5ba15b448ba946dabfd"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Bitpay_Core.xml" hash="122aa83102518a01122aaddcafa8ea7f"/></dir></dir><dir name="locale"><dir name="en_US"><file name="Bitpay_Core.csv" hash="1f6198bdeee3f77f87c36b4e09b45be2"/></dir></dir></dir><dir name="lib"><dir name="Bitpay"><file name="AccessToken.php" hash="dd33ed2e4802be42097c3c09e0d12b63"/><file name="AccessTokenInterface.php" hash="57b7b403c1644dba10474d67b3b781ca"/><file name="Application.php" hash="832324bd621f53ac57d5d4d04ecf4e1c"/><file name="ApplicationInterface.php" hash="8721d3fe85f80dbf71ead7df93eb3f82"/><file name="Autoloader.php" hash="109400039e04ef345ac879a944fe45ba"/><file name="Bill.php" hash="d41fc149de27e026546cda7db6c060cb"/><file name="BillInterface.php" hash="4d4f7c1e6b8ea9421a5e6651c7bd0654"/><file name="Bitpay.php" hash="50120aeed758c3acb3bebfc4b202f168"/><file name="Buyer.php" hash="aa43ea51f57b00568e3827d1e7ba2025"/><file name="BuyerInterface.php" hash="749f9fc623ff65e5bce296a5b4dfdbbc"/><dir name="Client"><dir name="Adapter"><file name="AdapterInterface.php" hash="b85307a1bd110c08141a7eb29b305973"/><file name="ca-bundle.crt" hash="9025ca14554240fc05c4e919ae3f8923"/><file name="CurlAdapter.php" hash="267beddc7821db66f81a113c4d806a20"/></dir><file name="ArgumentException.php" hash="3dc6e11dfc71116cad8e843255a09d2b"/><file name="BitpayException.php" hash="f8de7190213f0fab975e44f29ffa17f1"/><file name="Client.php" hash="2df93e3402b02922ad5939ede9988bd0"/><file name="ClientInterface.php" hash="365b7a595eb15705bd4bd88273d10293"/><file name="ConnectionException.php" hash="f5cd06c10cca143d3e7a4f6c24e2727b"/><file name="Request.php" hash="fbdd615774ab606df4062b3874c03496"/><file name="RequestInterface.php" hash="1a77530dddf63f24a78ce488c401f499"/><file name="Response.php" hash="195796fb21d235e1348caca2a990910d"/><file name="ResponseInterface.php" hash="1d53f3b84efc12e370c72ac7be0e8211"/></dir><dir name="Config"><file name="Configuration.php" hash="7cb0441f0dce52bab9f30f0cc3dee2fa"/></dir><dir name="Crypto"><file name="CryptoInterface.php" hash="13ac34aa5f26fe5640c037511c7789f4"/><file name="HashExtension.php" hash="62f5d49ddafbc7e7ca19aaaea76830ba"/><file name="McryptExtension.php" hash="160e7e94e6ec50b255742bb5366dea29"/><file name="OpenSSLExtension.php" hash="e8393638871fc2605dbd6ec58e7a7564"/></dir><file name="Currency.php" hash="85fad91aae2c896aee7f463c9952d320"/><file name="CurrencyInterface.php" hash="561ff6c529ab29813e751999e70fb166"/><dir name="DependencyInjection"><file name="BitpayExtension.php" hash="fc361f93a85be0b066dd1a60bb5d4a15"/><dir name="Loader"><file name="ArrayLoader.php" hash="5176febbc2ff9bf1646f623dccd54cd7"/></dir><file name="services.xml" hash="cda4e79bf0e6f6821e5b4c2e16c240cb"/></dir><file name="Invoice.php" hash="f93959d593e54c30f01ccae85f521168"/><file name="InvoiceInterface.php" hash="1e280dbf85d96ad462b47c087fbe6d9f"/><file name="Item.php" hash="a4fc84d7309cf44de812612ca2fa6c90"/><file name="ItemInterface.php" hash="94e9fc64fafde84425cb30f73b96dc48"/><file name="Key.php" hash="0c6bdce34e7b3a650914393c9da5c99d"/><file name="KeyInterface.php" hash="30253c1e42ee7b452bbb0a7451c88685"/><file name="KeyManager.php" hash="ad48cd3f5ddba0c47606659a32e85e7b"/><dir name="Math"><file name="BcEngine.php" hash="2db2b0d7aed63b5641d646f56f196942"/><file name="EngineInterface.php" hash="a0de5260325608e0911d4128fe3e52c2"/><file name="GmpEngine.php" hash="3136a8196599b00f097c15c0aa3a4c49"/><file name="Math.php" hash="98fb61ecc9379c625c9b970df7e0ac54"/></dir><dir name="Network"><file name="Customnet.php" hash="d2af606a4a63babf0a08d0e8abac72f5"/><file name="Livenet.php" hash="7107f34a87978e78588482e5b1f868d4"/><file name="NetworkAware.php" hash="d92aad1b38105078cd5055b295014a11"/><file name="NetworkAwareInterface.php" hash="1d1f87d25469a8ce2d0f1f2eaaf03ef1"/><file name="NetworkInterface.php" hash="998b026f803b4d99daec03b876d2d132"/><file name="Testnet.php" hash="98b315759b32549c558e143e50a365ad"/></dir><file name="Payout.php" hash="ca73c1f0a81a642ed0a6fed6fd1002c1"/><file name="PayoutInstruction.php" hash="ef96db181023671aecac43950b709001"/><file name="PayoutInstructionInterface.php" hash="5d6c51b0b6a980d84bfad21ecaecf92c"/><file name="PayoutInterface.php" hash="5fe5e08a395d2179e64baa3364ff512c"/><file name="PayoutTransaction.php" hash="80ed69aae8134c32caddbfd8e17a85e3"/><file name="PayoutTransactionInterface.php" hash="43a42bf47814d44b431328b5e70731a4"/><file name="Point.php" hash="605d50d4b9890f2e1a3120fb5b0c50d2"/><file name="PointInterface.php" hash="2a8fce4bbc8e84e221563c27ce7b57ce"/><file name="PrivateKey.php" hash="d3e6ec3b5c91eb9627509365b26fb744"/><file name="PublicKey.php" hash="dca40e9a5e8679f21d143d205cd2c389"/><file name="SinKey.php" hash="f126c1344247e87aa5c108d57f0ca354"/><dir name="Storage"><file name="EncryptedFilesystemStorage.php" hash="e42a3c81bd19393ae78c10fed77dfb75"/><file name="FilesystemStorage.php" hash="673528691f5b999fc5481ff112140dfe"/><file name="MagentoStorage.php" hash="a2b276b80d0b568b67bd6b1dd1c4af04"/><file name="MockStorage.php" hash="2570dbf74083bb8a7117595a6c4aefb4"/><file name="StorageInterface.php" hash="bb136e52d599fdb59739f32d027a1602"/></dir><file name="Token.php" hash="8440fcdcbf7d20d8bda3e7ee7e6ad73f"/><file name="TokenInterface.php" hash="a0da969c86e363b201cc48c0a228ebed"/><file name="User.php" hash="061f9f4dcff8d3090cb358ae1b87e259"/><file name="UserInterface.php" hash="7714dd84ab21eac77736a80d9e19f7c0"/><dir name="Util"><file name="Base58.php" hash="544526f4f89848bfb61f7bfcae348af6"/><file name="CurveParameterInterface.php" hash="72ca86056b4abfebbcfec87037478db7"/><file name="Error.php" hash="d4e4ba021b73f94467793043db14cc93"/><file name="Fingerprint.php" hash="0dde9668583a04391a2faf99d4b72914"/><file name="Secp256k1.php" hash="84d9a363e0f185200664c712832b8759"/><file name="SecureRandom.php" hash="9e699a6e383cb439a604f6e6e1837833"/><file name="Util.php" hash="00a6664bc2a77483a01c614054a20e58"/></dir></dir></dir></target></contents></package>
|