services:

##############
### ENGINE ###
##############

    engine:
        alias: phantomjs.engine

    phantomjs.engine:
        class: "%phantomjs.engine.class%"

##################
### PROCEDURES ###
##################

    procedure_loader:
        alias: phantomjs.procedure.chain_loader

    procedure_validator:
        alias: phantomjs.procedure.procedure_validator

    procedure_compiler:
        alias: phantomjs.procedure.procedure_compiler

    procedure_loader_factory:
        alias: phantomjs.procedure.procedure_loader_factory

    phantomjs.procedure.file_locator:
        class: "%phantomjs.loader.file_locator.class%"
        arguments:
            - "%phantomjs.procedure_dir%"
        public: false

    phantomjs.procedure.procedure_loader:
        class: "%phantomjs.procedure.procedure_loader.class%"
        arguments:
            - "@phantomjs.procedure.procedure_factory"
            - "@phantomjs.procedure.file_locator"
        public: false

    phantomjs.procedure.chain_loader:
        class: "%phantomjs.procedure.chain_loader.class%"
        arguments:
            - [ "@phantomjs.procedure.procedure_loader" ]
        public: false

    phantomjs.procedure.procedure_factory:
        class: "%phantomjs.procedure.procedure_factory.class%"
        arguments:
            - "@engine"
            - "@phantomjs.parser.json_parser"
            - "@phantomjs.cache.file_cache"
            - "@phantomjs.template.template_renderer"
        public: false

    phantomjs.procedure.procedure_loader_factory:
        class: "%phantomjs.procedure.procedure_loader_factory.class%"
        arguments:
            - "@phantomjs.procedure.procedure_factory"
        public: false

    phantomjs.procedure.procedure_compiler:
        class: "%phantomjs.procedure.procedure_compiler.class%"
        arguments:
            - "@procedure_loader"
            - "@procedure_validator"
            - "@phantomjs.cache.file_cache"
            - "@phantomjs.procedure.template_renderer"
        public: false

    phantomjs.procedure.procedure_validator:
        class: "%phantomjs.procedure.procedure_validator.class%"
        arguments:
            - "@procedure_loader"
            - "@validator"
        public: false

############
### HTTP ###
############

    message_factory:
        alias: phantomjs.http.message_factory

    phantomjs.http.message_factory:
        class: "%phantomjs.http.message_factory.class%"
        public: false

################
### PARSING ####
################

    phantomjs.parser.json_parser:
        class: "%phantomjs.parser.json_parser.class%"
        public: false

###################
### VALIDATION ####
###################

    validator:
        alias: phantomjs.validator.esprima

    phantomjs.validator.file_locator:
        class: "%phantomjs.loader.file_locator.class%"
        arguments:
            - "%phantomjs.validator_dir%"
        public: false

    phantomjs.validator.esprima:
        class: "%phantomjs.validator.esprima.class%"
        arguments:
            - "@phantomjs.validator.file_locator"
            - "%phantomjs.validator_engine%"
        public: false

##################
### TEMPLATES ####
##################

    phantomjs.template.template_renderer:
        class: "%phantomjs.template.template_renderer.class%"
        arguments:
            - "@phantomjs.twig.environment"
        public: false

    phantomjs.twig.environment:
        class: "%phantomjs.twig.environment.class%"
        arguments:
            - "@phantomjs.twig.array_loader"
        public: false

    phantomjs.twig.array_loader:
        class: "%phantomjs.twig.array_loader.class%"
        arguments:
            - []
        public: false

    phantomjs.procedure.template_renderer:
        class: "%phantomjs.template.template_renderer.class%"
        arguments:
            - "@phantomjs.procedure.twig.environment"
        public: false

    phantomjs.procedure.twig.environment:
        class: "%phantomjs.twig.environment.class%"
        arguments:
            - "@phantomjs.twig.array_loader"
        public: false
        calls:
            - [ "setLexer", [ "@phantomjs.procedure.twig.lexer" ] ]

    phantomjs.procedure.twig.lexer:
        class: "%phantomjs.twig.lexer.class%"
        arguments:
            - "@phantomjs.procedure.twig.environment"
            - { tag_variable: [ "[[", "]]" ], tag_comment: [ "[#", "#]" ], tag_block:  [ "[%", "%]" ], interpolation:  [ "#[", "]" ] }
        public: false

##################
### RESOURCES ####
##################

    phantomjs.cache.file_cache:
        class: "%phantomjs.cache.file_cache.class%"
        arguments:
            - "%phantomjs.cache_dir%"
            - "%phantomjs.procedure_extension%"
        public: false
