in pp3/module/Application/src/Application/Controller/AdminController.php [115:171]
public function indexAction() {
$this->_checkAdminUser();
$plugins = null;
$search = null;
$req = $this->request;
if ($this->params()->fromQuery('search')) {
$search = $this->params()->fromQuery('search');
$plugins = $this->_pluginRepository->getPluginsByName($search);
}
$pId = $this->params()->fromQuery('id');
$act = $this->params()->fromQuery('act');
$q = $this->params()->fromQuery('q');
if (!empty($pId)) {
$plugin = $this->_pluginRepository->find($pId);
if ($plugin) {
$plugins = array($plugin);
}
if ($act) {
switch ($act) {
case 'publish':
$plugin->setStatus(Plugin::STATUS_PUBLIC);
$plugin->setApprovedAt(new \DateTime('now'));
$this->_pluginRepository->persist($plugin);
$this->flashMessenger()->setNamespace('success')->addMessage('Plugin '.$plugin->getName().' approved.');
break;
case 'hide':
$plugin->setStatus(Plugin::STATUS_PRIVATE);
$this->_pluginRepository->persist($plugin);
$this->flashMessenger()->setNamespace('success')->addMessage('Plugin '.$plugin->getName().' made hidden.');
break;
case 'sync':
$plugin->setDataLoader(new MavenDataLoader());
try {
$plugin->reloadData();
$this->_pluginRepository->persist($plugin);
$this->flashMessenger()->setNamespace('success')->addMessage('Plugin data reloaded from maven-metadata.xml file.');
} catch (\Exception $e) {
// maven-metadata.xml not found
$this->flashMessenger()->setNamespace('error')->addMessage('Sorry, maven-metadata.xml file is missing.');
}
break;
case 'delete':
$this->_pluginRepository->remove($plugin);
$this->rebuildAllCatalogs();
$this->flashMessenger()->setNamespace('success')->addMessage('Plugin '.$plugin->getName().' deleted.');
return $this->redirect()->toRoute('admin', array(
'action' => 'index'
));
break;
}
}
}
return new ViewModel([
'plugins' => $plugins,
'search' => $search,
]);
}