本文整理汇总了PHP中Container::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::populate方法的具体用法?PHP Container::populate怎么用?PHP Container::populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::populate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toObject
public function toObject($tab = array())
{
$o = new Container();
$o->populate($tab);
return $this->closures($o);
}
示例2: array
<?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' => 'clementdharcourt@albumblog.com', '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);
示例3: createRow
/**
* 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;
}
示例4: row
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);
}
示例5: row
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;
}
示例6: store
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;
}