本文整理汇总了PHP中Registry类的典型用法代码示例。如果您正苦于以下问题:PHP Registry类的具体用法?PHP Registry怎么用?PHP Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Tax constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->db = $registry->get('db');
$this->session = $registry->get('session');
// If shipping address is being used
if (isset($this->session->data['shipping_address_id'])) {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['shipping_address_id'] . "'");
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif (isset($this->session->data['guest']['shipping'])) {
$this->setShippingAddress($this->session->data['guest']['shipping']['country_id'], $this->session->data['guest']['shipping']['zone_id']);
} elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'shipping') {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'");
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif ($this->config->get('config_tax_default') == 'shipping') {
$this->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
if (isset($this->session->data['payment_address_id'])) {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['payment_address_id'] . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif (isset($this->session->data['guest']['payment'])) {
$this->setPaymentAddress($this->session->data['guest']['payment']['country_id'], $this->session->data['guest']['payment']['zone_id']);
} elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'payment') {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif ($this->config->get('config_tax_default') == 'payment') {
$this->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
$this->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:35,代码来源:tax.php
示例2: __construct
public function __construct()
{
$this->prefix = DB_PREFIX;
$this->sdsdb = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry = new Registry();
$registry->set('db', $this->sdsdb);
}
开发者ID:rinodung,项目名称:opencart-15x-flat-admin,代码行数:7,代码来源:revslider_db.class.php
示例3: __construct
/**
* User constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');
if (isset($this->session->data['user_id'])) {
$user_query = $this->db->query("SELECT * FROM user WHERE user_id = '" . (int) $this->session->data['user_id'] . "' AND status = '1'");
if ($user_query->num_rows) {
$this->user_id = $user_query->row['user_id'];
$this->username = $user_query->row['username'];
/* [webme] deny order deletions by specified user_group - begin */
$this->usergroup_id = $user_query->row['user_group_id'];
/* [webme] deny order deletions by specified user_group - end */
$this->db->query("\r\n\t\t\t\t\tUPDATE user \r\n\t\t\t\t\tSET ip = :ip\r\n\t\t\t\t\tWHERE user_id = :userId\r\n\t\t\t\t\t", [':ip' => $this->request->server['REMOTE_ADDR'], ':userId' => $this->session->data['user_id']], false, true);
$user_group_query = $this->db->query("SELECT permission FROM user_group WHERE user_group_id = '" . (int) $user_query->row['user_group_id'] . "'");
$permissions = unserialize($user_group_query->row['permission']);
if (is_array($permissions)) {
foreach ($permissions as $key => $value) {
$this->permission[$key] = $value;
}
}
} else {
$this->logout();
}
}
}
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:30,代码来源:user.php
示例4: store
/**
* Stores an Identifier Range.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
$this->category = strlen($this->range_begin);
$this->free = $this->range_end - $this->range_begin + 1;
$this->next = $this->range_begin;
}
return parent::store($updateNulls);
}
开发者ID:petkivim,项目名称:id-registry,代码行数:34,代码来源:abstractpublisheridentifierrange.php
示例5: __construct
/**
* Customer constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->config = $registry->get('config');
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');
if (isset($this->session->data['customer_id'])) {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND STATUS = '1'");
if ($customer_query->num_rows) {
$this->customer_id = $customer_query->row['customer_id'];
$this->firstname = $customer_query->row['firstname'];
$this->lastname = $customer_query->row['lastname'];
$this->email = $customer_query->row['email'];
$this->telephone = $customer_query->row['telephone'];
$this->fax = $customer_query->row['fax'];
$this->newsletter = $customer_query->row['newsletter'];
$this->customer_group_id = $customer_query->row['customer_group_id'];
$this->address_id = $customer_query->row['address_id'];
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '') . "', wishlist = '" . $this->db->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '') . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->customer_id . "'");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'");
if (!$query->num_rows) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_ip SET customer_id = '" . (int) $this->session->data['customer_id'] . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', date_added = NOW()");
}
} else {
$this->logout();
}
}
}
开发者ID:yariknechyporuk,项目名称:granika,代码行数:33,代码来源:customer.php
示例6: store
/**
* Stores a publisher.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
}
// Question 7: from array to comma separated string
if (is_array($this->question_7)) {
if (count($this->question_7) > 0) {
$this->question_7 = implode(',', $this->question_7);
} else {
$this->question_7 = '';
}
} else {
$this->question_7 = '';
}
return parent::store($updateNulls);
}
开发者ID:petkivim,项目名称:id-registry,代码行数:41,代码来源:publisher.php
示例7:
* @var Registry
*/
protected $_registry;
/**
* Cria uma variável para a view. Não pode ser sobrescrito
* @param string $var nome da variável
* @param mixed $value valor da variável
* @return void
开发者ID:nylmarcos,项目名称:estagio,代码行数:8,代码来源:Controller.php
示例8: loadModel
/**
* Load and register a model
*
* @static
* @access public
* @param Core\Registry $registry DPI container
* @param string $name Model name
* @return mixed
*/
public static function loadModel(Registry $registry, $name)
{
if (!isset($registry->{$name})) {
$class = '\\Model\\' . ucfirst($name);
$registry->{$name} = new $class($registry);
}
return $registry->shared($name);
}
开发者ID:cvalenti,项目名称:kanboard,代码行数:17,代码来源:Tool.php
示例9: __construct
/**
* Weight constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$weight_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int) $this->config->get('config_language_id') . "'");
foreach ($weight_class_query->rows as $result) {
$this->weights[$result['weight_class_id']] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
开发者ID:yariknechyporuk,项目名称:granika,代码行数:14,代码来源:weight.php
示例10: __construct
/**
* Length constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$length_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class mc LEFT JOIN " . DB_PREFIX . "length_class_description mcd ON (mc.length_class_id = mcd.length_class_id) WHERE mcd.language_id = '" . (int) $this->config->get('config_language_id') . "'");
foreach ($length_class_query->rows as $result) {
$this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
开发者ID:yariknechyporuk,项目名称:granika,代码行数:14,代码来源:length.php
示例11: testConstructor
public function testConstructor()
{
$testValues = $this->exampleValues();
$data = array('test1' => $testValues);
$reg = new Registry();
$this->assertNull($reg->get('test1', 'a'), 'empty registry should return null');
$reg = new Registry($data);
$this->assertEquals('A', $reg->get('test1', 'a'));
}
开发者ID:Anyqax,项目名称:Phabric,代码行数:9,代码来源:RegistryTest.php
示例12: store
/**
* Stores an identifier.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
return parent::store($updateNulls);
}
开发者ID:petkivim,项目名称:id-registry,代码行数:19,代码来源:identifier.php
示例13: testDelElement
public function testDelElement()
{
$reg = new Registry();
$element = array("numbers" => array(1, 2, 3, 4, 5), "letters" => array("a", "b", "c", "..."));
$reg->add($element);
$count = $reg->elementCount();
$this->assertEqual(1, $count);
$reg->delete($element);
$count = $reg->elementCount();
$this->assertEqual(0, $count);
}
开发者ID:andreums,项目名称:framework1.5,代码行数:11,代码来源:registryTest.php
示例14: addRegistry
/**
* @param $name
* @param array $params
* @throws \Jironett\Registers\DuplicateKeyException
*/
public function addRegistry($name, $params = [])
{
if (array_key_exists($name, $this->registers)) {
throw new DuplicateKeyException("The registry with name " . $name . " already exists");
}
$registry = new Registry();
$dataType = isset($params['dataType']) ? $params['dataType'] : null;
$class = isset($params['class']) ? $params['class'] : null;
$registry->setDataType($dataType, $class);
$this->registers[$name] = $registry;
}
开发者ID:jironett,项目名称:registers,代码行数:16,代码来源:RegistersManager.php
示例15: register_project
/**
* Registering Functions
*/
function register_project($include_id)
{
if (Item::delete_holder_by_include_id($include_id)) {
if (Item::register_holder("project", "Project", $include_id) == false) {
return false;
}
} else {
return false;
}
if (Folder::delete_type_by_include_id($include_id)) {
if (Folder::register_type("project_folder", "ProjectFolder", $include_id) == false) {
return false;
}
if (Folder::register_type("project_status_folder", "ProjectStatusFolder", $include_id) == false) {
return false;
}
} else {
return false;
}
if (ValueVar::delete_by_include_id($include_id)) {
if (ValueVar::register_type("project", "ProjectValueVar", false, $include_id) == false) {
return false;
}
} else {
return false;
}
if (!Registry::is_value("project_user_default_quota")) {
$registry = new Registry(null);
$registry->create("project_user_default_quota", $include_id, "1073741824");
}
if (!Registry::is_value("project_user_default_permission")) {
$registry = new Registry(null);
$registry->create("project_user_default_permission", $include_id, "15");
}
if (!Registry::is_value("project_leader_default_permission")) {
$registry = new Registry(null);
$registry->create("project_leader_default_permission", $include_id, "51");
}
if (!Registry::is_value("project_quality_manager_default_permission")) {
$registry = new Registry(null);
$registry->create("project_quality_manager_default_permission", $include_id, "1");
}
if (!Registry::is_value("project_group_default_permission")) {
$registry = new Registry(null);
$registry->create("project_group_default_permission", $include_id, "1");
}
if (!Registry::is_value("project_organisation_unit_default_permission")) {
$registry = new Registry(null);
$registry->create("project_organisation_unit_default_permission", $include_id, "1");
}
return true;
}
开发者ID:suxinde2009,项目名称:www,代码行数:55,代码来源:register_execute.php
示例16: __construct
public function __construct()
{
/*
* Sets $loginStatus result of the authorization check.
**/
$this->loginStatus = LoginStatus::getLoginStatus();
$this->registry = Registry::getInstance();
$request = $this->registry->getObject('request');
/*
* Contains $_POST
* */
$this->post_data = $request->getPostData();
}
开发者ID:GerashenkoVladimir,项目名称:students2.0,代码行数:13,代码来源:AbstractController.php
示例17: __construct
public function __construct()
{
$this->prefix = DB_PREFIX;
if (DB_DRIVER == 'mysql') {
$file = DIR_DATABASE . 'mysqli.php';
require_once $file;
$this->sdsdb = new DBMySQLi(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
} else {
$this->sdsdb = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
}
$registry = new Registry();
$registry->set('db', $this->sdsdb);
}
开发者ID:rinodung,项目名称:opencart-15x-flat-admin,代码行数:13,代码来源:revslider_db.class.php
示例18: updateBitlyAccessToken
public function updateBitlyAccessToken($access_token)
{
$activeSystem = $this->getActiveSystem();
$activeSystem->setBitlyAccessToken($access_token);
$this->em->persist($activeSystem);
$this->em->flush();
}
开发者ID:CampaignChain,项目名称:core,代码行数:7,代码来源:SystemService.php
示例19: updateCode
/**
* @param SymfonyStyle|null $io
*/
public function updateCode(SymfonyStyle $io = null)
{
$io->title('CampaignChain Data Update');
if (empty($this->versions)) {
$io->warning('No code updater Service found, maybe you didn\'t enable a bundle?');
return;
}
$io->comment('The following data versions will be updated');
$migratedVersions = array_map(function (DataUpdateVersion $version) {
return $version->getVersion();
}, $this->em->getRepository('CampaignChainUpdateBundle:DataUpdateVersion')->findAll());
$updated = false;
foreach ($this->versions as $version => $class) {
if (in_array($version, $migratedVersions)) {
continue;
}
$io->section('Version ' . $class->getVersion());
$io->listing($class->getDescription());
$io->text('Begin data update');
$result = $class->execute($io);
if ($result) {
$dbVersion = new DataUpdateVersion();
$dbVersion->setVersion($version);
$this->em->persist($dbVersion);
$this->em->flush();
$io->text('Data update finished');
}
$updated = true;
}
if (!$updated) {
$io->success('All data is up to date.');
} else {
$io->success('Every data version has been updated.');
}
}
开发者ID:campaignchain,项目名称:update,代码行数:38,代码来源:DataUpdateService.php
示例20: cleanDB
private function cleanDB()
{
$this->mainlogrepo->getLoggableListener()->setEnabled(false);
$this->doctrine->getConnection()->executeQuery('SET foreign_key_checks = 0');
$this->doctrine->getManager()->getFilters()->disable('softdeleteable');
foreach ($this->mainlogrepo->findAll() as $result) {
$this->doctrine->getManager()->remove($result);
}
$this->doctrine->getManager()->flush();
$fixturesClasses = array(get_class(new Comment()), get_class(new RelatedArticle()), get_class(new User()), get_class(new Article()));
foreach ($fixturesClasses as $fixturesClass) {
$manager = $this->doctrine->getManagerForClass($fixturesClass);
$repo = $manager->getRepository($fixturesClass);
foreach ($repo->findAll() as $result) {
$manager->remove($result);
}
$manager->flush();
$manager->clear();
}
//make twice to be sure ???
foreach ($fixturesClasses as $fixturesClass) {
$manager = $this->doctrine->getManagerForClass($fixturesClass);
$repo = $manager->getRepository($fixturesClass);
foreach ($repo->findAll() as $result) {
$manager->remove($result);
}
$manager->flush();
$manager->clear();
}
$this->doctrine->getManager()->getFilters()->enable('softdeleteable');
$this->doctrine->getConnection()->executeQuery('SET foreign_key_checks = 1');
$this->mainlogrepo->getLoggableListener()->setEnabled(true);
}
开发者ID:fcpauldiaz,项目名称:IbrowsLoggableBundle,代码行数:33,代码来源:AbstractTest.php
注:本文中的Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论