public function api(EntityManagerInterface $entityManager): Response
{
$posts = $entityManager->createQuery('SELECT p FROM App\Entity\Post p')->getArrayResult();
return new JsonResponse($posts);
}
SELECT MAX(employee.salary)
FROM AppBundle:Employee employee
JOIN employee.department department
WHERE department.id = :id
SELECT MAX(employee.salary)
FROM AppBundle:Employee employee
WHERE IDENTITY(employee.department) = :id
<?php
namespace App\Entity;
/**
* @Entity
*/
class User
{
const DEFAULT_ROLE = 'user';
/**
* @Column(type="string", options={"default": User::DEFAULT_ROLE})
*
* @var string
*/
private $role = self::DEFAULT_ROLE;
}
Перепробывал несколько бандлов - все ругаются на зависимости от симфы.
class UserNotfier
{
public function notifyUser(User $user): void
{
if (null === $user->getEmail()) {
throw new \Exception('User must have an email!);
}
// ...
}
}
->add('cover', FileType::class, [ 'data_class' => null ])
//* @Entity */
class Group
{
/**
* @ManyToMany(targetEntity="User")
* @JoinTable(
* joinColumns={@JoinColumn(onDelete="CASCADE")},
* inverseJoinColumns={@JoinColumn(onDelete="CASCADE")}
* )
*/
private $users;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('taskName',TextType::class)
->add('file', FileType::class, [ 'mapped' => false, 'label' => 'Документ'])
;
}
$uploadedFile = $form['file']->getData();
$fileName = 'myfile.txt';
$uploadedFile->move('public/uploads', $fileName);
$task->setFileName('public/uploads/'.$fileName);
/**
* Only flushes the given entity according to a ruleset that keeps the UoW consistent.
*
* 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well!
* 2. Read Only entities are skipped.
* 3. Proxies are skipped.
* 4. Only if entity is properly managed.
*
* @param object $entity
*
* @return void
*
* @throws \InvalidArgumentException
*/
private function computeSingleEntityChangeSet($entity)
Модель всегда должна находиться в валидном состоянии.