Skip to content

Commit

Permalink
Merge pull request #11 from maartenJacobs/interfaces
Browse files Browse the repository at this point in the history
Interfaces for (nearly) everything
  • Loading branch information
reecefowell committed Feb 24, 2014
2 parents db63554 + 7beb6cc commit 2dd03b2
Show file tree
Hide file tree
Showing 33 changed files with 880 additions and 186 deletions.
34 changes: 17 additions & 17 deletions Component/Crumbs/CrumbBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace CCDNUser\ProfileBundle\Component\Crumbs;

use Symfony\Component\Security\Core\User\UserInterface;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;

/**
*
Expand Down Expand Up @@ -43,10 +43,10 @@ public function addMemberIndex()
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileOverviewShow(UserInterface $user)
public function addProfileOverviewShow(ProfileUserInterface $user)
{
return $this->addMemberIndex()
->add(
Expand All @@ -69,10 +69,10 @@ public function addProfileOverviewShow(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileBioShow(UserInterface $user)
public function addProfileBioShow(ProfileUserInterface $user)
{
return $this->addMemberIndex()
->add(
Expand All @@ -95,10 +95,10 @@ public function addProfileBioShow(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfilePersonalEdit(UserInterface $user)
public function addProfilePersonalEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.personal.edit',
Expand All @@ -115,10 +115,10 @@ public function addProfilePersonalEdit(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileInfoEdit(UserInterface $user)
public function addProfileInfoEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.info.edit',
Expand All @@ -135,10 +135,10 @@ public function addProfileInfoEdit(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileContactEdit(UserInterface $user)
public function addProfileContactEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.contact.edit',
Expand All @@ -155,10 +155,10 @@ public function addProfileContactEdit(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileAvatarEdit(UserInterface $user)
public function addProfileAvatarEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.avatar.edit',
Expand All @@ -175,10 +175,10 @@ public function addProfileAvatarEdit(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileBioEdit(UserInterface $user)
public function addProfileBioEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.bio.edit',
Expand All @@ -195,10 +195,10 @@ public function addProfileBioEdit(UserInterface $user)
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Component\Crumbs\Factory\CrumbTrail
*/
public function addProfileSignatureEdit(UserInterface $user)
public function addProfileSignatureEdit(ProfileUserInterface $user)
{
return $this->addProfileOverviewShow($user)
->add('crumbs.profile.signature.edit',
Expand Down
3 changes: 2 additions & 1 deletion Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\EventDispatcher\Event;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;

/**
*
Expand Down Expand Up @@ -252,7 +253,7 @@ protected function getSecurityContext()
/**
*
* @access protected
* @return \Symfony\Component\Security\Core\User\UserInterface
* @return ProfileUserInterface
*/
protected function getUser()
{
Expand Down
39 changes: 19 additions & 20 deletions Controller/ProfileBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

namespace CCDNUser\ProfileBundle\Controller;

use Symfony\Component\Security\Core\User\UserInterface;
use CCDNUser\ProfileBundle\Controller\BaseController;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;

/**
*
Expand All @@ -32,10 +31,10 @@ class ProfileBaseController extends BaseController
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdatePersonalFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdatePersonalFormHandler
*/
protected function getFormHandlerToEditPersonal(UserInterface $user)
protected function getFormHandlerToEditPersonal(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.personal');

Expand All @@ -48,10 +47,10 @@ protected function getFormHandlerToEditPersonal(UserInterface $user)
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdateInfoFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdateInfoFormHandler
*/
protected function getFormHandlerToEditInfo(UserInterface $user)
protected function getFormHandlerToEditInfo(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.info');

Expand All @@ -64,10 +63,10 @@ protected function getFormHandlerToEditInfo(UserInterface $user)
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdateContactFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdateContactFormHandler
*/
protected function getFormHandlerToEditContact(UserInterface $user)
protected function getFormHandlerToEditContact(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.contact');

Expand All @@ -80,10 +79,10 @@ protected function getFormHandlerToEditContact(UserInterface $user)
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdateAvatarFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdateAvatarFormHandler
*/
protected function getFormHandlerToEditAvatar(UserInterface $user)
protected function getFormHandlerToEditAvatar(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.avatar');

Expand All @@ -96,10 +95,10 @@ protected function getFormHandlerToEditAvatar(UserInterface $user)
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdateBioFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdateBioFormHandler
*/
protected function getFormHandlerToEditBio(UserInterface $user)
protected function getFormHandlerToEditBio(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.bio');

Expand All @@ -112,10 +111,10 @@ protected function getFormHandlerToEditBio(UserInterface $user)
/**
*
* @access protected
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\UpdateSignatureFormHandler
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\User\Profile\UpdateSignatureFormHandler
*/
protected function getFormHandlerToEditSignature(UserInterface $user)
protected function getFormHandlerToEditSignature(ProfileUserInterface $user)
{
$formHandler = $this->container->get('ccdn_user_profile.form.handler.signature');

Expand Down
1 change: 0 additions & 1 deletion Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace CCDNUser\ProfileBundle\Controller;

use CCDNUser\ProfileBundle\Controller\ProfileBaseController;
use CCDNUser\ProfileBundle\Component\Dispatcher\ProfileEvents;
use CCDNUser\ProfileBundle\Component\Dispatcher\Event\UserProfileResponseEvent;

Expand Down
10 changes: 5 additions & 5 deletions Entity/Model/ProfileModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace CCDNUser\ProfileBundle\Entity\Model;

use Symfony\Component\Security\Core\User\UserInterface;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;

/**
*
Expand All @@ -32,14 +32,14 @@ abstract class ProfileModel
/**
*
* @access protected
* @var Symfony\Component\Security\Core\User\UserInterface $user
* @var ProfileUserInterface $user
*/
protected $user;

/**
* Get user
*
* @return UserInterface
* @return ProfileUserInterface
*/
public function getUser()
{
Expand All @@ -49,10 +49,10 @@ public function getUser()
/**
* Set user
*
* @param UserInterface $user
* @param ProfileUserInterface $user
* @return Profile
*/
public function setUser(UserInterface $user = null)
public function setUser(ProfileUserInterface $user = null)
{
$this->user = $user;

Expand Down
58 changes: 58 additions & 0 deletions Entity/ProfileUserInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the CCDNUser ProfileBundle
*
* (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/>
*
* Available on github <http://www.github.com/codeconsortium/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CCDNUser\ProfileBundle\Entity;

use Symfony\Component\Security\Core\User\UserInterface;

/**
*
* @category CCDNUser
* @package ProfileBundle
*
* @author Maarten Jacobs <maarten.j.jacobs@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
* @version Release: 2.0
* @link https://github.com/codeconsortium/CCDNUserProfileBundle
*
*/
interface ProfileUserInterface extends UserInterface
{
/**
* Set profile
*
* @param Profile $profile
*/
public function setProfile(Profile $profile);

/**
* Get profile
*
* @return Profile
*/
public function getProfile();

/**
* Get registered date
*
* @return \Datetime
*/
public function getRegisteredDate();

/**
* Set registered date
*
* @param \Datetime $registeredDate
*/
public function setRegisteredDate(\Datetime $registeredDate);
}
4 changes: 2 additions & 2 deletions EventListener/ProfileUserCreationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace CCDNUser\ProfileBundle\EventListener;

use CCDNUser\ProfileBundle\Entity\Factory\ProfileFactoryInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct(ProfileFactoryInterface $profileFactory)
public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof UserInterface) {
if ($entity instanceof ProfileUserInterface) {
$profile = $this->profileFactory->createDefaultProfile();
$profile->setUser($entity);
$entity->setProfile($profile);
Expand Down
8 changes: 4 additions & 4 deletions Form/Handler/BaseFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace CCDNUser\ProfileBundle\Form\Handler;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\User\UserInterface;
use CCDNUser\ProfileBundle\Entity\ProfileUserInterface;

/**
*
Expand Down Expand Up @@ -60,17 +60,17 @@ class BaseFormHandler
/**
*
* @access protected
* @var \Symfony\Component\Security\Core\User\UserInterface $user
* @var ProfileUserInterface $user
*/
protected $user;

/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param ProfileUserInterface $user
* @return \CCDNUser\ProfileBundle\Form\Handler\BaseFormHandler
*/
public function setUser(UserInterface $user)
public function setUser(ProfileUserInterface $user)
{
$this->user = $user;

Expand Down
2 changes: 1 addition & 1 deletion Form/Handler/User/Profile/UpdateAvatarFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getForm()
*
* @access protected
* @param \CCDNUser\ProfileBundle\Entity\Profile $profile
* @return \CCDNUser\ProfileBundle\Manager\ProfileManager
* @return \CCDNUser\ProfileBundle\Model\Component\Manager\ProfileManager
*/
protected function onSuccess(Profile $profile)
{
Expand Down
Loading

0 comments on commit 2dd03b2

Please sign in to comment.