Skip to content

Instantly share code, notes, and snippets.

View bdunogier's full-sized avatar

Bertrand Dunogier bdunogier

View GitHub Profile
<?php
namespace My;
class Controller
{
/**
* @var \My\Service
*/
private $myService;
@bdunogier
bdunogier / query_builder.md
Created March 16, 2014 13:44
QueryBuilder analysis

Simplified search API, aka QueryBuilder

The objective is to conceive a fluent, easy to use API to build location and content search queries. The keyword is fluent, as defined by Martin Fowler: the API methods should match the Domain Language as closely as possible. Chaining of methods is esthetic sugar, but required sugar if we want IDEs to provide contextual completion that always makes sense. Within a given context, the IDE should suggests valid elements, and valid elements should always be suggested.

Criteria handling

Content/Location metadata criteria

Fields criteria

<?php
// "Simple" query (e.g. no logical operations)
// is_class( article, blog_post ) AND parent_location_id( 4 ) AND attr_enabled = true AND attr_publishing_date = <DATE>
$queryBuilder
->contentTypeIdentifier()->in( 'article', 'blog_post' )
->parentLocationId()->eq( 2 )
->checkboxField( 'enabled' )->isFalse()
->dateField( 'publishing_date' )->before( 'last monday' )
->sortBy()
->datePublished()->descending()
server {
listen 80;
server_name php55-vm.ezpublish5 php55-vm.ezpublish5.admin;
root /home/bertrand/ezpublish5/app/web;
access_log /home/bertrand/ezpublish5/app/logs/httpd-access.log;
error_log /home/bertrand/ezpublish5/app/logs/httpd-error.log debug;
disable_symlinks off;
Feature: template helpers
Scenario: As a template developer, I want to get a Route Reference to the current route
Given I am in any Twig template
And I am in the master request
When I use "{{ set route_reference = route_ref() }}"
Then "route_reference" contains a Route Reference to the current route
Scenario: As a template developer, I want to get a Route Reference to a location
Given I am in any Twig template
@bdunogier
bdunogier / .netrc
Created May 16, 2014 12:10
REST: Setting username & password for a host, for use with curl -n or HTTPie
# use admin/publish as the login/password for net requests to localhost
machine localhost login admin password publish
<?xml version="1.0" encoding="UTF-8"?>
<Content media-type="application/vnd.ez.api.Content+xml" href="/api/ezp/v2/content/objects/276" remoteId="2f7b3d4c6137721b88bd5c931efad513" id="276">
<ContentType media-type="application/vnd.ez.api.ContentType+xml" href="/api/ezp/v2/content/types/48"/>
<Name>EZP-23000</Name>
<Versions media-type="application/vnd.ez.api.VersionList+xml" href="/api/ezp/v2/content/objects/276/versions"/>
<CurrentVersion media-type="application/vnd.ez.api.Version+xml" href="/api/ezp/v2/content/objects/276/currentversion">
<Version media-type="application/vnd.ez.api.Version+xml" href="/api/ezp/v2/content/objects/276/versions/2">
<VersionInfo>
<id>863</id>
<versionNo>2</versionNo>
[fpm]
user = www-data
group = www-data
listen = 9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
$ php app/console bdtest:match-uri /Getting-Started/Selected-Features/Create
# Router
route: ez_urlalias
controller: ez_content:viewContent
arguments:
- contentId: 69
- locationId: 71
- viewType: full
- layout: 1
@bdunogier
bdunogier / curl.sh
Last active August 29, 2015 14:23
Creating an image content with the eZ Platform REST API, XML and base64
# Create the content
curl -v -X POST http://admin:[email protected]/api/ezp/v2/content/objects \
-H 'Content-Type: application/vnd.ez.api.ContentCreate+xml'
--data-binary "@payload.xml"
# Publish the content
## replace 122 with the content id returned by the POST request
curl -v -X PUBLISH http://admin:[email protected]/api/ezp/v2/content/objects/122/versions/1