Created
October 25, 2012 04:45
-
-
Save toopay/3950452 to your computer and use it in GitHub Desktop.
Observer sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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