Skip to content

Instantly share code, notes, and snippets.

View andrerom's full-sized avatar

André R. andrerom

View GitHub Profile
@andrerom
andrerom / Singleton.php
Created November 27, 2010 13:25
Note: Singleton's are not a good pattern for unit testing, you should as much as possible look into passing object around in your application flow instead of relying on Singleton's. But there are cases where it might make a lot of sense nevertheless, for
<?php
/**
* File contains misc ways to archive Singleton pattern depending on PHP version
*
* Note that the Singleton pattern is hard to test: {@link http://www.phparch.com/2010/03/03/static-methods-vs-singletons-choose-neither/}
*/
/**
* Singleton in any PHP 5.x version using code duplication
*/
@andrerom
andrerom / Deprecate eZMySQLDB for setup wizard
Created March 11, 2011 10:48
Makes ure it's not default one and make it clear that it's deprecated.
diff --git a/kernel/setup/ezsetupcommon.php b/kernel/setup/ezsetupcommon.php
index 9ef9cb7..bd137c8 100644
--- a/kernel/setup/ezsetupcommon.php
+++ b/kernel/setup/ezsetupcommon.php
@@ -51,9 +51,15 @@ function eZSetupOptionalTests()
function eZSetupDatabaseMap()
{
- return array( 'mysql' => array( 'type' => 'mysql',
+ return array( 'mysqli' => array( 'type' => 'mysqli',
@andrerom
andrerom / responsive_images.htm
Created May 15, 2012 23:22
Responsive image html support proposal
<p>The proposed (but human unreadable) WHATWG syntax:<p>
<pre>
<img src="face-600-200@1.jpg" alt=""
set="face-600-200@1.jpg 600w 200h 1x,
face-600-200@2.jpg 600w 200h 2x,
face-icon.png 200w 200h">
</pre>
<p>The propposed RICG syntax (that WHATWG rejects):</p>
@andrerom
andrerom / papi_bootstrap.php
Created September 5, 2012 09:46 — forked from pspanja/papi_bootstrap.php
Public API boostrap
<?php
/**
* Get ServiceContainer (exposes the API)
* @var \eZ\Publish\API\Container $serviceContainer
*/
$serviceContainer = require "bootstrap.php";
$repository = $serviceContainer->getRepository();
$administratorUser = $repository->getUserService()->loadUser( 14 );
@andrerom
andrerom / new_way.php
Last active December 12, 2015 09:49 — forked from dpobel/new_way.php
Updated query to reflect added ContentTypeIdentifier by @crevillo in 0cb178324a63767664dc0aed0f2ddd1ace7d1e1d in January 2013
<?php
use \eZ\Publish\API\Repository\Values\Content\Query;
$locationService = $this->getRepository()->getLocationService();
$searchService = $this->getRepository()->getSearchService();
$urlAliasService = $this->getRepository()->getUrlAliasService();
$root = $locationService->loadLocation( 2 );
$query = new Query();
$query->criterion = new Criterion\LogicalAND(
@andrerom
andrerom / dump.php
Created August 14, 2013 15:40
For dumping a database to a "fixture" php file, as used by integration tests in eZ Publish 5.x
#!/usr/bin/env php
<?php
require 'ezc/Base/base.php';
spl_autoload_register( 'ezcBase::autoload' );
$db = ezcDbFactory::create( 'mysql://user:password@server/databse_name' );
// Get all tables
$tables = array();
@andrerom
andrerom / gist:6792186
Created October 2, 2013 11:13
Backport of Zeta patch: "Fixed Header Mime encoding failing using multi-byte characters" in issue EZP-21567 for eZ Publish 5.0 and lower Gist based on: https://github.com/zetacomponents/Mail/pull/8 Note: 5.0 needs to run composer update and apply this patch for mixed + pure legacy setup.
diff --git a/ezpublish_legacy/lib/ezc/Mail/src/interfaces/part.php b/ezpublish_legacy/lib/ezc/Mail/src/interfaces/part.php
index 6adcabf..8bdceb6 100644
--- a/src/interfaces/part.php
+++ b/src/interfaces/part.php
@@ -387,18 +387,9 @@ public function generateHeaders()
// break intentionally missing
default:
- $preferences = array(
- 'input-charset' => $charset,
@andrerom
andrerom / gist:8605484
Created January 24, 2014 20:20
Abstract Logger class intended at time of writing (early 2013) for logging in new stack
<?php
/**
* File containing the Abstract ProfileLogger class
*
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
*/
namespace eZ\Publish\SPI\Profiler;
@andrerom
andrerom / contributing.md
Last active August 29, 2015 13:55
contributing.md proposal for eZ repos

How to contribute

Contributions are essential for keeping eZ products great. We simply can't access the huge number of platforms and myriad configurations that exists, even if we plan to add more platforms on our CI systems over time it won't cover everything. eZ thus strongly belive in the power of the community to help improve the product in anyway possible for the benefit of the ecosystem.

We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we

@andrerom
andrerom / gist:490e35e3a76e2afe6c0f
Created July 8, 2014 13:24
This is how composer tells you you have wrong PHP verison
[vagrant@ezp5 ezpublish5]$ composer.phar install --prefer-dist
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package php could not be found in any version, there may be a typo in the package name.
Problem 2
- The requested package php could not be found in any version, there may be a typo in the package name.
Problem 3