本文整理汇总了PHP中static::get方法的典型用法代码示例。如果您正苦于以下问题:PHP static::get方法的具体用法?PHP static::get怎么用?PHP static::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateFromRoute
/**
* Auto-generated template name based on class name and called method
* @return string
* @throws \Exception
*/
private function templateFromRoute()
{
$path = $this->f3->get('PATH');
$routes = $this->f3->get('ROUTES');
$requestType = $this->f3->get('VERB');
$calledMethod = current($routes[$path])[$requestType][0];
if (false == preg_match('/(?:.+\\\\)(?<controller>.+)Controller(?:->|::)(?<method>.+)/', $calledMethod, $match)) {
return null;
}
$template = $match['controller'] . '/' . $match['method'] . '.xhtml';
if (file_exists(__DIR__ . '/../Views/' . $template)) {
return $template;
} else {
throw new \Exception(sprintf('Template: %s not found!', $template));
}
}
示例2: getAppForSelect
public static function getAppForSelect($user)
{
$ins = new static();
if ($user->isAdmin()) {
return $ins->get(['key', 'name'])->toArray();
}
return $ins->ownBy($user)->get(['key', 'name'])->toArray();
}
示例3: loadBannedWords
function loadBannedWords()
{
if ($this->bannedWords) {
return;
}
$bw = new static();
$bannedWords = $bw->get();
$this->bannedWords = array();
foreach ($bannedWords as $word) {
$this->bannedWords[] = $word->getWord();
}
}
示例4: invoke
/**
* shortcut function
*
* @param string cachekey
* @param callback
* @return mixed
*/
public static function invoke($cache_key, $callback = null, $namespace = '_global_')
{
$cache = new static($namespace);
if ($cache->has($cache_key)) {
return $cache->get($cache_key);
}
if (is_callable($callback)) {
$value = $callback();
$cache->set($cache_key, $value);
return $value;
}
return null;
}
示例5: __construct
public function __construct()
{
static::$instance = $this;
static::$request = $_REQUEST;
static::$get = $_GET;
static::$post = $_POST;
static::$server = $_SERVER;
static::$headers = static::getAllHeaders();
static::$requestUri = static::prepareRequestUri();
static::$baseUrl = static::prepareBaseUrl();
static::$basePath = static::prepareBasePath();
static::$pathInfo = static::preparePathInfo();
static::$method = static::$server['REQUEST_METHOD'];
}
示例6: create
/**
* Create a new Irto\OAuth2Proxy\Server instance with $config
*
* @param array $config
*
* @return Irto\OAuth2Proxy\Server
*/
public static function create(array $config)
{
$server = new static();
isset($config['verbose']) && $server->setVerbose($config['verbose']);
$server->singleton('config', function ($server) use($config) {
return new Collection($config);
});
$server->bind('Irto\\OAuth2Proxy\\Server', function ($server) {
return $server;
});
// Create main loop React\EventLoop based
$server->singleton('React\\EventLoop\\LoopInterface', function ($server) {
return React\EventLoop\Factory::create();
});
// DNS resolve, used for create async requests
$server->singleton('React\\Dns\\Resolver\\Resolver', function ($server) {
$dnsResolverFactory = new React\Dns\Resolver\Factory();
return $dnsResolverFactory->createCached('8.8.8.8', $server['React\\EventLoop\\LoopInterface']);
//Google DNS
});
// HTTP Client
$server->singleton('React\\HttpClient\\Client', function ($server) {
$factory = new React\HttpClient\Factory();
return $factory->create($server['React\\EventLoop\\LoopInterface'], $server['React\\Dns\\Resolver\\Resolver']);
});
// Request handler to React\Http
$server->singleton('React\\Socket\\Server', function ($server) {
$socket = new React\Socket\Server($server['React\\EventLoop\\LoopInterface']);
$socket->listen($server->get('port'));
return $socket;
});
// HTTP server for handle requests
$server->singleton('React\\Http\\Server', function ($server) {
return new React\Http\Server($server['React\\Socket\\Server']);
});
// HTTP server for handle requests
$server->singleton('SessionHandlerInterface', function ($server) {
return $server->make('Irto\\OAuth2Proxy\\Session\\AsyncRedisSessionHandler', ['lifetime' => array_get($server['config']->all(), 'session.lifetime')]);
});
$server->bind('Illuminate\\Session\\Store', 'Irto\\OAuth2Proxy\\Session\\Store');
$server->boot();
return $server;
}
示例7: ensure
public static function ensure($reference, $type = null, $container = null)
{
if ($reference instanceof $type) {
return $reference;
} elseif (empty($reference)) {
throw new \Exception('The required component is not specified.');
}
if (is_string($reference)) {
$reference = new static($reference);
}
if ($reference instanceof self) {
$component = $reference->get($container);
if ($component instanceof $type || $type === null) {
return $component;
} else {
throw new \Exception('"' . $reference->id . '" refers to a ' . get_class($component) . "\n component. {$type} is expected.");
}
}
$valueType = is_object($reference) ? get_class($reference) : gettype($reference);
throw new \Exception("Invalid data type: {$valueType}. {$type} is expected.");
}
示例8: getId
/**
* Gets the asset id for the object instance
*
* @return int
* @since 2.0.0
**/
public function getId()
{
// Check for current asset id and compute other vars
$current = $this->model->get('asset_id', null);
$parentId = $this->getAssetParentId();
$name = $this->getAssetName();
$title = $this->getAssetTitle();
// Get joomla jtable model for assets
$asset = \JTable::getInstance('Asset', 'JTable', array('dbo' => \App::get('db')));
$asset->loadByName($name);
// Re-inject the asset id into the model
$this->model->set('asset_id', $asset->id);
if ($asset->getError()) {
return false;
}
// Specify how a new or moved node asset is inserted into the tree
if (!$this->model->get('asset_id', null) || $asset->parent_id != $parentId) {
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
if ($this->model->assetRules instanceof \JAccessRules) {
$asset->rules = (string) $this->model->assetRules;
}
if (!$asset->check() || !$asset->store()) {
return false;
}
// Register an event to update the asset name once we know the model id
if ($this->model->isNew()) {
$me = $this;
Event::listen(function ($event) use($asset, $me) {
$asset->name = $me->getAssetName();
$asset->store();
}, $this->model->getTableName() . '_new');
}
// Return the id
return (int) $asset->id;
}
示例9: pagination
/**
* Возвращает коллекцию в виде пагинации
*
* @param int $page
* @param int $limit
*/
public function pagination($page, $limit = 10)
{
/**
* @var \Illuminate\Support\Collection $data
*/
$countTotal = $this->_query->count();
$this->_query->skip($limit * $page - $limit);
$this->_query->limit($limit);
$data = collect();
foreach ($this->_query->get() as $key => $instance) {
$_listRow = [];
foreach ($this->columns->getColumns() as $column) {
$_listRow[$column->getKey()] = $column->getValues($instance);
}
$buttons = $this->filterAction($instance);
if (count($buttons)) {
$_listRow = array_merge($_listRow, [GridColumn::ACTION_NAME => implode('', $buttons)]);
}
$data->offsetSet($key, $_listRow);
}
return new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath(), 'pageName' => 'page']);
}
示例10: rescanMultilingualStacks
public static function rescanMultilingualStacks()
{
$sl = new static();
$stacks = $sl->get();
foreach ($stacks as $stack) {
$section = $stack->getMultilingualSection();
if (!$section) {
$section = false;
$parent = \Page::getByID($stack->getCollectionParentID());
if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
// this is the default
$section = Section::getDefaultSection();
} else {
if ($parent->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
$locale = $parent->getCollectionHandle();
$section = Section::getByLocale($locale);
}
}
if ($section) {
$stack->updateMultilingualSection($section);
}
}
}
}
示例11: create
/**
* Create's a new user. Returns user 'id'.
*
* @param array User array for creation
* @return int
* @throws SentryUserException
*/
public function create(array $user, $activation = false)
{
// check for required fields
if (empty($user[$this->login_column]) or empty($user['password'])) {
throw new SentryUserException(__('sentry::sentry.column_and_password_empty', array('column' => $this->login_column_str)));
}
// if login_column is set to username - email is still required, so check
if ($this->login_column != 'email' and empty($user['email'])) {
throw new SentryUserException(__('sentry::sentry.column_email_and_password_empty', array('column' => $this->login_column_str)));
}
// check to see if login_column is already taken
$user_exists = $this->user_exists($user[$this->login_column]);
if ($user_exists) {
// create new user object
$temp = new static((int) $user_exists['user']['id']);
// check if account is not activated
if ($activation and $temp->get('activated') != 1) {
// update and resend activation code
$hash = Str::random(24);
$update = array('password' => $user['password'], 'activation_hash' => $hash);
if ($temp->update($update)) {
return array('id' => $temp->user['id'], 'hash' => base64_encode($user[$temp->login_column]) . '/' . $hash);
}
return false;
}
// if login_column is not set to email - also check to make sure email doesn't exist
if ($this->login_column != 'email' and $this->user_exists($user['email'], 'email')) {
throw new SentryUserException(__('sentry::sentry.email_already_in_use'));
}
throw new SentryUserException(__('sentry::sentry.column_already_exists', array('column' => $this->login_column_str)));
}
// set new user values
$new_user = array($this->login_column => $user[$this->login_column], 'password' => $this->hash->create_password($user['password']), 'created_at' => $this->sql_timestamp(), 'activated' => (bool) $activation ? false : true, 'status' => 1) + $user;
// check for metadata
if (array_key_exists('metadata', $new_user)) {
$metadata = $new_user['metadata'];
unset($new_user['metadata']);
} else {
$metadata = array();
}
if (array_key_exists('permissions', $new_user)) {
$new_user['permissions'] = json_encode($new_user['permissions']);
}
// set activation hash if activation = true
if ($activation) {
$hash = Str::random(24);
$new_user['activation_hash'] = $this->hash->create_password($hash);
}
// insert new user
$insert_id = DB::connection($this->db_instance)->table($this->table)->insert_get_id($new_user);
// insert into metadata
$metadata = array('user_id' => $insert_id) + $metadata;
DB::connection($this->db_instance)->table($this->table_metadata)->insert($metadata);
// return activation hash for emailing if activation = true
if ($activation) {
// return array of id and hash
if ($insert_id) {
return array('id' => (int) $insert_id, 'hash' => base64_encode($user[$this->login_column]) . '/' . $hash);
}
return false;
}
return $insert_id ? (int) $insert_id : false;
}
示例12: _Log
/**
* Create a new log entry
* @param string $action Action requested
* @param integer $result_id Result ID of action
* @param string|array $params Action parameters
* @param string|array $response Response to action
* @param string created_by field, default to self::$user
* @param string $ip IP address of request
* @param integer $userID User ID, default to self:$userID
* @return boolean
*/
public static function _Log($action, $result_id, $params = FALSE, $response = FALSE, $user = FALSE, $ip = FALSE, $userID = 0)
{
// Set user
if (!$user) {
$user = static::$user;
}
// Set user id
if (!$userID) {
$userID = static::$userID;
}
// Create new log object
$log = new static();
// Set log variables
try {
$log->set('action', $action);
$log->set('result_id', $result_id);
$log->set('created_by', $user);
$log->set('user_id', $userID);
// Log Parameters
if ($params) {
// Convert array to JSON string
if (is_array($params)) {
$params = json_encode($params);
}
// Truncate if too long
$maxLength = self::_attributeProperties('params', 'max');
if ($maxLength !== FALSE && strlen((string) $params) > $maxLength) {
$params = substr((string) $params, 0, $maxLength);
}
// Set
$log->set('params', $params);
}
// Log Response
if ($response) {
// Convert array to JSON string
if (is_array($response)) {
$response = json_encode($response);
}
// Truncate if too long
$maxLength = self::_attributeProperties('response', 'max');
if ($maxLength !== FALSE && strlen((string) $response) > $maxLength) {
$response = substr((string) $response, 0, $maxLength);
}
// Set
$log->set('response', $response);
}
// Log IP
// If an IP is specified use that otherwise
// check for Client-IP header before using REMOTE_ADDR
// This gets around the netscaler reverse-proxy with the additional host header
if ($ip) {
$log->set('ip', $ip);
} else {
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$log->set('ip', $_SERVER['HTTP_CLIENT_IP']);
} else {
if (isset($_SERVER['REMOTE_ADDR'])) {
$log->set('ip', $_SERVER['REMOTE_ADDR']);
}
}
}
} catch (\Exception $e) {
new \Sonic\Message('error', 'Error setting auditlog attributes - ' . $e->getMessage());
return FALSE;
}
// Begin transaction
$log->db->beginTransaction();
try {
// Create log entry
if (!$log->Create()) {
new \Sonic\Message('error', $e->getMessage());
$log->db->rollBack();
return FALSE;
}
} catch (\Exception $e) {
new \Sonic\Message('error', 'Exception creating auditlog - ' . $e->getMessage());
$log->db->rollBack();
return FALSE;
}
// Set last ID
self::$_lastID = $log->get('id');
// Commit and return TRUE
$log->db->commit();
return TRUE;
}
示例13: make
/**
* Quick way to get the breadcrumb
*
* @param array $args
* @return mixed
*/
public static function make(array $args = [])
{
$bc = new static(null, $args);
return $bc->get();
}
示例14: find
/**
* **A static pseudonym for `get()`.**
*
* @param $abstract
*
* @return mixed
*
* @throws ContainerAbstractNotFound
*/
public static function find($abstract)
{
return static::$instance->get($abstract);
}
示例15: all
public static function all($store)
{
$model = new static($store);
return $model->get();
}