本文整理汇总了PHP中factory::get方法的典型用法代码示例。如果您正苦于以下问题:PHP factory::get方法的具体用法?PHP factory::get怎么用?PHP factory::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factory
的用法示例。
在下文中一共展示了factory::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructing cache object
*
* @param string $cache_link
* @param string $class
*/
public function __construct($cache_link = null, $class = null)
{
// if we need to use default link from application
if (empty($cache_link)) {
$cache_link = application::get(['flag', 'global', 'cache', 'default_cache_link']);
if (empty($cache_link)) {
throw new Exception('You must specify cache link and/or class!');
}
}
// get object from factory
$temp = factory::get(['cache', $cache_link]);
// if we have class
if (!empty($class) && !empty($cache_link)) {
// replaces in case we have it as submodule
$class = str_replace('.', '_', trim($class));
// if we are replacing database connection with the same link we
// need to manually close connection
if (!empty($temp['object']) && $temp['class'] != $class) {
$object = $temp['object'];
$object->close();
unset($this->object);
}
$this->object = new $class($cache_link);
// putting every thing into factory
factory::set(['cache', $cache_link], ['object' => $this->object, 'class' => $class]);
} else {
if (!empty($temp['object'])) {
$this->object = $temp['object'];
} else {
throw new Exception('You must specify cache link and/or class!');
}
}
}
示例2: __construct
/**
* Constructing crypt object
*
* @param string $db_link
* @param string $class
*/
public function __construct($crypt_link = null, $class = null, $options = [])
{
// if we need to use default link from application
if ($crypt_link == null) {
$crypt_link = application::get(['flag', 'global', 'crypt', 'default_crypt_link']);
if (empty($crypt_link)) {
throw new Exception('You must specify crypt link!');
}
}
// get object from factory
$temp = factory::get(['crypt', $crypt_link]);
// if we have class
if (!empty($class) && !empty($crypt_link)) {
// replaces in case we have it as submodule
$class = str_replace('.', '_', trim($class));
// creating new class
unset($this->object);
$this->object = new $class($crypt_link, $options);
factory::set(['crypt', $crypt_link], ['object' => $this->object, 'class' => $class]);
} else {
if (!empty($temp['object'])) {
$this->object = $temp['object'];
} else {
throw new Exception('You must specify crypt link and/or class!');
}
}
}
示例3: getInstance
/**
* Get the unique cache instance
*
* @param array $cfg Config for the cache instance
* @return cache_abstract The instance
*/
public static function getInstance(array $cfg = array())
{
if (!self::$cfg) {
self::$cfg = new config(factory::loadCfg(__CLASS__));
}
return factory::get('cache_' . self::$cfg->use, $cfg);
}
示例4: getInstance
/**
* Get the response object according to the requested out
*
* @return response_abstract
*/
public static function getInstance() {
if (self::$proxy)
return self::$proxy;
if (!self::$inst) {
self::$inst = factory::get('response_'.request::getResponseName());
self::$inst->setContentType(request::get('out'));
}
return self::$inst;
}
示例5: afterInit
protected function afterInit()
{
parent::afterInit();
$this->form = factory::get('form_db', array_merge($this->cfg->formOpts, array('table' => $this->cfg->table)));
$this->replaceName = str_replace('[]', '', $this->name) . '_fields[' . $this->cfg->replaceKey . '][[name]]';
foreach ($this->cfg->fields as $f) {
$f['name'] = str_replace('[name]', $f['name'], $this->replaceName);
$this->form->addFromField($f);
}
$this->prepareValuesForValid();
$this->valid->getCfg()->setRef('value', $this->valuesForValid);
}
示例6: afterInit
/**
* Set up the valid object
*/
protected function afterInit()
{
if (!$this->label && !is_bool($this->label)) {
$this->label = ucfirst($this->name);
}
if (!is_object($this->cfg->value)) {
$this->cfg->value = utils::htmlOut($this->cfg->value);
}
$this->id = $this->makeId($this->name);
$val =& $this->cfg->getRef('value');
$this->valid = factory::get($this->cfg->validType, array('value' => &$val, 'label' => $this->label, 'validEltArray' => $this->cfg->getInArray('valid', 'validEltArray')));
$this->cfg->delInArray('valid', 'validEltArray');
$this->initValid();
}
示例7: initForm
/**
* Init the filter form
*/
protected function initForm()
{
$this->form = factory::get('form_db', array_merge($this->cfg->formOpts, array('filter' => true, 'table' => $this->table, 'sectionName' => $this->cfg->formName, 'action' => request::uriDef(array('paramA' => array_merge(array_diff_key(request::get('paramA'), $this->cfg->actionPrmClear), $this->cfg->actionPrmForce))))));
$this->form->setSubmitText($this->cfg->submitText);
$this->form->setSubmitplus('<a href="' . $this->clearLink() . '">' . $this->cfg->clearText . '</a>');
if (!empty($this->cfg->fields)) {
foreach ($this->cfg->fields as $field) {
if ($f = $this->table->getField($field)) {
$f['label'] = $this->getLabel($f['name']);
$f['link'] = $this->table->getLinked($f['name']);
$this->form->addFromFieldFilter($f);
} else {
if ($r = $this->table->getRelated($field)) {
$r['label'] = $this->getLabel($r['table']);
$r['name'] = $r['tableLink'];
$this->form->addFromRelatedFilter($r);
} else {
if ($this->table->hasI18n() && db::isI18nName($field) && ($f = $this->table->getI18nTable()->getField(db::unI18nName($field)))) {
$name = db::unI18nName($field);
$f['name'] = $field;
$f['label'] = $this->getLabel($field);
$f['link'] = $this->table->getI18nTable()->getLinked($name);
$this->form->addFromFieldFilter($f);
}
}
}
}
} else {
// All fields
foreach ($this->table->getField() as $f) {
$f['label'] = $this->getLabel($f['name']);
$f['link'] = $this->table->getLinked($f['name']);
$this->form->addFromFieldFilter($f);
}
foreach ($this->table->getRelated() as $t => $r) {
$r['name'] = $r['tableLink'];
$r['label'] = $this->getLabel($r['table']);
$this->form->addFromRelated($r);
}
}
$this->fillValues();
}
示例8: __construct
/**
* Constructing database object
*
* @param string $db_link
* @param string $class
*/
public function __construct($db_link = null, $class = null)
{
// if we need to use default link from application
if (empty($db_link)) {
$db_link = application::get(['flag', 'global', 'db', 'default_db_link']);
if (empty($db_link)) {
throw new Exception('You must specify database link and/or class!');
}
}
// get object from factory
$temp = factory::get(['db', $db_link]);
// if we have class
if (!empty($class) && !empty($db_link)) {
// replaces in case we have it as submodule
$class = str_replace('.', '_', trim($class));
// if we are replacing database connection with the same link we
// need to manually close database connection
if (!empty($temp['object']) && $temp['class'] != $class) {
$object = $temp['object'];
$object->close();
unset($this->object);
}
// creating new class
$this->object = new $class($db_link);
// determining ddl class & object
$ddl_class = str_replace('_base_abc123', '_ddl', $class . '_abc123');
$ddl_object = new $ddl_class();
// backend
$this->backend = str_replace(['numbers_backend_db_', '_base'], '', $class);
// putting every thing into factory
factory::set(['db', $db_link], ['object' => $this->object, 'class' => $class, 'backend' => $this->backend, 'ddl_class' => $ddl_class, 'ddl_object' => $ddl_object]);
} else {
if (!empty($temp['object'])) {
$this->object =& $temp['object'];
$this->backend = $temp['backend'];
} else {
throw new Exception('You must specify database link and/or class!');
}
}
}
示例9: beforeInit
protected function beforeInit()
{
$required = array_key_exists('required', $this->cfg->valid) && $this->cfg->getInArray('valid', 'required');
$htVars = http_vars::getInstance();
$this->keep = $htVars->getVar($this->name . 'NyroKeep');
if ($this->keep) {
$this->cfg->value = $this->keep;
}
$prm = array_merge($this->cfg->fileUploadedPrm, array('name' => $this->cfg->name, 'current' => $this->cfg->value, 'helper' => $this->cfg->helper, 'helperPrm' => $this->cfg->helperPrm, 'required' => $required));
if ($this->cfg->dir) {
$prm['dir'] = $this->cfg->dir;
}
if ($this->cfg->subdir) {
$prm['subdir'] = $this->cfg->subdir;
}
$this->cfg->value = factory::get('form_fileUploaded', $prm);
if ($this->cfg->autoDeleteOnGet && !$this->cfg->value->isSaved(true) && $htVars->getVar($this->name . 'NyroDel')) {
$this->cfg->value->delete();
$this->deleted = true;
}
$this->cfg->valid = array_merge($this->cfg->valid, array('callback' => array($this->cfg->value, 'isValid')));
}
示例10: multipleDelete
/**
* Multiple delete action
*
* @param array $ids
*/
protected function multipleDelete(array $ids) {
$this->table->delete($this->table->getWhere(array(
'clauses'=>factory::get('db_whereClause', array(
'name'=>$this->table->getRawName().'.'.$this->table->getIdent(),
'in'=>$ids
))
)));
}
示例11: exec
/**
* Every called action must pass by this function
*
* @param null|string $prm Actopn Parameters
* @throws nException if wrong parameter or other errors
*/
final public function exec(array $prm=array()) {
$this->prmExec = array_merge(array(
'module'=>$this->getName(),
'action'=>'index',
'param'=>'',
'paramA'=>null,
'prefix'=>null),
$prm);
$this->prmExec['prefix'] = null;
if (array_key_exists(NYROENV, $this->cfg->basicPrefixExec) &&
in_array($this->prmExec['action'], $this->cfg->getInArray('basicPrefixExec', NYROENV)))
$this->prmExec['prefix'] = ucfirst(NYROENV);
else if ($this->cfg->prefixExec && !in_array($this->prmExec['action'], $this->cfg->noPrefixExec))
$this->prmExec['prefix'] = $this->cfg->prefixExec;
$this->beforeExec($prm);
if (!$this->cfg->render)
security::getInstance()->check($this->prmExec);
$fctName = ($this->cfg->render? 'render' : 'exec').$this->prmExec['prefix'].ucfirst($this->prmExec['action']);
if (!method_exists($this, $fctName))
response::getInstance()->error();
$this->setViewAction($this->prmExec['action']);
$param = is_array($this->prmExec['paramA'])? $this->prmExec['paramA'] : request::parseParam($this->prmExec['param']);
$tags = $this->cfg->cacheTags;
$search = array('/', '<', '>');
$replace = array('', '', '');
if (is_array($this->prmExec['paramA']))
foreach($this->prmExec['paramA'] as $k=>$v) {
if (is_object($v)) {
if (is_callable(array($v, '__toString')))
$tags[] = $k.'='.$v;
else
$tags[] = $k.'='.get_class($v);
} elseif (!is_numeric($k))
$tags[] = $k.'='.str_replace($search, $replace, $v);
else
$tags[] = str_replace($search, $replace, $v);
}
$paramTpl = array();
foreach($param as $k=>$v) {
if (is_object($v)) {
if (is_callable(array($v, '__toString')))
$paramTpl[] = $k.'='.$v;
else
$paramTpl[] = $k.'='.get_class($v);
} else
$paramTpl[] = $k.':'.$v;
}
$conf = array(
'layout'=>$this->cfg->layout,
'module'=>$this->getName(),
'action'=>$this->cfg->viewAction,
'param'=>implode(',', $paramTpl),
'cache'=>array_merge(array(
'enabled'=>$this->isCacheEnabled(),
'serialize'=>false,
'tags'=>$tags,
'request'=>array('uri'=>false, 'meth'=>array())
), $this->cfg->cache)
);
$this->tpl = factory::get('tpl', array_merge_recursive($conf, $this->cfg->tplPrm));
$this->tpl->getCfg()->layout = $this->cfg->layout;
$this->tpl->getCfg()->module = $this->getName();
$this->tpl->getCfg()->action = $this->cfg->viewAction;
$this->tpl->getCfg()->default = $this->cfg->viewAction;
$this->prmExec['callbackPrm'] = array(
'fctName'=>$fctName,
'fctNameParam'=>$param,
'prm'=>$prm
);
$this->middleExec($prm);
}
示例12: getForm
protected function getForm() {
$form = factory::get('form', array_merge(array(
'sectionName'=>$this->myCfg['formName'],
'action'=>$this->uri
), $this->myCfg['formCfg']));
$form->add('file', array(
'name'=>'file',
'subdir'=>$this->dir,
'helper'=>$this->myCfg['helper'][$this->type]['name'],
'helperPrm'=>$this->myCfg['helper'][$this->type]['prm'],
));
$form->get('file')->plupload(array_merge($this->myCfg['plupload'][$this->type], array(
'multipart_params'=>array(
'type'=>$this->type,
'config'=>$this->config,
),
'onAllComplete'=>'function() {window.location.href = "'.$this->uri.'";}'
)));
return $form;
}
示例13: getInstance
/**
* Get the unique session instance
*
* @param array $cfg Configuration array for the session
* @return session_abstract The instance
*/
public static function getInstance(array $cfg = array()) {
self::initCfg();
return factory::get('session_'.self::$cfg->use, $cfg);
}
示例14: logout
public function logout($prm = null) {
if ($this->isLogged()) {
$this->session->del('cryptic');
$this->logged = false;
// Clear the cookie
$cook = factory::get('http_cookie', $this->cfg->cookie);
$cook->del();
}
$this->hook('logout');
return $this->logged == false;
}
示例15: afterInit
protected function afterInit() {
$t = factory::get('tpl');
$this->module = factory::getModule(request::get('module'));
nReflection::callMethod($this->module, request::get('action').'Action', request::get('param'));
}