diff --git a/behat.yml.dist b/behat.yml.dist
index d7fccd3d..d47001c9 100644
--- a/behat.yml.dist
+++ b/behat.yml.dist
@@ -11,6 +11,7 @@ default:
bootstrap: ""
env: test
debug: true
+ bootstrap: ''
Behat\MinkExtension\Extension:
base_url: 'http://knpbundles.local/app_test.php'
default_session: symfony2
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Badge/BadgeGenerator.php b/src/Knp/Bundle/KnpBundlesBundle/Badge/BadgeGenerator.php
index fe792abe..7b4ad4dd 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Badge/BadgeGenerator.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Badge/BadgeGenerator.php
@@ -108,7 +108,7 @@ public function show(Bundle $bundle, $type = 'long', $regenerate = false)
$this->cacheDir
);
- $filename = sprintf('%s/badges/%s/%s-%s.png', $relativePath, $type, $bundle->getUsername(), $bundle->getName());
+ $filename = sprintf('%s/badges/%s/%s-%s.png', $relativePath, $type, $bundle->getOwnerName(), $bundle->getName());
if (!$this->filesystem->exists($filename) || false !== $regenerate) {
$this->generate($bundle);
}
@@ -206,7 +206,7 @@ protected function setFont(ImagineInterface $imagine, $font, $size, $color = '8c
*/
protected function getBadgeFile(Bundle $bundle, $type = self::LONG)
{
- return $this->cacheDir.'/badges/'.$type.'/'.$bundle->getUsername().'-'.$bundle->getName().'.png';
+ return $this->cacheDir.'/badges/'.$type.'/'.$bundle->getOwnerName().'-'.$bundle->getName().'.png';
}
/**
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Command/KbGenerateBadgesCommand.php b/src/Knp/Bundle/KnpBundlesBundle/Command/KbGenerateBadgesCommand.php
index e1b12bdb..211aff5b 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Command/KbGenerateBadgesCommand.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Command/KbGenerateBadgesCommand.php
@@ -34,7 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$badgeGenerator->generate($bundle);
++$badgesCount;
} catch (ImageNotSavedException $e) {
- $output->writeln('Error occured during an image saving for '.$bundle->getUsername().'-'.$bundle->getName().' ');
+ $output->writeln('Error occured during an image saving for '.$bundle->getOwnerName().'-'.$bundle->getName().' ');
}
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Command/KbPopulateCommand.php b/src/Knp/Bundle/KnpBundlesBundle/Command/KbPopulateCommand.php
index 7cc02eb9..0737c787 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Command/KbPopulateCommand.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Command/KbPopulateCommand.php
@@ -48,6 +48,5 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundles = $updater->searchNewBundles();
$updater->createMissingBundles($bundles);
$updater->updateBundlesData();
- $updater->updateUsers();
}
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Command/KbSolrIndexCommand.php b/src/Knp/Bundle/KnpBundlesBundle/Command/KbSolrIndexCommand.php
index 98ac3f73..7d31cfa7 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Command/KbSolrIndexCommand.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Command/KbSolrIndexCommand.php
@@ -50,8 +50,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$indexer = $this->getContainer()->get('knp_bundles.indexer.solr');
if ($bundleName) {
- list($username, $name) = explode('/', $bundleName);
- $bundles = array($doctrine->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle')->findOneByUsernameAndName($username, $name));
+ list($ownerName, $name) = explode('/', $bundleName);
+ $bundles = array($doctrine->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle')->findOneByOwnerNameAndName($ownerName, $name));
} elseif ($force) {
$bundles = $doctrine->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle')->findAll();
} else {
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Command/KbUpdateUsersCommand.php b/src/Knp/Bundle/KnpBundlesBundle/Command/KbUpdateUsersCommand.php
deleted file mode 100644
index a32b6c0e..00000000
--- a/src/Knp/Bundle/KnpBundlesBundle/Command/KbUpdateUsersCommand.php
+++ /dev/null
@@ -1,41 +0,0 @@
-setDefinition(array())
- ->setName('kb:update:users')
- ;
- }
-
- /**
- * {@inheritdoc}
- *
- * @throws \InvalidArgumentException When the target directory does not exist
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- /* @var $updater Updater */
- $updater = $this->getContainer()->get('knp_bundles.updater');
- $updater->setOutput($output);
- $updater->setUp();
-
- $updater->updateUsers();
-
- $em = $this->getContainer()->get('knp_bundles.entity_manager');
- $em->flush();
- }
-}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Command/MigrateUsersCommand.php b/src/Knp/Bundle/KnpBundlesBundle/Command/MigrateUsersCommand.php
new file mode 100644
index 00000000..d18c0244
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Command/MigrateUsersCommand.php
@@ -0,0 +1,141 @@
+setDefinition(array())
+ ->setName('kb:migrate:users')
+ ->addOption('users', 'u', InputOption::VALUE_OPTIONAL, 'how many users migrate per one cycle', 10)
+ ->addOption('remove-not-existing', 'rne', InputOption::VALUE_OPTIONAL, 'remove users which are not exist on github', false)
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ /**
+ * @var $connection \Doctrine\DBAL\Connection
+ * @var $github \Github\Client
+ */
+ $connection = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection();
+ $this->github = $github = $this->getContainer()->get('knp_bundles.github_client');
+
+ $usersPerCycle = $input->getOption('users');
+
+ $testFetch = $connection->fetchAssoc('SELECT * FROM user LIMIT 1');
+
+ if (!isset($testFetch['is_migrated'])) {
+ $connection->executeQuery($this->ownerTable);
+ $connection->executeQuery('ALTER TABLE user ADD is_migrated VARCHAR(10) NULL;');
+ }
+
+ do {
+ $oldUsers = $connection->fetchAll(sprintf('SELECT * FROM user WHERE is_migrated IS NULL LIMIT %d', $usersPerCycle));
+
+ foreach ($oldUsers as $oldUser) {
+ try {
+ $ghUser = $github->api('user')->show($oldUser['name']);
+ } catch (ApiLimitExceedException $e) {
+ throw $e;
+ } catch (\RuntimeException $e) {
+ sleep(10);
+ continue;
+ }
+
+ if (isset($ghUser['message']) && $ghUser['message'] == 'Not Found') {
+ if ($input->getOption('remove-not-existing')) {
+ $connection->executeQuery('DELETE user WHERE id = :user_id', array('user_id' => $oldUser['id']));
+ } else {
+ $connection->executeQuery('UPDATE user SET is_migrated = 1 WHERE id = :user_id', array('user_id' => $oldUser['id']));
+ }
+ continue;
+ }
+
+ $data = $oldUser;
+ $data['discriminator'] = $ghUser['type'] == 'Organization' ? 'organization' : 'developer';
+ $data = $this->migrateColumns($data, $ghUser);
+
+ $this->owners[] = $data;
+ }
+
+ $connection->beginTransaction();
+ try {
+ foreach ($this->owners as $ownerData) {
+ $connection->insert('owner', $ownerData);
+ $connection->executeQuery('UPDATE user SET is_migrated = 1 WHERE id = :user_id', array('user_id' => $ownerData['id']));
+ }
+
+ $connection->commit();
+
+ $output->writeln(sprintf('%d users has been successfully migrated', $usersPerCycle));
+ } catch (\Exception $e) {
+ $connection->rollback();
+ $connection->close();
+
+ throw $e;
+ }
+
+ $this->owners = array();
+ } while (count($oldUsers) > 0);
+
+ $connection->executeQuery($this->afterMigration);
+ }
+
+ private function migrateColumns($data, $ghUser)
+ {
+ $data['url'] = $data['blog'];
+ $data['avatarUrl'] = isset($ghUser['avatar_url']) ? $ghUser['avatar_url'] : null;
+
+ unset($data['blog'], $data['gravatarHash'], $data['is_migrated']);
+
+ return $data;
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Consumer/GithubHookConsumer.php b/src/Knp/Bundle/KnpBundlesBundle/Consumer/GithubHookConsumer.php
index 84cb25f1..aef16f03 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Consumer/GithubHookConsumer.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Consumer/GithubHookConsumer.php
@@ -56,7 +56,7 @@ public function execute($msg)
$payload = $message->payload;
$bundle = $this->manager->getRepository('KnpBundlesBundle:Bundle')->findOneBy(array(
'name' => $payload->repository->name,
- 'username' => $payload->repository->owner->name
+ 'ownerName' => $payload->repository->owner->name
));
if (!$bundle) {
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Consumer/UpdateBundleConsumer.php b/src/Knp/Bundle/KnpBundlesBundle/Consumer/UpdateBundleConsumer.php
index c9fd7e7d..f5763587 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Consumer/UpdateBundleConsumer.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Consumer/UpdateBundleConsumer.php
@@ -6,8 +6,8 @@
use Knp\Bundle\KnpBundlesBundle\Git;
use Knp\Bundle\KnpBundlesBundle\Entity\Bundle;
use Knp\Bundle\KnpBundlesBundle\Entity\Score;
-use Knp\Bundle\KnpBundlesBundle\Entity\User;
-use Knp\Bundle\KnpBundlesBundle\Entity\UserManager;
+use Knp\Bundle\KnpBundlesBundle\Entity\Owner;
+use Knp\Bundle\KnpBundlesBundle\Entity\OwnerManager;
use Knp\Bundle\KnpBundlesBundle\Indexer\SolrIndexer;
use Knp\Bundle\KnpBundlesBundle\Travis\Travis;
@@ -43,9 +43,9 @@ class UpdateBundleConsumer implements ConsumerInterface
private $em;
/**
- * @var Knp\Bundle\KnpBundlesBundle\Entity\UserManager
+ * @var Knp\Bundle\KnpBundlesBundle\Entity\OwnerManager
*/
- private $users;
+ private $ownerManager;
/**
* @var Knp\Bundle\KnpBundlesBundle\Indexer\SolrIndexer
@@ -64,18 +64,18 @@ class UpdateBundleConsumer implements ConsumerInterface
/**
* @param ObjectManager $em
- * @param UserManager $users
+ * @param OwnerManager $ownerManager
* @param Repo $githubRepoApi
* @param Travis $travis
* @param SolrIndexer $indexer
*/
- public function __construct(ObjectManager $em, UserManager $users, Repo $githubRepoApi, Travis $travis, SolrIndexer $indexer)
+ public function __construct(ObjectManager $em, OwnerManager $ownerManager, Repo $githubRepoApi, Travis $travis, SolrIndexer $indexer)
{
$this->em = $em;
- $this->users = $users;
+ $this->ownerManager = $ownerManager;
$this->githubRepoApi = $githubRepoApi;
$this->travis = $travis;
- $this->users = $users;
+ $this->ownerManager = $ownerManager;
$this->indexer = $indexer;
}
@@ -187,7 +187,7 @@ private function updateContributors(Bundle $bundle)
$contributors = array();
foreach ($contributorNames as $contributorName) {
- $contributors[] = $this->users->getOrCreate($contributorName);
+ $contributors[] = $this->ownerManager->getOrCreate($contributorName);
}
$bundle->setContributors($contributors);
@@ -220,9 +220,9 @@ private function updateKeywords(Bundle $bundle)
*/
protected function removeBundle(Bundle $bundle)
{
- $user = $bundle->getUser();
- if ($user instanceof User) {
- $user->removeBundle($bundle);
+ $owner = $bundle->getOwner();
+ if ($owner instanceof Owner) {
+ $owner->removeBundle($bundle);
}
// remove bundle from search index
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Controller/BadgeController.php b/src/Knp/Bundle/KnpBundlesBundle/Controller/BadgeController.php
index 1baaa802..31ce7b87 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Controller/BadgeController.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Controller/BadgeController.php
@@ -11,11 +11,11 @@
*/
class BadgeController extends BaseController
{
- public function showAction($username, $name, $type = 'long')
+ public function showAction($ownerName, $name, $type = 'long')
{
- $bundle = $this->getBundleRepository()->findOneByUsernameAndName($username, $name);
+ $bundle = $this->getBundleRepository()->findOneByOwnerNameAndName($ownerName, $name);
if (!$bundle) {
- throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $username, $name));
+ throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $ownerName, $name));
}
return $this->container->get('knp_bundles.badge_generator')->show($bundle, $type);
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Controller/BaseController.php b/src/Knp/Bundle/KnpBundlesBundle/Controller/BaseController.php
index eeeeb988..7f7372e7 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Controller/BaseController.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Controller/BaseController.php
@@ -57,16 +57,6 @@ protected function getPaginator(Query $query, $page, $limit = 10)
return $paginator;
}
- protected function getBundleRepository()
- {
- return $this->getRepository('Bundle');
- }
-
- protected function getUserRepository()
- {
- return $this->getRepository('User');
- }
-
protected function getRepository($class)
{
return $this->container->get('knp_bundles.entity_manager')->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\'.$class);
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Controller/BundleController.php b/src/Knp/Bundle/KnpBundlesBundle/Controller/BundleController.php
index ed682202..b066e6bd 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Controller/BundleController.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Controller/BundleController.php
@@ -16,7 +16,7 @@
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\SolariumAdapter;
use Knp\Bundle\KnpBundlesBundle\Entity\Bundle;
-use Knp\Bundle\KnpBundlesBundle\Entity\User;
+use Knp\Bundle\KnpBundlesBundle\Entity\Developer;
use Knp\Menu\MenuItem;
use Knp\Bundle\KnpBundlesBundle\Updater\Exception\UserNotFoundException;
@@ -58,7 +58,8 @@ public function searchAction(Request $request)
}
$dismax = $select->getDisMax();
- $dismax->setQueryFields(array('name^2', 'username', 'fullName^1.5', 'description', 'keywords', 'text', 'text_ngram'));
+
+ $dismax->setQueryFields(array('name^2', 'ownerName', 'fullName^1.5', 'description', 'keywords', 'text', 'text_ngram'));
$dismax->setPhraseFields(array('description^30'));
$dismax->setQueryParser('edismax');
@@ -73,7 +74,7 @@ public function searchAction(Request $request)
if ('html' === $format && count($bundles) === 1) {
$first = $bundles->current();
if (strtolower($first['name']) == strtolower($query)) {
- return $this->redirect($this->generateUrl('bundle_show', array('username' => $first['username'], 'name' => $first['name'])));
+ return $this->redirect($this->generateUrl('bundle_show', array('ownerName' => $first['ownerName'], 'name' => $first['name'])));
}
}
@@ -85,19 +86,19 @@ public function searchAction(Request $request)
));
}
- public function showAction(Request $request, $username, $name)
+ public function showAction(Request $request, $ownerName, $name)
{
/* @var $bundle Bundle */
- $bundle = $this->getRepository('Bundle')->findOneByUsernameAndName($username, $name);
+ $bundle = $this->getRepository('Bundle')->findOneByOwnerNameAndName($ownerName, $name);
if (!$bundle) {
- throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $username, $name));
+ throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $ownerName, $name));
}
$format = $this->recognizeRequestFormat($request);
$this->highlightMenu('bundles');
- $user = $this->get('security.context')->getToken()->getUser();
+ $owner = $this->get('security.context')->getToken()->getUser();
return $this->render('KnpBundlesBundle:Bundle:show.'.$format.'.twig', array(
'series' => array(
@@ -106,10 +107,10 @@ public function showAction(Request $request, $username, $name)
'data' => $bundle->getScores(),
)
),
- 'bundle' => $bundle,
- 'score_details' => $bundle->getScoreDetails(),
- 'isUsedByUser' => $user instanceof User && $user->isUsingBundle($bundle),
- 'callback' => $request->query->get('callback')
+ 'bundle' => $bundle,
+ 'score_details' => $bundle->getScoreDetails(),
+ 'isUsedByDeveloper' => $owner instanceof Owner && $owner->isUsingBundle($bundle),
+ 'callback' => $request->query->get('callback')
));
}
@@ -123,9 +124,9 @@ public function listAction(Request $request, $sort)
$sortField = $this->sortFields[$sort];
- $query = $this->getRepository('Bundle')->queryAllWithUsersAndContributorsSortedBy($sortField);
+ $query = $this->getRepository('Bundle')->queryAllWithOwnersAndContributorsSortedBy($sortField);
$bundles = $this->getPaginator($query, $request->query->get('page', 1));
- $users = $this->getRepository('User')->findAllSortedBy('createdAt', 20);
+ $owners = $this->getRepository('Developer')->findAllSortedBy('createdAt', 20);
$this->highlightMenu('bundles');
@@ -137,7 +138,7 @@ public function listAction(Request $request, $sort)
)
),
'bundles' => $bundles,
- 'users' => $users,
+ 'developers' => $owners,
'sort' => $sort,
'sortLegends' => $this->sortLegends,
'callback' => $request->query->get('callback')
@@ -156,7 +157,7 @@ public function evolutionAction()
'series' => array(
array(
'name' => 'Developers',
- 'data' => $this->getRepository('User')->getUsersCountEvolution(),
+ 'data' => $this->getRepository('Developer')->getUsersCountEvolution(),
),
array(
'name' => 'Bundles updated',
@@ -164,7 +165,7 @@ public function evolutionAction()
)
),
'bundles' => $this->getRepository('Bundle')->count(),
- 'users' => $this->getRepository('User')->count()
+ 'developers' => $this->getRepository('Developer')->count()
));
}
@@ -192,10 +193,10 @@ public function addAction(Request $request)
if (!$error) {
$bundle = trim(str_replace(array('http://github.com', 'https://github.com', '.git'), '', $bundle), '/');
if (preg_match('/^[a-z0-9-]+\/[a-z0-9-\.]+$/i', $bundle)) {
- list($username, $name) = explode('/', $bundle);
+ list($ownerName, $name) = explode('/', $bundle);
- $url = $this->generateUrl('bundle_show', array('username' => $username, 'name' => $name));
- if ($this->getRepository('Bundle')->findOneByUsernameAndName($username, $name)) {
+ $url = $this->generateUrl('bundle_show', array('ownerName' => $ownerName, 'name' => $name));
+ if ($this->getRepository('Bundle')->findOneByOwnerNameAndName($ownerName, $name)) {
if (!$request->isXmlHttpRequest()) {
return $this->redirect($url);
} else {
@@ -241,29 +242,29 @@ public function addAction(Request $request)
), $error ? 400 : 201);
}
- public function changeUsageStatusAction($username, $name)
+ public function changeUsageStatusAction($ownerName, $name)
{
/* @var $bundle Bundle */
- $bundle = $this->getRepository('Bundle')->findOneByUsernameAndName($username, $name);
+ $bundle = $this->getRepository('Bundle')->findOneByOwnerNameAndName($ownerName, $name);
if (!$bundle) {
- throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $username, $name));
+ throw new NotFoundHttpException(sprintf('The bundle "%s/%s" does not exist', $ownerName, $name));
}
- $params = array('username' => $username, 'name' => $name);
+ $params = array('ownerName' => $ownerName, 'name' => $name);
- if (!$user = $this->get('security.context')->getToken()->getUser()) {
+ if (!$owner = $this->get('security.context')->getToken()->getUser()) {
return $this->redirect($this->generateUrl('bundle_show', $params));
}
$em = $this->get('doctrine')->getEntityManager();
- if ($user->isUsingBundle($bundle)) {
+ if ($owner->isUsingBundle($bundle)) {
$bundle->updateScore(-5);
- $bundle->removeRecommender($user);
+ $bundle->removeRecommender($owner);
} else {
$bundle->updateScore(5);
- $bundle->addRecommender($user);
+ $bundle->addRecommender($owner);
}
$em->persist($bundle);
@@ -300,7 +301,7 @@ public function settingsAction(Request $request, $id)
}
// Save only if sender is owner of bundle
- if ((null !== $user = $this->get('security.context')->getToken()->getUser()) && $bundle->isOwnerOrContributor($user)) {
+ if ((null !== $owner = $this->get('security.context')->getToken()->getUser()) && $bundle->isOwnerOrContributor($owner)) {
$state = $request->request->get('state', Bundle::STATE_UNKNOWN);
$bundle->setState($state);
@@ -312,6 +313,6 @@ public function settingsAction(Request $request, $id)
$request->getSession()->setFlash('notice', sprintf('Bundle status was successful changed to: %s', $state));
}
- return $this->redirect($this->generateUrl('bundle_show', array('username' => $bundle->getUserName(), 'name' => $bundle->getName())));
+ return $this->redirect($this->generateUrl('bundle_show', array('ownerName' => $bundle->getOwnerName(), 'name' => $bundle->getName())));
}
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Controller/UserController.php b/src/Knp/Bundle/KnpBundlesBundle/Controller/DeveloperController.php
similarity index 53%
rename from src/Knp/Bundle/KnpBundlesBundle/Controller/UserController.php
rename to src/Knp/Bundle/KnpBundlesBundle/Controller/DeveloperController.php
index fcbdc81b..cb098792 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Controller/UserController.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Controller/DeveloperController.php
@@ -3,15 +3,15 @@
namespace Knp\Bundle\KnpBundlesBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Templating\EngineInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query;
-use Zend\Paginator\Paginator;
use Knp\Menu\MenuItem;
-class UserController extends BaseController
+class DeveloperController extends BaseController
{
protected $sortFields = array(
'name' => 'name',
@@ -19,13 +19,13 @@ class UserController extends BaseController
);
protected $sortLegends = array(
- 'name' => 'users.sort.name',
- 'best' => 'users.sort.best',
+ 'name' => 'developers.sort.name',
+ 'best' => 'developers.sort.best',
);
public function userbarAction()
{
- $response = $this->render('KnpBundlesBundle:User:userbar.html.twig');
+ $response = $this->render('KnpBundlesBundle:Developer:userbar.html.twig');
// this is private cache (don't cache with shared proxy)
$response->setPrivate();
@@ -35,17 +35,17 @@ public function userbarAction()
public function showAction(Request $request, $name)
{
- if (!$user = $this->getUserRepository()->findOneByNameWithRepos($name)) {
- throw new NotFoundHttpException(sprintf('The user "%s" does not exist', $name));
+ if (!$developer = $this->getRepository('Developer')->findOneByNameWithRepos($name)) {
+ throw new NotFoundHttpException(sprintf('The developer "%s" does not exist', $name));
}
$format = $this->recognizeRequestFormat($request);
- $this->highlightMenu('users');
+ $this->highlightMenu('developers');
- return $this->render('KnpBundlesBundle:User:show.'.$format.'.twig', array(
- 'user' => $user,
- 'callback' => $request->query->get('callback')
+ return $this->render('KnpBundlesBundle:Developer:show.'.$format.'.twig', array(
+ 'developer' => $developer,
+ 'callback' => $request->query->get('callback')
));
}
@@ -59,13 +59,13 @@ public function listAction(Request $request, $sort = 'name')
$sortField = $this->sortFields[$sort];
- $this->highlightMenu('users');
+ $this->highlightMenu('developers');
- $query = $this->getUserRepository()->queryAllWithBundlesSortedBy($sortField);
- $users = $this->getPaginator($query, $request->query->get('page', 1), 18);
+ $query = $this->getRepository('Developer')->queryAllWithBundlesSortedBy($sortField);
+ $developers = $this->getPaginator($query, $request->query->get('page', 1), 18);
- return $this->render('KnpBundlesBundle:User:list.'.$format.'.twig', array(
- 'users' => $users,
+ return $this->render('KnpBundlesBundle:Developer:list.'.$format.'.twig', array(
+ 'developers' => $developers,
'sort' => $sort,
'sortLegends' => $this->sortLegends,
'callback' => $request->query->get('callback')
@@ -74,14 +74,18 @@ public function listAction(Request $request, $sort = 'name')
public function bundlesAction(Request $request, $name)
{
- if (!$user = $this->getUserRepository()->findOneByName($name)) {
- throw new NotFoundHttpException(sprintf('The user "%s" does not exist', $name));
+ $format = $this->recognizeRequestFormat($request);
+
+ if ($format == 'html') {
+ return $this->redirect($this->generateUrl('developer_show', array('name' => $name)));
}
- $format = $this->recognizeRequestFormat($request);
+ if (!$developer = $this->getRepository('Developer')->findOneByName($name)) {
+ throw new NotFoundHttpException(sprintf('The developer "%s" does not exist', $name));
+ }
return $this->render('KnpBundlesBundle:Bundle:list.'.$format.'.twig', array(
- 'bundles' => $user->getBundles(),
+ 'bundles' => $developer->getBundles(),
'callback' => $request->query->get('callback')
));
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Controller/OrganizationController.php b/src/Knp/Bundle/KnpBundlesBundle/Controller/OrganizationController.php
new file mode 100644
index 00000000..63cc3b6c
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Controller/OrganizationController.php
@@ -0,0 +1,108 @@
+ 'name',
+ 'bundles' => 'bundles',
+ 'developers' => 'developers'
+ );
+
+ protected $sortLegends = array(
+ 'name' => 'organizations.sort.name',
+ 'bundles' => 'organizations.sort.bundles',
+ 'developers' => 'organizations.sort.developers',
+ );
+
+ public function showAction(Request $request, $name)
+ {
+ if (!$organization = $this->getRepository('Organization')->findOneByNameWithRepos($name)) {
+ throw new NotFoundHttpException(sprintf('The organization "%s" does not exist', $name));
+ }
+
+ $format = $this->recognizeRequestFormat($request);
+
+ $this->highlightMenu('organizations');
+
+ return $this->render('KnpBundlesBundle:Organization:show.'.$format.'.twig', array(
+ 'organization' => $organization,
+ 'callback' => $request->query->get('callback')
+ ));
+ }
+
+ public function listAction(Request $request, $sort = 'name')
+ {
+ if (!array_key_exists($sort, $this->sortFields)) {
+ throw new HttpException(sprintf('%s is not a valid sorting field', $sort), 406);
+ }
+
+ $format = $this->recognizeRequestFormat($request);
+
+ $sortField = $this->sortFields[$sort];
+
+ $this->highlightMenu('organizations');
+
+ $query = $this->getRepository('Organization')->queryAllWithBundlesSortedBy($sortField);
+ $paginator = $this->getPaginator($query, $request->query->get('page', 1));
+
+ $organizations = $paginator->getCurrentPageResults();
+ /**
+ * @see http://stackoverflow.com/a/8527531
+ */
+ if (is_array($organizations[0])) {
+ foreach ($organizations as $i => $org) {
+ $organizations[$i] = $org[0];
+ }
+ }
+
+ return $this->render('KnpBundlesBundle:Organization:list.'.$format.'.twig', array(
+ 'organizations' => $organizations,
+ 'paginator' => $paginator,
+ 'callback' => $request->query->get('callback'),
+ 'sortLegends' => $this->sortLegends,
+ 'sort' => $sort
+ ));
+ }
+
+ public function bundlesAction(Request $request, $name)
+ {
+ $format = $this->recognizeRequestFormat($request);
+
+ if ($format == 'html') {
+ return $this->redirect($this->generateUrl('organization_show', array('name' => $name)));
+ }
+
+ if (!$organization = $this->getRepository('Organization')->findOneByName($name)) {
+ throw new NotFoundHttpException(sprintf('The organization "%s" does not exist', $name));
+ }
+
+ return $this->render('KnpBundlesBundle:Bundle:list.'.$format.'.twig', array(
+ 'bundles' => $organization->getBundles(),
+ 'callback' => $request->query->get('callback')
+ ));
+ }
+
+ public function membersAction(Request $request, $name)
+ {
+ $format = $this->recognizeRequestFormat($request);
+
+ if ($format == 'html') {
+ return $this->redirect($this->generateUrl('organization_show', array('name' => $name)));
+ }
+
+ if (!$organization = $this->getRepository('Organization')->findOneByName($name)) {
+ throw new NotFoundHttpException(sprintf('The organization "%s" does not exist', $name));
+ }
+
+ return $this->render('KnpBundlesBundle:Developer:list.'.$format.'.twig', array(
+ 'bundles' => $organization->getMembers(),
+ 'callback' => $request->query->get('callback')
+ ));
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/DataFixtures/ORM/Data.php b/src/Knp/Bundle/KnpBundlesBundle/DataFixtures/ORM/Data.php
index 304a66eb..b23a0999 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/DataFixtures/ORM/Data.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/DataFixtures/ORM/Data.php
@@ -8,7 +8,7 @@
class Data implements FixtureInterface
{
- protected $names = array(
+ protected $devNames = array(
'John' => 'John Doe',
'Brian' => 'Brian Lester',
'Jack' => 'Jack Gill',
@@ -26,6 +26,13 @@ class Data implements FixtureInterface
'Dexter' => 'Dexter Schwartz'
);
+ protected $orgNames = array(
+ 'KnpLabs' => 'Happy Awesome Developers',
+ 'FriendsOfSymfony' => 'FriendsOfSymfony',
+ 'sonata-project' => 'Sonata Project',
+ 'nelmio' => 'Nelmio'
+ );
+
private $keywords = array(
'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit'
);
@@ -128,118 +135,80 @@ class XX
EOD;
+ private $states = array(
+ Entity\Bundle::STATE_UNKNOWN,
+ Entity\Bundle::STATE_NOT_YET_READY,
+ Entity\Bundle::STATE_READY,
+ Entity\Bundle::STATE_DEPRECATED
+ );
+
+ private $canonicalConfigDump = <<names as $name => $fullName) {
+ foreach ($this->devNames as $name => $fullName) {
$i++;
- $user = new Entity\User();
- $user->fromArray(array(
+ $developer = new Entity\Developer();
+ $developer->fromArray(array(
'name' => $name,
'email' => strtolower(str_replace(' ', '.', $fullName)).'@foomail.bar',
'fullName' => $fullName,
'company' => ($i%2) ? 'Company '.$i : null,
'location' => ($i%2) ? 'Location '.$i : null,
- 'blog' => ($i%2) ? 'blog'.$i.'.com' : null,
+ 'url' => ($i%2) ? 'blog'.$i.'.com' : null,
'score' => 0,
));
- $manager->persist($user);
+ $manager->persist($developer);
- $users[] = $user;
+ $developers[] = $developer;
}
- $states = array(
- Entity\Bundle::STATE_UNKNOWN,
- Entity\Bundle::STATE_NOT_YET_READY,
- Entity\Bundle::STATE_READY,
- Entity\Bundle::STATE_DEPRECATED
- );
+ foreach ($this->orgNames as $name => $fullName) {
+ $organization = new Entity\Organization();
+ $organization->fromArray(array(
+ 'name' => $name,
+ 'fullName' => $fullName,
+ 'email' => strtolower(str_replace(' ', '.', $fullName)).'@foomail.bar',
+ 'location' => ($i%2) ? 'Location '.$i : null,
+ 'url' => ($i%2) ? 'blog'.$i.'.com' : null,
+ 'score' => 0
+ ));
- $canonicalConfigDump = <<persist($organization);
-EOT;
+ $organizations[] = $organization;
+ }
- foreach ($users as $i => $user) {
+ foreach ($developers as $i => $developer) {
$contributors = array();
- $contributors[] = isset($users[$i + 1]) ? $users[$i + 1] : $users[0];
- $contributors[] = isset($users[$i - 1]) ? $users[$i - 1] : $users[count($users) - 1];
+ $contributors[] = isset($developers[$i + 1]) ? $developers[$i + 1] : $developers[0];
+ $contributors[] = isset($developers[$i - 1]) ? $developers[$i - 1] : $developers[count($developers) - 1];
- /* @var $contributor Entity\User */
+ /* @var $contributor Entity\Developer */
$contributor = array_pop($contributors);
- $bundle = new Entity\Bundle();
- $bundle->fromArray(array(
- 'name' => ucfirst($user->getName()).'FooBundle',
- 'username' => $user->getName(),
- 'user' => $user,
- 'description' => $this->descriptions[mt_rand(0, 4)],
- 'homepage' => ($i%2) ? 'Bundle'.$i.'.com' : null,
- 'readme' => str_replace('__BUNDLE__', "the bundle number: {$i}", $this->readme),
- 'tags' => ($i%2) ? array('1.0', '1.1') : array(),
- 'usesTravisCi' => ($i%2) ? false : true,
- 'composerName' => ($i%2) ? null : 'knplabs/knp-menu-bundle',
- 'state' => $states[mt_rand(0, 3)],
- 'travisCiBuildStatus' => ($i%2 == 0) ? $trilean[$i%3] : null,
- 'nbFollowers' => $i*10,
- 'nbForks' => $i,
- 'lastCommitAt' => \DateTime::createFromFormat('Y-m-d', sprintf('2012-07-%d', $i)),
- 'lastCommits' => array(
- array(
- 'commit' => array(
- 'author' => array(
- 'date' => '2010-05-16T09:58:32-09:00',
- 'name' => $contributor->getFullName(),
- 'email' => $contributor->getEmail()
- ),
- 'committer' => array(
- 'date' => '2010-05-16T09:58:32-09:00',
- 'name' => $contributor->getFullName(),
- 'login' => $contributor->getName()
- ),
- 'url' => 'http://github.com',
- 'message' => 'Fix something on this Bundle',
- ),
- ),
- array(
- 'commit' => array(
- 'author' => array(
- 'date' => '2010-05-16T09:58:32-07:00',
- 'name' => $user->getFullName(),
- 'email' => $user->getEmail()
- ),
- 'committer' => array(
- 'date' => '2010-05-16T09:58:32-07:00',
- 'name' => $user->getFullName(),
- 'email' => $user->getEmail()
- ),
- 'url' => 'http://github.com',
- 'message' => 'Commit something on this bundle',
- ),
- ),
- ),
- 'isFork' => false,
- 'contributors' => array($contributor),
- 'canonicalConfig' => ($i%2 == 0) ? $canonicalConfigDump : null,
- 'nbRecommenders' => rand(0, 90),
- ));
+ $bundle = $this->makeBundle($developer, $i, $contributor);
if ($i%5 == 0) {
$bundle->setLastTweetedAt(new \DateTime());
@@ -252,7 +221,7 @@ class:
}
$bundle->setScore(mt_rand(10, 666));
- $bundle->addRecommender(isset($users[$i + 2]) ? $users[$i + 2] : ($users[0] != $user ? $users[0] : $users[1]));
+ $bundle->addRecommender(isset($developers[$i + 2]) ? $developers[$i + 2] : ($developers[0] != $developer ? $developers[0] : $developers[1]));
if (isset($this->keywords[$i])) {
$keyword = new Entity\Keyword();
$keyword->setValue($this->keywords[$i]);
@@ -291,6 +260,80 @@ class:
}
}
+ foreach ($organizations as $key => $organization) {
+ for ($i = 1; $i < rand(2, 7); $i++) {
+ $manager->persist($this->makeBundle($organization, $i));
+ }
+ }
+
$manager->flush();
}
+
+ protected function makeBundle($owner, $i, $contributor = null)
+ {
+ $trilean = array(true, false, null);
+
+ $bundle = new Entity\Bundle();
+ $bundle->fromArray(array(
+ 'name' => ucfirst($owner->getName()).$i.'FooBundle',
+ 'ownerName' => $owner->getName(),
+ 'owner' => $owner,
+ 'description' => $this->descriptions[mt_rand(0, 4)],
+ 'homepage' => ($i%2) ? 'Bundle'.$i.'.com' : null,
+ 'readme' => str_replace('__BUNDLE__', "the bundle number: {$i}", $this->readme),
+ 'tags' => ($i%2) ? array('1.0', '1.1') : array(),
+ 'usesTravisCi' => ($i%2) ? false : true,
+ 'composerName' => ($i%2) ? null : 'knplabs/knp-menu-bundle',
+ 'symfonyVersions' => array(
+ 'dev-master' => '2.1.*',
+ '1.2.0' => '2.0.*',
+ '1.1.0' => '2.*',
+ ),
+ 'state' => $this->states[mt_rand(0, 3)],
+ 'travisCiBuildStatus' => ($i%2 == 0) ? $trilean[$i%3] : null,
+ 'nbFollowers' => $i*10,
+ 'nbForks' => $i,
+ 'lastCommitAt' => \DateTime::createFromFormat('Y-m-d', sprintf('2012-07-%d', $i)),
+ 'lastCommits' => array(
+ array(
+ 'commit' => array(
+ 'author' => array(
+ 'date' => '2010-05-16T09:58:32-09:00',
+ 'name' => $owner->getFullName(),
+ 'email' => $owner->getEmail()
+ ),
+ 'committer' => array(
+ 'date' => '2010-05-16T09:58:32-09:00',
+ 'name' => $owner->getFullName(),
+ 'login' => $owner->getName()
+ ),
+ 'url' => 'http://github.com',
+ 'message' => 'Fix something on this Bundle',
+ ),
+ ),
+ array(
+ 'commit' => array(
+ 'author' => array(
+ 'date' => '2010-05-16T09:58:32-07:00',
+ 'name' => $owner->getFullName(),
+ 'email' => $owner->getEmail()
+ ),
+ 'committer' => array(
+ 'date' => '2010-05-16T09:58:32-07:00',
+ 'name' => $owner->getFullName(),
+ 'email' => $owner->getEmail()
+ ),
+ 'url' => 'http://github.com',
+ 'message' => 'Commit something on this bundle',
+ ),
+ ),
+ ),
+ 'isFork' => false,
+ 'contributors' => $contributor ? array($contributor) : array(),
+ 'canonicalConfig' => ($i%2 == 0) ? $this->canonicalConfigDump : null,
+ 'nbRecommenders' => rand(0, 90),
+ ));
+
+ return $bundle;
+ }
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/Bundle.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/Bundle.php
index 518acb96..97fda83f 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Entity/Bundle.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Entity/Bundle.php
@@ -19,7 +19,7 @@
* indexes={
* @ORM\Index(name="trend1", columns={"trend1"})
* },
- * uniqueConstraints={@ORM\UniqueConstraint(name="full_name_unique",columns={"username", "name"})}
+ * uniqueConstraints={@ORM\UniqueConstraint(name="full_name_unique",columns={"ownerName", "name"})}
* )
* @ORM\HasLifecycleCallbacks
*/
@@ -49,31 +49,31 @@ class Bundle
protected $name;
/**
- * The name of the user who owns this bundle
- * This value is redundant with the name of the referenced User, for performance reasons
+ * The name of the owner who owns this bundle
+ * This value is redundant with the name of the referenced Owner, for performance reasons
*
* @Assert\NotBlank()
* @Assert\Length(min = 2)
*
* @ORM\Column(type="string", length=127)
*/
- protected $username;
+ protected $ownerName;
/**
- * User who owns the bundle
+ * Owner of the bundle
*
- * @ORM\ManyToOne(targetEntity="User", inversedBy="bundles")
- * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
+ * @ORM\ManyToOne(targetEntity="Owner", inversedBy="bundles")
+ * @ORM\JoinColumn(name="owner_id", referencedColumnName="id", nullable=false)
*/
- protected $user;
+ protected $owner;
/**
- * Recommenders recommending the bundle
+ * Developers recommending the bundle
*
- * @ORM\ManyToMany(targetEntity="User", inversedBy="recommendedBundles")
+ * @ORM\ManyToMany(targetEntity="Developer", inversedBy="recommendedBundles")
* @ORM\JoinTable(name="bundles_usage",
* joinColumns={@ORM\JoinColumn(name="bundle_id", referencedColumnName="id")},
- * inverseJoinColumns={@ORM\JoinColumn(name="knpbundles_user_id", referencedColumnName="id")}
+ * inverseJoinColumns={@ORM\JoinColumn(name="knpbundles_owner_id", referencedColumnName="id")}
* )
*/
protected $recommenders;
@@ -186,12 +186,12 @@ class Bundle
protected $state = self::STATE_UNKNOWN;
/**
- * Recommenders who contributed to the Repo
+ * Developers who contributed to the Repo
*
- * @ORM\ManyToMany(targetEntity="User", inversedBy="contributionBundles")
+ * @ORM\ManyToMany(targetEntity="Developer", inversedBy="contributionBundles")
* @ORM\JoinTable(name="contribution",
* joinColumns={@ORM\JoinColumn(name="bundle_id", referencedColumnName="id", onDelete="CASCADE")},
- * inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")}
+ * inverseJoinColumns={@ORM\JoinColumn(name="developer_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*
* @var Collection
@@ -293,11 +293,11 @@ class Bundle
public function __construct($fullName = null)
{
if ($fullName) {
- list($this->username, $this->name) = explode('/', $fullName);
+ list($this->ownerName, $this->name) = explode('/', $fullName);
}
- $this->createdAt = new \DateTime('NOW');
- $this->updatedAt = new \DateTime('NOW');
+ $this->createdAt = new \DateTime();
+ $this->updatedAt = new \DateTime();
$this->lastCommitAt = new \DateTime('2010-01-01');
$this->lastCommits = serialize(array());
@@ -491,7 +491,7 @@ public function setLastCommits(array $lastCommits)
{
foreach($lastCommits as $index => $commit) {
$lastCommits[$index]['bundle_name'] = $this->getName();
- $lastCommits[$index]['bundle_username'] = $this->getUsername();
+ $lastCommits[$index]['bundle_ownerName'] = $this->getOwnerName();
}
$this->lastCommits = serialize($lastCommits);
@@ -695,7 +695,7 @@ public function setNbFollowers($nbFollowers)
*/
public function getGitHubUrl()
{
- return sprintf('http://github.com/%s/%s', $this->username, $this->name);
+ return sprintf('http://github.com/%s/%s', $this->ownerName, $this->name);
}
/**
@@ -705,7 +705,7 @@ public function getGitHubUrl()
*/
public function getTravisUrl()
{
- return $this->usesTravisCi ? sprintf('http://travis-ci.org/%s/%s', $this->username, $this->name) : false;
+ return $this->usesTravisCi ? sprintf('http://travis-ci.org/%s/%s', $this->ownerName, $this->name) : false;
}
/**
@@ -725,17 +725,17 @@ public function getPackagistUrl()
*/
public function getGitUrl()
{
- return sprintf('git://github.com/%s/%s.git', $this->username, $this->name);
+ return sprintf('git://github.com/%s/%s.git', $this->ownerName, $this->name);
}
/**
- * Get full name, including username
+ * Get full name, including ownerName
*
* @return string
*/
public function getFullName()
{
- return $this->username.'/'.$this->name;
+ return $this->ownerName.'/'.$this->name;
}
/**
@@ -769,39 +769,39 @@ public function getId()
}
/**
- * Get username
+ * Get ownername
*
* @return string
*/
- public function getUsername()
+ public function getOwnerName()
{
- return $this->username;
+ return $this->ownerName;
}
/**
- * Set username
+ * Set ownername
*
* @param string
*/
- public function setUsername($username)
+ public function setOwnerName($ownername)
{
- $this->username = $username;
+ $this->ownerName = $ownername;
}
/**
- * @return User
+ * @return Owner
*/
- public function getUser()
+ public function getOwner()
{
- return $this->user;
+ return $this->owner;
}
/**
- * @param null|User $user
+ * @param null|Owner $owner
*/
- public function setUser(User $user = null)
+ public function setOwner(Owner $owner = null)
{
- $this->user = $user;
+ $this->owner = $owner;
}
/**
@@ -1007,7 +1007,7 @@ public function toSmallArray()
return array(
'type' => $this->getClass(),
'name' => $this->getName(),
- 'username' => $this->getUsername(),
+ 'ownerName' => $this->getOwnerName(),
'description' => $this->getDescription(),
'homepage' => $this->getHomepage(),
'score' => $this->getScore(),
@@ -1030,7 +1030,7 @@ public function fromArray(array $data)
public function __toString()
{
- return $this->username.'/'.$this->name;
+ return $this->ownerName.'/'.$this->name;
}
public function getClass()
@@ -1066,34 +1066,34 @@ public function getNbRecommenders()
return count($this->recommenders);
}
- public function addRecommender(User $user)
+ public function addRecommender(Owner $owner)
{
- $user->addRecommendedBundle($this);
+ $owner->addRecommendedBundle($this);
- $this->recommenders[] = $user;
+ $this->recommenders[] = $owner;
$this->nbRecommenders++;
}
- public function removeRecommender(User $user)
+ public function removeRecommender(Owner $owner)
{
- $user->getUsedBundles()->removeElement($this);
+ $owner->getUsedBundles()->removeElement($this);
- $this->recommenders->removeElement($user);
+ $this->recommenders->removeElement($owner);
$this->nbRecommenders--;
}
/**
- * @param User $user
+ * @param Owner $owner
*
* @return boolean
*/
- public function isOwnerOrContributor(User $user)
+ public function isOwnerOrContributor(Owner $owner)
{
- if ($this->user->isEqualTo($user)) {
+ if ($this->owner->isEqualTo($owner)) {
return true;
}
- return $this->contributors->contains($user);
+ return $this->contributors->contains($owner);
}
/**
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/Developer.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/Developer.php
new file mode 100644
index 00000000..fc42ccd8
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Entity/Developer.php
@@ -0,0 +1,290 @@
+organizations = new ArrayCollection();
+ $this->recommendedBundles = new ArrayCollection();
+ $this->contributionBundles = new ArrayCollection();
+
+ parent::__construct();
+ }
+
+
+ /**
+ * @param $company
+ */
+ public function setCompany($company)
+ {
+ $this->company = $company;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getCompany()
+ {
+ return $this->company;
+ }
+
+ /**
+ * Add organizations
+ *
+ * @param Organization $organizations
+ */
+ public function addOrganization(Organization $organizations)
+ {
+ $this->organizations[] = $organizations;
+ }
+
+ /**
+ * Remove organizations
+ *
+ * @param Organization $organizations
+ */
+ public function removeOrganization(Organization $organizations)
+ {
+ $this->organizations->removeElement($organizations);
+ }
+
+ /**
+ * Get organizations
+ *
+ * @return ArrayCollection
+ */
+ public function getOrganizations()
+ {
+ return $this->organizations;
+ }
+
+ /**
+ * Add recommendedBundles
+ *
+ * @param Bundle $recommendedBundles
+ */
+ public function addRecommendedBundle(Bundle $recommendedBundles)
+ {
+ $this->recommendedBundles[] = $recommendedBundles;
+ }
+
+ /**
+ * Remove recommendedBundles
+ *
+ * @param Bundle $recommendedBundles
+ */
+ public function removeRecommendedBundle(Bundle $recommendedBundles)
+ {
+ $this->recommendedBundles->removeElement($recommendedBundles);
+ }
+
+ /**
+ * Get recommendedBundles
+ *
+ * @return ArrayCollection
+ */
+ public function getRecommendedBundles()
+ {
+ return $this->recommendedBundles;
+ }
+
+ /**
+ * Add contributionBundles
+ *
+ * @param Bundle $contributionBundles
+ */
+ public function addContributionBundle(Bundle $contributionBundles)
+ {
+ $this->contributionBundles[] = $contributionBundles;
+ }
+
+ /**
+ * Remove contributionBundles
+ *
+ * @param Bundle $contributionBundles
+ */
+ public function removeContributionBundle(Bundle $contributionBundles)
+ {
+ $this->contributionBundles->removeElement($contributionBundles);
+ }
+
+ /**
+ * Get contributionBundles
+ *
+ * @return ArrayCollection
+ */
+ public function getContributionBundles()
+ {
+ return $this->contributionBundles;
+ }
+
+ /**
+ * @param $lastCommitsCache
+ */
+ public function setLastCommitsCache($lastCommitsCache)
+ {
+ $this->lastCommitsCache = $lastCommitsCache;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLastCommitsCache()
+ {
+ return $this->lastCommitsCache;
+ }
+
+ /**
+ * Get the date of the last commit
+ *
+ * @return \DateTime
+ */
+ public function getLastCommitAt()
+ {
+ $lastCommits = $this->getLastCommits(1);
+ if (empty($lastCommits)) {
+ return null;
+ }
+ $lastCommit = $lastCommits[0];
+ $date = new \DateTime($lastCommit['committed_date']);
+
+ return $date;
+ }
+
+ /**
+ * Get the more recent commits by this user
+ *
+ * @param integer $nb
+ * @return array
+ */
+ public function getLastCommits($nb = 10)
+ {
+ if (null === $this->lastCommitsCache) {
+ $commits = array();
+ foreach ($this->getAllBundles() as $bundle) {
+ foreach ($bundle->getLastCommits() as $commit) {
+ if (isset($commit['author']['login']) && $commit['author']['login'] === $this->name) {
+ $commits[] = $commit;
+ }
+ }
+ }
+ usort($commits, function($a, $b) {
+ return strtotime($a['committed_date']) < strtotime($b['committed_date']);
+ });
+ $this->lastCommitsCache = $commits;
+ }
+ $commits = array_slice($this->lastCommitsCache, 0, $nb);
+
+ return $commits;
+ }
+
+ public function toSmallArray()
+ {
+ return array(
+ 'name' => $this->getName(),
+ 'email' => $this->getEmail(),
+ 'gravatarHash' => $this->getAvatarUrl(),
+ 'fullName' => $this->getFullName(),
+ 'company' => $this->getCompany(),
+ 'location' => $this->getLocation(),
+ 'blog' => $this->getUrl(),
+ 'bundles' => $this->getBundleNames(),
+ 'lastCommitAt' => $this->getLastCommitAt() ? $this->getLastCommitAt()->getTimestamp() : null,
+ 'score' => $this->getScore(),
+ );
+ }
+
+ public function toBigArray()
+ {
+ return $this->toSmallArray() + array(
+ 'lastCommits' => $this->getLastCommits()
+ );
+ }
+
+ /**
+ * @return array
+ */
+ public function getAllBundles()
+ {
+ return array_merge($this->bundles->toArray(), $this->contributionBundles->toArray());
+ }
+
+ /* ---------- Security User ---------- */
+ public function getUsername()
+ {
+ return $this->name;
+ }
+
+ public function getRoles()
+ {
+ return array('ROLE_USER');
+ }
+
+ public function getPassword()
+ {
+ return '';
+ }
+
+ public function getSalt()
+ {
+ return '';
+ }
+
+ public function eraseCredentials()
+ {
+ }
+
+ public function isEqualTo(Developer $developer)
+ {
+ return $developer->getName() === $this->getName();
+ }
+ /* !--------- Security User ---------! */
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/Organization.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/Organization.php
new file mode 100644
index 00000000..d18e64d6
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Entity/Organization.php
@@ -0,0 +1,105 @@
+members = new ArrayCollection();
+
+ parent::__construct();
+ }
+
+ /**
+ * Add members
+ *
+ * @param Developer $member
+ */
+ public function addMember(Developer $member)
+ {
+ $this->members[] = $member;
+ }
+
+ /**
+ * Remove members
+ *
+ * @param Developer $member
+ */
+ public function removeMember(Developer $member)
+ {
+ $this->members->removeElement($member);
+ }
+
+ /**
+ * Get members
+ *
+ * @return ArrayCollection
+ */
+ public function getMembers()
+ {
+ return $this->members;
+ }
+
+ /**
+ * Set members
+ * @param ArrayCollection|array $members
+ */
+ public function setMembers($members)
+ {
+ if ($members instanceof ArrayCollection) {
+ $this->members = $members;
+ } elseif (is_array($members)) {
+ foreach ($members as $member) {
+ if (!$this->members->contains($member)) {
+ $this->addMember($member);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the names of this organization members
+ *
+ * @return array
+ */
+ public function getMemberNames()
+ {
+ $names = array();
+ foreach ($this->members as $member) {
+ $names[] = $member->getName();
+ }
+
+ return $names;
+ }
+
+ public function toArray()
+ {
+ return array(
+ 'name' => $this->getName(),
+ 'email' => $this->getEmail(),
+ 'avatarUrl' => $this->getAvatarUrl(),
+ 'fullName' => $this->getFullName(),
+ 'location' => $this->getLocation(),
+ 'blog' => $this->getUrl(),
+ 'bundles' => $this->getBundleNames(),
+ 'members' => $this->getMemberNames(),
+ 'score' => $this->getScore(),
+ );
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/Owner.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/Owner.php
new file mode 100644
index 00000000..3bcad5b7
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Entity/Owner.php
@@ -0,0 +1,355 @@
+bundles = new ArrayCollection();
+ $this->createdAt = new \DateTime();
+ $this->score = 0;
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set fullName
+ *
+ * @param string $fullName
+
+ */
+ public function setFullName($fullName)
+ {
+ $this->fullName = $fullName;
+ }
+
+ /**
+ * Get fullName
+ *
+ * @return string
+ */
+ public function getFullName()
+ {
+ return $this->fullName;
+ }
+
+ /**
+ * Set email
+ *
+ * @param string $email
+
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ }
+
+ /**
+ * Get email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Set avatarUrl
+ *
+ * @param string $avatarUrl
+
+ */
+ public function setAvatarUrl($avatarUrl)
+ {
+ $this->avatarUrl = $avatarUrl;
+ }
+
+ /**
+ * Get avatarUrl
+ *
+ * @return string
+ */
+ public function getAvatarUrl()
+ {
+ return $this->avatarUrl;
+ }
+
+ /**
+ * Set url
+ *
+ * @param string $url
+ */
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+
+ /**
+ * Get url
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * Set location
+ *
+ * @param string $location
+ */
+ public function setLocation($location)
+ {
+ $this->location = $location;
+ }
+
+ /**
+ * Get location
+ *
+ * @return string
+ */
+ public function getLocation()
+ {
+ return $this->location;
+ }
+
+ /**
+ * Set createdAt
+ *
+ * @param \DateTime $createdAt
+ */
+ public function setCreatedAt($createdAt)
+ {
+ $this->createdAt = $createdAt;
+ }
+
+ /**
+ * Get createdAt
+ *
+ * @return \DateTime
+ */
+ public function getCreatedAt()
+ {
+ return $this->createdAt;
+ }
+
+ /**
+ * Set score
+ *
+ * @param integer $score
+ */
+ public function setScore($score)
+ {
+ $this->score = $score;
+ }
+
+ /**
+ * Get score
+ *
+ * @return integer
+ */
+ public function getScore()
+ {
+ return $this->score;
+ }
+
+ /**
+ * Add bundles
+ *
+ * @param Bundle $bundles
+ */
+ public function addBundle(Bundle $bundles)
+ {
+ $this->bundles[] = $bundles;
+ }
+
+ /**
+ * Remove bundles
+ *
+ * @param Bundle $bundles
+ */
+ public function removeBundle(Bundle $bundles)
+ {
+ $this->bundles->removeElement($bundles);
+ }
+
+ /**
+ * Get bundles
+ *
+ * @return ArrayCollection
+ */
+ public function getBundles()
+ {
+ return $this->bundles;
+ }
+
+ /**
+ * Count the user bundles
+ *
+ * @return integer
+ */
+ public function getNbBundles()
+ {
+ return $this->bundles->count();
+ }
+
+ /**
+ * @return boolean
+ */
+ public function hasBundles()
+ {
+ return ($this->getNbBundles() > 0);
+ }
+
+ /**
+ * Owner profile url on GitHub
+ *
+ * @return string
+ */
+ public function getGithubUrl()
+ {
+ return sprintf('http://github.com/%s', $this->name);
+ }
+
+ /**
+ * Get the names of this user bundles
+ *
+ * @return array
+ */
+ public function getBundleNames()
+ {
+ $names = array();
+ foreach ($this->bundles as $bundle) {
+ $names[] = $bundle->getName();
+ }
+
+ return $names;
+ }
+
+ /**
+ * Common method to fill in entity from array
+ * @todo move it to another place
+ */
+ public function fromArray(array $data)
+ {
+ foreach ($data as $key => $value) {
+ $this->{'set'.$key}($value);
+ }
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/OwnerManager.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/OwnerManager.php
new file mode 100644
index 00000000..b02b9259
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Entity/OwnerManager.php
@@ -0,0 +1,115 @@
+
+ */
+class OwnerManager
+{
+ /**
+ * @var ObjectManager
+ */
+ private $entityManager;
+
+ /**
+ * @var \Knp\Bundle\KnpBundlesBundle\Repository\OwnerRepository
+ */
+ private $repository;
+
+ /**
+ * @var Client
+ */
+ private $github;
+
+ /**
+ * @param ObjectManager $entityManager
+ * @param Client $github
+ */
+ public function __construct(ObjectManager $entityManager, Client $github)
+ {
+ $this->entityManager = $entityManager;
+ $this->repository = $entityManager->getRepository('Knp\Bundle\KnpBundlesBundle\Entity\Owner');
+ $this->github = $github;
+ }
+
+ /**
+ * @param array $data
+ *
+ * @return mixed
+ */
+ public function findOwnerBy(array $data)
+ {
+ return $this->repository->findOneBy($data);
+ }
+
+ /**
+ * @param string|UserResponseInterface $data
+ *
+ * @return Developer
+ *
+ * @throws UserNotFoundException
+ */
+ public function getOrCreate($data)
+ {
+ if (is_string($data)) {
+ $ownerName = $data;
+ } elseif ($data instanceof UserResponseInterface) {
+ if ($data instanceof SensioConnectUserResponse) {
+ $ownerName = $data->getLinkedAccount('github') ?: $data->getNickname();
+ } else {
+ $ownerName = $data->getNickname();
+ }
+ }
+
+ if (!$owner = $this->findOwnerBy(array('name' => $ownerName))) {
+ if (!$api = $this->getApiByOwnerName($data)) {
+ return false;
+ }
+
+ $owner = $api->import($data);
+
+ $this->entityManager->persist($owner);
+ $this->entityManager->flush();
+ }
+
+ return $owner;
+ }
+
+ /**
+ * @param $ownerName
+ * @return GithubOwnerInterface
+ */
+ public function getApiByOwnerName($ownerName)
+ {
+ $githubOwner = $this->github->api('user')->show($ownerName);
+
+ if (!is_array($githubOwner) || !isset($githubOwner['type'])) {
+ return false;
+ }
+
+ if ($githubOwner['type'] != 'Organization') {
+ $api = new GithubDeveloper($this->github, new NullOutput());
+ } else {
+ $api = new GithubOrganization($this->github, new NullOutput());
+ $api->setRepository($this->repository);
+ }
+
+ return $api;
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/User.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/User.php
deleted file mode 100644
index 01780ecf..00000000
--- a/src/Knp/Bundle/KnpBundlesBundle/Entity/User.php
+++ /dev/null
@@ -1,621 +0,0 @@
-bundles = new ArrayCollection();
- $this->recommendedBundles = new ArrayCollection();
- $this->contributionBundles = new ArrayCollection();
- $this->createdAt = new \DateTime('NOW');
- }
-
- /**
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * Get the gravatar hash
- *
- * @return string
- */
- public function getGravatarHash()
- {
- if (32 === strlen($this->gravatarHash)) {
- return sprintf('http://www.gravatar.com/avatar/%s?s=80&r=g&d=identicon', $this->gravatarHash);
- }
-
- return $this->gravatarHash;
- }
-
- /**
- * Set the gravatar hash
- *
- * @param string $gravatarHash
- */
- public function setGravatarHash($gravatarHash)
- {
- $this->gravatarHash = $gravatarHash;
- }
-
- /**
- * Get blog
- *
- * @return string
- */
- public function getBlog()
- {
- return $this->blog;
- }
-
- /**
- * Set blog
- *
- * @param string $blog
- */
- public function setBlog($blog)
- {
- $this->blog = $blog;
- }
-
- /**
- * Get location
- *
- * @return string
- */
- public function getLocation()
- {
- return $this->location;
- }
-
- /**
- * Set location
- *
- * @param string $location
- */
- public function setLocation($location)
- {
- $this->location = $location;
- }
-
- /**
- * Get company
- *
- * @return string
- */
- public function getCompany()
- {
- return $this->company;
- }
-
- /**
- * Set company
- *
- * @param string $company
- */
- public function setCompany($company)
- {
- $this->company = $company;
- }
-
- /**
- * Get fullName
- *
- * @return string
- */
- public function getFullName()
- {
- return $this->fullName;
- }
-
- /**
- * Set fullName
- *
- * @param string $fullName
- */
- public function setFullName($fullName)
- {
- $this->fullName = $fullName;
- }
-
- /**
- * Get score
- *
- * @return integer
- */
- public function getScore()
- {
- return $this->score;
- }
-
- /**
- * Set score
- *
- * @param integer $score
- */
- public function setScore($score)
- {
- $this->score = (int) $score;
- }
-
- /**
- * Calculate the score of this user based on his bundles' scores
- */
- public function recalculateScore()
- {
- $score = 0;
- foreach ($this->bundles as $bundle) {
- $score += $bundle->getScore();
- }
-
- $this->setScore($score);
- }
-
- /**
- * Get bundles
- *
- * @return ArrayCollection
- */
- public function getBundles()
- {
- return $this->bundles;
- }
-
- public function getAllBundles()
- {
- return array_merge($this->bundles->toArray(), $this->contributionBundles->toArray());
- }
-
- /**
- * Count the user bundles
- *
- * @return integer
- */
- public function getNbBundles()
- {
- return $this->bundles->count();
- }
-
- public function hasBundles()
- {
- return ($this->getNbBundles() > 0);
- }
-
- /**
- * Get the names of this user bundles
- *
- * @return array
- */
- public function getBundleNames()
- {
- $names = array();
- foreach ($this->bundles as $bundle) {
- $names[] = $bundle->getName();
- }
-
- return $names;
- }
-
- /**
- * Add a bundle to this user bundles
- *
- * @param Bundle $bundle
- */
- public function addBundle(Bundle $bundle)
- {
- if ($this->bundles->contains($bundle)) {
- throw new \OverflowException(sprintf('User %s already owns the %s bundle', $this->name, $bundle->getName()));
- }
- $this->bundles->add($bundle);
- $bundle->setUser($this);
- }
-
- /**
- * Remove a bundle from this user bundles
- *
- * @param Bundle $bundle
- */
- public function removeBundle(Bundle $bundle)
- {
- $this->bundles->removeElement($bundle);
- $bundle->setUser(null);
- }
-
- /**
- * Get contributionBundles
- *
- * @return ArrayCollection
- */
- public function getContributionBundles()
- {
- return $this->contributionBundles;
- }
-
- public function getContributionBundlesSortedByScore()
- {
- return $this->sortBundlesByScore($this->contributionBundles->toArray());
- }
-
- public function hasContributionBundles()
- {
- return !empty($this->contributionBundles);
- }
-
- /**
- * Set contributionBundles
- *
- * @param ArrayCollection $contributionBundles
- */
- public function setContributionBundles(ArrayCollection $contributionBundles)
- {
- $this->contributionBundles = $contributionBundles;
- }
-
- public function getNbContributionBundles()
- {
- return $this->contributionBundles->count();
- }
-
- protected function sortBundlesByScore(array $bundles)
- {
- uasort($bundles, function($a, $b) {
- return $a->getScore() > $b->getScore();
- });
-
- return $bundles;
- }
-
- /**
- * Get the date of the last commit
- *
- * @return \DateTime
- */
- public function getLastCommitAt()
- {
- $lastCommits = $this->getLastCommits(1);
- if (empty($lastCommits)) {
- return null;
- }
- $lastCommit = $lastCommits[0];
- $date = new \DateTime($lastCommit['committed_date']);
-
- return $date;
- }
-
- /**
- * Get the more recent commits by this user
- *
- * @param integer $nb
- *
- * @return array
- */
- public function getLastCommits($nb = 10)
- {
- if (null === $this->lastCommitsCache) {
- $commits = array();
- foreach ($this->getAllBundles() as $bundle) {
- foreach ($bundle->getLastCommits() as $commit) {
- if (isset($commit['author']['login']) && $commit['author']['login'] === $this->name) {
- $commits[] = $commit;
- }
- }
- }
- usort($commits, function($a, $b) {
- return strtotime($a['committed_date']) < strtotime($b['committed_date']);
- });
- $this->lastCommitsCache = $commits;
- }
- $commits = array_slice($this->lastCommitsCache, 0, $nb);
-
- return $commits;
- }
-
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
-
- /**
- * Get an obfuscated email, less likely to be deciphered by spambots
- *
- * @return string
- */
- public function getObfuscatedEmail()
- {
- $text = $this->email;
- $result = '';
- $length = strlen($text);
- for ($i = 0; $i < $length; $i++) {
- if (mt_rand(0, 1)) {
- $result .= substr($text, $i, 1);
- } else {
- if (mt_rand(0, 1)) {
- $result .= ''.ord(substr($text, $i, 1)).';';
- } else {
- $result .= ''.sprintf("%x", ord(substr($text, $i, 1))).';';
- }
- }
- }
- if (mt_rand(0, 1)) {
- return str_replace('@', '@', $result);
- }
-
- return str_replace('@', '@', $result);
- }
-
- /**
- * Set email
- *
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
-
- /**
- * User url on GitHub
- *
- * @return string
- */
- public function getGithubUrl()
- {
- return sprintf('http://github.com/%s', $this->name);
- }
-
- /**
- * Get name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Get name
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->getName();
- }
-
- /**
- * Set name
- *
- * @param string $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
-
- /**
- * getCreatedAt
- *
- * @return \DateTime
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
-
- /**
- * Set the user creation date
- *
- * @param \DateTime $createdAt
- */
- public function setCreatedAt(\DateTime $createdAt)
- {
- $this->createdAt = $createdAt;
- }
-
- /** @ORM\PrePersist */
- public function markAsCreated()
- {
- $this->createdAt = new \DateTime();
- }
-
- public function __toString()
- {
- return $this->getName();
- }
-
- public function toSmallArray()
- {
- return array(
- 'name' => $this->getName(),
- 'email' => $this->getEmail(),
- 'gravatarHash' => $this->getGravatarHash(),
- 'fullName' => $this->getFullName(),
- 'company' => $this->getCompany(),
- 'location' => $this->getLocation(),
- 'blog' => $this->getBlog(),
- 'bundles' => $this->getBundleNames(),
- 'lastCommitAt' => $this->getLastCommitAt() ? $this->getLastCommitAt()->getTimestamp() : null,
- 'score' => $this->getScore(),
- );
- }
-
- public function toBigArray()
- {
- return $this->toSmallArray() + array(
- 'lastCommits' => $this->getLastCommits()
- );
- }
-
- public function fromArray(array $data)
- {
- foreach ($data as $key => $value) {
- $this->{'set'.$key}($value);
- }
- }
-
- public function getUsedBundles()
- {
- return $this->recommendedBundles;
- }
-
- public function isUsingBundle(Bundle $bundle)
- {
- return $this->recommendedBundles->contains($bundle);
- }
-
- public function addRecommendedBundle(Bundle $bundle)
- {
- $this->recommendedBundles[] = $bundle;
- }
-
- /* ---------- Security User ---------- */
-
- public function getRoles()
- {
- return array('ROLE_USER');
- }
-
- public function getPassword()
- {
- return '';
- }
-
- public function getSalt()
- {
- return '';
- }
-
- public function eraseCredentials()
- {
- }
-
- public function isEqualTo(UserInterface $user)
- {
- return $user instanceof User && $user->getUsername() === $this->getUsername();
- }
-}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Entity/UserManager.php b/src/Knp/Bundle/KnpBundlesBundle/Entity/UserManager.php
deleted file mode 100644
index b568c230..00000000
--- a/src/Knp/Bundle/KnpBundlesBundle/Entity/UserManager.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
- */
-class UserManager
-{
- /**
- * @var Doctrine\Common\Persistence\ObjectManager
- */
- private $entityManager;
-
- /**
- * @var Doctrine\ORM\EntityRepository
- */
- private $repository;
-
- /**
- * @var GithubUser
- */
- private $githubUserApi;
-
- /**
- * @param ObjectManager $entityManager
- */
- public function __construct(ObjectManager $entityManager)
- {
- $this->entityManager = $entityManager;
- $this->repository = $entityManager->getRepository('Knp\Bundle\KnpBundlesBundle\Entity\User');
- $this->githubUserApi = new GithubUser(new Client(), new NullOutput());
- }
-
- /**
- * @param array $data
- *
- * @return mixed
- */
- public function findUserBy(array $data)
- {
- return $this->repository->findOneBy($data);
- }
-
- /**
- * @param string|UserResponseInterface $data
- *
- * @return User
- *
- * @throws UserNotFoundException
- */
- public function getOrCreate($data)
- {
- if (is_string($data)) {
- $username = $data;
- } elseif ($data instanceof UserResponseInterface) {
- if ($data instanceof SensioConnectUserResponse) {
- $username = $data->getLinkedAccount('github') ?: $data->getNickname();
- } else {
- $username = $data->getNickname();
- }
- }
-
- if (!$user = $this->findUserBy(array('name' => $username))) {
- if (!$user = $this->githubUserApi->import($data)) {
- throw new UserNotFoundException();
- }
-
- $this->entityManager->persist($user);
- $this->entityManager->flush();
- }
-
- return $user;
- }
-}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Features/Context/FeatureContext.php b/src/Knp/Bundle/KnpBundlesBundle/Features/Context/FeatureContext.php
index 49e21e5c..90b10f37 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Features/Context/FeatureContext.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Features/Context/FeatureContext.php
@@ -35,7 +35,8 @@
*/
class FeatureContext extends RawMinkContext implements KernelAwareInterface
{
- private $users;
+ private $developers;
+ private $organizations;
private $bundles;
/**
@@ -58,18 +59,23 @@ public function theSiteHasFollowingUsers(TableNode $table)
{
$entityManager = $this->getEntityManager();
- $this->users = array();
+ $this->developers = array();
foreach ($table->getHash() as $row) {
- $user = new Entity\User();
+ $developer = new Entity\Developer();
- $user->fromArray(array(
+ $developer->fromArray(array(
'name' => $row['name'],
'score' => 0,
));
- $entityManager->persist($user);
+ if (isset($row['organization'])) {
+ $organization = $this->organizations[$row['organization']];
+ $developer->addOrganization($organization);
+ }
+
+ $entityManager->persist($developer);
- $this->users[$user->getName()] = $user;
+ $this->developers[$developer->getName()] = $developer;
}
$entityManager->flush();
@@ -84,13 +90,17 @@ public function theSiteHasFollowingBundles(TableNode $table)
$this->bundles = array();
foreach ($table->getHash() as $row) {
- $user = $this->users[$row['username']];
+ if (isset($this->developers[$row['username']])) {
+ $owner = $this->developers[$row['username']];
+ } elseif (isset($this->organizations[$row['username']])) {
+ $owner = $this->organizations[$row['username']];
+ }
$bundle = new Entity\Bundle();
$bundle->fromArray(array(
'name' => $row['name'],
- 'user' => $user,
- 'username' => $user->getName(),
+ 'owner' => $owner,
+ 'ownerName' => $owner->getName(),
'description' => $row['description'],
'state' => isset($row['state']) ? $row['state'] : Entity\Bundle::STATE_UNKNOWN,
'lastCommitAt' => new \DateTime($row['lastCommitAt']),
@@ -101,14 +111,14 @@ public function theSiteHasFollowingBundles(TableNode $table)
$this->setPrivateProperty($bundle, "trend1", $row['trend1']);
if (isset($row['recommendedBy'])) {
- $usernames = explode(',', $row['recommendedBy']);
- foreach ($usernames as $username) {
- $user = $this->users[trim($username)];
+ $ownerNames = explode(',', $row['recommendedBy']);
+ foreach ($ownerNames as $ownerName) {
+ $owner = $this->developers[trim($ownerName)];
- $bundle->addRecommender($user);
- $user->addRecommendedBundle($bundle);
+ $bundle->addRecommender($owner);
+ $owner->addRecommendedBundle($bundle);
- $entityManager->persist($user);
+ $entityManager->persist($owner);
}
}
@@ -196,11 +206,11 @@ public function searchFor($text)
}
/**
- * @Then /^I should be on "(?P[^"]+)\/(?P[^"]+)" bundle page$/
+ * @Then /^I should be on "(?P[^"]+)\/(?P[^"]+)" bundle page$/
*/
- public function assertBundlePage($username, $name)
+ public function assertBundlePage($ownerName, $name)
{
- $url = $this->getRouter()->generate('bundle_show', array('username' => $username, 'name' => $name));
+ $url = $this->getRouter()->generate('bundle_show', array('ownerName' => $ownerName, 'name' => $name));
return new Step\Then('I should be on "'.$url.'"');
}
@@ -266,15 +276,15 @@ public function iAmAtHomepage()
}
/**
- * @Then /^I should see "([^"]*)" developer$/
+ * @Then /^I should see "([^"]*)" (developer|organization)$/
*/
- public function iShouldSeeDeveloper($username)
+ public function iShouldSeeOwner($ownerName)
{
- return new Step\Then(sprintf('I should see "%s"', $username));
+ return new Step\Then(sprintf('I should see "%s"', $ownerName));
}
/**
- * @Then /^I should see that "([^"]*)" is managed by developer$/
+ * @Then /^I should see that "([^"]*)" is managed by (developer|organization)$/
*/
public function iShouldSeeThatIsManagedByDeveloper($bundleName)
{
@@ -286,10 +296,10 @@ public function iShouldSeeThatIsManagedByDeveloper($bundleName)
*/
public function iAmLoggedInAs($username)
{
- if (!$this->users[$username]) {
+ if (!$this->developers[$username]) {
throw new ExpectationException('User not found');
}
- $user = $this->users[$username];
+ $user = $this->developers[$username];
$token = new OAuthToken(null,$user->getRoles());
$token->setUser($user);
@@ -300,6 +310,38 @@ public function iAmLoggedInAs($username)
$session->save();
}
+ /**
+ * @Given /^the site has following organizations:$/
+ */
+ public function theSiteHasFollowingOrganizations(TableNode $table)
+ {
+ $entityManager = $this->getEntityManager();
+
+ $this->organizations = array();
+ foreach ($table->getHash() as $row) {
+ $organization = new Entity\Organization();
+
+ $organization->fromArray(array(
+ 'name' => $row['name'],
+ 'score' => 0,
+ ));
+
+ $entityManager->persist($organization);
+
+ $this->organizations[$organization->getName()] = $organization;
+ }
+
+ $entityManager->flush();
+ }
+
+ /**
+ * @Given /^organization "([^"]*)" has following members:$/
+ */
+ public function organizationHasFollowingMembers($orgName, TableNode $table)
+ {
+ throw new PendingException();
+ }
+
/**
* Sets Kernel instance.
*
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Features/bundleSearch.feature b/src/Knp/Bundle/KnpBundlesBundle/Features/bundleSearch.feature
index 3c6d3776..88a4d30d 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Features/bundleSearch.feature
+++ b/src/Knp/Bundle/KnpBundlesBundle/Features/bundleSearch.feature
@@ -34,6 +34,7 @@ Feature: Searching bundles
Then I should see "Found 5 bundles"
And I should see "UserBundle"
+ @wip
Scenario: Search one bundle with exact name
When I go to "/"
And I search for "FOSUserBundle"
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Features/bundleShow.feature b/src/Knp/Bundle/KnpBundlesBundle/Features/bundleShow.feature
index 8bf3a8db..fa6f972d 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Features/bundleShow.feature
+++ b/src/Knp/Bundle/KnpBundlesBundle/Features/bundleShow.feature
@@ -9,7 +9,7 @@ Feature: Showing bundles
Given the site has following bundles:
| username | name | description | lastCommitAt | score | trend1 |
| knplabs | TestBundle | test desc |-1 day | 10 | 15 |
-
+@wip
Scenario: Show bundle
When I go to "/"
And I follow "TestBundle"
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Features/organizationList.feature b/src/Knp/Bundle/KnpBundlesBundle/Features/organizationList.feature
new file mode 100644
index 00000000..b6fe4a5b
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Features/organizationList.feature
@@ -0,0 +1,17 @@
+@organizations
+Feature: Listing organizations
+ As a Visitor
+ I want to browse through organizations list
+
+ Background:
+ Given the site has following organizations:
+ | name |
+ | KnpLabs |
+ | FriendsOfSymfony |
+
+ Scenario: Listing organizations
+ When I go to "/"
+ And I follow "Organizations"
+ Then I should see "2 organizations using Symfony2"
+ And I should see "KnpLabs" organization
+ And I should see "FriendsOfSymfony" organization
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Features/organizationShow.feature b/src/Knp/Bundle/KnpBundlesBundle/Features/organizationShow.feature
new file mode 100644
index 00000000..9aec71e9
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Features/organizationShow.feature
@@ -0,0 +1,24 @@
+@organizations
+Feature: Show organization page
+ As a Visitor
+ I want to see detailed info about organization
+
+ Background:
+ Given the site has following organizations:
+ | name |
+ | KnpLabs |
+ | FriendsOfSymfony |
+ Given the site has following bundles:
+ | username | name | description | lastCommitAt | score | trend1 |
+ | KnpLabs | TestBundle | test desc | -1 day | 10 | 15 |
+ | FriendsOfSymfony | UserBundle | user desc | -2 days | 20 | 5 |
+ Given the site has following users:
+ | name | organization |
+ | cursedcoder | KnpLabs |
+ | stof | FriendsOfSymfony |
+
+ Scenario: Show organization page
+ When I go to "/organization"
+ And I follow "KnpLabs"
+ Then response is successful
+ And I should see that "TestBundle" is managed by organization
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Git/RepoManager.php b/src/Knp/Bundle/KnpBundlesBundle/Git/RepoManager.php
index 22295929..e57cac81 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Git/RepoManager.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Git/RepoManager.php
@@ -35,8 +35,8 @@ public function __construct(Filesystem $filesystem, $dir, $gitExecutable)
}
/**
- * @param Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
- * @return Knp\Bundle\KnpBundlesBundle\Git\Repo
+ * @param \Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
+ * @return \Knp\Bundle\KnpBundlesBundle\Git\Repo
*/
public function getRepo(BundleEntity $bundle)
{
@@ -51,7 +51,7 @@ public function getRepo(BundleEntity $bundle)
}
/**
- * @param Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
+ * @param \Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
* @return boolean
*/
public function hasRepo(BundleEntity $repo)
@@ -83,7 +83,7 @@ public function setDir($dir)
}
/**
- * @param Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
+ * @param \Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
* @return PHPGit_Repository
*/
protected function createGitRepo(BundleEntity $bundle)
@@ -105,11 +105,11 @@ protected function cloneRepo($repoUrl, $targetDir)
}
/**
- * @param Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
+ * @param \Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle
* @return string
*/
protected function getRepoDir(BundleEntity $repo)
{
- return $this->dir.DIRECTORY_SEPARATOR.$repo->getUsername().DIRECTORY_SEPARATOR.$repo->getName();
+ return $this->dir.DIRECTORY_SEPARATOR.$repo->getOwnerName().DIRECTORY_SEPARATOR.$repo->getName();
}
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Github/Developer.php b/src/Knp/Bundle/KnpBundlesBundle/Github/Developer.php
new file mode 100644
index 00000000..35e59616
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Github/Developer.php
@@ -0,0 +1,100 @@
+setName($response);
+ } else {
+ $developer->setName($response->getNickname());
+ $developer->setFullName($response->getRealName());
+ }
+
+ if ($response instanceof SensioConnectUserResponse) {
+ $developer->setName($response->getLinkedAccount('github') ?: $response->getNickname());
+ }
+
+ if ($response instanceof AdvancedUserResponseInterface) {
+ $developer->setEmail($response->getEmail());
+ $developer->setAvatarUrl($response->getProfilePicture());
+ }
+
+ if (!$this->update($developer)) {
+ return false;
+ }
+
+ return $developer;
+ }
+
+ /**
+ * @param EntityDeveloper $developer
+ *
+ * @return boolean
+ */
+ public function update(EntityDeveloper $developer)
+ {
+ $keywords = array(
+ $developer->getName()
+ );
+ if (null !== $developer->getFullName()) {
+ $keywords[] = $developer->getFullName();
+ }
+ if (null !== $developer->getEmail()) {
+ $keywords[] = $developer->getEmail();
+ }
+
+ $api = $this->github->api('user');
+ $data = $api->show($developer->getName());
+
+ if (empty($data)) {
+ foreach ($keywords as $field) {
+ try {
+ $data = $api->search($field);
+ if (isset($data['users']) && 0 < count($data['users'])) {
+ $data = $data['users'][0];
+ // Let's call API one more time to get clean user data
+ $data = $api->show($data['login']);
+ }
+ } catch(ApiLimitExceedException $e) {
+ break;
+ }
+
+ // Did we found user in this iteration ?
+ if (!empty($data) && !isset($data['message'])) {
+ break;
+ }
+ }
+ }
+
+ // Developer has been removed / not found ?
+ if (empty($data) || isset($data['message'])) {
+ return false;
+ }
+
+ $developer->setFullName(isset($data['fullname']) ? $data['fullname'] : null);
+ $developer->setEmail(isset($data['email']) ? $data['email'] : null);
+ $developer->setAvatarUrl(isset($data['avatar_url']) ? $data['avatar_url'] : null);
+ $developer->setCompany(isset($data['company']) ? $data['company'] : null);
+ $developer->setLocation(isset($data['location']) ? $data['location'] : null);
+ $developer->setUrl(isset($data['blog']) ? $this->fixUrl($data['blog']) : null);
+
+ return true;
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Github/Organization.php b/src/Knp/Bundle/KnpBundlesBundle/Github/Organization.php
new file mode 100644
index 00000000..71d3ddf8
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Github/Organization.php
@@ -0,0 +1,103 @@
+repository = $repository;
+ }
+
+ /**
+ * @param string
+ *
+ * @return boolean|EntityOrganization
+ */
+ public function import($response)
+ {
+ $organization = new EntityOrganization();
+ $organization->setName($response);
+
+ if (!$this->update($organization)) {
+ return false;
+ }
+
+ return $organization;
+ }
+
+ /**
+ * @param EntityOrganization $organization
+ *
+ * @return boolean
+ */
+ public function update(EntityOrganization $organization)
+ {
+ $keywords = array(
+ $organization->getName()
+ );
+ if (null !== $organization->getFullName()) {
+ $keywords[] = $organization->getFullName();
+ }
+ if (null !== $organization->getEmail()) {
+ $keywords[] = $organization->getEmail();
+ }
+
+ /**
+ * @var $api \Github\Api\Organization
+ */
+ $api = $this->getGithubClient()->api('organization');
+ $data = $api->show($organization->getName());
+
+ // Organization has been removed / not found ?
+ if (empty($data)) {
+ return false;
+ }
+
+ $organization->setFullName(isset($data['fullname']) ? $data['fullname'] : null);
+ $organization->setEmail(isset($data['email']) ? $data['email'] : null);
+ $organization->setAvatarUrl(isset($data['avatar_url']) ? $data['avatar_url'] : null);
+ $organization->setLocation(isset($data['location']) ? $data['location'] : null);
+ $organization->setUrl(isset($data['url']) ? $this->fixUrl($data['url']) : null);
+
+ $membersData = $api->members()->all($organization->getName());
+
+ if (!$members = $this->updateMembers($membersData)) {
+ return false;
+ }
+
+ $organization->setMembers($members);
+
+ return true;
+ }
+
+ private function updateMembers($membersData)
+ {
+ $members = array();
+ $api = new Developer($this->github, new NullOutput());
+
+ foreach ($membersData as $memberData) {
+ if (!$member = $this->repository->findOneBy(array('name' => $memberData['login']))) {
+ $member = $api->import($memberData['login']);
+ }
+
+ $members[] = $member;
+ }
+
+ return $members;
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Github/Owner.php b/src/Knp/Bundle/KnpBundlesBundle/Github/Owner.php
new file mode 100644
index 00000000..61495a1a
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Github/Owner.php
@@ -0,0 +1,90 @@
+github = $github;
+ $this->output = $output;
+ }
+
+ /**
+ * Get output
+ *
+ * @return OutputInterface
+ */
+ public function getOutput()
+ {
+ return $this->output;
+ }
+
+ /**
+ * Set output
+ *
+ * @param OutputInterface $output
+ */
+ public function setOutput($output)
+ {
+ $this->output = $output;
+ }
+
+ /**
+ * Get github
+ *
+ * @return Client
+ */
+ public function getGithubClient()
+ {
+ return $this->github;
+ }
+
+ /**
+ * Set github
+ *
+ * @param Client $github
+ */
+ public function setGithubClient($github)
+ {
+ $this->github = $github;
+ }
+
+ /**
+ * Fixes url.
+ * Adds http protocol by default, when no protocol is specified.
+ *
+ * @param string $url
+ * @return string
+ */
+ public function fixUrl($url)
+ {
+ $scheme = parse_url($url, PHP_URL_SCHEME);
+ if (null === $scheme) {
+ return 'http://'.$url;
+ }
+
+ return $url;
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Github/OwnerInterface.php b/src/Knp/Bundle/KnpBundlesBundle/Github/OwnerInterface.php
new file mode 100644
index 00000000..1b701a96
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Github/OwnerInterface.php
@@ -0,0 +1,8 @@
+output->write(' infos');
- $data = $this->github->api('repo')->show($bundle->getUsername(), $bundle->getName());
+ $data = $this->github->api('repo')->show($bundle->getOwnerName(), $bundle->getName());
if (empty($data) || isset($data['message'])) {
return false;
}
@@ -125,7 +125,7 @@ public function updateCommits(Bundle $bundle)
{
$this->output->write(' commits');
- $commits = $this->github->api('repo')->commits()->all($bundle->getUsername(), $bundle->getName(), array('sha' => 'HEAD', 'per_page' => 30));
+ $commits = $this->github->api('repo')->commits()->all($bundle->getOwnerName(), $bundle->getName(), array('sha' => 'HEAD', 'per_page' => 30));
if (empty($commits) || isset($data['message'])) {
return false;
}
@@ -140,14 +140,14 @@ public function updateFiles(Bundle $bundle, array $onlyFiles = null)
$api = $this->github->api('repo')->contents();
- $files = $api->show($bundle->getUsername(), $bundle->getName());
+ $files = $api->show($bundle->getOwnerName(), $bundle->getName());
foreach ($files as $data) {
if (!$bundle->isValid() && false !== strpos($data['name'], 'Bundle.php')) {
if (null !== $onlyFiles && !in_array('sf', $onlyFiles)) {
continue;
}
- $file = $api->show($bundle->getUsername(), $bundle->getName(), $data['name']);
+ $file = $api->show($bundle->getOwnerName(), $bundle->getName(), $data['name']);
if (!isset($file['message']) && 'base64' == $file['encoding']) {
$this->validateSymfonyBundle($bundle, $file['content']);
}
@@ -161,7 +161,7 @@ public function updateFiles(Bundle $bundle, array $onlyFiles = null)
continue;
}
- $file = $api->show($bundle->getUsername(), $bundle->getName(), 'LICENSE');
+ $file = $api->show($bundle->getOwnerName(), $bundle->getName(), 'LICENSE');
if (!isset($file['message']) && 'base64' == $file['encoding']) {
$bundle->setLicense(base64_decode($file['content']));
break;
@@ -181,7 +181,7 @@ public function updateFiles(Bundle $bundle, array $onlyFiles = null)
continue;
}
- $file = $api->show($bundle->getUsername(), $bundle->getName(), 'composer.json');
+ $file = $api->show($bundle->getOwnerName(), $bundle->getName(), 'composer.json');
if (!isset($file['message']) && 'base64' == $file['encoding']) {
$this->updateComposerFile(base64_decode($file['content']), $bundle);
break;
@@ -190,14 +190,14 @@ public function updateFiles(Bundle $bundle, array $onlyFiles = null)
}
if (null === $onlyFiles || in_array('readme', $onlyFiles)) {
- $readme = $api->readme($bundle->getUsername(), $bundle->getName());
+ $readme = $api->readme($bundle->getOwnerName(), $bundle->getName());
if (!isset($readme['message']) && 'base64' == $readme['encoding']) {
$bundle->setReadme(base64_decode($readme['content']));
}
}
if (null === $bundle->getLicense() && (null === $onlyFiles || in_array('license', $onlyFiles))) {
- $file = $api->show($bundle->getUsername(), $bundle->getName(), 'Resources/meta/LICENSE');
+ $file = $api->show($bundle->getOwnerName(), $bundle->getName(), 'Resources/meta/LICENSE');
if (!isset($file['message']) && 'base64' == $file['encoding']) {
$bundle->setLicense(base64_decode($file['content']));
}
@@ -270,7 +270,7 @@ public function updateTags(Bundle $bundle)
$this->output->write(' tags');
$tags = array();
- $data = $this->github->api('repo')->tags($bundle->getUsername(), $bundle->getName());
+ $data = $this->github->api('repo')->tags($bundle->getOwnerName(), $bundle->getName());
if ($data) {
foreach ($data as $tag) {
$tags[] = $tag['name'];
@@ -284,7 +284,7 @@ public function updateTags(Bundle $bundle)
public function fetchComposerKeywords(Bundle $bundle)
{
- $file = $this->github->api('repo')->contents()->show($bundle->getUsername(), $bundle->getName(), 'composer.json');
+ $file = $this->github->api('repo')->contents()->show($bundle->getOwnerName(), $bundle->getName(), 'composer.json');
if (!isset($file['message']) && 'base64' == $file['encoding']) {
$composer = json_decode(base64_decode($file['content']), true);
if (JSON_ERROR_NONE === json_last_error()) {
@@ -297,14 +297,14 @@ public function fetchComposerKeywords(Bundle $bundle)
public function getContributorNames(Bundle $bundle)
{
- $contributors = $this->github->api('repo')->contributors($bundle->getUsername(), $bundle->getName());
+ $contributors = $this->github->api('repo')->contributors($bundle->getOwnerName(), $bundle->getName());
if (empty($contributors)) {
return array();
}
$names = array();
foreach ($contributors as $contributor) {
- if ($bundle->getUsername() != $contributor['login']) {
+ if ($bundle->getOwnerName() != $contributor['login']) {
$names[] = $contributor['login'];
}
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Github/User.php b/src/Knp/Bundle/KnpBundlesBundle/Github/User.php
deleted file mode 100644
index 587efb3e..00000000
--- a/src/Knp/Bundle/KnpBundlesBundle/Github/User.php
+++ /dev/null
@@ -1,184 +0,0 @@
-github = $github;
- $this->output = $output;
- }
-
- /**
- * @param string|UserResponseInterface $response
- *
- * @return boolean|EntityUser
- */
- public function import($response)
- {
- $user = new EntityUser();
- if (is_string($response)) {
- $user->setName($response);
- } else {
- $user->setName($response->getNickname());
- $user->setFullName($response->getRealName());
- }
-
- if ($response instanceof SensioConnectUserResponse) {
- $user->setName($response->getLinkedAccount('github') ?: $response->getNickname());
- }
-
- if ($response instanceof AdvancedUserResponseInterface) {
- $user->setEmail($response->getEmail());
- $user->setGravatarHash($response->getProfilePicture());
- }
-
- if (!$this->update($user)) {
- return false;
- }
-
- return $user;
- }
-
- /**
- * @param EntityUser $user
- *
- * @return boolean
- */
- public function update(EntityUser $user)
- {
- $keywords = array(
- $user->getName()
- );
- if (null !== $user->getFullName()) {
- $keywords[] = $user->getFullName();
- }
- if (null !== $user->getEmail()) {
- $keywords[] = $user->getEmail();
- }
-
- $api = $this->github->api('user');
- $data = $api->show($user->getName());
-
- if (empty($data)) {
- foreach ($keywords as $field) {
- try {
- $data = $api->search($field);
- if (isset($data['users']) && 0 < count($data['users'])) {
- $data = $data['users'][0];
- // Let's call API one more time to get clean user data
- $data = $api->show($data['login']);
- }
- } catch(ApiLimitExceedException $e) {
- break;
- }
-
- // Did we found user in this iteration ?
- if (!empty($data) && !isset($data['message'])) {
- break;
- }
- }
- }
-
- // User has been removed / not found ?
- if (empty($data) || isset($data['message'])) {
- return false;
- }
-
- $user->setFullName(isset($data['fullname']) ? $data['fullname'] : null);
- $user->setEmail(isset($data['email']) ? $data['email'] : null);
- $user->setGravatarHash(isset($data['avatar_url']) ? $data['avatar_url'] : (isset($data['gravatar_id']) ? $data['gravatar_id'] : null));
- $user->setCompany(isset($data['company']) ? $data['company'] : null);
- $user->setLocation(isset($data['location']) ? $data['location'] : null);
- $user->setBlog(isset($data['blog']) ? $this->fixUrl($data['blog']) : null);
-
- return true;
- }
-
- /**
- * Fixes url.
- * Adds http protocol by default, when no protocol is specified.
- *
- * @param string $url
- * @return string
- */
- protected function fixUrl($url)
- {
- $scheme = parse_url($url, PHP_URL_SCHEME);
- if (null === $scheme) {
- return 'http://'.$url;
- }
-
- return $url;
- }
-
- /**
- * Get output
- *
- * @return OutputInterface
- */
- public function getOutput()
- {
- return $this->output;
- }
-
- /**
- * Set output
- *
- * @param OutputInterface $output
- */
- public function setOutput($output)
- {
- $this->output = $output;
- }
-
- /**
- * Get github
- *
- * @return Client
- */
- public function getGithubClient()
- {
- return $this->github;
- }
-
- /**
- * Set github
- *
- * @param Client $github
- */
- public function setGithubClient($github)
- {
- $this->github = $github;
- }
-}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Indexer/SolrIndexer.php b/src/Knp/Bundle/KnpBundlesBundle/Indexer/SolrIndexer.php
index 40431008..83e667f9 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Indexer/SolrIndexer.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Indexer/SolrIndexer.php
@@ -61,13 +61,13 @@ private function updateDocumentFromBundle(\Solarium_Document_ReadWrite $document
{
$document->setField('id', $bundle->getId());
$document->setField('name', $bundle->getName());
- $document->setField('username', $bundle->getUsername());
+ $document->setField('ownerName', $bundle->getOwnerName());
$document->setField('fullName', $bundle->getFullName());
$document->setField('description', $bundle->getDescription());
$document->setField('readme', $bundle->getReadme());
$document->setField('totalScore', $bundle->getScore());
$document->setField('state', $bundle->getState());
- $document->setField('userGravatarHash', $bundle->getUser()->getGravatarHash());
+ $document->setField('avatarUrl', $bundle->getOwner()->getAvatarUrl());
$document->setField('lastCommitAt', $helper->formatDate($bundle->getLastCommitAt()));
$document->setField('lastTweetedAt', null !== $bundle->getLastTweetedAt() ? $helper->formatDate($bundle->getLastTweetedAt()) : null);
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Menu/MenuBuilder.php b/src/Knp/Bundle/KnpBundlesBundle/Menu/MenuBuilder.php
index a6f85f8a..25fbc59a 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Menu/MenuBuilder.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Menu/MenuBuilder.php
@@ -25,7 +25,8 @@ public function createMainMenu(Request $request, Translator $translator, Securit
$menu->setCurrentUri($request->getRequestUri());
$menu->addChild('bundles', array('route' => 'bundle_list'))->setLabel($translator->trans('menu.bundles'));
- $menu->addChild('users', array('route' => 'user_list'))->setLabel($translator->trans('menu.users'));
+ $menu->addChild('developers', array('route' => 'developer_list'))->setLabel($translator->trans('menu.developers'));
+ $menu->addChild('organizations', array('route' => 'organization_list'))->setLabel($translator->trans('menu.organizations'));
$menu->addChild('evolution', array('route' => 'evolution'))->setLabel($translator->trans('menu.evolution'));
$menu->addChild('add-bundle', array('route' => 'add_bundle'))->setLabel($translator->trans('menu.addBundleManually'));
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Repository/BundleRepository.php b/src/Knp/Bundle/KnpBundlesBundle/Repository/BundleRepository.php
index 57c8b48f..ae0d3551 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Repository/BundleRepository.php
+++ b/src/Knp/Bundle/KnpBundlesBundle/Repository/BundleRepository.php
@@ -26,31 +26,31 @@ public function queryAllSortedBy($field, $order = 'desc')
}
/**
- * Finds all the bundles with their associated users and contributors, sorted
+ * Finds all the bundles with their associated owners and contributors, sorted
* by the specified field
*
* @param string $field The name of the field to sort by
*
- * @return \Doctrine\Common\Collection
+ * @return \Doctrine\Common\Collections\Collection
*/
- public function findAllWithUsersAndContributorsSortedBy($field)
+ public function findAllWithOwnersAndContributorsSortedBy($field)
{
- return $this->queryAllWithUsersAndContributorsSortedBy($field)->execute();
+ return $this->queryAllWithOwnersAndContributorsSortedBy($field)->execute();
}
/**
- * Returns the query to retrieve all the bundles with their associated users
+ * Returns the query to retrieve all the bundles with their associated owners
* and contributors, sorted by the specified field
*
* @param string $field The name of the field to sort by
*
- * @return \Doctrine\Query
+ * @return \Doctrine\ORM\Query
*/
- public function queryAllWithUsersAndContributorsSortedBy($field)
+ public function queryAllWithOwnersAndContributorsSortedBy($field)
{
$q = $this->createQueryBuilder('bundle')
- ->select('bundle, user, contributors')
- ->leftJoin('bundle.user', 'user')
+ ->select('bundle, owner, contributors')
+ ->leftJoin('bundle.owner', 'owner')
->leftJoin('bundle.contributors', 'contributors')
->addOrderBy('bundle.' . $field, 'name' === $field ? 'asc' : 'desc')
->addOrderBy('bundle.score', 'desc')
@@ -63,8 +63,8 @@ public function queryAllWithUsersAndContributorsSortedBy($field)
public function queryByKeywordSlug($slug)
{
return $this->createQueryBuilder('bundle')
- ->addSelect('user')
- ->leftJoin('bundle.user', 'user')
+ ->addSelect('owner')
+ ->leftJoin('bundle.owner', 'owner')
->leftJoin('bundle.keywords', 'keyword')
->where('keyword.slug = :slug')
->addOrderBy('bundle.score', 'desc')
@@ -98,13 +98,13 @@ public function findByLastCommitAt($nb)
return $this->createQueryBuilder('bundle')->orderBy('bundle.lastCommitAt', 'DESC')->getQuery()->setMaxResults($nb)->execute();
}
- public function findOneByUsernameAndName($username, $name)
+ public function findOneByOwnerNameAndName($ownerName, $name)
{
return $this->createQueryBuilder('bundle')
- ->leftJoin('bundle.recommenders', 'user')
- ->where('bundle.username = :username')
+ ->leftJoin('bundle.recommenders', 'owner')
+ ->where('bundle.ownerName = :ownerName')
->andWhere('bundle.name = :name')
- ->setParameter('username', $username)
+ ->setParameter('ownerName', $ownerName)
->setParameter('name', $name)
->getQuery()
->getOneOrNullResult();
@@ -113,7 +113,7 @@ public function findOneByUsernameAndName($username, $name)
public function getStaleBundlesForIndexing()
{
return $this->createQueryBuilder('bundle')
- ->leftJoin('bundle.user', 'user')
+ ->leftJoin('bundle.owner', 'owner')
->where('bundle.indexedAt IS NULL OR bundle.indexedAt < bundle.updatedAt')
->getQuery()
->getResult();
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Repository/DeveloperRepository.php b/src/Knp/Bundle/KnpBundlesBundle/Repository/DeveloperRepository.php
new file mode 100644
index 00000000..92ed73ea
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Repository/DeveloperRepository.php
@@ -0,0 +1,52 @@
+createQueryBuilder('d')
+ ->leftJoin('d.bundles', 'b')
+ ->leftJoin('d.contributionBundles', 'cr')
+ ->where('d.name = :name')
+ ->setParameter('name', $name)
+ ->getQuery()
+ ->getOneOrNullResult();
+ }
+
+ public function findAllWithBundlesSortedBy($field)
+ {
+ return $this->queryAllWithBundlesSortedBy($field)->getResult();
+ }
+
+ public function queryAllWithBundlesSortedBy($field)
+ {
+ return $this->createQueryBuilder('d')
+ ->orderBy('d.'.$field, 'name' === $field ? 'asc' : 'desc')
+ ->leftJoin('d.bundles', 'b')
+ ->leftJoin('d.contributionBundles', 'cr')
+ ->select('d, b, cr')
+ ->getQuery();
+ }
+
+ public function getUsersCountEvolution()
+ {
+ return $this->createQueryBuilder('d')
+ ->select('d.createdAt AS date, COUNT(d.id) AS value')
+ ->groupBy('d.createdAt')
+ ->orderBy('d.createdAt', 'asc')
+ ->getQuery()
+ ->execute();
+ }
+
+ public function count()
+ {
+ return $this->getEntityManager()->createQuery('SELECT COUNT(e.id) FROM '.$this->getEntityName().' e')->getSingleScalarResult();
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Repository/OrganizationRepository.php b/src/Knp/Bundle/KnpBundlesBundle/Repository/OrganizationRepository.php
new file mode 100644
index 00000000..06eb8963
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Repository/OrganizationRepository.php
@@ -0,0 +1,50 @@
+createQueryBuilder('d')
+ ->leftJoin('d.bundles', 'b')
+ ->where('d.name = :name')
+ ->setParameter('name', $name)
+ ->getQuery()
+ ->getOneOrNullResult();
+ }
+
+ public function queryAllWithBundlesSortedBy($field)
+ {
+ $qb = $this->createQueryBuilder('u')
+ ->select('u')
+ ->leftJoin('u.bundles', 'b')
+ ;
+
+ switch ($field) {
+ case 'name':
+ $qb->orderBy('u.name', 'asc');
+ break;
+
+ case 'bundles':
+ $qb
+ ->addSelect('SIZE(u.bundles) bundles')
+ ->orderBy('bundles', 'desc');
+ break;
+
+ case 'developers':
+ $qb
+ ->addSelect('SIZE(u.members) members')
+ ->orderBy('members', 'desc');
+ break;
+ }
+
+ return $qb->getQuery();
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Repository/OwnerRepository.php b/src/Knp/Bundle/KnpBundlesBundle/Repository/OwnerRepository.php
new file mode 100644
index 00000000..b398a890
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Repository/OwnerRepository.php
@@ -0,0 +1,33 @@
+createQueryBuilder('d')
+ ->where('d.name = :name')
+ ->setParameter('name', $name)
+ ->getQuery()
+ ->getOneOrNullResult();
+ }
+
+ public function findAllSortedBy($field, $limit = null)
+ {
+ $query = $this->createQueryBuilder('u')
+ ->orderBy('u.'.$field, 'name' === $field ? 'asc' : 'desc')
+ ->getQuery();
+
+ if (null !== $limit) {
+ $query->setMaxResults($limit);
+ }
+
+ return $query->execute();
+ }
+}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing.yml
index a773c37e..7a196a81 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing.yml
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing.yml
@@ -11,33 +11,14 @@ _login_github:
_login_sensio:
pattern: /login/check-sensio
-user_list:
- pattern: /developer/{sort}
- defaults: { _controller: KnpBundlesBundle:User:list, sort: name }
- requirements: { _method: "GET", sort: "(name|best)"}
-
-bundle_list:
- pattern: /{sort}
- defaults: { _controller: KnpBundlesBundle:Bundle:list, sort: trend }
- requirements: { _method: "GET", sort: "(best|updated|newest|trend|recommended)"}
-
-bundle_keyword:
- pattern: /keyword/{slug}
- defaults: { _controller: KnpBundlesBundle:Bundle:searchByKeyword }
- requirements: { _method: "GET", slug: ".+" }
-
-user_bundle_list:
- pattern: /{name}/bundles
- defaults: { _controller: KnpBundlesBundle:User:bundles }
- requirements: { _method: "GET", format: "(json|js)" }
-
-user_show:
- pattern: /{name}/profile
- defaults: { _controller: KnpBundlesBundle:User:show }
- requirements: { _method: "GET"}
-
_static:
resource: "routing/static.yml"
+_users:
+ resource: "routing/developers.yml"
+
+_organizations:
+ resource: "routing/organizations.yml"
+
_bundles:
resource: "routing/bundles.yml"
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/bundles.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/bundles.yml
index 34941e41..113e7b4e 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/bundles.yml
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/bundles.yml
@@ -24,22 +24,22 @@ bundle_keyword:
requirements: { _method: "GET", slug: ".+" }
bundle_change_usage_status:
- pattern: /{username}/{name}/change-usage-status
+ pattern: /{ownerName}/{name}/change-usage-status
defaults: { _controller: KnpBundlesBundle:Bundle:changeUsageStatus }
requirements: { _method: "GET", name: ".+" }
bundle_get_badge_short:
- pattern: /{username}/{name}/badge-short
+ pattern: /{ownerName}/{name}/badge-short
defaults: { _controller: KnpBundlesBundle:Badge:show, type: short }
requirements: { _method: "GET", name: ".+" }
bundle_get_badge:
- pattern: /{username}/{name}/badge
+ pattern: /{ownerName}/{name}/badge
defaults: { _controller: KnpBundlesBundle:Badge:show }
requirements: { _method: "GET", name: ".+" }
bundle_show:
- pattern: /{username}/{name}
+ pattern: /{ownerName}/{name}
defaults: { _controller: KnpBundlesBundle:Bundle:show }
requirements: { _method: "GET", format: "(html|json|js)", name: ".+" }
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/developers.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/developers.yml
new file mode 100644
index 00000000..536fc0aa
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/developers.yml
@@ -0,0 +1,14 @@
+developer_list:
+ pattern: /developer/{sort}
+ defaults: { _controller: KnpBundlesBundle:Developer:list, sort: name }
+ requirements: { _method: "GET", sort: "(name|best)"}
+
+developer_bundle_list:
+ pattern: /developer/{name}/bundles
+ defaults: { _controller: KnpBundlesBundle:Developer:bundles }
+ requirements: { _method: "GET", format: "(json|js)" }
+
+developer_show:
+ pattern: /developer/{name}/profile
+ defaults: { _controller: KnpBundlesBundle:Developer:show }
+ requirements: { _method: "GET"}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/organizations.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/organizations.yml
new file mode 100644
index 00000000..c3f8fc96
--- /dev/null
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/routing/organizations.yml
@@ -0,0 +1,19 @@
+organization_list:
+ pattern: /organization/{sort}
+ defaults: { _controller: KnpBundlesBundle:Organization:list, sort: name }
+ requirements: { _method: "GET", sort: "(name|developers|bundles)"}
+
+organization_show:
+ pattern: /organization/{name}/profile
+ defaults: { _controller: KnpBundlesBundle:Organization:show }
+ requirements: { _method: "GET"}
+
+organization_bundle_list:
+ pattern: /organization/{name}/bundles
+ defaults: { _controller: KnpBundlesBundle:Organization:bundles }
+ requirements: { _method: "GET", format: "(json|js)" }
+
+organization_members_list:
+ pattern: /organization/{name}/members
+ defaults: { _controller: KnpBundlesBundle:Organization:members }
+ requirements: { _method: "GET", format: "(json|js)" }
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/services.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/services.yml
index e8badebc..1780f8e8 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/config/services.yml
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/config/services.yml
@@ -5,12 +5,13 @@ parameters:
knp_bundles.trending_bundle_twitterer.template: "Discover {name}, today's trending #Symfony2 bundle {url} on #KnpBundles"
knp_bundles.consumer.update_bundle.class: Knp\Bundle\KnpBundlesBundle\Consumer\UpdateBundleConsumer
knp_bundles.consumer.github_hook.class: Knp\Bundle\KnpBundlesBundle\Consumer\GithubHookConsumer
- knp_bundles.user.manager.class: Knp\Bundle\KnpBundlesBundle\Entity\UserManager
+ knp_bundles.owner.manager.class: Knp\Bundle\KnpBundlesBundle\Entity\OwnerManager
knp_bundles.output.class: Symfony\Component\Console\Output\NullOutput
knp_bundles.travis.class: Knp\Bundle\KnpBundlesBundle\Travis\Travis
knp_bundles.github.client.class: Github\Client
knp_bundles.github.http_client.class: Github\HttpClient\HttpClient
- knp_bundles.github.users.class: Knp\Bundle\KnpBundlesBundle\Github\User
+ knp_bundles.github.developer.class: Knp\Bundle\KnpBundlesBundle\Github\Developer
+ knp_bundles.github.organization.class: Knp\Bundle\KnpBundlesBundle\Github\Organization
knp_bundles.git_repository_manager.class: Knp\Bundle\KnpBundlesBundle\Git\RepoManager
knp_bundles.github.repository_api.class: Knp\Bundle\KnpBundlesBundle\Github\Repo
knp_bundles.badge_generator.class: Knp\Bundle\KnpBundlesBundle\Badge\BadgeGenerator
@@ -36,20 +37,20 @@ services:
class: %knp_bundles.updater.class%
arguments:
- @knp_bundles.entity_manager
- - @knp_bundles.user.manager
+ - @knp_bundles.owner.manager
- @knp_bundles.finder
- - @knp_bundles.github.users
- @knp_bundles.github_repository_api
- knp_bundles.user.manager:
- class: %knp_bundles.user.manager.class%
+ knp_bundles.owner.manager:
+ class: %knp_bundles.owner.manager.class%
arguments:
- @knp_bundles.entity_manager
+ - @knp_bundles.github_client
knp_bundles.user.provider:
class: %knp_bundles.user.provider.class%
arguments:
- - @knp_bundles.user.manager
+ - @knp_bundles.owner.manager
knp_bundles.trending_bundle_twitterer:
class: %knp_bundles.trending_bundle_twitterer.class%
@@ -93,8 +94,14 @@ services:
- @knp_bundles.git_repository_manager
- @event_dispatcher
- knp_bundles.github.users:
- class: %knp_bundles.github.users.class%
+ knp_bundles.github.developer:
+ class: %knp_bundles.github.developer.class%
+ arguments:
+ - @knp_bundles.github_client
+ - @knp_bundles.output
+
+ knp_bundles.github.organization:
+ class: %knp_bundles.github.organization.class%
arguments:
- @knp_bundles.github_client
- @knp_bundles.output
@@ -109,7 +116,7 @@ services:
class: %knp_bundles.consumer.update_bundle.class%
arguments:
- @doctrine.orm.entity_manager
- - @knp_bundles.user.manager
+ - @knp_bundles.owner.manager
- @knp_bundles.github_repository_api
- @knp_bundles.travis
- @knp_bundles.indexer.solr
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/public/css/styles.css b/src/Knp/Bundle/KnpBundlesBundle/Resources/public/css/styles.css
index 15295d09..50b191ca 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/public/css/styles.css
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/public/css/styles.css
@@ -93,8 +93,8 @@ code, pre {
.icon-globe:before { content: 'p'; }
.icon-thumbs-up:before, .icon-recommended:before { content: '<'; }
.icon-thumbs-down:before { content: '>'; }
-.icon-user:before { content: 'u'; }
-.icon-users:before { content: 'U'; }
+.icon-developer:before { content: 'u'; }
+.icon-developers:before { content: 'U'; }
.icon-calendar:before, .icon-newest:before { content: '='; }
.icon-chart:before, .icon-best:before { content: 'x'; }
.icon-download:before { content: 'd'; }
@@ -471,12 +471,12 @@ code, pre {
}
/* Intro - bundle description */
-#intro.bundle-details, #intro.user-details {
+#intro.bundle-details, #intro.developer-details {
margin-top: 4px;
font: 13px Arial
}
-#intro.user-details figure {
+#intro.developer-details figure {
float: left;
padding: 3px;
margin: 0 15px 0 0;
@@ -512,14 +512,14 @@ code, pre {
color: #27566f
}
-#intro.user-details h1 {
+#intro.developer-details h1 {
margin: 3px 0 0;
font: normal 30px Arial;
line-height: 30px;
color: #27566f
}
-#intro.bundle-details h2, #intro.user-details h2 {
+#intro.bundle-details h2, #intro.developer-details h2 {
font: normal 16px Arial;
text-shadow: 1px 2px 1px #75b9dc;
color: #fff
@@ -1206,23 +1206,23 @@ code, pre {
font-size: 12px
}
-.sidebar-users-list section ul {
+.sidebar-developers-list section ul {
float: left;
margin: 15px 5px 5px
}
-.sidebar-users-list section li {
+.sidebar-developers-list section li {
display: inline
}
-.sidebar-users-list section li a {
+.sidebar-developers-list section li a {
float: left;
height: 40px;
width: 40px;
margin: 0 0 10px 10px
}
-.sidebar-users-list section li .box-more-users {
+.sidebar-developers-list section li .box-more-developers {
float: left;
height: 38px;
width: 38px;
@@ -1232,11 +1232,11 @@ code, pre {
cursor: pointer
}
-.sidebar-users-list section li .box-more-users abbr:before {
+.sidebar-developers-list section li .box-more-developers abbr:before {
margin: 10px
}
-.sidebar-users-list section li a.btn-recommend {
+.sidebar-developers-list section li a.btn-recommend {
height: auto;
width: 210px
}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/solr/conf/schema.xml b/src/Knp/Bundle/KnpBundlesBundle/Resources/solr/conf/schema.xml
old mode 100755
new mode 100644
index b9ade777..bb5e4fe1
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/solr/conf/schema.xml
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/solr/conf/schema.xml
@@ -78,7 +78,7 @@
-
+
@@ -105,12 +105,12 @@
-
+
-
+
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/translations/messages.en.yml b/src/Knp/Bundle/KnpBundlesBundle/Resources/translations/messages.en.yml
index 65bde77c..352fcb5e 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/translations/messages.en.yml
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/translations/messages.en.yml
@@ -2,7 +2,8 @@ date_format: "Y-m-d"
menu:
bundles: "Bundles"
- users: "Developers"
+ developers: "Developers"
+ organizations: "Organizations"
evolution: "Evolution"
addBundleManually: "Register a bundle"
@@ -132,7 +133,7 @@ bundles.activity:
medium: "Medium"
low: "Low"
-users:
+developers:
meta:
title: "Discover %count% Symfony2 Developers"
description: "All Open Source Symfony 2 Developers sorted by %sort%"
@@ -141,7 +142,7 @@ users:
name: "Alphabetical"
best: "Best score"
-users.show:
+developers.show:
meta:
description: "%username% has created %nb% Symfony2 bundles"
github: "View on Github"
@@ -149,14 +150,39 @@ users.show:
location: "Location: "
lastCommit: "Last commit: "
nbBundles: "Number of bundles: "
- blog: "Website: "
+ url: "Website: "
bundles_manage: "Bundles I owe"
bundles_contribute: "Bundles I contribute to"
-users.list:
+developers.list:
location: " from "
lastCommit: "Last commit "
+organizations:
+ meta:
+ title: "Discover %count% Symfony2 organizations"
+ description: "All Open Source Symfony 2 organizations sorted by %sort%"
+ title: "%count% organizations using Symfony2"
+ sort:
+ name: "Alphabetical"
+ bundles: "Number of bundles"
+ developers: "Number of developers"
+
+organizations.show:
+ meta:
+ description: "%ownerName% has created %nb% Symfony2 bundles"
+ github: "View on Github"
+ stats:
+ location: "Location: "
+ nbBundles: "Number of bundles: "
+ nbMembers: "Number of members: "
+ url: "Website: "
+ bundles_manage: "Bundles this organization manage:"
+ members: "Members of this organization:"
+
+organizations.list:
+ location: " from "
+
api:
meta:
title: "Developer HTTP API"
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/add.html.twig b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/add.html.twig
index 495b5dab..388be4cd 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/add.html.twig
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/add.html.twig
@@ -55,10 +55,10 @@
{% for bundle in bundles %}
-
-
+
- {{ bundle.name }}
- {{ bundle.createdAt|date('d-m-Y') }} by {{ bundle.userName }}
+ {{ bundle.name }}
+ {{ bundle.createdAt|date('d-m-Y') }} by {{ bundle.ownerName }}
{% endfor %}
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/bigList.html.twig b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/bigList.html.twig
index cdd8c259..989e07cc 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/bigList.html.twig
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/bigList.html.twig
@@ -6,7 +6,7 @@
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/evolution.html.twig b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/evolution.html.twig
index 1c279e9c..63e4edea 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/evolution.html.twig
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/evolution.html.twig
@@ -32,7 +32,7 @@
-
{{ users }}Developers
+
{{ developers }}Developers
diff --git a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/list.html.twig b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/list.html.twig
index b4c3368f..1ef9e94a 100644
--- a/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/list.html.twig
+++ b/src/Knp/Bundle/KnpBundlesBundle/Resources/views/Bundle/list.html.twig
@@ -50,17 +50,17 @@
-
-