This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
AbstractFactory consistency #4364
Merged
ralphschindler
merged 10 commits into
zendframework:develop
from
weierophinney:hotfix/abstract-manager-prefix-removal
Apr 30, 2013
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3759507
Removed prefix requirement from session containers
weierophinney 5c51516
Session Container configuration key is configurable
weierophinney 8077acc
Remove prefix requirement from Logger abstract factory
weierophinney b503a74
Remove Cache prefix in cache abstract factory
weierophinney 8231aef
Remove service prefix requirement from form abstract factory
weierophinney a728a97
Make abstract factories consistent
weierophinney adae4d7
Rename abstract factories for consistency
weierophinney dbcd397
Ensure DB abstract factory is in line with others
weierophinney 7285654
CS fixes
weierophinney e928062
Fix CS issue in unrelated component
weierophinney File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
59 changes: 0 additions & 59 deletions
59
library/Zend/Cache/Service/StorageCacheAbstractFactory.php
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Cache\Service; | ||
|
||
use Zend\Cache\StorageFactory; | ||
use Zend\ServiceManager\AbstractFactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* Storage cache factory for multiple caches. | ||
*/ | ||
class StorageCacheAbstractServiceFactory implements AbstractFactoryInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Configuration key for cache objects | ||
* | ||
* @var string | ||
*/ | ||
protected $configKey = 'caches'; | ||
|
||
/** | ||
* @param ServiceLocatorInterface $services | ||
* @param string $name | ||
* @param string $requestedName | ||
* @return bool | ||
*/ | ||
public function canCreateServiceWithName(ServiceLocatorInterface $services, $name, $requestedName) | ||
{ | ||
$config = $this->getConfig($services); | ||
if (empty($config)) { | ||
return false; | ||
} | ||
|
||
return (isset($config[$requestedName]) && is_array($config[$requestedName])); | ||
} | ||
|
||
/** | ||
* @param ServiceLocatorInterface $services | ||
* @param string $name | ||
* @param string $requestedName | ||
* @return \Zend\Cache\Storage\StorageInterface | ||
*/ | ||
public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName) | ||
{ | ||
$config = $this->getConfig($services); | ||
$config = $config[$requestedName]; | ||
return StorageFactory::factory($config); | ||
} | ||
|
||
/** | ||
* Retrieve cache configuration, if any | ||
* | ||
* @param ServiceLocatorInterface $services | ||
* @return array | ||
*/ | ||
protected function getConfig(ServiceLocatorInterface $services) | ||
{ | ||
if ($this->config !== null) { | ||
return $this->config; | ||
} | ||
|
||
if (!$services->has('Config')) { | ||
$this->config = array(); | ||
return $this->config; | ||
} | ||
|
||
$config = $services->get('Config'); | ||
if (!isset($config[$this->configKey])) { | ||
$this->config = array(); | ||
return $this->config; | ||
} | ||
|
||
$this->config = $config[$this->configKey]; | ||
return $this->config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to create a new subnamespace? ->
Zend\Form\Service\FormAbstractFactory
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Because the FormElementManager is already in the component root namespace, it makes no sense to create a new subnamespace. If we'd anticipated multiple SM-related factories originally, yes.