当前位置: 首页>>代码示例>>PHP>>正文


PHP Base::getInstance方法代码示例

本文整理汇总了PHP中Base::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Base::getInstance方法的具体用法?PHP Base::getInstance怎么用?PHP Base::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Base的用法示例。


在下文中一共展示了Base::getInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRefEntity

 public function getRefEntity()
 {
     if ($this->refEntity === null) {
         $this->refEntity = Base::getInstance($this->refEntityName);
     }
     return $this->refEntity;
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:7,代码来源:referencefield.php

示例2: getEntity

 /**
  * @static
  * @return Base
  */
 public static function getEntity()
 {
     $class = get_called_class();
     if (!isset(static::$entity[$class])) {
         static::$entity[$class] = Base::getInstance(get_called_class());
     }
     return static::$entity[$class];
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:12,代码来源:datamanager.php

示例3: __construct

 /**
  * @param Base|Query|string $source
  * @throws \Exception
  */
 public function __construct($source)
 {
     if ($source instanceof $this) {
         $this->init_entity = Base::getInstanceByQuery($source);
     } elseif ($source instanceof Base) {
         $this->init_entity = $source;
     } elseif (is_string($source)) {
         $this->init_entity = Base::getInstance($source);
     } else {
         throw new \Exception(sprintf('Unknown source type "%s" for new %s', gettype($source), __CLASS__));
     }
 }
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:16,代码来源:query.php

示例4: __construct

 /**
  * 初始化
  */
 public function __construct($configfile = null)
 {
     global $config;
     if (empty($config) && file_exists($configfile)) {
         require $configfile;
     }
     $this->config = $config;
     $this->Base = Base::getInstance();
     $this->Base->init($this->config);
     self::$app = $this->Base->app();
     $this->loadIniSet();
     $this->loadMemcache();
     $this->loadRedis();
     $this->loadSession();
     $this->loadCookie();
 }
开发者ID:xpmozong,项目名称:wavephp2,代码行数:19,代码来源:Wave.php

示例5: create

 public function create($post)
 {
     if (isset($post['obj']) && !empty($post['obj'])) {
         $obj_model = Base::getInstance($post['obj']);
         $obj = $obj_model->find($post['id']);
         if ($obj && $obj['published'] && isset($post['text']) && !empty($post['text'])) {
             $user_model = User::getInstance();
             $user = $user_model->checkUser();
             $isValid = true;
             $comment = $this->mapper;
             $comment->reset();
             if ($user) {
                 $comment->user_id = $user['id'];
             } else {
                 if (isset($post['name']) && !empty($post['name'])) {
                     $comment->name = $post['name'];
                 } else {
                     \helpers\Msg::error('comments.name.empty');
                     $isValid = false;
                 }
             }
             if ($isValid) {
                 $comment->obj_id = $obj['id'];
                 $comment->text = $post['text'];
                 $comment->ip = \Base::instance()->get('IP');
                 $comment->save();
                 \helpers\Msg::success('comments.created');
                 return true;
             }
         }
     }
     if (!$obj) {
         \helpers\Msg::error('comments.obj.empty');
     }
     if (empty($post['text'])) {
         \helpers\Msg::error('comments.text.empty');
     }
     return false;
 }
开发者ID:k-kalashnikov,项目名称:forKoda,代码行数:39,代码来源:comment.php

示例6: template

 /**
  * Stores template information. This is later used while rendering templates
  *
  * @param string $template
  * @param array  $data
  * @param string $options
  * @return Template
  */
 public function template($template, $data = array(), $options = '')
 {
     $this->template = array($template, $data, $options);
     $template = new Template(Base::getInstance());
     $this->loaderHooks($template, 'pre_template', $class = '', $method_name = '', $data = array());
     return $template;
 }
开发者ID:joynal,项目名称:eaglehorn_framework,代码行数:15,代码来源:Loader.php

示例7: getChainByDefinition

 public static function getChainByDefinition(Base $init_entity, $definition)
 {
     $chain = new QueryChain();
     $chain->addElement(new QueryChainElement($init_entity));
     $def_elements = explode('.', $definition);
     $def_elements_size = count($def_elements);
     $prev_entity = $init_entity;
     $i = 0;
     foreach ($def_elements as &$def_element) {
         $is_first_elem = $i == 0;
         $is_last_elem = ++$i == $def_elements_size;
         $not_found = false;
         // all elements should be a Reference field or Entity
         // normal (scalar) field can only be the last element
         if ($prev_entity->hasField($def_element)) {
             // field has been found at current entity
             $field = $prev_entity->getField($def_element);
             if ($field instanceof ReferenceField) {
                 $prev_entity = $field->getRefEntity();
             } elseif ($field instanceof ExpressionField) {
                 // expr can be in the middle too
             } elseif (!$is_last_elem) {
                 throw new \Exception(sprintf('Normal fields can be only the last in chain, `%s` %s is not the last.', $field->getName(), get_class($field)));
             }
             if ($is_last_elem && $field instanceof ExpressionField) {
                 // we should have own copy of build_from_chains to set join aliases there
                 $field = clone $field;
             }
             $chain->addElement(new QueryChainElement($field));
         } elseif ($prev_entity->hasUField($def_element)) {
             // extend chain with utm/uts entity
             $ufield = $prev_entity->getUField($def_element);
             $u_entity = null;
             if ($ufield->isMultiple()) {
                 // add utm entity  user.utm:source_object (1:N)
                 $utm_entity = Base::getInstance($prev_entity->getNamespace() . 'Utm' . $prev_entity->getName());
                 $u_entity = $utm_entity;
                 $chain->addElement(new QueryChainElement(array($utm_entity, $utm_entity->getField('SOURCE_OBJECT')), array('ufield' => $ufield)));
                 if ($ufield->getTypeId() == 'iblock_section' && substr($ufield->getName(), -3) == '_BY' && $prev_entity->hasUField(substr($ufield->getName(), 0, -3))) {
                     // connect next entity
                     $utm_fname = $ufield->getName();
                     $prev_entity = Base::getInstance('Bitrix\\Iblock\\Section');
                 } else {
                     $utm_fname = $ufield->getValueFieldName();
                 }
                 $chain->addElement(new QueryChainElement($utm_entity->getField($utm_fname), array('ufield' => $ufield)));
             } else {
                 // uts table - single value
                 // add uts entity user.uts (1:1)
                 $uts_entity = Base::getInstance($prev_entity->getNamespace() . 'Uts' . $prev_entity->getName());
                 $u_entity = $uts_entity;
                 $chain->addElement(new QueryChainElement($prev_entity->getField('UTS_OBJECT')));
                 // add `value` field
                 $chain->addElement(new QueryChainElement($uts_entity->getField($def_element)));
             }
         } elseif (Base::isExists($def_element) && Base::getInstance($def_element)->getReferencesCountTo($prev_entity->getName()) == 1) {
             // def_element is another entity with only 1 reference to current entity
             // need to identify Reference field
             $ref_entity = Base::getInstance($def_element);
             $field = end($ref_entity->getReferencesTo($prev_entity->getName()));
             $prev_entity = $ref_entity;
             $chain->addElement(new QueryChainElement(array($ref_entity, $field)));
         } elseif (($pos_wh = strpos($def_element, ':')) > 0) {
             $ref_entity_name = substr($def_element, 0, $pos_wh);
             if (strpos($ref_entity_name, '\\') === false) {
                 // if reference has no namespace, then it'is in the namespace of previous entity
                 $ref_entity_name = $prev_entity->getNamespace() . $ref_entity_name;
             }
             if (Base::isExists($ref_entity_name) && Base::getInstance($ref_entity_name)->hasField($ref_field_name = substr($def_element, $pos_wh + 1)) && Base::getInstance($ref_entity_name)->getField($ref_field_name)->getRefEntity()->getName() == $prev_entity->getName()) {
                 // chain element is another entity with >1 references to current entity
                 // def like NewsArticle:AUTHOR, NewsArticle:LAST_COMMENTER
                 // NewsArticle - entity, AUTHOR and LAST_COMMENTER - Reference fields
                 $chain->addElement(new QueryChainElement(array(Base::getInstance($ref_entity_name), Base::getInstance($ref_entity_name)->getField($ref_field_name))));
                 $prev_entity = Base::getInstance($ref_entity_name);
             } else {
                 $not_found = true;
             }
         } elseif ($def_element == '*' && $is_last_elem) {
             continue;
         } else {
             // unknown chain
             $not_found = true;
         }
         if ($not_found) {
             throw new \Exception(sprintf('Unknown field definition `%s` (%s) for %s Entity.', $def_element, $definition, $prev_entity->getName()), 100);
         }
     }
     return $chain;
 }
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:89,代码来源:querychain.php

示例8: postInitialize

 public function postInitialize()
 {
     // базовые свойства
     $classPath = explode('\\', $this->className);
     $this->name = substr(end($classPath), 0, -6);
     // default db table name
     if (is_null($this->dbTableName)) {
         $_classPath = array_slice($classPath, 0, -1);
         $this->dbTableName = 'b_';
         foreach ($_classPath as $i => $_pathElem) {
             if ($i == 0 && $_pathElem == 'Bitrix') {
                 // skip bitrix namespace
                 continue;
             }
             if ($i == 1 && $_pathElem == 'Main') {
                 // also skip Main module
                 continue;
             }
             $this->dbTableName .= strtolower($_pathElem) . '_';
         }
         // add class
         if ($this->name !== end($_classPath)) {
             $this->dbTableName .= Base::camel2snake($this->name);
         } else {
             $this->dbTableName = substr($this->dbTableName, 0, -1);
         }
     }
     $this->primary = array();
     $this->references = array();
     if (empty($this->filePath)) {
         throw new \Exception(sprintf('Parameter `filePath` required for `%s` Entity', $this->name));
     }
     // инициализация атрибутов
     foreach ($this->fieldsMap as $fieldName => &$fieldInfo) {
         $field = $this->initializeField($fieldName, $fieldInfo);
         if ($field instanceof ReferenceField) {
             // references cache
             $this->references[strtolower($fieldInfo['data_type'])][] = $field;
         }
         $this->fields[$fieldName] = $field;
         if ($field instanceof ScalarField && $field->isPrimary()) {
             $this->primary[] = $fieldName;
         }
         // add reference field for UField iblock_section
         if ($field instanceof UField && $field->getTypeId() == 'iblock_section') {
             $refFieldName = $field->GetName() . '_BY';
             if ($field->isMultiple()) {
                 $localFieldName = $field->getValueFieldName();
             } else {
                 $localFieldName = $field->GetName();
             }
             $newFieldInfo = array('data_type' => 'Bitrix\\Iblock\\Section', 'reference' => array($localFieldName, 'ID'));
             $refEntity = Base::getInstance($newFieldInfo['data_type']);
             $newRefField = new ReferenceField($refFieldName, $this, $refEntity, $newFieldInfo['reference'][0], $newFieldInfo['reference'][1]);
             $this->fields[$refFieldName] = $newRefField;
         }
     }
     if (empty($this->primary)) {
         throw new \Exception(sprintf('Primary not found for %s Entity', $this->name));
     }
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:61,代码来源:base.php

示例9:

/**
 * @return Dispatcher
 */
function &getInstance()
{
    return Base::getInstance();
}
开发者ID:nowk,项目名称:baseapp-framework,代码行数:7,代码来源:baseapp.php

示例10: _createInstance

 /**
  * Creates an instance of the component which is being loaded.
  *
  * @param $namespace
  * @param $class
  * @param $params
  * @param $method_name
  * @param $data
  * @return object
  */
 private function _createInstance($namespace, $class, $params, $method_name, $data)
 {
     $ns_class = $namespace . $class;
     //create a reflection class so that we can pass parameters to the constructor
     $ref_class = new \ReflectionClass($ns_class);
     if (is_array($params) && sizeof($params) > 0) {
         $instance = $ref_class->newInstanceArgs($params);
     } else {
         $instance = new $ns_class();
     }
     $this->logger->info("{$namespace} object created for {$class} class");
     //call the method along with parameters, if they exist !
     if (method_exists($instance, $method_name)) {
         if (is_callable(array($instance, $method_name))) {
             $last_hook = $this->loading[count($this->loading) - 1];
             $this->loaderHooks($instance, "pre_{$last_hook}", $class, $method_name, $data);
             call_user_func_array(array($instance, $method_name), $data);
             $this->loaderHooks($instance, "post_{$last_hook}", $class, $method_name, $data);
         }
     } elseif (is_object($instance)) {
         $last_hook = $this->loading[count($this->loading) - 1];
         $this->loaderHooks($instance, "pre_{$last_hook}", $class, $method_name, $data);
     } else {
         if (strpos($namespace, 'controller') > 0) {
             header("HTTP/1.0 404 Not Found");
             Base::getInstance()->hook('404', array('file' => $ref_class, 'controller' => $class, 'method' => $method_name, 'message' => '404'));
             die;
         }
     }
     $this->clearCurrentLoader();
     return $instance;
 }
开发者ID:ajaxtown,项目名称:eaglehorn_framework,代码行数:42,代码来源:Loader.php

示例11: define

<?php

/**
* Bootstrap
*	File: index.php
*-----------------------------------------------------------------------------*/
/**
* Path to Application directory
*/
define('APPPATH', './application/');
/**
* Path to System directory (Base files)
*/
define('SYSTEMPATH', './system/');
/**
* "Bases Loaded!"
*/
require_once SYSTEMPATH . 'init.php';
//base object instance
$base = Base::getInstance();
开发者ID:neosyler,项目名称:Base,代码行数:20,代码来源:index.php


注:本文中的Base::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。