namespace App\Repository;
use App\Entity\Account;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Account|null find($id, $lockMode = null, $lockVersion = null)
* @method Account|null findOneBy(array $criteria, array $orderBy = null)
* @method Account[] findAll()
* @method Account[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AccountRepository extends \Doctrine\ORM\EntityRepository
{
public function __construct($registry)
{
}
Fatal error: Uncaught Error: Call to a member function getUnitOfWork() on null in папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM\EntityRepository.php:194
Stack trace:
#0 папка_проекта\worker\test.php(22): Doctrine\ORM\EntityRepository->findOneBy(Array)
#1 {main}
thrown in папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM\EntityRepository.php on line 194
Fatal error: Uncaught TypeError: Argument 1 passed to App\Repository\AccountRepository::__construct() must be an instance of Symfony\Bridge\Doctrine\RegistryInterface, instance of Doctrine\ORM\EntityManager given, called in папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php on line 68 and defined in папка_проекта\src\Repository\AccountRepository.php:17
Stack trace:
#0 папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php(68): App\Repository\AccountRepository->__construct(Object(Doctrine\ORM\EntityManager), Object(Doctrine\ORM\Mapping\ClassMetadata))
#1 папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php(50): Doctrine\ORM\Repository\DefaultRepositoryFactory->createRepository(Object(Doctrine\ORM\EntityManager), 'App\\Entity\\Acco...')
#2 папка_проекта\vendor\doctrine\orm\lib\Doctrine\ORM in папка_проекта\src\Repository\AccountRepository.php on line 17
namespace App\Repository;
use App\Entity\Account;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Account|null find($id, $lockMode = null, $lockVersion = null)
* @method Account|null findOneBy(array $criteria, array $orderBy = null)
* @method Account[] findAll()
* @method Account[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AccountRepository extends \Doctrine\ORM\EntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Account::class);
}
<?php
require __DIR__.'/../vendor/autoload.php';
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use App\Entity\Account; // Подключаю объект account, который прекрасно работает из Symfony
$isDevMode = true;
$entitiesPaths = array(__DIR__.'/../src/Entity'); //Путь до папки /src/Entity
$dbParams = array(
'dbname' => 'база',
'user' => 'логин',
'password' => 'пароль',
'host' => '127.0.0.1',
'driver' => 'pdo_mysql');
$config = Setup::createAnnotationMetadataConfiguration($entitiesPaths, $isDevMode, null, null, false);
$em = EntityManager::create($dbParams, $config);
$id = 9; // для примера
$account = $em->getRepository(Account::class)->findOneBy([
'id'=>$id,
]);
var_dump($account);
Fatal error: Uncaught TypeError: Argument 1 passed to App\Repository\AccountRepository::__construct() must be an instance of Symfony\Bridge\Doctrine\RegistryInterface, instance of Doctrine\ORM\EntityManager given, called in _папка_проекта_\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php on line 68 and defined in _папка_проекта_\src\Repository\AccountRepository.php:17
Stack trace:
#0 _папка_проекта_\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php(68): App\Repository\AccountRepository->__construct(Object(Doctrine\ORM\EntityManager), Object(Doctrine\ORM\Mapping\ClassMetadata))
#1 _папка_проекта_\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php(50): Doctrine\ORM\Repository\DefaultRepositoryFactory->createRepository(Object(Doctrine\ORM\EntityManager), 'App\\Entity\\Acco...')
#2 _папка_проекта_\vendor\doctrine\orm\lib\Doctrine\ORM in _папка_проекта_\src\Repository\AccountRepository.php on line 17
<?php
namespace App\Repository;
use App\Entity\Account;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Account|null find($id, $lockMode = null, $lockVersion = null)
* @method Account|null findOneBy(array $criteria, array $orderBy = null)
* @method Account[] findAll()
* @method Account[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AccountRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Account::class);
}
// /**
// * @return Account[] Returns an array of Account objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->orderBy('a.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Account
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\AccountRepository")
*/
class Account
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true, nullable=false)
*/
private $username;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $password;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $status;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $status_title;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $access_date;
/**
* @ORM\Column(type="integer")
*/
private $owner_id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $avatar;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $autopay;
/**
* @ORM\Column(type="integer")
*/
private $worker_id;
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
public function getStatusTitle(): ?string
{
return $this->status_title;
}
public function setStatusTitle(?string $status_title): self
{
$this->status_title = $status_title;
return $this;
}
public function getAccessDate(): ?\DateTimeInterface
{
return $this->access_date;
}
public function setAccessDate(?\DateTimeInterface $access_date): self
{
$this->access_date = $access_date;
return $this;
}
public function getOwnerId(): ?int
{
return $this->owner_id;
}
public function setOwnerId(int $owner_id): self
{
$this->owner_id = $owner_id;
return $this;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function setAvatar(string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getAutopay(): ?bool
{
return $this->autopay;
}
public function setAutopay(?bool $autopay): self
{
$this->autopay = $autopay;
return $this;
}
public function getWorkerId(): ?int
{
return $this->worker_id;
}
public function setWorkerId(int $worker_id): self
{
$this->worker_id = $worker_id;
return $this;
}
}
Fatal error: Uncaught TypeError: Argument 1 passed to App\Repository\AccountRepository::__construct() must be an instance of Symfony\Bridge\Doctrine\RegistryInterface, instance of Doctrine\ORM\EntityManager given, called in _путь к проекту_\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php on line 68 and defined in _путь к проекту_\src\Repository\AccountRepository.php:17
Fatal error: Uncaught TypeError: Argument 1 passed to Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\ORM\EntityManager given, called in _путь к проекту_\vendor\doctrine\orm\lib\Doctrine\ORM\Repository\DefaultRepositoryFactory.php on line 68 and defined in _путь к проекту_\vendor\doctrine\doctrine-bundle\Repository\ServiceEntityRepository.php:28
Host: example.ru
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Authorization: Digest username="root", --- тут далее результаты basic-авторизации (хеши) ---
Connection: keep-alive
Upgrade-Insecure-Requests: 1
If-Modified-Since: Fri, 03 Nov 2017 12:55:11 GMT
If-None-Match: "-1330132489"
Cache-Control: max-age=0
Не правы. Понять десяток файлов не сложно, понять несколько тысяч файлов - не реально.