简体   繁体   English

从App.php调用数据模型

[英]Calling Data Model from App.php

Is there a way I can make a call to a data function function within app.php? 有没有办法在app.php中调用数据函数函数?

The function I am trying to call is located at src/Project/Model/Data/ImportData.php 我试图调用的函数位于src / Project / Model / Data / ImportData.php

Currently the variable is set like so (coming from parameters.yml): 目前变量设置如此(来自parameters.yml):

$app['active_import_id'] = $config['parameters']['active_import_id'];

What I am trying to do: 我想做什么:

$app['active_import_id'] = $myDataModel->myDataFunction();

The application was not initialized, I got it working once I added the code below. 应用程序没有初始化,我在下面添加代码后得到了它。

$myDataModel = $app['project.my_import_data_model'];
$app['active_import_id'] = $myDataModel->getActiveImportId();

I placed this code after all the providers had been registered. 我在所有提供商注册后都放置了此代码。 Hope this helps someone. 希望这有助于某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM