Creates container for storing export files.

@param string $resource Path to the file
@param string $key Configuration key prefix for the container type/format/options keys
@return MW_Container_Interface Container item
198943
protected function _createContainer( $resource, $key )
	{
		$config = $this->_getContext()->getConfig();

		$type = $config->get( $key . '/type', 'Zip' );
		$format = $config->get( $key . '/format', 'CSV' );
		$options = $config->get( $key . '/options', array() );

		return MW_Container_Factory::getContainer( $resource, $type, $format, $options );
	}
1209465
public function initContainer($container, $key = '')
    {
        if ($container instanceof Container) {
            $this->setContainer($container);
            $this->setLogger(
                $this->getContainer()->offsetGet(LoggerService::SERVICE_ID)->getLogger()
            );

            // @TODO: implemented because of the legacy, we will don't need it when we're using the container in every case.
            if (!empty($key)) {
                try {
                    return $this->getContainer()->offsetGet($key);
                } catch (\InvalidArgumentException $e) {
                }
            }

            return null;
        }

        return $container;
    }
1329728
protected function createItem(/*# string */ $key)/*# : CacheItemInterface */
    {
        // validate key first
        $this->validateKey($key);

        // use item factory
        if (is_callable($this->item_factory)) {
            $func = $this->item_factory;
            $item = $func($key, $this, $this->item_config);

        // default CacheItem class
        } else {
            $item = new CacheItem($key, $this, $this->item_config);
        }

        return $item;
    }
557505
public static function getMappings($resource, $key = 'default')
	{
		$resourceName = $resource;

		if( is_object($resource) )
		{
			$resourceName = get_class($resource);
		}

		$mappings = [];
		if( isset(self::$mappers[$key]) )
		{
			$mappings = array_merge_recursive( $mappings, call_user_func(self::$mappers[$key], $resourceName) );
		}

		if( isset(self::$mappings[$key]) && isset(self::$mappings[$key][$resourceName]) )
		{
			$mappings = array_merge_recursive( $mappings, (array) self::$mappings[$key][$resourceName] );
		}

		return $mappings;
	}
647690
protected function getKeyResource($key, $password = null)
    {
        if (is_resource($key)) {
            return $key;
        }

        $resource = openssl_pkey_get_public($key) ?: openssl_pkey_get_private($key, $password);
        if ($resource === false) {
            throw new RuntimeException('Could not read key resource: ' . openssl_error_string());
        }
        return $resource;
    }
1247944
public function actionExportDownload($key)
    {
        $sessionkey = Yii::$app->session->get('tempNgRestFileKey');
        $fileName = Yii::$app->session->get('tempNgRestFileName');
        $mimeType = Yii::$app->session->get('tempNgRestFileMime');
        
        if ($sessionkey !== base64_decode($key)) {
            throw new ForbiddenHttpException('Invalid download key.');
        }
    
        $content = FileHelper::getFileContent('@runtime/'.$sessionkey.'.tmp');
    
        Yii::$app->session->remove('tempNgRestFileKey');
        Yii::$app->session->remove('tempNgRestFileName');
        Yii::$app->session->remove('tempNgRestFileMime');
        @unlink(Yii::getAlias('@runtime/'.$sessionkey.'.tmp'));
    
        return Yii::$app->response->sendContentAsFile($content, $fileName, ['mimeType' => $mimeType]);
    }
1206891
private function configureResources(array $resources, ContainerBuilder $container)
    {
        $builder = new PoolBuilder($container);
        foreach ($resources as $prefix => $config) {
            foreach ($config as $resourceName => $parameters) {
                $builder
                    ->configure($prefix, $resourceName, $parameters)
                    ->build();
            }
        }
    }
1361145
public function getDataItemStreamWrapper(string $key): \BearFramework\App\IDataItemStreamWrapper
    {
        return new \BearFramework\App\FileDataItemStreamWrapper($key, $this->dir);
    }
1158850
protected function writeCsvContent($resource)
    {
        $columns    = $this->exportInfo->columns;
        $strategies = $this->getColumnStrategyInstances();

        $delimiter = $this->getDelimiterSymbol();
        $enclosure = $this->getEnclosureSymbol();
        $escape    = $this->getEscapeSymbol();


        // Generate header row, if not disabled
        if ($this->shouldHaveHeaderRow()) {

            $headers = array_map(
                function (ModelExportColumnDataInterface $column) {
                    return $column->header();
                },
                $columns
            );

            fputcsv($resource, $headers, $delimiter, $enclosure, $escape);
        }

        // For each query chunk: get a model instance,
        // and for each column, generate the column content using the strategies
        $this->query->chunk(
            static::CHUNK_SIZE,
            function ($records) use ($resource, $columns, $strategies, $delimiter, $enclosure, $escape) {
                /** @var Collection|Model[] $records */

                foreach ($records as $record) {

                    $fields = [];

                    foreach ($strategies as $key => $strategy) {
                        $fields[] = $strategy->render($record, $columns[$key]->source);
                    }

                    fputcsv($resource, $fields, $delimiter, $enclosure, $escape);
                }
            }
        );
    }
968198
public function appendResource($resource) {
		$resource = $this->handleResource($resource);
		
		$this->resources[] = $resource;
		return $resource;
	}
252823
protected function buildKey($key)
    {
        return $this->aerospike->initKey(
            $this->config['namespace'],
            $this->config['set'],
            $this->config['prefix'] . $key
        );
    }
1241707
protected function import(string $key)
    {
        $container = JinitializeContainer::getInstance();
        return $container->getPlugin($this->getPluginName())->getContainer()->get($key);
    }
905409
private function store($key, $data) 
    {
        $cachePath = $this->getCachePath($key);
        $cacheDir  = dirname($cachePath);
    
        if(!is_dir($cacheDir) && !@mkdir($cacheDir, 0755, true)) {
            throw new \wf\cache\Exception("Could not make cache directory");
        }
            
        if($this->isCompress && function_exists('gzdeflate') && function_exists('gzinflate')) {
            $data['value'] = gzdeflate($data['value']);
        }
        
        $text = "<?php\n# Auto generate by windwork cache engine,please don't edit me.\nreturn " . var_export($data, true) . ';';
        return @file_put_contents($cachePath, $text);
    }
1030537
public static function fromResource($resource) {
        $newImage = new self();
        try {
            $newImage->setResource($resource);
        } catch(\Exception $e) {
            throw new ImageException($e->getMessage(), ImageException::UnsupportedFormatException, $e);
        }
        return $newImage;
    }
1132460
public static function make(string $key, array $args = [], bool $protected = false)
    {
        return static::getContainer()->createSharedObject($key, $args, $protected);
    }
838578
private function generateSourceSeo($key)
    {
        if (isset($this->{$key})) {
            return $this->{$key};
        }

        $object = $this;
        foreach (explode('.', $key) as $segment) {
            if (!is_object($object) || !$tmp = $object->{$segment}) {
                return null;
            }

            $object = $object->{$segment};
        }

        return $object;
    }
139110
public function createStream( $resource )
	{
		if( is_resource( $resource ) === true ) {
			return new \Slim\Http\Stream( $resource );
		}

		if( ( $fh = @fopen( $resource, 'r' ) ) !== false ) {
			return new \Slim\Http\Stream( $fh );
		}

		throw new \Aimeos\MW\Exception( sprintf( 'Unable to open file "%1$s"', $resource ) );
	}