Skip to content

Instantly share code, notes, and snippets.

View arfaram's full-sized avatar

Ramzi Arfaoui arfaram

View GitHub Profile
@arfaram
arfaram / mysql_diff_ezplatform2_ezplatform3
Last active April 9, 2020 14:09
MySQL diff ezplatform2.5.9 vs ezplatform3
+--------------------------------------------+
| Catalog Diff Report |
+--------------------------------------------+
Schema `default`.`ezplatform2.5.9` was modified
Table `ezplatform2.5.9`.`ezworkflow_process` was dropped
Table `ezplatform2.5.9`.`ezworkflow_group_link` was dropped
Table `ezplatform2.5.9`.`ezworkflow_group` was dropped
Table `ezplatform2.5.9`.`ezworkflow_event` was dropped
Table `ezplatform2.5.9`.`ezworkflow_assign` was dropped
@arfaram
arfaram / LegacyPathGenerator.php
Last active November 22, 2019 16:50
eZ Platform Image path generation
//Image Path Example
// var/site/storage/images/0/5/5/7/7550-6-ger-DE/Homepage-banner.jpg
// Returns a relative storage path
// Computes a 4 levels directory structure from $id , more info in ezcontentobject_attribute "ezimage" and "id" columns
// our base path is the last 4 digits, defaulting to 0, reversed
// getStoragePathForField($fieldId, $versionNo, $languageCode) of the curent published content
//use eZ\Publish\Core\FieldType\Image\PathGenerator\LegacyPathGenerator;
$legacyPathGenerator = new LegacyPathGenerator();
<?php
namespace Bundle\Slot;
use eZ\Publish\Core\SignalSlot\Slot as BaseSlot;
use eZ\Publish\Core\SignalSlot\Signal;
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\LocationService;
class FixArticlePublishSlot extends BaseSlot
@arfaram
arfaram / ContentTypeIdentifierForCreateView.php
Created July 3, 2019 09:57
Custom ezstring FieldType edit Template for a given ContentType(artcile) in ezplatform 2.x - for demo purpose
<?php
namespace EzSystems\CustomizeAdminUIBundle\lib\Matcher\ContentBased\Identifier;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued;
use eZ\Publish\Core\MVC\Symfony\View\View;
@arfaram
arfaram / ConfigureLeftSidebarMenuListener.php
Last active June 14, 2019 13:31
Example on how to remove the Content Browse Button from the Left Siedbar in eZPlatform 2. Note: you can dump $root and remove/add or reorder items ;)
<?php
declare(strict_types=1);
namespace AppBundle\Event\Listener;
use EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent;
class ConfigureLeftSidebarMenuListener
curl -v -X POST \
   https://localhost:8000/graphql \
   -H 'Cookie: eZSESSID21232f297a57a5a743894a0e4a801fc3=3p30i5bu4h8seeu6avubimdj4c; eZSESSID98defd6ee70dfb1dea416cecdf391f58=igsqlrp39miio4h4a1ddc7b1et' \
   -F 'operations={"query":"mutation CreateImage($name: String!, $alternativeText: String!, $file: FileUpload!) { createImage( parentLocationId: 51, input: { name: $name, image: {name: \"Son-Gohan\", alternativeText: $alternativeText, file: $file} } ) { _info { id mainLocationId } name image { fileName alternativeText uri } } }","variables":{"file": null, "name": "Gohan", "alternativeText": "Final cell battle"}}' \
   -F 'map={"0":["variables.file"]}' \
   -F "0"=@/Users/bdunogier/Documents/Capture\ d’écran\ 2019-03-07\ à\ 00.50.42.png
@arfaram
arfaram / TrashSignal_eZPlatform.debug
Last active January 12, 2019 14:28
Information about deleted content from the trash from several signals (delete single item or empty trash) in ezPlatform 2.4+
EmptyTrashSignal:
eZ\Publish\Core\SignalSlot\Signal\TrashService\EmptyTrashSignal Object (
[trashItemDeleteResultList]
=> eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResultList Object
(
[items] => Array
(
[0] => eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResult
Object(
@arfaram
arfaram / create_ezcommerce_product_with_rest_api
Created December 12, 2018 18:14
Create ezcommerce product using the eZ Platform Rest API
POST /api/ezp/v2/content/objects HTTP/1.1
Host: www.ezcomerce_demo.local
Accept: application/vnd.ez.api.Content+xml
X-CSRF-Token: S0s-myzSK5NHB5JMMrhTvRozEL0Jn3tl5QdjpWXyOt0
Content-Type: application/vnd.ez.api.ContentCreate+json
{
"ContentCreate": {
"ContentType": {
"_href": "/api/ezp/v2/content/types/44"
},
@arfaram
arfaram / add_field_form_themes_ezplatform.md
Last active August 6, 2018 11:27
FieldType custom edit template in eZ Platform

Solution 1:

Add in config.yml as global

twig:
    #...
    form_themes:
        - 'AcmeTestBundle:adminui/field:my_field_template.html.twig'

Solution2:

@arfaram
arfaram / 01_ezplatform_db_upgrade_v2.1_to_v2.2.sql
Last active March 29, 2019 12:08
Upgrading your database from ezplatform 2.1 to 2.2. Below you'll find some sql queries to execute and a shell script to convert your table to use utf8mb4. More Information for the upgrade steps : https://doc.ezplatform.com/en/2.2/releases/updating_ez_platform/#4-update-database
--
-- Avoid creating eznotification table again in enterprise edition, this table is already exist in 2.1. This could break the script and cause some key error when the script is executing once again
-- For Community edition see below "add_eznotification.sql"
--
SET default_storage_engine=InnoDB;
BEGIN;
-- Set storage engine schema version number
UPDATE ezsite_data SET value='7.2.0' WHERE name='ezpublish-version';