service container序里你也许会创建一个对象来管理产品目录清单或者另从_第1页
service container序里你也许会创建一个对象来管理产品目录清单或者另从_第2页
service container序里你也许会创建一个对象来管理产品目录清单或者另从_第3页
service container序里你也许会创建一个对象来管理产品目录清单或者另从_第4页
service container序里你也许会创建一个对象来管理产品目录清单或者另从_第5页
已阅读5页,还剩23页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Service一个现代的PHP程序充满了对象。一个对象也许会帮助发送邮件而另一个也许帮你信息到数据库。在你的程序里,你也许会创建一个对象来管理你的产品,或者另一个对象从第API处理数据。关键就在于现代的应用程序会做很多事情并组织很多对象来处理每个任务。AmodernPHPapplicationisfullofobjects.Oneobjectmayfacilitatethedeliveryofmessageswhileanothermayallowyoutopersistinformationintoadatabase.Inyourapplication,youmaycreateanobjectthatmanagesyourproductinventory,oranotherobjectthatprocessesdatafromathird-partyAPI.Thepointisthatamodernapplicationdoesmanythingsandisorganizedintomanyobjectsthathandleeachtask.ThischapterisaboutaspecialPHPobjectinSymfonythathelpsyouinstantiate,organizeandretrievethemanyobjectsofyourapplication.Thisobject,calledaservicecontainer,willallowyoutostandardizeandcentralizethewayobjectsareconstructedinyourapplication.Thecontainermakesyourlifeeasier,issuperfast,andemphasizesanarchitecturethatpromotesreusableanddecoupledcode.SinceallcoreSymfonyclassesusethecontainer,you'lllearnhowtoextend,configureanduseanyobjectinSymfony.Inlargepart,theservicecontaineristhebiggestcontributortothespeedandextensibilityofSymfony.最终,配置和使用服务容器很容易。在这章的结尾,你将完全可以通过容器和任何第bunde的自定义象创建属于自己的对象。你将可以写出更加可重用、可测试、解耦合、简约的代码,因为服务容器让写出好的代码变得如此容易。Finally,configuringandusingtheservicecontaineriseasy.Bytheendofthischapter,you'llbecomfortablecreatingyourownobjectsviathecontainerandcustomizingobjectsfromanythird-partybundle.You'llbeginwritingcodethatismorereusable,testableanddecoupled,simplybecausetheservicecontainermakeswritinggoodcodesoeasy.WhatisaService?简单说,服务就是提供类似全局”任务的PHP对象。这是一个在计算机科学里普遍使用的名字,用来描述一个事物为了某个特殊的目的而被创建(比如发送邮件)你的程序来使用。你不用做任何特殊的事情来创建服务,只需要写一个PHP类,这个类用来实现一个特定的任务。恭喜你,你已经创建了一个服务!Putsimply,aServiceisanyPHPobjectthatperformssomesortof"global"task.It'sapurposefully-genericnameusedincomputersciencetodescribeanobjectthat'screatedforaspecificpurpose(e.g.delivering s).Eachserviceisusedthroughoutyourapplicationwheneveryouneedthespecificfunctionalityitprovides.Youdon'thavetodoanythingspecialtomakeaservice:simplywriteaPHPclasswithsomecodethat plishesaspecifictask.作为规则,在你程序里使用的全局对象就是服务。一个简单的Mile服务用于全局性地发送邮件,然而它发送Asarule,aPHPobjectisaserviceifitisusedgloballyinyourapplication.Asingle isusedgloballytosend messageswhereasthemany objectsthatitdeliversarenotservices.Similarly,a objectisnotaservice,butanobjectthat objectstoadatabaseisaservice.接下来呢?“服务”有利于你开始思考将你程序里的功能拆分成一系列的服务块。既然每个服务只做一个工作,你可以很容易进入每个服务并在任何需要它的地方使用它的功能。每个服务也可以很简单的测试和配置,只要它从程序的其他功能分离出来。这个观念被称为面向服务架构,并且对Symfony甚至PHP它都是独一无二的。围绕一套独立的服务类来构建你程序的结构是知名且可信的面向对象的最佳实现。这些技能是任何语言的开发者成长为好的开发者的关键。Sowhat'sthebigdealthen?Theadvantageofthinkingabout"services"isthatyoubegintothinkaboutseparatingeachpieceoffunctionalityinyourapplicationintoaseriesofservices.Sinceeachservicedoesjustonejob,youcaneasilyaccesseachserviceanduseitsfunctionalitywhereveryouneedit.Eachservicecanalsobemoreeasilytestedandconfiguredsinceit'sseparatedfromtheotherfunctionalityinyourapplication.Thisideaiscalledservice-orientedarchitectureandisnotuniquetoSymfonyorevenPHP.Structuringyourapplicationaroundasetofindependentserviceclassesisawell-knownandtrustedobject-orientedbest-practice.Theseskillsarekeytobeingagooddeveloperinalmostanylanguage.WhatisaServiceContainer?AServiceContainer(ordependencyinjectioncontainer)issimplyaPHPobjectthatmanagestheinstantiationofservices(i.e.objects).Forexample,supposeyouhaveasimplePHPclassthatdelivers messages.Withoutaservicecontainer,youmustmanuallycreatetheobjectwheneveryouneedit:这个足够容易。这个虚构的Mailer类允许您配置用来发送邮件的方式(如sendmail,smtp等)是,如果你想在其他地方使用的这个邮件服务呢?你当然不希望每次你需要使用这个Mailer对象的时候都重复这个mailer的配置。如果你需要把程序的每个地方的发送接口都从sendmail改成smtpMailer服务的地方并修改它。Thisiseasyenough.Theimaginary classallowsyoutoconfigurethemethodusedtodeliverthemessages(e.g. ,etc).Butwhatifyouwantedtousethemailerservicesomewhereelse?Youcertainlydon'twanttorepeatthemailerconfigurationeverytimeyouneedtousethe object.Whatifyouneededtochange everywhereintheapplication?You'dneedtohuntdowneveryceyoucreatea serviceandchangeit.Creating/ConfiguringServicesintheContainer一个更好的解决办法是让服务容器为你创建Mailer对象。为了实现它,你必须容器如何创Mailer服务。这是通过配置完成的,你可以指定使用YAML,XML或Abetteransweristolettheservicecontainercreatethe objectforyou.Inorderforthistowork,youmustteachthecontainerhowtocreatethe service.Thisisdoneviaconfiguration,whichcanbespecifiedinYAML,XMLorPHP:当Symfony初始化时,它会通过使用应用程序配置来创建服务,默认情况下是)。这个加载的文件是由AppKernel::registerContainerConfiguration方法支配的,它加载一个特定环境下的配置文件(如config_dev.yml为dev环境或config_prod.yml为prod)。WhenSymfonyinitializes,itbuildstheservicecontainerusingtheapplicationconfiguration(bydefault).Theexactfilethat'sloadedisdictatedbythemethod,whichloadsanspecificconfigurationfile(e.g.forthe orfor Aninstanceofthe containerisavailableinanytraditionalSymfonycontrollerwhereyoucanaccesstheservicesofthecontainerviathe shortcutmethod:当你调用容器里的my_maer服务,这个容器会构建这个对象并返回它。这是另一个使用容器的有利条件。即只有需要这个服务,才会构建它。如果你定义了一个服务且从没运用它,这个服务就不会创建。这样会省内存且提速程序。这意味着定义很多服务对性能的影响很小甚至没有影响。服务不用就不会构建。Whenyouaskforthe servicefromthecontainer,thecontainerconstructstheobjectandreturnsit.Thisisanothermajoradvantageofusingtheservicecontainer.Namely,aserviceisneverconstructeduntilit'sneeded.Ifyoudefineaserviceandneveruseitonarequest,theserviceisnevercreated.Thissavesmemoryandincreasesthespeedofyourapplication.Thisalsomeansthatthere'sverylittleornoperformancehitfordefininglotsofservices.Servicesthatareneverusedareneverconstructed.(这样更灵活和强大),接下来在”HowtoWorkwithScopes”cookbook的文章里你可以学习怎样配置一个服务多Asabonus,the serviceisonlycreatedonceandthesameinstanceisreturnedeachtimeyouaskfortheservice.Thisisalmostalwaysthebehavioryou'llneed(it'smoreflexibleandpowerful),butyou'lllearnlaterhowyoucanconfigureaservicethathasmultipleinstancesinthe"HowtoWorkwithScopes"cookbookarticle.在这个例子里,控制器拓展于mo的基础控制器,它给了你服务控制器自身的机会。你可以使用get方法从服务容器里定位并获取mmailr服务。你也可以定义你自己的控制器来做服务。虽然这样稍微显得高级且没有必要,但它允许你将你需要的服务注射进你的控制器。Inthisexample,thecontrollerextendsSymfony'sbaseController,whichgivesyouaccesstotheservicecontaineritself.Youcanthenusethemethodtolocateandretrieve servicefromtheservicecontainer.Youcanalsodefineyourcontrollersasservices.Thisisabitmoreadvancedandnotnecessary,butitallowsyoutoinjectonlytheservicesyouneedintoyourcontroller.ServiceParameters新服务的创建(即对象),Thecreationofnewservices(i.e.objects)viathecontainerisprettystraightforward.Parametersmakedefiningservicesmoreorganizedandflexible: Theendresultisexactlythesameasbefore-thedifferenceisonlyinhowyoudefinedtheservice.Bysurroundingthestringinpercent()signs,thecontainerknowstolookforaparameterwiththatname.Whenthecontainerisbuilt,itlooksupthevalueofeachparameterandusesitintheservicedefinition.Ifyouwanttouseastringthatstartswithansignasaparametervalue(e.g.averysafemailerpassword)inaYAMLfile,youneedtoescapeitbyaddinganothersign(thisonlyappliestotheYAMLformat):Thepercentsigninsideaparameterorargument,aspartofthestring,mustbeescapedwithanotherpercentsign:用一个paamtrs关键字就可以实现所有服务选项的分离和组织性。参数值可以被多个服务定义共用。Thepurposeofparametersistofeedinformationintoservices.Ofcoursetherewasnothingwrongwithdefiningtheservicewithoutusinganyparameters.Parameters,however,haveseveraladvantages:separationandorganizationofallservice"options"underasinglekey;parametervaluescanbeusedinmultipleservicedefinitions;whencreatingaserviceinabundle(thisfollowsshortly),usingparametersallowstheservicetobeeasilycustomizedinyourapplication.选择使用或者不用参数取决于你。高质量的第bundle总是会使用参数以使容器里存放的服务更具可配置Thechoiceofusingornotusingparametersisuptoyou.High-qualitythird-partybundleswillalwaysuseparametersastheymaketheservicestoredinthecontainermoreconfigurable.Fortheservicesinyourapplication,however,youmaynotneedtheflexibilityofparameters.ImportingotherContainerConfiguration在这个部分,服务的配置文件被归类于资源。这凸显出了,大部分的配置都是文件(如YAML,XML,PHP),Symfony是如此的灵活以至于配置文件可以从任何来源加载(如数据库,甚至其他外部的web服Inthissection,serviceconfigurationfilesarereferredtoasresources.Thisistohighlightthefactthat,whilemostconfigurationresourceswillbefiles(e.g.YAML,XML,PHP),Symfonyissoflexiblethatconfigurationcouldbeloadedfromanywhere(e.g.adatabaseorevenviaanexternalweb服务容器是由单一的配置资源建立的(默认是app/config/config.yml)。所有其他的服务配置(包括Theservicecontainerisbuiltusingasingleconfigurationresource(bydefault).Allotherserviceconfiguration(includingthecoreSymfonyandthird-partybundleconfiguration)mustbeimportedfrominsidethisfileinonewayoranother.Thisgivesyouabsoluteflexibilityovertheservicesinyourapplication.会学习第二种方法,这种方法是从第bundle引入服务配置,灵活且首选的方法。Externalserviceconfigurationcanbeimportedintwodifferentways.Thefirst-andmostcommonmethod-isviathe directive.Later,you'lllearnaboutthesecondmethod,whichistheflexibleandpreferredmethodforimportingserviceconfigurationfromthird-partybundles.ImportingConfigurationwithimports至此,你已经把my_milr服务容器直接定义在了你的程序配置文件里了(如pp/onig/onig.yml)。当然,自从Mil类本身存在于AmeoBundle中,它就为my_mil容器在这个bundl里的定义增加了更多地意义。Sofar,you'vecedyour servicecontainerdefinitiondirectlyintheapplicationconfigurationfile(e.g.).Ofcourse,sincethe classitselflivesinsidetheAcme oBundle,itmakesmoresensetoputthe thebundleaswell.首先,将my_mailer容器的定义移动到一个在AcmeoBundle里的新容器资源文件里。如果Resources或 First,movethe containerdefinitionintoanewcontainerresourcefileinside oBundle.Ifthe ordirectoriesdon'texist,createthem.Thedefinitionitselfhasn'tchanged,onlyitslocation.Ofcoursetheservicecontainerdoesn'tknowaboutthenewresourcefile.Fortunay,youcaneasilyimporttheresourcefileusing keyintheapplicationDuetothewayinwhichparametersareresolved,youcannotusethemtobuildpathsinimportsdynamically.Thismeansthatsomethinglikethefollowingdoesn'twork:imports指令允许你的程序包含任意地址的服务容器配置资源(通常来自budls)。资源地址,即文件地址,是资源文件的绝对地址。这个特殊的@cme oBudle语法解决cme oBudle的 径。样能帮助你定义资源的路径而不必为挪动cme oBudl的 而担忧。 fromanyotherlocation(mostcommonlyfrombundles).The location,forfiles,istheabsolutepathtotheresourcefile.Thespecial syntaxresolvesthedirectorypathoftheAcme oBundlebundle.ThishelpsyouspecifythepathtotheresourcewithoutworryinglaterifyoumovetheAcme oBundletoadifferentdirectory.ImportingConfigurationviaContainerExtensions当使用Symfony开发,你通常会使用imports指令你为程序创建的bundles的容器配置文件。第容器配置文件,包括Symfony服务,通过可以通过另一个方法加载,这个方法更灵活且容易配置WhendeveloinSymfony,you'llmostcommonlyusethe directivetoimportcontainerconfigurationfromthebundlesyou'vecreatedspecificallyforyourapplication.Third-partybundlecontainerconfiguration,includingSymfonycoreservices,areusuallyloadedusinganothermethodthat'smoreflexibleandeasytoconfigureinyourapplication.这里介绍它是怎样工作的。在内部,每个bunde定义它的服务就如同你已看到的那样。即一个bunde使用一个或多个配置资源文件(通常是XL)来定义针对这个bunde的参数和服务。然而,除了用mpots直程序配置的这些资源,你也可以简单地一个满足你需求的bunde的服务容器扩展。一个容器扩展是由这个bunde作者创建的PP类,用来实现两个目的:提供语义的、直接的配置文件,以此来实现bunle的配置,而无需与此bunl服务容器内单调的配置有任何瓜葛。Here'showitworks.Internally,eachbundledefinesitsservicesverymuchlikeyou'veseensofar.Namely,abundleusesoneormoreconfigurationresourcefiles(usuallyXML)tospecifytheparametersandservicesforthatbundle.However,insteadofimportingeachoftheseresourcesdirectlyfromyourapplicationconfigurationusingthe directive,youcansimplyinvokeaservicecontainerextensioninsidethebundlethatdoestheworkforyou.AservicecontainerextensionisaPHPclasscreatedbythebundleauthor plishtwothings:importallservicecontainerresourcesneededtoconfiguretheservicesforthebundle;providesemantic,straightforwardconfigurationsothatthebundlecanbeconfiguredwithout ctingwiththeflatparametersofthebundle'sservicecontainerconfiguration.Inotherwords,aservicecontainerextensionconfigurestheservicesforabundleonyourbehalf.Andasyou'llseeinamoment,theextensionprovidesasensible,high-levelinterfaceforconfiguringthebundle.TaketheFrameworkBundle-thecoreSymfonyframeworkbundle-asanexample.ThepresenceofthefollowingcodeinyourapplicationconfigurationinvokestheservicecontainerextensioninsidetheFrameworkBundle:当配置文件被解析,容器会寻找一个可以处理fameok配置指令的扩展。这个存在于FameokBunde展已被调用,并且FameokBunde的服务配置也被加载了。如果你从程序配置文件完全删除fameok字,Symfony服务不会被加载。重点在于你掌握着一切:Symfony框架并没包含任何魔法或失去你控制的执行动作。Whentheconfigurationisparsed,thecontainerlooksforanextensionthatcan configurationdirective.Theextensioninquestion,whichlivesintheFrameworkBundle,isinvokedandtheserviceconfigurationfortheFrameworkBundleisloaded.Ifyouremovethe fromyourapplicationconfigurationfileentirely,thecoreSymfonyserviceswon'tbeloaded.Thepointisthatyou'reincontrol:theSymfonyframeworkdoesn'tcontainanymagicorperformanyactionsthatyoudon'thavecontrolover.Ofcourseyoucandomuchmorethansimply"activate"theservicecontainerextensionoftheFrameworkBundle.Eachextensionallowsyoutoeasilycustomizethebundle,withoutworryingabouthowtheinternalservicesaredefined.这个案例里,这个扩展允许你自定义error_handler,csrf_protection,router的配置,甚至更多。在内部,Inthiscase,theextensionallowsyouto ,, configurationandmuchmore.Internally,theFrameworkBundleusestheoptionsspecifiedheretodefineandconfiguretheservicesspecifictoit.Thebundletakescareofcreatingallthenecessaryand fortheservicecontainer,whilestillallowingmuchoftheconfigurationtobeeasilycustomized.Asabonus,mostservicecontainerextensionsarealsosmartenoughtoperformvalidation-notifyingyouofoptionsthataremissingorthewrongdataReferenceGuide里找到。Wheninstallingorconfiguringabundle,seethebundle's ationforhowtheservicesforthebundleshouldbeinstalledandconfigured.TheoptionsavailableforthecorebundlescanbefoundinsidetheReferenceNatively,theservicecontaineronlyrecognizesthe, ,and Anyotherdirectivesarehandledbyaservicecontainerextension.如果你想要你自己的bundle实现用户友好的配置,请看cookbook的HowtoLoadServiceConfigurationinsideaBundleIfyouwanttoexposeuserfriendlyconfigurationinyourownbundles,readthe"HowtoLoadServiceConfigurationinsideaBundle"cookbookrecipe.Referencing(Injecting)Services至此,这个原始的y_mier服务还是简单:在它的构造方法里只有一个参数,它还很好配置。你会看到,当你创建了一个服务,而这个服务依赖于同一个容器内的另一个或其他几个服务时,容器的真正强大之处已经实现了。Sofar,theoriginal serviceissimple:ittakesjustoneargumentinitsconstructor,whichiseasilyconfigurable.Asyou'llsee,therealpowerofthecontainerisrealizedwhenyouneedtocreateaservicethatdependsononeormoreotherservicesinthecontainer.Asanexample,supposeyouhaveanewservice,,thathelpstomanagethepreparationanddeliveryofan messagetoacollectionofaddresses.Ofcourse messages,soyou'lluseinsidetohandletheactualdeliveryofthemessages.Thispretendclassmightlooksomethinglikethis:Withoutusingtheservicecontainer,youcancreateanewfairlyeasilyfrominsideacontroller:这方法很好,但是如果你稍后又决定eslttManger需要添加第二个或第三个构造器参数呢?如果你决定重构你的代码,重命名这个类呢?两种情况,你都需要找到esltteMangr实例化的地方修改它。当然,服务容器给了你一个更吸引人的选项:Thisapproachisfine,butwhatifyoudecidelaterthattheclassneedsasecondorthirdconstructorargument?Whatifyoudecidetorefactoryourcodeandrenametheclass?Inbothcases,you'dneedtofindeverycewheretheisinstantiatedandmodifyit.Ofcourse,theservicecontainergivesyouamuchmoreappealingoption:InYAML,thespecial lsthecontainertolookforaservicenamed passthatobjectintotheconstructorof.Inthiscase,however,thespecified mustexist.Ifitdoesnot,anexceptionwillbethrown.Youcanmarkyourdependenciesasoptional-thiswillbediscussedinthenextsection.使用标注是非常强大的工具,它允许你创建独立的有明确依赖关系的服务类。在这个例子里,nesletr_mnager服务需要my_mlr服务提供的功能。当你在服务容器定义了这个依赖关系,容器会注意这个类在实例化过程中得全部工作。well-defineddependencies.Inthisexample,theservice serviceinordertofunction.Whenyoudefinethisdependencyintheservicecontainer,thecontainertakescareofalltheworkofinstantiatingtheclasses.UsingtheExpressionLanguageTheservicecontaineralsosupportsan"expression"thatallowsyoutoinjectveryspecificvaluesintoaservice.例如,假设你有一个第服务(这里不展示),叫做mir_confguraon,它包含一个getalerMehod()方法,基于一些配置它将返回一个字符串,类似sendml。记住y_malr服务的首个参数是一个简单地字符串sndmal:Forexample,supposeyouhaveathirdservice(notshownhere),called,whichhasamethodonit,whichwillreturnastringlike basedonsomeconfiguration.Rememberthatthefirstargumenttothe serviceisthesimple Butinsteadofhardcodingthis,howcouldwegetthisvaluefromtheofthenewservice?Onewayistouseanexpression:要学习更多关于表示语言的语法,请看TheExpressionInthiscontext,youhaveaccessto2 Youalsohaveaccessto via Expressionscanbeusedin ,asargumentswithandasarguments (methodcalls).OptionalDependencies:SetterInjectionInjectingdependenciesintotheconstructorinthismannerisanexcellentwayofensuringthatthedependencyisavailabletouse.Ifyouhaveoptionaldependenciesforaclass,then"setterinjection"maybeabetteroption.Thismeansinjectingthedependencyusingamethodcallratherthanthroughtheconstructor.Theclasswouldlooklikethis:InjectingthedependencybythesettermethodjustneedsachangeofTheapproachespresentedinthissectionarecalled"constructorinjection"and"setterinjection".TheSymfonyservicecontaineralsosupports"propertyinjection".InjectingtheRequest在Symfony2.4,不在注射request服务,代替为注射request_stack服务,并用呼叫AsofSymfony2.4,insteadofinjecting service,youshouldtheserviceandaccess bycallingtheNow,justinjectthe,whichbehaveslikeanynormal 器。详见TheRequestasaControllerArgumentWhynotInjecttherequestAlmostallSymfony2built-inservicesbehaveinthesameway:asingleinstanceiscreatedbythecontainerwhichitreturnswheneveryougetitorwhenitisinjectedintoanotherservice.ThereisoneexceptioninastandardSymfony2application:the Ifyoutrytoinjectthe aexception.That'sbecausethe thelife-timeofacontainer(whenasub-requestiscreatedforinstance).Ifyoudefineacontrollerasaservicethenyoucangetthe objectwithoutinjectingthecontainerbyhavingitpassedinasanargumentofyouractionmethod.SeeTheRequestasaControllerArgumentfordetails.MakingReferencesoptional有时,你某个服务可能有一个任选的依赖,这意味着这个依赖并不能使你的服务正常的工作。在上班的例子里,my_maer服务必须存在,否则会抛出一个异常。通过修改nesette_managerSometimes,oneofyourservicesmayhaveanoptionaldependency,meaningthatthedependencyisnotrequiredforyourservicetoworkproperly.Intheexampleabove,the servicemustexist,otherwiseanexceptionwillbethrown.Bymodifyingtheservicedefinition,youcanmakethisreferenceoptional.Thecontainerwilltheninjectitifitexistsanddonothingifitdoesn't:InYAML,thespecial syntaxlstheservicecontainerthatthedependencyisoptional.Ofcourse,themustalsoberewrittentoallowforanoptionalCoreSymfonyandThird-PartyBundleServices因为Symfony和全部第bunde通过容器进行配置和接收服务,你可以轻易的进入它们,甚至在你自己的服务里使用它们。简化事物,默认Symfony不需要控制器被定义为服务。然而,Symfony注射整个服务容器到你的控制器里。例如,为了处理用户sesson的信息,Symfony提供一个sesson服务,通过如下在一个标准控制器里就可以进入它:SinceSymfonyandallthird-partybundlesconfigureandretrievetheirservicesviathecontainer,youcaneasilyaccessthemorevenusetheminyourownservices.Tokeepthingssimple,Symfonybydefaultdoesnotrequirethatcontrollersbedefinedasservices.Furthermore,Symfonyinjectstheentireservicecontainerintoyourcontroller.Forexample,tohandlethestorageofinformationonauser'ssession,Symfonyprovides service,whichyoucanaccessinsideastandardcontrollerasfollows:在Symfony,你将经常使用Symfony或者第bundle提供的服务完成各种任务,诸如渲染模板,InSymfony,you'llconstantlyuseservicesprovidedbytheSymfonycoreorotherthird-partybundlestoperformtaskssuchasrenderingtemtes( ),sendings( ),oraccessinginformationontherequest( Symfonymailer服务(代替之前的my_mailer)。也可以将模板引擎服务传给NewsletterManager,让它能够通Youcantakethisastepfurtherbyusingtheseservicesinsideservicesthatyou'vecreatedforyourapplication.BeginningbymodifyingthetousetherealSym

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论