本文整理汇总了PHP中static::load方法的典型用法代码示例。如果您正苦于以下问题:PHP static::load方法的具体用法?PHP static::load怎么用?PHP static::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeFromFile
/**
* Creates and returns an instance of Ini
*
* @param array|mixed $file
*
* @return static
*/
public static function makeFromFile($file)
{
$_ini = new static();
$_ini->setFile($file);
$_ini->load();
return $_ini;
}
示例2: fetchForUser
/**
* Get the current user's wishlist
*
* @return \Shop\Models\Wishlists
*/
public static function fetchForUser()
{
$wishlist = new static();
$identity = \Dsc\System::instance()->get('auth')->getIdentity();
$session_id = \Dsc\System::instance()->get('session')->id();
if (!empty($identity->id)) {
$wishlist->load(array('user_id' => new \MongoId((string) $identity->id)));
$wishlist->user_id = $identity->id;
$session_wishlist = static::fetchForSession();
// if there was no user wishlist but there IS a session wishlist, just add the user_id to the session wishlist and save it
if (empty($wishlist->id) && !empty($session_wishlist->id)) {
$wishlist = $session_wishlist;
$wishlist->user_id = $identity->id;
$wishlist->save();
}
// if there was a user wishlist and there is a session wishlist, merge them and delete the session wishlist
// if we already did the merge, skip this
$session_wishlist_merged = \Dsc\System::instance()->get('session')->get('shop.session_wishlist_merged');
if (!empty($session_wishlist->id) && $session_wishlist->id != $wishlist->id && empty($session_wishlist_merged)) {
$wishlist->session_id = $session_id;
$wishlist->merge($session_wishlist->cast());
$session_wishlist->remove();
\Dsc\System::instance()->get('session')->set('shop.session_wishlist_merged', true);
}
if (empty($wishlist->id)) {
$wishlist->save();
}
}
return $wishlist;
}
示例3: create
/**
* Create a thumbnail
*/
static function create($source, $options = array())
{
// Create thumb
$thumb = new static();
// Load
$thumb->load($source);
// Set properties
$properties = array('type', 'quality', 'alignX', 'alignY', 'background');
// Loop
foreach ($properties as $property) {
// If set
if (isset($options[$property])) {
// Set it
$thumb->{$property} = $options[$property];
}
}
// If there's width
if (isset($options['width']) && ($width = $options['width'])) {
// Set width
$thumb->width = $width;
}
// If there's height
if (isset($options['height']) && ($height = $options['height'])) {
// Set height
$thumb->height = $height;
}
// Resize
$thumb->resize();
// Render and return
return $thumb->render();
}
示例4: Factory
public static function Factory($id = null)
{
$obj = new static();
if ($id) {
$obj->load($id);
}
return $obj;
}
示例5: getByID
public static function getByID($avID)
{
$uav = new static();
$uav->load($avID);
if ($uav->getAttributeValueID() == $avID) {
return $uav;
}
}
示例6: getByID
public static function getByID($akID)
{
$ak = new static();
$ak->load($akID);
if ($ak->getAttributeKeyID() > 0) {
return $ak;
}
}
示例7: create
/**
* โหลด template
* ครั้งแรกจะตรวจสอบไฟล์จาก module ถ้าไม่พบ จะใช้ไฟล์จาก owner
*
* @param string $owner ชื่อโมดูลที่ติดตั้ง
* @param string $module ชื่อโมดูล
* @param string $name ชื่อ template ไม่ต้องระบุนามสกุลของไฟล์
* @return \static
*
* @assert ('', '', 'FileNotFound')->isEmpty() [==] true
*/
public static function create($owner, $module, $name)
{
$obj = new static();
$obj->skin = $obj->load($owner, $module, $name);
$obj->items = array();
$obj->num = -1;
return $obj;
}
示例8: saveAndGetId
/**
* Save link preview model and return id
* @param $post
* @return integer|null
*/
public static function saveAndGetId($post)
{
$model = new static();
if ($model->load($post) && $model->save()) {
return $model->id;
}
return null;
}
示例9: create
/**
* โหลด template
* ครั้งแรกจะตรวจสอบไฟล์จาก module ถ้าไม่พบ จะใช้ไฟล์จาก owner
*
* @param string $owner ชื่อโมดูลที่ติดตั้ง
* @param string $module ชื่อโมดูล
* @param string $name ชื่อ template ไม่ต้องระบุนามสกุลของไฟล์
* @param int $cols 0 (default) แสดงผลแบบปกติ มากกว่า 0 แสดงผลด้วยกริด
* @return \static
*/
public static function create($owner, $module, $name, $cols = 0)
{
$obj = new static();
$obj->skin = $obj->load($owner, $module, $name);
$obj->items = array();
$obj->cols = (int) $cols;
$obj->num = $obj->cols;
return $obj;
}
示例10: userIsInGroup
/**
* Check if a user is in a group
* @param int $group_id
* @param int $user_id
* @return bool
*/
public static function userIsInGroup($group_id, $user_id = null)
{
$f3 = \Base::instance();
if ($user_id === null) {
$user_id = $f3->get("user.id");
}
$group = new static();
$group->load(array('user_id = ? AND group_id = ?', $user_id, $group_id));
return $group->id ? true : false;
}
示例11: cancel
/**
* Cancel the invoice
* @return static
* @throws UnsavedException
*/
public function cancel()
{
if (!$this->saved()) {
throw new UnsavedException();
}
$path = $this->router->path([$this->_id, 'cancel']);
$response = $this->client->get($path);
$cancelInvoice = new static($this->client, true);
$cancelInvoice->load($response['id']);
return $cancelInvoice;
}
示例12: setVal
/**
* Set a configuration value
* @param string $key
* @param mixed $value
* @return Config
*/
public static function setVal($key, $value)
{
$f3 = \Base::instance();
$f3->set($key, $value);
$item = new static();
$item->load(array('attribute = ?', $key));
$item->attribute = $key;
$item->value = $value;
$item->save();
return $item;
}
示例13: createByXml
/**
* @param string $xml
* @return static
*/
public static function createByXml($xml)
{
$model = new static();
$attributes = ToolsHelper::xmlToArray($xml);
foreach ($attributes as $name => $value) {
if ($value instanceof SimpleXMLElement) {
unset($attributes[$name]);
}
}
$model->load($attributes, '');
return $model;
}
示例14: getList
static function getList($sql = NULL)
{
$db = Registry::getInstance()->get(static::DB);
$recordset = $db->getRecordset($sql ? $sql : 'SELECT * FROM `' . static::TABLE . '` ORDER BY `name`');
$list = [];
while ($record = $recordset->fetch()) {
$entity = new static();
$entity->load($record);
$list[$entity->id] = $entity;
}
return $list;
}
示例15: loadById
/**
* Load a DAO by its ID(s)
*
* @param ...$id
*
* @return static
* @throws DaoNotFoundException
*/
public static function loadById(...$id)
{
$dao = new static();
/**
* @var $dao AbstractDao
*/
$dao->hydrateDao(array_combine($dao->getDaoIDProperties(), $id));
/**
* @var $dao LsdTrait
*/
$dao->load();
return $dao;
}