$object = new \stdClass();
$a = new \stdClass();
$a->name = 'a';
$b = new \stdClass();
$b->name = 'b';
$c = new \stdClass();
$c->name = 'c';
$object->a = $a;
$a->b = $b;
$b->c = $c;
$path = 'a.b.c';
$propertyAccessor = \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor();
var_dump($propertyAccessor->getValue($object, $path));
$data['name1']['name2']['name3'] = 'some data';
$propertyAccessor = \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor();
$keys = '[name1][name2][name3]';
echo $propertyAccessor->getValue($data, $keys);
composer req seld/jsonlint
#!/usr/bin/env php
<?php
use Seld\JsonLint\JsonParser;
use Seld\JsonLint\ParsingException;
require_once __DIR__ . '/../vendor/autoload.php';
$parser = new JsonParser();
$data = file_get_contents(__DIR__ . '/../test.json');
$tries = 0;
do {
$repeat = false;
try {
$parser->parse($data);
} catch (ParsingException $e) {
$details = $e->getDetails();
$start = $details['loc']['first_column'];
$end = mb_strpos($data, ',', $start, 'utf8') - 1;
$problemString = mb_substr($data, $start, $end - $start, 'utf8');
$data = str_replace($problemString, addslashes($problemString), $data);
$repeat = true;
$tries++;
}
} while ($repeat);
echo $data;
Catalog
Controller
Admin
ProductController.php
ProductController.php # ReviewManager используется тут
Entity
Product.php
Review.php
ReviewManager.php
Order
Controller
Admin
OrderController.php
OrderController.php
Entity
Order.php
Item.php
User
Controller
Admin
UserController.php
UserController.php
Entity
User.php
Controller
Admin
Catalog
ProductController.php
Order
OrderController.php
User
UserController.php
Catalog
ProductController.php # ReviewManager используется тут
Order
OrderController.php
User
UserController.php
Entity
Catalog
Product.php
Review.php
Order
Order.php
Item.php
User
User.php
Catalog
ReviewManager.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){
if (!$data = $event->getData()) {
return;
}
$form = $event->getForm();
// Тут можно в зависимо от $data навешивать свои поля
$form
->add('someField', TextType::class)
;
});
}
$dateTime = new \DateTime('this friday');
echo $dateTime->format('Y-m-d');
$now = new \DateTime();
$friday = new \DateTime('this friday');
$result = new \DateTime('next monday');
if ($now->format('Y-m-d') == $friday->format('Y-m-d') &&
$now->format('H:i:s') >= '14:00:00') {
$result->add(new \DateInterval('P1W'));
} elseif ($friday < $now) {
$result->add(new \DateInterval('P1W'));
}
echo $result->format('Y-m-d');
<script src="{{ asset('bundles/admin/css/vendor.css') }}"></script>
<script src="{{ asset('bundles/admin/css/elephant.css') }}"></script>
<script src="{{ asset('bundles/admin/css/application.css') }}"></script>
<script src="{{ asset('bundles/admin/css/demo.css') }}"></script>
Вопрос - где мне и как писать этот логгер ?
Для него нужен отдельный бандл?
For most projects, you should store everything inside the AppBundle. Inside here, you can create whatever directories you want to organize things
Скажите хотя бы как этот вопрос гуглить или в какую сторону копать