Exemplo n.º 1
0
 /**
  * @return ItemInterface
  */
 public function createMainMenu()
 {
     /* @var $menu ItemInterface */
     $menu = $this->factory->createItem('root')->setUri($this->request_stack->getMasterRequest()->getRequestUri());
     $menu->addChild('Search', ['route' => 'home_search'])->setLinkAttribute('class', 'icon-label icon-gray-search');
     $add = $menu->addChild('Add record')->setLabelAttribute('class', 'icon-label icon-gray-add');
     // synchronization items
     if ($this->plugin_import->hasPlugins() || $this->plugin_export->hasPlugins()) {
         $sync = $menu->addChild('Synchronization')->setLabelAttribute('class', 'icon-label icon-white-cloud-sync');
         // add import plugin items
         $this->addPluginItems($this->plugin_import, $sync, 'Import items', '', 'icon-label icon-white-cloud-download');
         // add export plugin items
         $this->addPluginItems($this->plugin_export, $sync, 'Export items', '', 'icon-label icon-white-cloud-arrow-up');
     }
     $settings = $menu->addChild('Settings')->setLabelAttribute('class', 'icon-label icon-gray-settings');
     // add search plugin items
     $this->addPluginItems($this->plugin_search, $add, 'Search by name', 'Search by name the source of filling item', 'icon-label icon-white-search');
     if ($this->plugin_search->hasPlugins()) {
         $add->addChild('Search in all plugins', ['route' => 'fill_search_in_all'])->setAttribute('title', $this->translator->trans('Search by name in all plugins'))->setLinkAttribute('class', 'icon-label icon-white-cloud-search');
         $add->addChild('Add from URL', ['route' => 'fill_search_filler'])->setAttribute('title', $this->translator->trans('Search plugin by the URL for filling item'))->setLinkAttribute('class', 'icon-label icon-white-cloud-search');
     }
     // add filler plugin items
     $this->addPluginItems($this->plugin_filler, $add, 'Fill from source', 'Fill record from source (example source is URL)', 'icon-label icon-white-share');
     // add manually
     $add->addChild('Fill manually', ['route' => 'item_add_manually'])->setLinkAttribute('class', 'icon-label icon-white-add');
     $settings->addChild('File storages', ['route' => 'storage_list'])->setLinkAttribute('class', 'icon-label icon-white-storage');
     $settings->addChild('List of notice', ['route' => 'notice_list'])->setLinkAttribute('class', 'icon-label icon-white-alert');
     $settings->addChild('Labels', ['route' => 'label'])->setLinkAttribute('class', 'icon-label icon-white-label');
     $plugins = $settings->addChild('Plugins')->setLabelAttribute('class', 'icon-label icon-white-plugin');
     $settings->addChild('Update', ['route' => 'update'])->setLinkAttribute('class', 'icon-label icon-white-update');
     $settings->addChild('General', ['route' => 'home_settings'])->setLinkAttribute('class', 'icon-label icon-white-settings');
     // plugins
     $plugins->addChild('Installed', ['route' => 'plugin_installed'])->setLinkAttribute('class', 'icon-label icon-white-plugin');
     $plugins->addChild('Store', ['route' => 'plugin_store'])->setLinkAttribute('class', 'icon-label icon-white-shop');
     // add settings plugin items
     foreach ($this->plugin_setting->getPlugins() as $plugin) {
         /* @var $plugin PluginInMenuInterface */
         $plugin->buildMenu($plugins);
     }
     // add link to guide
     $settings->addChild('Help', ['uri' => $this->api_client->getSiteUrl(self::GUIDE_LINK)])->setLinkAttribute('class', 'icon-label icon-white-help');
     return $menu;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getPlugins
  *
  * @param string $method
  * @param string $event
  * @param array $data
  */
 public function testAddNewPlugin($method, $event, array $data)
 {
     $that = $this;
     // check download logo
     if ($data['logo']) {
         $this->downloader->expects($this->once())->method('entity')->will($this->returnCallback(function ($logo, $plugin, $override) use($that, $data) {
             $that->assertEquals($data['logo'], $logo);
             $that->assertTrue($override);
             $that->checkNewPlugin($plugin, $data);
         }));
     }
     $this->rep->expects($this->once())->method('find')->will($this->returnValue(null))->with('foo/bar');
     $this->em->expects($this->once())->method('persist')->will($this->returnCallback(function ($plugin) use($that, $data) {
         $that->checkNewPlugin($plugin, $data);
     }));
     $this->em->expects($this->once())->method('flush');
     $this->client->expects($this->once())->method('getPlugin')->with('foo', 'bar')->will($this->returnValue($data));
     // test
     call_user_func([$this->listener, $method], $this->getEvent($this->getPackage($this->exactly(2)), $event));
 }
Exemplo n.º 3
0
 /**
  * Add plugin from package.
  *
  * @param ComposerPackage $package
  */
 protected function addPackage(ComposerPackage $package)
 {
     $plugin = $this->rep->find($package->getName());
     // create new plugin if not exists
     if (!$plugin) {
         $plugin = new Plugin();
         $plugin->setName($package->getName());
     }
     list($vendor, $package) = explode('/', $plugin->getName());
     try {
         $data = $this->client->getPlugin($vendor, $package);
         $plugin->setTitle($data['title'])->setDescription($data['description']);
         if ($data['logo']) {
             $this->downloader->entity($data['logo'], $plugin, true);
         }
     } catch (\Exception $e) {
         // is not a critical error
     }
     $this->em->persist($plugin);
     $this->em->flush();
 }
Exemplo n.º 4
0
 /**
  * Test get site URL
  *
  * @dataProvider getPaths
  *
  * @param string $path
  * @param string $locale
  */
 public function testGetSiteUrl($path, $locale)
 {
     $this->client->setLocale($locale);
     $this->assertEquals($this->host . '/' . $locale . $path, $this->client->getSiteUrl($path));
 }