本文整理汇总了PHP中Zend\ServiceManager\AbstractPluginManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPluginManager::get方法的具体用法?PHP AbstractPluginManager::get怎么用?PHP AbstractPluginManager::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ServiceManager\AbstractPluginManager
的用法示例。
在下文中一共展示了AbstractPluginManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @inheritdoc
*
* @param string $name
* @param array $options
* @param bool $usePeeringServiceManagers
* @return JobInterface
*/
public function get($name, $options = [], $usePeeringServiceManagers = true)
{
// parent::get calls validatePlugin() so we're sure $instance is a JobInterface
$instance = parent::get($name, $options, $usePeeringServiceManagers);
$instance->setMetadata('__name__', $name);
return $instance;
}
示例2: get
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
$plugin = parent::get($name, $options, $usePeeringServiceManagers);
$plugin->setConfig($this->getConfig()->{$name});
$plugin->setObjectManager($this->getObjectManager());
return $plugin;
}
示例3: get
/**
* Override: do not use peering service managers
*
* @param string $name
* @param array $options
* @param bool $usePeeringServiceManagers
* @return mixed
*/
public function get($name, $options = [], $usePeeringServiceManagers = false)
{
if (is_string($options)) {
$options = ['class_name' => $options];
}
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例4: get
/**
* Retrieve a registered instance
*
* After the plugin is retrieved from the service locator, inject the
* controller in the plugin every time it is requested. This is required
* because a controller can use a plugin and another controller can be
* dispatched afterwards. If this second controller uses the same plugin
* as the first controller, the reference to the controller inside the
* plugin is lost.
*
* @param string $name
* @param mixed $options
* @param bool $usePeeringServiceManagers
* @return mixed
*/
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
$plugin = parent::get($name, $options, $usePeeringServiceManagers);
$this->injectController($plugin);
return $plugin;
}
示例5: hydrate
/**
* Converts the given value so that it can be hydrated by the hydrator.
*
* @param mixed $value The original value.
* @param array $data (optional) The original data for context.
* @return mixed Returns the value that should be hydrated.
*/
public function hydrate($value)
{
if ($value instanceof StateInterface) {
return $value;
}
if (is_string($value)) {
if ($this->checkPlugin() && $this->plugins->has($value)) {
return $this->plugins->get($value);
}
throw new \RuntimeException(sprintf('No service registered in %s with name %s', is_object($this->plugins) ? get_class($this->plugins) : gettype($this->plugins), $value));
}
if (empty($value) && $this->checkPlugin() && $this->plugins->has($this->firstStateName)) {
return $this->plugins->has($this->firstStateName);
}
// FIXME is correct? or exception
return $value;
}
示例6: get
/**
* Override get to inject options as PatternOptions instance.
*
* {@inheritDoc}
*/
public function get($plugin, array $options = [], $usePeeringServiceManagers = true)
{
if (empty($options)) {
return parent::get($plugin, [], $usePeeringServiceManagers);
}
$plugin = parent::get($plugin, [], $usePeeringServiceManagers);
$plugin->setOptions(new Pattern\PatternOptions($options));
return $plugin;
}
示例7: get
/**
* {@inheritDoc}
*/
public function get($name, $options = [], $usePeeringServiceManagers = true)
{
try {
$instance = parent::get($name, $options, $usePeeringServiceManagers);
} catch (ServiceNotFoundException $e) {
$instance = new Fallback();
$instance->setServiceLocator($this->getServiceLocator());
}
return $instance;
}
示例8: get
/**
* {@inheritDoc}
*/
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
$formElementManager = $this->getServiceLocator()->get('FormElementManager');
if ($formElementManager->has($name)) {
$form = $formElementManager->get($name);
if ($form instanceof FormInterface) {
return $form;
}
}
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例9: get
/**
* Retrieve a service from the manager by name
*
* Allows passing an array of options to use when creating the instance.
* createFromInvokable() will use these and pass them to the instance
* constructor if not null and a non-empty array.
*
* @param string $name
* @param array $options
* @param bool $usePeeringServiceManagers
* @return object
* @throws InvalidPluginException
*/
public function get($name, $options = [], $usePeeringServiceManagers = true)
{
// If service not registered check the the Service Locator.
if (!$this->has($name)) {
return $this->getServiceLocator()->get($name);
}
if (isset($options['initialize'])) {
$this->initialize = $options['initialize'];
unset($options['initialize']);
}
$instance = parent::get($name, $options, $usePeeringServiceManagers);
$this->validatePlugin($instance);
return $instance;
}
示例10: get
/**
* Retrieve a service from the manager by name
*
* Allows passing an array of options to use when creating the instance.
* createFromInvokable() will use these and pass them to the instance
* constructor if not null and a non-empty array.
*
* @param string $name
* @param string|array $options
* @param bool $usePeeringServiceManagers
* @return object
*/
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
if (is_string($options)) {
$options = array('name' => $options);
}
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例11: get
/**
* {@inheritDoc}
*/
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
return parent::get($name, $options, false);
// Don't look in peering service managers
}
示例12: get
/**
* Override: do not use peering service manager to retrieve controller
*
* @param string $name
* @param array $options
* @param bool $usePeeringServiceManagers
* @return mixed
*/
public function get($name, $options = array(), $usePeeringServiceManagers = false)
{
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例13: get
/**
* {@inheritDoc}
*
* @return AbstractPlugin
*/
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
if (empty($options['name'])) {
$options['name'] = $name;
}
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例14: get
public function get($name, $options = [], $usePeeringServiceManagers = true)
{
$this->incrementCallCount('get', $name, $options);
return parent::get($name, $options, $usePeeringServiceManagers);
}
示例15: get
/**
* Retrieve a registered instance
*
* After the plugin is retrieved from the service locator, inject the
* controller in the plugin every time it is requested. This is required
* because a controller can use a plugin and another controller can be
* dispatched afterwards. If this second controller uses the same plugin
* as the first controller, the reference to the controller inside the
* plugin is lost.
*
* @param string $name
* @return DispatchableInterface
*/
public function get($name, array $options = null)
{
$plugin = parent::get($name, $options);
$this->injectController($plugin);
return $plugin;
}