Skip to content

Instantly share code, notes, and snippets.

View janit's full-sized avatar

Jani Tarvainen janit

View GitHub Profile
<?php
$stateId = 3;
$stateService = $this->get('ezpublish.api.service.object_state');
$contentService = $this->get('ezpublish.api.service.content');
$contentInfo = $contentService->loadContentInfo(93);
$objectStateGroup = $stateService->loadObjectStateGroup(4);
Here used to be a rough prototype of an
implementation, which is now deprecated.
in favour of this:
https://www.symfony.fi/entry/sharing-state-in-a-symfony-hybrid-app-with-twig-react-etc
-----
Using this approach you can bootstrap a
React application on the server side using
PHP/Symfony so that your client application
@janit
janit / ezp-26555.patch
Last active November 8, 2016 09:36
A simple patch to enable use of eZ Platform MapLocation fieldtype with Google Maps until OpenStreetMaps work is complete.
--- vendor/ezsystems/platform-ui-bundle/Resources/public/js/services/ez-googlemapapiloader2.js 2016-11-08 11:20:11.000000000 +0200
+++ vendor/ezsystems/platform-ui-bundle/Resources/public/js/services/ez-googlemapapiloader.js 2016-11-07 11:34:54.000000000 +0200
@@ -14,7 +14,7 @@
var EVENT_MAP_API_READY = 'mapAPIReady',
EVENT_MAP_API_FAILED = 'mapAPIFailed',
- GMAP_JSONP_URI = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback={callback}';
+ GMAP_JSONP_URI = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback={callback}&key=YOUR_PERSONAL_MAP_KEY_FROM_GOOGLE_HERE';
/**
<head>
// ...whatever you have here
{% if content.versionInfo.contentInfo.id is defined %}
<link rel="amphtml" href="{{ url('ez_amp', {'objectId': content.versionInfo.contentInfo.id }) }}" />
{% endif %}
</head>
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
{% if content is defined and title is not defined %}
{% set title = ez_content_name(content) %}
{% endif %}
<title>{{ title|default('Home')|trans }}</title>
<link rel="canonical" href="{{ url( "ez_urlalias", {"locationId": content.contentInfo.mainLocationId} ) }}" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
{% extends 'amp/pagelayout.html.twig' %}
{% block content %}
<h1>{{ ez_render_field(content,'title') }}</h1>
{{ ez_render_field(content,'content') }}
{% endblock %}
<?php
class AmpController extends Controller
{
public function viewObjectAction($objectId)
{
$objectId = (int) $objectId;
<?php
// imports, etc...
class AmpController extends Controller
{
/**
* @Route("/ez-amp/{objectId}", name="ez_amp")
*/
class AmpController extends Controller
{
/**
* @Route("/ez-amp/{objectId}", name="ez_amp")
*/
public function viewObjectAction($objectId)
{
@janit
janit / angular-component.ts
Last active June 5, 2016 08:17
An example of a Angular 2 Component for Symfony developers
// Imports, similar to use statements in PHP
import { Component, OnInit } from '@angular/core';
import { ListComponent } from './list.component';
import { DomainEntry } from './domain-entry';
import { DomainEntriesService } from './domain-entries.service';
// The component decorator
@Component({