M
M
magary42017-02-17 16:36:03
symfony
magary4, 2017-02-17 16:36:03

Defening configuration as a service?

configuration like this symfony.com/doc/current/components/config/definiti... when key-value is not enough
and I did

class  DownloadMap {

    private static $filter = [
        "key"   => "category",
        "field" => "property__category__multi_string"
    ];

    private static $order = [
        [
            "key"   => "name",
            "field" => "name"
        ],
        [
            "key"   => "format",
            "field" => "control__mimeType__string"
        ],
        [
            "key"   => "size",
            "field" => "control__fileSize__string"
        ]
    ];

    public static function getFilter()
    {
        return self::$filter;
    }

    public static function getOrder()
    {
        return self::$order;
    }
}

well, in the controller, the call to DownloadMap::getOrder(),
but what if you need to override it in the next project? or rather, not "what if" but really need to be
shoved into the service container?
parameters:
    download_map_class: namespace\DownloadMap
services:
    download_map:
        class: %download_map_class%

crooked or not?
$this->container->get("download_map")->getOrder()
how can i do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2017-02-21
@prototype_denis

Why do you need this class at all?
Throw everything into the parameters.yml.dist application parameters Keep it
simple and everything will be fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question