private function createResourcesWidget() { $this->log('Creating resources_widget widget...'); $roles = $this->om->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles(); $widget = new Widget(); $widget->setName('resources_widget'); $widget->setConfigurable(true); $widget->setPlugin(null); $widget->setExportable(false); $widget->setDisplayableInDesktop(true); $widget->setDisplayableInWorkspace(true); foreach ($roles as $role) { $widget->addRole($role); } $this->om->persist($widget); $this->om->flush(); }
/** * Loads the core widgets. * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $roles = $manager->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles(); //name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace $items = [['core_resource_logger', true, true, true], ['simple_text', true, true, true], ['my_workspaces', false, true, false], ['my_profile', false, true, false], ['resources_widget', true, true, true]]; foreach ($items as $item) { $widget = new Widget(); $widget->setName($item[0]); $widget->setConfigurable($item[1]); $widget->setPlugin(null); $widget->setExportable(false); $widget->setIsDisplayableInDesktop($item[2]); $widget->setIsDisplayableInWorkspace($item[3]); foreach ($roles as $role) { $widget->addRole($role); } $manager->persist($widget); } }
/** * @param array $widgetConfiguration * @param Plugin $plugin * @param PluginBundle $pluginBundle */ private function createWidget($widgetConfiguration, Plugin $plugin, PluginBundle $pluginBundle, array $roles = array()) { $widget = new Widget(); foreach ($roles as $role) { $widget->addRole($role); } $this->persistWidget($widgetConfiguration, $plugin, $pluginBundle, $widget); }