// App\Kernel
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
// ...
$container->addCompilerPass(new class implements CompilerPassInterface {
public function process(ContainerBuilder $container)
{
$container->getDefinition('oneup_flysystem.adapter.local')->setLazy(true);
}
});
}
Since every developer uses a different IDE, the recommended way to enable this feature is to configure it on a system level. This can be done by setting the xdebug.file_link_format option in your php.ini configuration file.
# services.yaml
imports:
- { resource: 'local.yaml', ignore_errors: true }
# local.yaml
framework:
ide: 'phpstorm://open?file=%%f&line=%%l'
# .gitignore
/config/local.yaml
class Decoder{
private $inputStr;
private $pos;
private $out;
private $length;
public function __construct(string $str) {
$this->inputStr = $str;
$this->pos = 0; // Было $this->$pos
$this->out = ''; // Было $this->$out
$this->length = mb_strlen($str); // Было $this->$length
}
public function decode(): string {
return $this->out; // // Было $this->$out
}
}
$this->$length = mb_strlen($str);
=> $this->null = mb_strlen($str);
return $this->$out;
=> return $this->null // 6
// Этот класс в бандле
/** @MappedSuperclass */
class BaseAnimal
{
/** @Column(type="string") */
protected $name;
/** @Column(type="integer") */
protected $size;
/** @Column(type="boolean") */
protected $canFly;
}
// Этот класс в проекте
/** @Entity */
class Animal extends BaseAnimal
{
/** @Column(type="string") */
private $id;
/** @ManyToOne(targetEntity="Person") */
private $owner;
}
$validator = (new ValidatorBuilder())->getValidator();
$constraints = [
new Assert\Collection([
'fields' => [
'address' => [
new Assert\NotNull(),
new Assert\Type('array'),
],
],
'allowMissingFields' => true,
'allowExtraFields' => true,
]),
new Assert\Collection([
'fields' => [
'required' => [
new Assert\NotNull(),
],
],
'allowExtraFields' => true,
]),
];
$data = [];
dump($data);
dump($validator->validate($data, $constraints)); // Ko
$data = [
'address' => null,
];
dump($data);
dump($validator->validate($data, $constraints)); // Ko
$data = [
'address' => [],
];
dump($data);
dump($validator->validate($data, $constraints)); // Ko
$data = [
'address' => 'address',
];
dump($data);
dump($validator->validate($data, $constraints)); // Ko
$data = [
'address' => [],
'required' => 'value',
];
dump($data);
dump($validator->validate($data, $constraints)); // Ok
/** @var UserInterface $user */
/** @var RoleHierarchyInterface $hierarchy */
$roles = $hierarchy->getReachableRoleNames($user->getRoles());
$result = array_search('ROLE_GROUP_MANAGER', $roles) !== false;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\RouteCollectionBuilder;
require_once __DIR__.'/../vendor/autoload.php';
$locator = new FileLocator([__DIR__.'/../data']);
$loader = new YamlFileLoader($locator);
$builder = new RouteCollectionBuilder($loader);
$builder->import('dir1/routes.yaml');
$builder->import('dir2/routes.yaml');
$routes = $builder->build();
var_dump($routes);
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Routing\Loader\GlobFileLoader;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\RouteCollectionBuilder;
require_once __DIR__.'/../vendor/autoload.php';
$locator = new FileLocator([__DIR__.'/../data']);
$resolver = new LoaderResolver([
new GlobFileLoader($locator), // needs symfony/finder
new YamlFileLoader($locator),
]);
$loader = new DelegatingLoader($resolver);
$builder = new RouteCollectionBuilder($loader);
$builder->import('**/*/routes.yaml', '/', 'glob');
$routes = $builder->build();
var_dump($routes);
class Locale
{
/**
* @var string
*/
private $value;
public function __construct(string $value)
{
$this->value = $value;
}
public function __toString()
{
return $this->value;
}
}
class LocaleFactory
{
/**
* @var RequestStack
*/
private $requestStack;
/**
* @var string
*/
private $default;
public function __construct(RequestStack $requestStack, string $default)
{
$this->requestStack = $requestStack;
$this->default = $default;
}
public function create(): Locale
{
if ($request = $this->requestStack->getMasterRequest()) {
return new Locale($request->get('locale', $this->default));
}
return new Locale($this->default);
}
}
services:
App\Locale\Locale:
factory: ['@App\Locale\LocaleFactory', 'create']
public function add(Request $request, EntityManagerInterface $manager, Locale $lang)
"config": {
"preferred-install": {
"my/lib": "source"
}
},
$parameters = $matcher->match($request->getPathInfo());
$invoker = new Invoker\Invoker(null, $container);
$invoker->call($parameters['_controller'], $parameters);
$parameters = $matcher->match($request->getPathInfo());
list($class, $action) = $parameters['_controller'];
unset($parameters['_controller']);
$controller = new $class;
$controller->$action($parameters);
referencedColumnName: Name of the primary key identifier that is used for joining of this relation.
/**
* @OneToMany(targetEntity="Address", mappedBy="customer", cascade={"persist", "remove"})
* @JoinColumn(name="customer_id", referencedColumnName="customer_id")
*/
protected $addresses;
Address::$customer_id
- это primary key?/**
* @Entity
* @Table(name="`address`")
*/
class Address
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="IDENTITY")
*/
protected $address_id;
/**
* @Column(type="string")
*/
protected $firstname;
/**
* @ManyToOne(targetEntity="Customer", inversedBy="address")
* @JoinColumn(name="customer_id", referencedColumnName="customer_id")
*/
protected $customer;
}
/**
* @Entity(repositoryClass="\Core\Repositories\CustomerRepository")
* @Table(name="`customer`")
*/
class Customer
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="IDENTITY")
*/
protected $customer_id;
/**
* @OneToMany(targetEntity="Address", mappedBy="customer", cascade={"persist", "remove"})
*/
protected $addresses;
public function __construct()
{
$this->addresses = new ArrayCollection();
}
}
referencedColumnName: Name of the primary key identifier that is used for joining of this relation.
/**
* @OneToOne(targetEntity="\Core\Entities\Delivery\BoxberryTtn", mappedBy="ttn_boxberry", cascade={"persist", "remove"})
* @JoinColumn(name="order_code", referencedColumnName="id")
*/
protected $boxberry_ttn;
/**
* @Entity
* @Table(name="`ttn_boxberry`")
*/
class BoxberryTtn
{
/**
* @Id
* @Column(type="string")
* @GeneratedValue(strategy="NONE")
*/
protected $id;
public function __construct(string $id)
{
$this->id = $tid;
}
}
order_code
/**
* @Entity
* @Table(name="`order`")
*/
class Order
{
/**
* @Id
* @Column(type="integer")
*/
protected $order_code;
/**
* @OneToOne(targetEntity="\Core\Entities\Delivery\BoxberryTtn", mappedBy="ttn_boxberry", cascade={"persist", "remove"})
* @JoinColumn(name="order_code", referencedColumnName="order_code")
*/
protected $boxberry_ttn;
}
/**
* @Entity
* @Table(name="`order`")
*/
class Order
{
/**
* @Id
* @Column(type="integer")
*/
protected $order_id;
/**
* @Id
* @Column(type="integer")
*/
protected $order_code;
/**
* @Column(type="integer")
*/
protected $warehouse_id;
/**
* @OneToOne(targetEntity="\Core\Entities\Delivery\BoxberryTtn", cascade={"persist", "remove"})
* @JoinColumn(referencedColumnName="order_code")
*/
protected $boxberry_ttn;
public function __construct(int $order_id, string $order_code)
{
$this->order_id = $order_id;
$this->order_code = $order_code;
}
}
/**
* @Entity
* @Table(name="`ttn_boxberry`")
*/
class BoxberryTtn
{
/**
* @Id
* @Column(type="string")
* @GeneratedValue(strategy="NONE")
*/
protected $order_code;
/**
* @Column(type="string")
*/
protected $ttn_num;
/**
* @Column(type="float", scale=2)
*/
protected $delivery_cost;
public function __construct(Order $order)
{
$this->order_code = $order->getOrderCode();
}
}
public function __toString()
{
return $this->name;
}
\Symfony\Component\Form\Extension\Core\Type\ColorType
в котором, судя по всему, ваша сущность кастится в строку.\App\Form\ColorType
метод getBlockPrefix
и все заработает:public function getBlockPrefix()
{
return 'app_color';
}
<?php
$items = range(1, 30);
$chunks = array_chunk($items, 5);
$chunks = array_map(function($items){
return array_chunk($items, 4);
}, $chunks);
?>
<?php foreach ($chunks as $chunk): ?>
<div class="item">
<div class="item-left">
<?php foreach ($chunk[0] as $item): ?>
<div class="point"><?=$item?></div>
<?php endforeach; ?>
</div>
<div class="item-right">
<?php foreach ($chunk[1] as $item): ?>
<div class="point"><?=$item?></div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
$chunk[1]