public init ( crudlex\DataFactoryInterface $dataFactory, string $crudFile, crudlex\FileProcessorInterface $fileProcessor, boolean $manageI18n, Pimple\Container $app ) | ||
$dataFactory | crudlex\DataFactoryInterface | the factory to create the concrete AbstractData instances |
$crudFile | string | the CRUD YAML file to parse |
$fileProcessor | crudlex\FileProcessorInterface | the file processor used for file fields |
$manageI18n | boolean | holds whether we manage the i18n |
$app | Pimple\Container | the application container |
public function init(DataFactoryInterface $dataFactory, $crudFile, FileProcessorInterface $fileProcessor, $manageI18n, Container $app)
{
$parsedYaml = $this->readYaml($crudFile);
$this->validateEntityDefinition($app, $parsedYaml);
$this->initMissingServiceProviders($app);
$this->manageI18n = $manageI18n;
$locales = $this->initLocales($app);
$this->datas = [];
foreach ($parsedYaml as $name => $crud) {
$definition = $this->createDefinition($app, $locales, $crud, $name);
$this->datas[$name] = $dataFactory->createData($definition, $fileProcessor);
}
$twigExtensions = new TwigExtensions();
$twigExtensions->registerTwigExtensions($app);
$this->initChildren();
}
public static function createServiceProvider($useUUIDs = false) { static::$fileProcessorHandle = Phony::mock('\\CRUDlex\\SimpleFilesystemFileProcessor'); static::$fileProcessorHandle->renderFile->returns('rendered file'); $fileProcessorMock = static::$fileProcessorHandle->get(); $app = static::createAppAndDB($useUUIDs); $crudServiceProvider = new ServiceProvider(); $dataFactory = new MySQLDataFactory($app['db'], $useUUIDs); $crudFile = __DIR__ . '/../crud.yml'; $crudServiceProvider->init($dataFactory, $crudFile, $fileProcessorMock, true, $app); return $crudServiceProvider; }