Skip to content

Instantly share code, notes, and snippets.

@toopay
Created October 25, 2012 04:45
Show Gist options
  • Save toopay/3950452 to your computer and use it in GitHub Desktop.
Save toopay/3950452 to your computer and use it in GitHub Desktop.
Observer sample
<?php
namespace App;
use Juriya\Pattern\Observer;
use Juriya\ResponseHttp;
class CustomContent implements Observer {
public static function onExecute($observable, $arguments)
{
$currentCode = $arguments->getCode();
$currentContent = $arguments->getContent();
// We will change all 'a' character into 'i'
$customContent = str_replace('a', 'i', $currentContent);
$newResponse = new ResponseHttp($currentCode, $customContent);
$newResponse->render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment