Multiple services of type Model\Users
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Fyasko
- Člen | 106
Ahoj, toto téma je sice na fóru několikrát, ale ani jedno mi nepomohlo. Už si opravdu nevím rady. Dá se z tohoto něco vyčíst?
Samozřejmě můžu dodat cokoliv bude dál potřeba, akorát nemám tušení co by to mohlo být :/. Za jakoukoliv pomoc děkuju.
- Fyasko
- Člen | 106
config.neon
<?php
php:
date.timezone: Europe/Prague
application:
errorPresenter: Base:Error
mapping:
*: *Module\Presenters\*Presenter
session:
expiration: 14 days
includes:
- other/services.neon
- other/parameters.neon
- other/extensions.neon
- other/facebook.neon
- other/databases.neon
decorator:
Libs\ProjectInitializer:
inject: on
?>
services.neon
<?php
services:
-
class: Console\ProjectInstall
tags: [kdyby.console.command]
router: Routers\RouterFactory::createRouter
imageStorage: Libs\ImageStorage(%wwwDir%/)
tracy.logger:
autowired: no
logger:
class: Libs\IcLogger
arguments: [%appDir%/../log, 'fyaskostyler@ninecreative.cz']
inject: yes
- Libs\ProjectInitializer
- Libs\FileStorage
- Libs\AirbankMailer
- Libs\MapCoordinates
- Model\Authenticator
- Model\Authorizator
- Nette\Mail\SendmailMailer
- Model\Emails
# BASEMODULE
- BaseModule\Components\TemplateMailer
- BaseModule\Components\ICustomerFormFactory
# ADMINMODULE
- AdminModule\Components\ISignInFormFactory
- AdminModule\Components\IContentFormFactory
- AdminModule\Components\IUserFormFactory
- AdminModule\Components\IEmailFormFactory
- AdminModule\Components\IAnalyticFormFactory
- AdminModule\Components\IArticleFormFactory
- AdminModule\Components\IGalleryFormFactory
- AdminModule\Components\IEmailTemplateFormFactory
- AdminModule\Components\IScaffoldFormFactory
- AdminModule\Components\IUserRightsFormFactory
- AdminModule\Components\IGroupsFormFactory
# FRONTMODULE
- FrontModule\Components\ISignInFormFactory
- FrontModule\Components\ISignUpFormFactory
- FrontModule\Components\IForgottenPasswordFormFactory
- FrontModule\Components\ISubscribeFormFactory
- Model\Analytics
- Model\Contents
- Model\Customers
- Model\Languages
- Model\Articles
- Model\Settings
- Model\Users
- Model\EmailLogs
- Model\GalleryImages
- Model\EmailTemplates
- Kdyby\Doctrine\DI\OrmExtension
- Model\Logs
- Model\Groups
- Model\AdminActions
- Model\Scaffolds
?>
Model\Users
<?php
namespace Model;
use Entity\User;
use Kdyby;
use Kdyby\Doctrine\EntityManager;
use Nette;
use Nette\Security\Passwords;
class Users extends BaseService
{
/** @var Groups */
public $groups;
public function __construct(EntityManager $em, Groups $groups)
{
parent::__construct($em, $em->getRepository(User::class));
$this->groups = $groups;
}
/**
* @return array
*/
public function getFullNames(){
$users = [];
foreach($this->findAll() as $user){
$users[$user->getId()] = $user->getFullName();
}
return $users;
}
public function getFullName($id){
$user = $this->find($id);
if(!$user){
return NULL;
}
return $user->getFullName();
}
/**
* @return array
*/
public function getLastLogins(){
$users = [];
foreach($this->findAll() as $user){
$users[$user->getId()] = $user->getLastLogin();
}
return $users;
}
public function getLastLogin($id){
$user = $this->find($id);
return $user->getLastLogin();
}
public function getSID($id)
{
$user = $this->find($id);
$sid = $user->sid;
return $sid;
}
public function findByFacebookId($id)
{
return $this->findOneBy(['facebook_id' => $id]);
}
public function registerFromFacebook($user_fb_id, $info)
{
$group = $this->groups->find(3);
$user = new User;
$user->setSection($group);
$user->setPassword(Passwords::hash('fb_'.$user_fb_id));
$user->setStatus(1);
$user->setRole('guest');
$user->setEmail($info->email);
$user->setName($info->first_name);
$user->setSurname($info->last_name);
$user->setFacebookId($user_fb_id);
$this->save($user);
}
public function updateFacebookAccessToken($user_fb_id, $access_token)
{
$user = $this->findOneBy(['facebook_id' => $user_fb_id]);
$user->facebook_token = $access_token;
$this->save($user);
}
}
?>
cache jsem mazal. Popravdě na localhostu mi to jede vpohodě, ale na produkčním serveru ne.
Editoval Fyasko (28. 8. 2016 12:52)
- Fyasko
- Člen | 106
Pak tu mám ještě konstruktory
<?php
class UserRightsForm extends UI\Control
{
/** @var Users */
private $users;
public function __construct(Users $users, ...)
{
parent::__construct();
$this->users = $users;
...
}
...
?>
<?php
class Authenticator extends Nette\Object implements Nette\Security\IAuthenticator
{
private $users;
public function __construct(Users $users, ...)
{
$this->users = $users;
}
...
?>
<?php
class UserForm extends UI\Control
{
/** @var Users */
private $users;
public function __construct(Users $users, ...)
{
parent::__construct();
$this->users = $users;
...
}
...
?>
<?php
class EventForm extends UI\Control
{
/** @var Users */
private $users;
public function __construct(Users $users, ...)
{
parent::__construct();
$this->users = $users;
...
}
...
?>
<?php
class GroupsForm extends UI\Control
{
/** @var Users */
private $users;
public function __construct(Users $users, ...)
{
parent::__construct();
$this->users = $users;
...
}
...
?>
Pokud dám PHPStormem find in path User $users, najde mi to jen tyhle konstruktory. Nikde jinde by snad být neměly. A pokud vyhledám extends Users, nebo extends Model\Users, nenajde mi to nic.