/** * Create a repository to work with model of type $modelName (full namespaced name) * * @param string $modelName * * @return \Parable\ORM\Repository */ public function getRepository($modelName) { /** @var \Parable\ORM\Model $model */ $model = \Parable\DI\Container::create($modelName); /** @var \Parable\ORM\Repository $repository */ $repository = \Parable\DI\Container::create(\Parable\ORM\Repository::class); $repository->setModel($model); return $repository; }
/** * @return Query */ public static function createInstance() { return \Parable\DI\Container::create(static::class); }
protected function loadInits() { $locations = $this->config->get('initLocations'); if (!is_array($locations)) { return; } foreach ($locations as $location) { $directory = $this->path->getDir($location); if (!file_exists($directory)) { continue; } $dirIterator = new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS); $iteratorIterator = new \RecursiveIteratorIterator($dirIterator); foreach ($iteratorIterator as $file) { /** @var \SplFileInfo $file */ if ($file->getExtension() !== 'php') { continue; } $className = '\\Init\\' . str_replace('.' . $file->getExtension(), '', $file->getFilename()); \Parable\DI\Container::create($className); } } }