In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use Resources, the resource of Zend Framework. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The details are as follows:
Zend_Application_Resource_Resource
Zend_Application_Bootstrap_ResourceBootstrapper is the interface used by the bootstrap class to load the registered resource plug-in.
Zend_Application_Resource_Resource is a resource plug-in interface.
Zend_Application_Resource_Resource is often used in bootstrap classes that implement Zend_Application_Bootstrap_ResourceBootstrapper.
A resource plug-in is an interface that is configurable, preloaded, and can initialize resources through policy mode.
Zend_Application_Resource_Resource Interface
MethodReturn ValueParametersDescription__construct ($options = null) Void$options: optional. Allocate resources.
SetBootstrap (Zend_Application_Bootstrap_Bootstrapper $bootstrap) Zend_Application_Resource_Resource$bootstrap: required. Initialize the parent pilot class of the resource
GetBootstrap () Zend_Application_Bootstrap_BootstrapperN/A
SetOptions (array $options) Zend_Application_Resource_Resource$options: required. Configuration options.
GetOptions () ArrayN/A
Init () MixedN/An adopts policy mode: run, initialize resources.
Zend_Application_Resource_ResourceAbstract
Zend_Application_Resource_ResourceAbstract is an abstract class that implements the Zend_Application_Resource_Resource interface and provides a convenient way to create custom plug-in resources.
Note: this abstract class does not implement the init () method. You can inherit and use this abstract class to customize the implementation of the init method.
Zend_Application_Resource_ResourceAbstract Methods
MethodReturn ValueParametersDescription__construct ($options = null) Void$options: optional. Allocation of resources
SetBootstrap (Zend_Application_Bootstrap_Bootstrapper $bootstrap) Zend_Application_Resource_ResourceAbstract$bootstrap: required.
GetBootstrap () Zend_Application_Bootstrap_BootstrapperN/A
SetOptions (array $options) Zend_Application_Resource_ResourceAbstract$options: required.
GetOptions () ArrayN/A
Resource name
One problem that arises when registering plug-in resources is how you should boot the class from the parent. There are three different mechanisms that can be used, depending on how you configure the boot and its plug-in resources.
First, if your plug-in name definition contains a prefix path, you can use their "short name"-that is, part of the class name. For example, the short name of the class "Zend_Application_Resource_View" is "View" if the prefix path "Zend_Application_Resource" is registered. You may register them with the full or short name of the class:
$app = new Zend_Application (APPLICATION_ENV, array ('pluginPaths' = > array (' My_Resource' = > 'My/Resource/',),' resources' = > array (/ / if the following class exists: 'My_Resource_View' = > array (), / / then this is equivalent:' View' = > array (),)
You can later use short names to guide resources and get:
$bootstrap- > bootstrap ('view'); $view = $bootstrap- > getResource (' view')
Second, if there is no matching definition of the plug-in path, you may still use the full name of the resource class. In this case, you can refer to the full class name of the resource used as follows:
$app = new Zend_Application (APPLICATION_ENV, array ('resources' = > array (/ / This will load the standard' View' resource: 'View' = > array (), / / While this loads a resource with a specific class name:' My_Resource_View' = > array (),)
Guide resources and how to get them
$bootstrap- > bootstrap ('My_Resource_View'); $view = $bootstrap- > getResource (' My_Resource_View')
This gives us a third option. You can specify an explicit name to register yourself as a given resource class. This allows you to increase the string value of public $_ explicitType through the resource plug-in class, which will be used to specify the boot plug-in resource. As an example, let's define our own view class:
Class My_Resource_View extends Zend_Application_Resource_ResourceAbstract {public $_ explicitType = 'My_View'; public function init () {/ / do some initialization... }}
We can then guide the resource or get it through its name "My_View":
$bootstrap- > bootstrap ('My_View'); $view = $bootstrap- > getResource (' My_View')
You can use these different naming methods to overwrite existing resources, add your own, mix I with multiple resources, to achieve complex initialization, and so on.
This is the end of the article on "how to use Resources, the resource of Zend Framework". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 297
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.