/** * 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 * @param Widget $widget */ private function persistWidget($widgetConfiguration, Plugin $plugin, PluginBundle $pluginBundle, Widget $widget, $withDisplay = true) { $widget->setName($widgetConfiguration['name']); $widget->setConfigurable($widgetConfiguration['is_configurable']); $widget->setExportable($widgetConfiguration['is_exportable']); $widget->setPlugin($plugin); $widget->setDefaultWidth($widgetConfiguration['default_width']); $widget->setDefaultHeight($widgetConfiguration['default_height']); if ($withDisplay) { $widget->setIsDisplayableInDesktop($widgetConfiguration['is_displayable_in_desktop']); $widget->setIsDisplayableInWorkspace($widgetConfiguration['is_displayable_in_workspace']); } $this->em->persist($widget); }