1 | <?php |
||
24 | abstract class AbstractAdapterFactory implements AdapterFactoryInterface |
||
25 | { |
||
26 | protected static $dependencies = []; |
||
27 | |||
28 | /** |
||
29 | * @param array $config |
||
30 | * |
||
31 | * @return CacheItemPoolInterface |
||
32 | */ |
||
33 | abstract protected function getAdapter(array $config); |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 3 | public function createAdapter(array $options = []) |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 6 | public static function validate(array $options, $adapterName) |
|
72 | |||
73 | /** |
||
74 | * Make sure that we have the required class and throw and exception if we don't. |
||
75 | * |
||
76 | * @throws \LogicException |
||
77 | */ |
||
78 | 6 | protected static function verifyDependencies() |
|
79 | { |
||
80 | 6 | foreach (static::$dependencies as $dependency) { |
|
81 | 6 | if (!class_exists($dependency['requiredClass'])) { |
|
82 | throw new \LogicException( |
||
83 | sprintf( |
||
84 | 'You must install the "%s" package to use the "%s" factory.', |
||
85 | $dependency['packageName'], |
||
86 | static::class |
||
87 | ) |
||
88 | ); |
||
89 | } |
||
90 | } |
||
91 | 6 | } |
|
92 | |||
93 | /** |
||
94 | * By default we do not have any options to configure. A factory should override this function and confgure |
||
95 | * the options resolver. |
||
96 | * |
||
97 | * @param OptionsResolver $resolver |
||
98 | */ |
||
99 | 6 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
102 | } |
||
103 |