/** * Bootstrap the module * * @param Application $application * @return void */ public static function bootstrap(Application $application) { $path = BASE_PATH . APP_URI; if ($path == '') { $path = '/'; } $cookie = Cookie::getInstance(['path' => $path]); if (isset($cookie->phire)) { $phire = (array) $cookie->phire; if (!isset($phire['fields_media_library'])) { $phire['fields_media_library'] = $application->module('phire-fields')->config()['media_library']; } $cookie->set('phire', $phire); } $modules = $application->modules(); $roles = \Phire\Table\Roles::findAll(); foreach ($roles->rows() as $role) { if (isset($modules['phire-fields']) && isset($modules['phire-fields']->config()['models']) && isset($modules['phire-fields']->config()['models']['Phire\\Model\\User']) && isset($modules['phire-fields']->config()['models']['Phire\\Model\\Role'])) { $models = $modules['phire-fields']->config()['models']; $models['Phire\\Model\\User'][] = ['type_field' => 'role_id', 'type_value' => $role->id, 'type_name' => $role->name]; $models['Phire\\Model\\Role'][] = ['type_field' => 'id', 'type_value' => $role->id, 'type_name' => $role->name]; $application->module('phire-fields')->mergeConfig(['models' => $models]); } } foreach ($modules as $module => $config) { if ($module != 'phire-fields' && isset($config['models'])) { $application->module('phire-fields')->mergeConfig(['models' => $config['models']]); } } }
/** * Determine if the module has been registered with an application object * * @return boolean */ public function isRegistered() { return null !== $this->application && null !== $this->application->modules() && $this->application->modules()->hasModule($this); }