public function toObject($tab = array()) { $o = new Container(); $o->populate($tab); return $this->closures($o); }
<?php namespace Thin; /* GENERAL */ $config = array('database' => array('adapter' => 'mysql', 'host' => 'localhost', 'username' => 'root', 'password' => 'root', 'dbname' => 'ajf', 'port' => 3306, 'driver' => 'pdo_mysql', 'proxy_namespace' => 'ThinDoctrine', 'proxy_dir' => APPLICATION_PATH . DS . 'models' . DS . 'Doctrine' . DS . 'Proxies'), 'application' => array('plugins_dir' => __DIR__ . '/../../app/plugins/', 'helpers_dir' => __DIR__ . '/../../app/plugins/', 'library_dir' => __DIR__ . '/../../app/lib/', 'view' => array('cache' => true, 'cacheTtl' => 7200)), 'mailer' => array('host' => 'smtp.mandrillapp.com', 'login' => '*****@*****.**', 'password' => 'BT99CIkPBCsoWX5otYpo9g', 'port' => 587, 'secure' => null, 'auth' => true, 'debug' => false), 'mongo' => array('hostname' => 'localhost', 'replicaSet' => false, 'db' => SITE_NAME)); /* PRODUCTION ENVIRONMENT */ $production = array(); /* TESTING ENVIRONMENT */ $testing = array(); /* DEVELOPMENT ENVIRONMENT */ $development = array('application' => array('view' => array('cache' => false))); /* LOCAL ENVIRONMENT */ $local = File::exists(__DIR__ . DS . 'local.php') ? include __DIR__ . DS . 'local.php' : array(); $config = arrayMergeRecursive($config, $local); $application = new Container(); $configEnv = Config::get('application.env', APPLICATION_ENV); $configEnv = ${$configEnv}; $config = arrayMergeRecursive($config, $configEnv); return $application->populate($config);
/** * Create a new row Object * * @param string $rowId The ID of the new row * @param string $id Unique ID of the item * @param string $name Name of the item * @param int $qty Item qty to add to the cart * @param float $price Price of one item * @param Array $options Array of additional options, such as 'size' or 'color' * @return Collection */ protected function createRow($rowId, $id, $name, $qty, $price, $options) { $cart = $this->getContent(); $newRow = new Container(); $values = array('rowid' => $rowId, 'id' => $id, 'name' => $name, 'qty' => $qty, 'price' => $price, 'options' => new Container($options), 'subtotal' => $qty * $price); $newRow->populate($values); $cart->put($rowId, $newRow); return $cart; }
public function row(array $values) { $class = $this; $class->results = null; $class->wheres = null; $obj = new Container(); $save = function () use($class, $obj) { return $class->push($obj->assoc()); }; $delete = function () use($class, $obj) { return $class->pop($obj->getId()); }; $date = function ($f) use($obj) { return date('Y-m-d H:i:s', $obj->{$f}); }; $hydrate = function ($data) use($obj) { if (Arrays::isAssoc($data)) { foreach ($data as $k => $v) { $obj->{$k} = $v; } } return $obj; }; $display = function ($field) use($obj) { return Html\Helper::display($obj->{$field}); }; $tab = function () use($obj) { return $obj->assoc(); }; $asset = function ($field) use($obj) { return '/storage/img/' . $obj->{$field}; }; $obj->event('save', $save)->event('delete', $delete)->event('date', $date)->event('hydrate', $hydrate)->event('tab', $tab)->event('asset', $asset)->event('display', $display); return $obj->populate($values); }
private function row(array $row) { $object = new Container(); $object->populate($row); $db = $this; $save = function () use($object, $db) { return $db->save($object); }; $delete = function () use($object, $db) { return strlen($object->getId()) ? $db->delete($object->getId()) : false; }; $hook = function ($name, $cb) use($object, $db) { $object->{$name} = function () use($cb, $object, $db) { return call_user_func_array($cb, func_get_args()); }; return $object; }; $object->event('save', $save)->event('delete', $delete)->event('hook', $hook); return $object; }
public static function store($flatArticle, $key = null) { $article = new Container(); $article->populate($flatArticle); $serialize = serialize($article); if (is_null($key)) { $key = sha1($serialize); } $file = STORAGE_PATH . DS . 'articles' . DS . $key . '.message'; File::delete($file); File::put($file, $serialize); return $key; }