diff --git a/phalcon/Annotations/AnnotationsFactory.zep b/phalcon/Annotations/AnnotationsFactory.zep index 5cb8b114fd5..dc10c56c779 100644 --- a/phalcon/Annotations/AnnotationsFactory.zep +++ b/phalcon/Annotations/AnnotationsFactory.zep @@ -66,9 +66,7 @@ class AnnotationsFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Cache/AdapterFactory.zep b/phalcon/Cache/AdapterFactory.zep index cb88c1d5217..7f9baf13f5b 100644 --- a/phalcon/Cache/AdapterFactory.zep +++ b/phalcon/Cache/AdapterFactory.zep @@ -63,9 +63,7 @@ class AdapterFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Config/ConfigFactory.zep b/phalcon/Config/ConfigFactory.zep index 89532b5e666..ea447c53d9c 100644 --- a/phalcon/Config/ConfigFactory.zep +++ b/phalcon/Config/ConfigFactory.zep @@ -115,9 +115,7 @@ class ConfigFactory extends AbstractFactory { var definition, options; - this->checkService(name); - - let definition = this->mapper[name], + let definition = this->getService(name), options = [], options[] = fileName; diff --git a/phalcon/Db/Adapter/PdoFactory.zep b/phalcon/Db/Adapter/PdoFactory.zep index bf4a2d7badb..da3dfc0e2fe 100644 --- a/phalcon/Db/Adapter/PdoFactory.zep +++ b/phalcon/Db/Adapter/PdoFactory.zep @@ -62,9 +62,7 @@ class PdoFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Factory/AbstractFactory.zep b/phalcon/Factory/AbstractFactory.zep index 2e659736292..c28b1c8dcd5 100644 --- a/phalcon/Factory/AbstractFactory.zep +++ b/phalcon/Factory/AbstractFactory.zep @@ -24,16 +24,6 @@ abstract class AbstractFactory */ protected services = []; - /** - * Checks if a service exists and throws an exception - */ - protected function checkService(string! name) -> void - { - if unlikely !isset this->mapper[name] { - throw new Exception("Service " . name . " is not registered"); - } - } - /** * Checks the config if it is a valid object */ @@ -63,6 +53,18 @@ abstract class AbstractFactory */ abstract protected function getAdapters() -> array; + /** + * Checks if a service exists and throws an exception + */ + protected function getService(string! name) -> var + { + if unlikely !isset this->mapper[name] { + throw new Exception("Service " . name . " is not registered"); + } + + return this->mapper[name]; + } + /** * AdapterFactory constructor. */ diff --git a/phalcon/Html/TagFactory.zep b/phalcon/Html/TagFactory.zep index 0126e7f7894..7e1e98689a4 100644 --- a/phalcon/Html/TagFactory.zep +++ b/phalcon/Html/TagFactory.zep @@ -44,10 +44,8 @@ class TagFactory extends AbstractFactory { var definition; - this->checkService(name); - if !isset this->services[name] { - let definition = this->mapper[name], + let definition = this->getService(name), this->services[name] = create_instance_params( definition, [ diff --git a/phalcon/Image/ImageFactory.zep b/phalcon/Image/ImageFactory.zep index 8c57c823c5c..5b5e7e93795 100644 --- a/phalcon/Image/ImageFactory.zep +++ b/phalcon/Image/ImageFactory.zep @@ -73,9 +73,7 @@ class ImageFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Logger/AdapterFactory.zep b/phalcon/Logger/AdapterFactory.zep index 5ecb1dad9b3..29010d58af7 100644 --- a/phalcon/Logger/AdapterFactory.zep +++ b/phalcon/Logger/AdapterFactory.zep @@ -34,9 +34,7 @@ class AdapterFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Paginator/PaginatorFactory.zep b/phalcon/Paginator/PaginatorFactory.zep index 0abc54582ce..eb8ce2c7ddb 100644 --- a/phalcon/Paginator/PaginatorFactory.zep +++ b/phalcon/Paginator/PaginatorFactory.zep @@ -72,9 +72,7 @@ class PaginatorFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Storage/AdapterFactory.zep b/phalcon/Storage/AdapterFactory.zep index 7cac45a6339..c124ec4ce22 100644 --- a/phalcon/Storage/AdapterFactory.zep +++ b/phalcon/Storage/AdapterFactory.zep @@ -58,9 +58,7 @@ class AdapterFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Storage/SerializerFactory.zep b/phalcon/Storage/SerializerFactory.zep index bf3ead37a7a..54eb6162a5c 100644 --- a/phalcon/Storage/SerializerFactory.zep +++ b/phalcon/Storage/SerializerFactory.zep @@ -35,9 +35,7 @@ class SerializerFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance(definition); } diff --git a/phalcon/Translate/InterpolatorFactory.zep b/phalcon/Translate/InterpolatorFactory.zep index 609a214eebb..1f7feba579c 100644 --- a/phalcon/Translate/InterpolatorFactory.zep +++ b/phalcon/Translate/InterpolatorFactory.zep @@ -30,9 +30,7 @@ class InterpolatorFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance(definition); } diff --git a/phalcon/Translate/TranslateFactory.zep b/phalcon/Translate/TranslateFactory.zep index 39d6b128498..22c2a957b63 100644 --- a/phalcon/Translate/TranslateFactory.zep +++ b/phalcon/Translate/TranslateFactory.zep @@ -67,9 +67,7 @@ class TranslateFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance_params( definition, diff --git a/phalcon/Validation/ValidatorFactory.zep b/phalcon/Validation/ValidatorFactory.zep index ca7ef772b8a..8979d3e98a1 100644 --- a/phalcon/Validation/ValidatorFactory.zep +++ b/phalcon/Validation/ValidatorFactory.zep @@ -30,9 +30,7 @@ class ValidatorFactory extends AbstractFactory { var definition; - this->checkService(name); - - let definition = this->mapper[name]; + let definition = this->getService(name); return create_instance(definition); }