public function load(ObjectManager $manager) { $tools = array(array('home', 'home', false, false, true, true, true, false, false, false, false), array('parameters', 'cogs', false, false, true, true, false, false, false, true, true), array('resource_manager', 'folder-open', false, false, true, true, true, true, false, false, false), array('logs', 'list', false, false, true, false, false, false, false, false, true), array('analytics', 'bar-chart-o', false, false, true, false, false, false, false, false, true), array('users', 'user', true, false, true, false, false, false, false, false, true), array('my_contacts', 'users', false, false, false, true, false, false, false, false, true)); foreach ($tools as $tool) { $entity = new Tool(); $entity->setName($tool[0]); $entity->setClass($tool[1]); $entity->setIsWorkspaceRequired($tool[2]); $entity->setIsDesktopRequired($tool[3]); $entity->setDisplayableInWorkspace($tool[4]); $entity->setDisplayableInDesktop($tool[5]); $entity->setExportable($tool[6]); $entity->setIsConfigurableInWorkspace($tool[7]); $entity->setIsConfigurableInDesktop($tool[8]); $entity->setIsLockedForAdmin($tool[9]); $entity->setIsAnonymousExcluded($tool[10]); $manager->persist($entity); $this->createToolMaskDecoders($manager, $entity); $this->createPersonalWorkspaceToolConfig($manager, $entity); if ($tool[0] === 'parameters' || $tool[0] === 'resource_manager' || $tool[0] === 'my_contacts') { $this->createAdminOrderedTool($manager, $entity); } } $this->updatePersonalWorkspaceResourceRightsConfig($manager); $manager->flush(); }
/** * @param array $toolConfiguration * @param Plugin $plugin * @param Tool $tool */ private function persistTool($toolConfiguration, Plugin $plugin, Tool $tool) { $tool->setName($toolConfiguration['name']); $tool->setDisplayableInDesktop($toolConfiguration['is_displayable_in_desktop']); $tool->setDisplayableInWorkspace($toolConfiguration['is_displayable_in_workspace']); $tool->setIsDesktopRequired(false); $tool->setIsWorkspaceRequired(false); $tool->setPlugin($plugin); $tool->setExportable($toolConfiguration['is_exportable']); $tool->setIsConfigurableInWorkspace($toolConfiguration['is_configurable_in_workspace']); $tool->setIsConfigurableInDesktop($toolConfiguration['is_configurable_in_desktop']); $tool->setIsLockedForAdmin($toolConfiguration['is_locked_for_admin']); $tool->setIsAnonymousExcluded($toolConfiguration['is_anonymous_excluded']); if (isset($toolConfiguration['class'])) { $tool->setClass("{$toolConfiguration['class']}"); } else { $tool->setClass("wrench"); } $this->toolManager->create($tool); $this->persistCustomToolRights($toolConfiguration['tool_rights'], $tool); }
private function addMyContactsTool() { $this->log('Installing my_contacts tool...'); $om = $this->container->get('claroline.persistence.object_manager'); $toolManager = $this->container->get('claroline.manager.tool_manager'); $myContactsTool = $toolManager->getOneToolByName('my_contacts'); if (is_null($myContactsTool)) { $myContactsTool = new Tool(); $myContactsTool->setName('my_contacts'); $myContactsTool->setClass('users'); $myContactsTool->setIsWorkspaceRequired(false); $myContactsTool->setIsDesktopRequired(false); $myContactsTool->setDisplayableInWorkspace(false); $myContactsTool->setDisplayableInDesktop(true); $myContactsTool->setExportable(false); $myContactsTool->setIsConfigurableInWorkspace(false); $myContactsTool->setIsConfigurableInDesktop(false); $myContactsTool->setIsLockedForAdmin(false); $myContactsTool->setIsAnonymousExcluded(true); $toolManager->create($myContactsTool); $myContactsOt = new OrderedTool(); $myContactsOt->setTool($myContactsTool); $myContactsOt->setType(0); $myContactsOt->setOrder(10); $myContactsOt->setLocked(false); $myContactsOt->setName($myContactsTool->getName()); $myContactsOt->setVisibleInDesktop(true); $om->persist($myContactsOt); $om->flush(); } }