Skip to content

Instantly share code, notes, and snippets.

<?php
public function __call($method, $arguments)
{
// If arguments are passed can't use the property accessor, so no free obj.name in twig.
if(count($arguments))
return $this->proxyCurrentLocaleTranslation($method, $arguments);
else
return \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Example
*
* @ORM\Table()
SELECT
t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3,
t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7,
t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11,
t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14,
t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17,
t0.first_name AS first_name18, t0.last_name AS last_name19
FROM app_user t0
WHERE t0.id = ? LIMIT 1 [1] []
// In ProjectRepository
public function getBaseExportQuery()
{
return $this->createQueryBuilder('p')
->getQuery()
->setHint(\Doctrine\ORM\Query::HINT_INCLUDE_META_COLUMNS, true)
->getArrayResult();
}
// In ProjectRepository
public function getBaseExportQuery()
{
return $this->createQueryBuilder('p')
->getQuery()
->getArrayResult();
}
<?php
namespace My\AppBundle\Listener;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
{% block checkbox_hierarchy_widget %}
<ul class="listless spaced-listless" id="mainList">
{% for choiceOrOptionGroup,children in form.vars.choices %}
{% if children is iterable %}
<ul>
{% for child,choiceView in children %}
<li>
<label class="checkbox">
{{ form_widget(form.offsetGet(child)) }}
{{ form.offsetGet(child).vars.label }}
<?php
class Form extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('permissions','choice',['choices' => $choices, 'multiple' => true]);
}
}
<?php
$choices = [
'Permission 1' => 'Permission 1',
'Permission 1 Sub-Permissions' => [
'Permission 1a' => '1a',
'Permission 1b' => '1b'
],
'Permission 2' => 'Permission 2',
'Permission 3' => 'Permission 3',
'Permission 3 Sub-Permissions' => [
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
....