Function to get file from store
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Function to get file from store
hello,
i have created a helper file in laravel project with this function that return the file from store like this:
My question is there a sample why to optimize this function because i have instanciate another object maybe there is already existing one . i have tried like this but not working:
i have created a helper file in laravel project with this function that return the file from store like this:
Code: Select all
function file_from_store($path): string
{
$context = app('aimeos.context')->get();
$config = $context->getConfig();
$baseUrl = $config->get('resource/fs/baseurl');
$view = new \Aimeos\MW\View\Standard();
$view->addHelper('encoder', new \Aimeos\MW\View\Helper\Encoder\Standard($view));
$view->addHelper('content', new \Aimeos\MW\View\Helper\Content\Standard($view, $baseUrl));
return $view->encoder()->attr($view->content($baseUrl . '/' . $path));
}
Code: Select all
$view = app('aimeos.view')->get();
$context = app('aimeos.context')->get();
$config = $context->getConfig();
$baseUrl = $config->get('resource/fs/baseurl');
return $view->encoder()->attr($view->content($baseUrl . '/' . $path));
Re: Function to get file from store
Normally, something like this should work:
Code: Select all
function file_from_store($path): string
{
$view = app('aimeos.view')->get();
return $view->encoder()->attr($view->content$path));
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Function to get file from store
i get an exception with get(), i searched in project i have found view object is instantieted like this:
app( 'aimeos.view' )->create( $context, $tmplPaths, $langid ) ?
app( 'aimeos.view' )->create( $context, $tmplPaths, $langid ) ?
Re: Function to get file from store
You are right, in then it's:
Code: Select all
function file_from_store( $path ): string
{
$context = app('aimeos.context')->get();
$langId = $context->getLocale()->getLanguageId();
$paths = app('aimeos')->get()->getCustomPaths( 'client/html/templates' );
$view = app('aimeos.view')->create( $context, $paths, $langId );
return $view->encoder()->attr( $view->content( $path ) );
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Function to get file from store
Yeh Great it work as expected, thank you 
