public function get_stores_for_definition(cache_definition $definition) {
        // Check if MUC has been disabled.
        $factory = cache_factory::instance();
        if ($factory->stores_disabled()) {
            // Yip its been disabled.
            // To facilitate this we are going to always return an empty array of stores to use.
            // This will force all cache instances to use the cachestore_dummy.
            // MUC will still be used essentially so that code using it will still continue to function but because no cache stores
            // are being used interaction with MUC will be purely based around a static var.
            return array();
        }

        $availablestores = $this->get_stores($definition->get_mode(), $definition->get_requirements_bin());
        $stores = array();
        $id = $definition->get_id();

        // Now get any mappings and give them priority.
        foreach ($this->configdefinitionmappings as $mapping) {
            if ($mapping['definition'] !== $id) {
                continue;
            }
            $storename = $mapping['store'];
            if (!array_key_exists($storename, $availablestores)) {
                continue;
            }
            if (array_key_exists($storename, $stores)) {
                $store = $stores[$storename];
                unset($stores[$storename]);
                $stores[$storename] = $store;
            } else {
                $stores[$storename] = $availablestores[$storename];
            }
        }

        if (empty($stores) && !$definition->is_for_mappings_only()) {
            $mode = $definition->get_mode();
            // Load the default stores.
            foreach ($this->configmodemappings as $mapping) {
                if ($mapping['mode'] === $mode && array_key_exists($mapping['store'], $availablestores)) {
                    $store = $availablestores[$mapping['store']];
                    if (empty($store['mappingsonly'])) {
                        $stores[$mapping['store']] = $store;
                    }
                }
            }
        }

        return $stores;
    }
public function get_stores_for_definition(cache_definition $definition) {
        // Check if MUC has been disabled.
        $factory = cache_factory::instance();
        if ($factory->stores_disabled()) {
            // Yip its been disabled.
            // To facilitate this we are going to always return an empty array of stores to use.
            // This will force all cache instances to use the cachestore_dummy.
            // MUC will still be used essentially so that code using it will still continue to function but because no cache stores
            // are being used interaction with MUC will be purely based around a static var.
            return array();
        }

        $availablestores = $this->get_stores($definition->get_mode(), $definition->get_requirements_bin());
        $stores = array();
        $id = $definition->get_id();

        // Now get any mappings and give them priority.
        foreach ($this->configdefinitionmappings as $mapping) {
            if ($mapping['definition'] !== $id) {
                continue;
            }
            $storename = $mapping['store'];
            if (!array_key_exists($storename, $availablestores)) {
                continue;
            }
            if (array_key_exists($storename, $stores)) {
                $store = $stores[$storename];
                unset($stores[$storename]);
                $stores[$storename] = $store;
            } else {
                $stores[$storename] = $availablestores[$storename];
            }
        }

        if (empty($stores) && !$definition->is_for_mappings_only()) {
            $mode = $definition->get_mode();
            // Load the default stores.
            foreach ($this->configmodemappings as $mapping) {
                if ($mapping['mode'] === $mode && array_key_exists($mapping['store'], $availablestores)) {
                    $store = $availablestores[$mapping['store']];
                    if (empty($store['mappingsonly'])) {
                        $stores[$mapping['store']] = $store;
                    }
                }
            }
        }

        return $stores;
    }
public function get_stores_for_definition ( cache_definition $ definition ) { // Check if MUC has been disabled. $ factory = cache_factory :: instance ( ) ; if ( $ factory -> stores_disabled ( ) ) { // Yip its been disabled. // To facilitate this we are going to always return an empty array of stores to use. // This will force all cache instances to use the cachestore_dummy. // MUC will still be used essentially so that code using it will still continue to function but because no cache stores // are being used interaction with MUC will be purely based around a static var. return array ( ) ; } $ availablestores = $ this -> get_stores ( $ definition -> get_mode ( ) , $ definition -> get_requirements_bin ( ) ) ; $ stores = array ( ) ; $ id = $ definition -> get_id ( ) ; // Now get any mappings and give them priority. foreach ( $ this -> configdefinitionmappings as $ mapping ) { if ( $ mapping [ 'definition' ] !== $ id ) { continue ; } $ storename = $ mapping [ 'store' ] ; if ( ! array_key_exists ( $ storename , $ availablestores ) ) { continue ; } if ( array_key_exists ( $ storename , $ stores ) ) { $ store = $ stores [ $ storename ] ; unset ( $ stores [ $ storename ] ) ; $ stores [ $ storename ] = $ store ; } else { $ stores [ $ storename ] = $ availablestores [ $ storename ] ; } } if ( empty ( $ stores ) && ! $ definition -> is_for_mappings_only ( ) ) { $ mode = $ definition -> get_mode ( ) ; // Load the default stores. foreach ( $ this -> configmodemappings as $ mapping ) { if ( $ mapping [ 'mode' ] === $ mode && array_key_exists ( $ mapping [ 'store' ] , $ availablestores ) ) { $ store = $ availablestores [ $ mapping [ 'store' ] ] ; if ( empty ( $ store [ 'mappingsonly' ] ) ) { $ stores [ $ mapping [ 'store' ] ] = $ store ; } } } } return $ stores ; }
Gets all of the stores that are to be used for the given definition.

@param cache_definition $definition
@return array
Gets all of the stores that are to be used for the given definition .