Мне этот вариант показался слишком грязным, придется в каждом методе описать функцию постлоЛоада. Проблему решит, но не красиво.
<?php
namespace App\EventSubscriber;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;
class InvalidEntitySubscriber implements EventSubscriber
{
public function getSubscribedEvents(): array
{
return [ Events::postLoad ];
}
public function postLoad(LifecycleEventArgs $args): void
{
$entity = $args->getEntity();
if ($entity instanceof User) {
if (null === $user->getEmail()) {
throw new InvalidEntityException();
}
}
// И так для каждой сущности
}
}
services:
App\EventSubscriber\EntityNullValueSubscriber:
tags: ['doctrine.event_subscriber']
$file = $product->getBrochure();
$file->move(
$this->getParameter('brochures_directory'),
$fileName
);
// updates the 'brochure' property to store the PDF file name
// instead of its contents
$product->setBrochure($fileName);
public function compileDelete(Builder $query)
{
if (isset($query->joins) || isset($query->limit)) {
$selectSql = parent::compileSelect($query->select("{$query->from}.rowid"));
return "delete from {$this->wrapTable($query->from)} where {$this->wrap('rowid')} in ({$selectSql})";
}
$wheres = is_array($query->wheres) ? $this->compileWheres($query) : '';
return trim("delete from {$this->wrapTable($query->from)} $wheres");
}
protected function compileDeleteWithJoins($query, $table)
{
$using = ' USING '.collect($query->joins)->map(function ($join) {
return $this->wrapTable($join->table);
})->implode(', ');
$where = count($query->wheres) > 0 ? ' '.$this->compileUpdateWheres($query) : '';
return trim("delete from {$table}{$using}{$where}");
}
Сильное сообщество, если опять сравнивать с WP это не армия школьников научившихся php за 10 дней и выкладывающая говно плагины в репозиторий, в основном это чуваки, которые умеют писать код и причем правильно.
На мой взгяд, единственное что точно хуже работает в Vim - это автодополнение.