コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @param PluginBundle $plugin
  *
  * @todo Create dedicated repository methods to retrieve tool/type names
  */
 public function check(PluginBundle $plugin, $updateMode = false)
 {
     if (!is_file($plugin->getConfigFile())) {
         $error = new ValidationError('config.yml file missing');
         $errors = [$error];
         return $errors;
     }
     $config = $this->yamlParser->parse(file_get_contents($plugin->getConfigFile()));
     $names = [];
     $listResource = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findAll();
     foreach ($listResource as $resource) {
         $names[] = $resource->getName();
     }
     $tools = [];
     /** @var \Claroline\CoreBundle\Entity\Tool\Tool[] $listTool */
     $listTool = $this->em->getRepository('ClarolineCoreBundle:Tool\\Tool')->findAllWithPlugin();
     foreach ($listTool as $tool) {
         $toolPlugin = $tool->getPlugin();
         $tools[] = sprintf('%s%s', $toolPlugin ? $toolPlugin->getBundleFQCN() . '-' : '', $tool->getName());
     }
     $resourceActions = [];
     $listResourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\\MenuAction')->findBy(['resourceType' => null, 'isCustom' => true]);
     foreach ($listResourceActions as $resourceAction) {
         $resourceActions[] = $resourceAction->getName();
     }
     $widgets = [];
     /** @var \Claroline\CoreBundle\Entity\Widget\Widget[] $listWidget */
     $listWidget = $this->em->getRepository('ClarolineCoreBundle:Widget\\Widget')->findAllWithPlugin();
     foreach ($listWidget as $widget) {
         $widgetPlugin = $widget->getPlugin();
         $widgets[] = sprintf('%s%s', $widgetPlugin ? $widgetPlugin->getBundleFQCN() . '-' : '', $widget->getName());
     }
     $processor = new Processor();
     $configuration = new Configuration($plugin, $names, $tools, $resourceActions, $widgets);
     $configuration->setUpdateMode($updateMode);
     try {
         $this->processedConfiguration = $processor->processConfiguration($configuration, $config);
     } catch (\Exception $e) {
         $error = new ValidationError($e->getMessage());
         return [$error];
     }
 }
コード例 #2
0
ファイル: DatabaseWriter.php プロジェクト: ChMat/CoreBundle
 /**
  * @param array        $resource
  * @param ResourceType $resourceType
  * @param PluginBundle $pluginBundle
  */
 private function updateIcons(array $resource, ResourceType $resourceType, PluginBundle $pluginBundle)
 {
     $resourceIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/' . $resourceType->getName());
     if (null === $resourceIcon) {
         $resourceIcon = new ResourceIcon();
         $resourceIcon->setMimeType('custom/' . $resourceType->getName());
     }
     if (isset($resource['icon'])) {
         $ds = DIRECTORY_SEPARATOR;
         $webBundleDir = "{$this->kernelRootDir}{$ds}..{$ds}web{$ds}bundles";
         $webPluginDir = "{$webBundleDir}{$ds}{$pluginBundle->getAssetsFolder()}";
         $webPluginImgDir = "{$webPluginDir}{$ds}images";
         $webPluginIcoDir = "{$webPluginImgDir}{$ds}icons";
         $this->fileSystem->mkdir(array($webBundleDir, $webPluginDir, $webPluginImgDir, $webPluginIcoDir));
         $this->fileSystem->copy("{$pluginBundle->getImgFolder()}{$ds}{$resource['icon']}", "{$webPluginIcoDir}{$ds}{$resource['icon']}");
         $resourceIcon->setRelativeUrl("bundles/{$pluginBundle->getAssetsFolder()}/images/icons/{$resource['icon']}");
     } else {
         $defaultIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/default');
         $resourceIcon->setRelativeUrl($defaultIcon->getRelativeUrl());
     }
     $resourceIcon->setShortcut(false);
     $this->em->persist($resourceIcon);
     $this->im->createShortcutIcon($resourceIcon);
 }
コード例 #3
0
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new DynamicConfigPass());
 }
コード例 #4
0
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new QuestionHandlerPass());
 }
コード例 #5
0
ファイル: Installer.php プロジェクト: ChMat/CoreBundle
 private function checkInstallationStatus(PluginBundle $plugin, $shouldBeInstalled = true)
 {
     $this->log(sprintf('<fg=blue>Checking installation status for plugin %s</fg=blue>', $plugin->getName()));
     if ($this->recorder->isRegistered($plugin) !== $shouldBeInstalled) {
         $stateDiscr = $shouldBeInstalled ? 'not' : 'already';
         throw new \LogicException("Plugin '{$plugin->getName()}' is {$stateDiscr} installed.");
     }
 }
コード例 #6
0
ファイル: DatabaseWriter.php プロジェクト: ngydat/CoreBundle
 /**
  * @param array        $resource
  * @param ResourceType $resourceType
  * @param PluginBundle $pluginBundle
  */
 private function updateIcons(array $resource, ResourceType $resourceType, PluginBundle $pluginBundle)
 {
     $resourceIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/' . $resourceType->getName());
     if (null === $resourceIcon) {
         $resourceIcon = new ResourceIcon();
         $resourceIcon->setMimeType('custom/' . $resourceType->getName());
     }
     if (isset($resource['icon'])) {
         $resourceIcon->setRelativeUrl("bundles/{$pluginBundle->getAssetsFolder()}/images/icons/{$resource['icon']}");
     } else {
         $defaultIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/default');
         $resourceIcon->setRelativeUrl($defaultIcon->getRelativeUrl());
     }
     $resourceIcon->setShortcut(false);
     $this->em->persist($resourceIcon);
     $this->im->createShortcutIcon($resourceIcon);
 }