Location: PHPKode > projects > Spiral > ametaireau-spiral-272a2b1/framework/di/tests/fixtures/schema/XML/Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns="http://namespaces.spiral-project.org/framework/di/services"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://namespaces.spiral-project.org/framework/di/services
		http://namespaces.spiral-project.org/framework/di/services/services-1.0.xsd">

	<!--
		Null argument type (as default type)
		Null argument type
		Static callback on event "afterCreation"
		CurrentService argument type
	-->
	<service id="store" class="\spiral\framework\di\fixtures\Store">
		<method name="setName">
			<argument type="null"/>
		</method>
		<callback event="afterCreation" class="\spiral\framework\di\fixtures\StoreRegister" method="register">
			<argument type="currentService"/>
		</callback>
	</service>

	<!--
		Multiple method calls
		Service injection
		Singleton scope (as default scope)
		Service extension
	-->
	<service id="musicStore" class="\spiral\framework\di\fixtures\MusicStore" extends="store">
		<method name="addArtist">
			<argument ref="jamesBrown"/>
		</method>
		<method name="setAlbumFinder">
			<argument ref="albumFinder"/>
		</method>
		<method name="setArtistFinder">
			<argument ref="artistFinder"/>
		</method>
		<method name="setSongFinder">
			<argument ref="songFinder"/>
		</method>
	</service>

	<!--
		Direct instantiation
		String type injection
		String type injection (as default type)
		Singleton scope
		Use of a service method result as an argument
		Use of a service attribute as an argument
		Callback on a service on event "afterCreation"
	-->
	<service id="jamesBrown" class="\spiral\framework\di\fixtures\Artist" scope="singleton">
		<constructor>
			<argument type="string" value="James"/>
			<argument value="Brown"/>
		</constructor>
		<method name="setNickname">
			<argument ref="jamesBrownInformation" method="getElement">
				<argument value="nickname"/>
			</argument>
		</method>
		<method name="setBirthdate">
			<argument ref="jamesBrownInformation" attribute="birthdate"/>
		</method>
		<method name="setDiscography">
			<argument ref="discography"/>
		</method>
		<callback event="afterCreation" ref="goldenMicrophone" method="say">
			<argument type="currentService"/>
			<argument value="I Feel Good !"/>
		</callback>
	</service>

	<!--
		Alias
	-->
	<service id="theGodfatherOfSoul" ref="jamesBrown"/>

	<service id="goldenMicrophone" class="\spiral\framework\di\fixtures\GoldenMicrophone"/>

	<!--
		Attribute injection
	-->
	<service id="jamesBrownInformation" class="\spiral\framework\di\fixtures\Collection">
		<attribute name="birthdate" value="1933-05-03"/>
		<method name="setElement">
			<argument value="nickname"/>
			<argument value="The Godfather Of Soul"/>
		</method>
	</service>

	<!--
		Multiple call on the same method
		Only method injection
	-->
	<service id="discography" class="\spiral\framework\di\fixtures\Discography">
		<method name="addAlbum">
			<argument type="service" ref="pleasePleasePlease"/>
		</method>
		<method name="addAlbum">
			<argument type="service" ref="sexMachine"/>
		</method>
	</service>

	<!--
		Instantation via a static factory
		Float type injection
		Int type injection
		Global constant type injection
		Simple array type injection
		Prototype scope when using a factory (as default scope)
	-->
	<service id="pleasePleasePlease">
		<constructor factoryClass="\spiral\framework\di\fixtures\StaticAlbumFactory" factoryMethod="create">
			<argument value="Please Please Please"/>
			<argument type="int" value="2004"/>
			<argument type="constant" value="ALBUM_SUPPORT_CD"/>
		</constructor>
		<method name="addSong">
			<argument type="array">
				<item key="title" value="Give It Up Or Turn It Loose"/>
				<item key="length" type="float" value="2.17"/>
			</argument>
		</method>
	</service>

	<!--
		Instantation via a factory instance
		Class constant type injection
		Array containing array type injection
		Singleton scope when using a factory
	-->
	<service id="sexMachine" scope="singleton">
		<constructor factoryService="albumFactory" factoryMethod="create">
			<argument value="Sex Machine"/>
			<argument type="int" value="1970"/>
			<argument type="constant" class="\spiral\framework\di\fixtures\Album" value="SUPPORT_VINYL"/>
		</constructor>
		<method name="setSongs">
			<argument type="array">
				<item type="array">
					<item key="title" value="Get Up I Feel Like Being A Sex Machine"/>
					<item key="minutes" type="int" value="10"/>
					<item key="seconds" type="int" value="48"/>
				</item>
				<item type="array">
					<item key="title" value="Brother Rapp"/>
					<item key="minutes" type="int" value="5"/>
					<item key="seconds" type="int" value="9"/>
				</item>
			</argument>
		</method>
	</service>

	<!--
		No constructor and no method
		Prototype scope
	-->
	<service id="albumFactory" class="\spiral\framework\di\fixtures\AlbumFactory" scope="prototype"/>

	<!--
		Only constructor injection
		Explicit container injection
	-->
	<service id="albumFinder" class="\spiral\framework\di\fixtures\AlbumFinder">
		<constructor>
			<argument type="container"/>
		</constructor>
	</service>

	<!--
		Implicit container injection (via ContainerAware interface)
	-->
	<service id="artistFinder" class="\spiral\framework\di\fixtures\ArtistFinder"/>

	<!--
		Do not inject container (even when ContainerAware interface is implemented)
	-->
	<service id="songFinder" class="\spiral\framework\di\fixtures\SongFinder" containerAware="false"/>

</services>
Return current item: Spiral