The Mongo PHP Adapter is a userland library designed to act as an adapter between applications relying on ext-mongo and the new driver (ext-mongodb).
It provides the API of ext-mongo built on top of mongo-php-library, thus being compatible with PHP 7.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$addFields = function (FormInterface $form, FormModel $model){
foreach ($model->getFields() as $field) {
$form->add($field->getName(), $field->getType(), $field->getOptions());
}
};
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($addFields) {
$data = $event->getData();
$form = $event->getForm();
$addFields($form, $data);
});
}
namespace Site\AppBundle\Twig;
use Symfony\Component\HttpFoundation\Request;
class TwigExtension extends \Twig_Extension
{
public function getTests()
{
return array(
new \Twig_SimpleTest('match_route', array($this, 'matchRoute')),
);
}
public function matchRoute(Request $request, $routeName, $routeParameters = array())
{
if (!$requestRouteName = $request->attributes->get('_route')) {
return false;
}
if ($requestRouteName != $routeName) {
return false;
}
if (empty($routeParameters)) {
return true;
}
if (!$requestRouteParameters = $request->attributes->get('_route_params')) {
return false;
}
$arrayIntersect = array_intersect_assoc($requestRouteParameters, $routeParameters);
if (count($arrayIntersect) == count($routeParameters)) {
return true;
}
return false;
}
public function getName()
{
return 'twig_extension';
}
}
{% if app.request is match_route('homepage') %}текущая страница "homepage"{% endif %}
{% if app.request is match_route('entry', { 'name': 'info' }) %}текущая страница "info"{% endif %}
{% if app.request.attributes.get('_route') == 'homepage' %}
<li class="selected"><span>HOME</span></li>
{% else %}
<li><a href="{{ path('homepage') }}">HOME</a></li>
{% endif %}
{% if app.request.attributes.get('_route') == 'entry' and
app.request.attributes.get('_route_params').name is defined and
app.request.attributes.get('_route_params').name == 'info' %}
<li class="selected"><span>INFO</span></li>
{% else %}
<li><a href="{{ path('entry', { 'name': 'info' }) }}">INFO</a></li>
{% endif %}
{% if app.request.attributes.get('_route') == 'entry' and
app.request.attributes.get('_route_params').name is defined and
app.request.attributes.get('_route_params').name == 'settings' %}
<li class="selected"><span>SETTINGS</span></li>
{% else %}
<li><a href="{{ path('entry', { 'name': 'settings' }) }}">SETTINGS</a></li>
{% endif %}
{% if app.request.attributes.get('_route') == 'download' %}
<li class="selected"><span>DOWNLOAD</span></li>
{% else %}
<li><a href="{{ path('download') }}">DOWNLOAD</a></li>
{% endif %}
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
providers:
admin:
memory:
users:
%admin_username%: # парметры admin_username и admin_password можно задавать в parameters.yml
password: %admin_password%
roles: 'ROLE_SYNC'
firewalls:
admin_area:
provider: admin
pattern: ^/admin
logout:
path: /admin/logout
target: /admin
http_basic: ~
anonymous: false
access_control:
- { path: ^/admin/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/administrator, role: IS_AUTHENTICATED_FULLY }
- { path: ^/admin, role: IS_AUTHENTICATED_REMEMBERED }
/**
* @Security("is_granted('OFFER_OWNER', offer) and has_role('ROLE_USER')"")
*/
public function editAction(Request $request, Offer $offer)
{
}
return $builder
->getQuery()
->useQueryCache(true)
->useResultCache(true, 300)
->getResult()
;
check_path: app_main_admin_login
login_path: app_main_admin_login
app_main_admin_login:
path: /admin/login
defaults: { _controller: app_main.security_controller:loginAction }
app_main_admin_check:
path: /admin/check
app_main_admin_logout:
path: /admin/logout
check_path: app_main_admin_check
login_path: app_main_admin_login