Skip to content

Instantly share code, notes, and snippets.

View basz's full-sized avatar

Bas Kamer basz

View GitHub Profile
@basz
basz / JsonModel
Created May 22, 2012 17:46
Inside my controller, as long as result is Traversable or is an object with public props it works...
public function getTransactionDataAction()
{
try {
if ($this->transaction == false || $this->transaction->getStatus() != Transaction::STATUS_COMPLETED) {
return $this->envelopeResult(false, sprintf(self::ERR_INCORRECT_TRANSACTION, $this->_transaction));
}
return $this->envelopeResult(true, $this->transaction->toArray());
} catch (\Exception $e) {
return $this->envelopeResult(false, $e->getMessage());
{
"name":"bushbaby/project-lumasol-store",
"description":"Store for Lumasol, build in zf2",
"license":"Proprietary",
"homepage":"store.lumasol.nl",
"authors":[
{
"name":"Bas Kamer",
"email":"bas@bushbaby.nl"
}
{
"name":"bushbaby/project-lumasol-store",
"description":"Store for Lumasol, build in zf2",
"license":"MIT",
"homepage":"http://store.lumasol.nl",
"authors":[
{
"name":"Bas Kamer",
"email":"bas@bushbaby.nl"
class Module
{
public function init(Manager $moduleManager)
{
$this->sharedEvents = $moduleManager->events()->getSharedManager();
$this->sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'boostrapHandler'), 100);
}
public function boostrapHandler($e)
However this works... yet it feels a little clumsy
'idealLogger' => array(
'stream' => array('stream' => __DIR__ . '/../../../data/logs/ideal.log'),
)
$logger = new \Zend\Log\Logger();
foreach($sm->get('config')->idealLogger as $name => $options) {
$writer = $logger->plugin($name, $options->toArray());
@basz
basz / solution
Created May 30, 2012 20:49
addInitializer example
public function onBootstrap(\Zend\Mvc\MvcEvent $e)
{
$sm = $e->getApplication()->getServiceManager();
$sm->get('ControllerLoader')->addInitializer(function($instance) use ($sm) {
if ($instance instanceof \Zend\Log\LoggerAwareInterface) {
if ($instance instanceof \Application\Controller\PaypalController) {
$logger = $sm->get(__NAMESPACE__ . '.paypal.logger');
}
if ($instance instanceof \Application\Controller\StoreController) {
root@s2:/etc/apache2/sites-available# apt-cache policy php5
php5:
Geïnstalleerd: 5.3.2-1ubuntu4.15
Kandidaat: 5.3.2-1ubuntu4.15
Versietabel:
*** 5.3.2-1ubuntu4.15 0
500 http://security.ubuntu.com/ubuntu/ lucid-updates/main Packages
500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
100 /var/lib/dpkg/status
5.3.2-1ubuntu4 0
root@s2:~# doveconf -n
# 2.0.19: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.39.1-linode34 i686 Ubuntu 12.04 LTS
auth_mechanisms = plain login
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_privileged_group = vmail
passdb {
args = /etc/dovecot/dovecot-sql.conf
driver = sql
# Just an example.
# @video is a direct reference to a '<video>' element.
# $() is assuming jQuery is being used in this example.
@video.addEventListener("loadedmetadata", (event) =>
actualRatio = @video.videoWidth/@video.videoHeight
targetRatio = $(@video).width()/$(@video).height()
adjustmentRatio = targetRatio/actualRatio
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})")
)
<?php
namespace MultiSess\Service;
use Zend\Session\Container as SessionContainer,
Zend\Http\PhpEnvironment\Response as HttpResponse,
Zend\EventManager\StaticEventManager;
class DomainSession
{