$json = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key='.$steam_api_key.'&steamid='.$user_steam_id); //Получение JSON
// true, чтобы на выходе был ассоциативный массив, а не \stdClass (для PHP 7 неактуально, т.к. array_column может работать с массивами объектов)
$data = json_decode($json, true);
$stats = array_column($data['playerstats']['stats'], 'value', 'name');
echo $stats['total_deaths'];
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);
});
}
/**
* @return void
*/
public function processUpdates()
{
$updates = $this->api->getUpdates();
$lastUpdateId = null;
foreach ($updates as $update) {
$lastUpdateId = $update->getUpdateId();
$this->processUpdate($update);
}
if ($lastUpdateId) {
$this->api->getUpdates($lastUpdateId + 1, 1);
}
}
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 }
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.
/**
* @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()
;