本文整理汇总了PHP中get_real_class函数的典型用法代码示例。如果您正苦于以下问题:PHP get_real_class函数的具体用法?PHP get_real_class怎么用?PHP get_real_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_real_class函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after_update
public function after_update(\Orm\Model $obj)
{
if (!class_exists($this->model_to)) {
throw new \FuelException('Class not found : ' . $this->model_to);
}
$this->model_to = get_real_class($this->model_to);
if ($this->is_check_updated_at) {
$check_property = $this->is_check_updated_at['property'];
if ($obj->updated_at != $obj->{$check_property}) {
return;
}
}
$cache = $this->get_model_obj($obj);
foreach ($this->properties as $key => $value) {
$property_from = $value;
$property_to = $value;
if (is_string($key) && !empty($key)) {
$property_to = $key;
}
$cache->{$property_to} = $obj->{$property_from};
}
foreach ($this->special_properties as $property => $values) {
$value = isset($values['value']) ? $values['value'] : null;
$cache->{$property} = $value;
}
$cache->save();
}
示例2: __construct
public function __construct($from, $name, array $config)
{
$this->name = $name;
$this->model_from = $from;
$this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
$this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from;
$this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to;
$this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array();
if (!empty($config['table_through'])) {
$this->table_through = $config['table_through'];
} else {
$table_name = array($this->model_from, $this->model_to);
natcasesort($table_name);
$table_name = array_merge($table_name);
$this->table_through = \Inflector::tableize($table_name[0]) . '_' . \Inflector::tableize($table_name[1]);
}
$this->key_through_from = !empty($config['key_through_from']) ? (array) $config['key_through_from'] : (array) \Inflector::foreign_key($this->model_from);
$this->key_through_to = !empty($config['key_through_to']) ? (array) $config['key_through_to'] : (array) \Inflector::foreign_key($this->model_to);
$this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
$this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete;
if (!class_exists($this->model_to)) {
throw new \FuelException('Related model not found by Many_Many relation "' . $this->name . '": ' . $this->model_to);
}
$this->model_to = get_real_class($this->model_to);
}
示例3: toObj
public function toObj()
{
$obj = array('status' => 'error', 'errorType' => get_real_class($this), 'message' => $this->message);
if ($this->data != null) {
$obj['data'] = $this->data;
}
return $obj;
}
示例4: after_insert
public function after_insert(\Orm\Model $obj)
{
if (!class_exists($this->model_to)) {
throw new \FuelException('Class not found : ' . $this->model_to);
}
$this->model_to = get_real_class($this->model_to);
$this->save_single_record($obj, $this->properties, $this->special_properties);
if ($this->additional_records) {
$this->save_multiple_records($obj, $this->additional_records);
}
}
示例5: add_model
public function add_model($model)
{
if (is_string($model)) {
$this->model = get_real_class($model);
}
if (get_parent_class($this->model) == 'Orm\\Model') {
$this->grab_fields($this->model);
} else {
throw new \FuelException($model . ' does not appear to be of the correct type. Only model of type Orm\\Model is supported at the moment.');
}
}
示例6: __construct
public function __construct($from, $name, array $config)
{
$this->name = $name;
$this->model_from = $from;
$this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
$this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : (array) \Inflector::foreign_key($this->model_to);
$this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to;
$this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array();
$this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
$this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete;
if (!class_exists($this->model_to)) {
throw new \FuelException('Related model not found by Belongs_To relation "' . $this->name . '": ' . $this->model_to);
}
$this->model_to = get_real_class($this->model_to);
}
示例7: after_insert
public function after_insert(\Orm\Model $obj)
{
if (!class_exists($this->model_to)) {
throw new \FuelException('Class not found : ' . $this->model_to);
}
$model_to = get_real_class($this->model_to);
$cache = new $this->model_to();
foreach ($this->properties as $key => $value) {
$property_from = $value;
$property_to = $value;
if (is_string($key) && !empty($key)) {
$property_to = $key;
}
$cache->{$property_to} = $obj->{$property_from};
}
foreach ($this->special_properties as $property => $values) {
$value = isset($values['value']) ? $values['value'] : null;
$cache->{$property} = $value;
}
$cache->save();
}
示例8: get_datetime_from_relational_model
private function get_datetime_from_relational_model($obj)
{
if (!($relational_model = $this->get_relational_model($obj, $this->_model_from))) {
return false;
}
if (!class_exists($relational_model)) {
return false;
}
$model_from = get_real_class($this->relational_model);
$query = $model_from::query();
foreach ($this->_conditions as $property_to => $froms) {
foreach ($froms as $value_from => $type) {
$value = \Site_Model::get_value_for_observer_setting($obj, $value_from, $type);
$query->where($property_to, $value);
}
}
$model = $query->get_one();
if (empty($model->{$this->_copy_property})) {
return false;
}
return $model->{$this->_copy_property};
}
示例9: __construct
public function __construct($model, $columns = null)
{
if ($model instanceof \Petro\Controller_App) {
$this->petro_app = $model;
$model = $this->petro_app->model;
}
if (!class_exists($model)) {
throw new \FuelException('Petro_Grid : The given model "' . $model . '" does not exist');
}
$this->model = get_real_class($model);
\Config::load('petro', true);
\Lang::load('petro');
static::$template = \Config::get('petro.template');
if (isset($columns)) {
$this->set_columns($columns);
} else {
$this->grab_columns();
}
if (empty($this->order_by) and count($this->columns) > 0) {
$col_name = $this->columns[0]['name'];
$this->set_order_by(implode('_', array($col_name, 'asc')));
}
}
示例10: execute
/**
* Execute the controller.
* @param $action String Action to execute.
* @return Response the response to send.
*/
public function execute($action, $args = [])
{
$this->action = $action;
// On récupère le nom de la classe
$myClassName = get_real_class($this);
if ($i = strpos($myClassName, 'Controller')) {
$myClassName = substr($myClassName, 0, $i);
}
// Par défaut, le nom de la view est le même
// que le nom de l'action et dans le répertoire
// dont le nom correspond à celui du controller.
$this->view = $myClassName . DS . $action;
/**
* On ne peut executer que les fonctions écrites dans les sous classes
* du controller. Par exemple beforeAction n'est pas une action
*/
if (!method_exists($this, $action) && !in_array($action, get_class_methods('MerciKI\\Body\\Controller'))) {
throw new ActionNotExist('Action "' . $action . '" inexistante !');
}
$this->beforeAction();
// No redirect is required.
if ($this->redirect != null) {
return new RedirectResponse($this->redirect);
}
$view = call_user_func_array(array($this, $action), $args);
// No redirect is required.
if ($this->redirect != null) {
return new RedirectResponse($this->redirect);
}
if (is_array($view) || $view instanceof \JsonSerializable) {
return new JsonResponse($view);
}
return new HtmlResponse($view);
}
示例11: _render_filters
public static function _render_filters($filters)
{
$param = Input::param('q', array());
$out = '';
foreach ($filters as $name => $prop) {
if (isset($prop['label'])) {
$label = $prop['label'];
} else {
$label = \Lang::get($name) ?: \Inflector::humanize($name);
}
if (isset($prop['collection']) and is_string($prop['collection'])) {
$model = get_real_class($prop['collection']);
$arr = $model::property($name, array());
$prop['collection'] = isset($arr['form']['options']) ? $arr['form']['options'] : array();
}
$out .= '<div class="filter-' . $prop['type'] . '">' . PHP_EOL;
switch (\Str::lower($prop['type'])) {
case 'date':
$out .= static::render_filter_date($name, $label, $param);
break;
case 'date_range':
$out .= static::render_filter_date_range($name, $label, $param);
break;
case 'numeric':
$out .= static::render_filter_numeric($name, $label, $param);
break;
case 'select':
$out .= static::render_filter_select($name, $label, $prop['collection'], $param);
break;
case 'checkbox':
$out .= static::render_filter_checkbox($name, $label, $prop['collection'], $param);
break;
case 'radio':
$out .= static::render_filter_radio($name, $label, $prop['collection'], $param);
break;
default:
// handle as string
$out .= static::render_filter_string($name, $label, $param);
}
$out .= '</div>' . PHP_EOL;
}
return $out;
}
示例12: processApiKeys
public function processApiKeys()
{
while (true) {
$eveApis = ECP\EveApiQuery::create()->filterByStatus('not processed yet')->_or()->condition('c1', 'EveApi.lastComputed < ?', time() - 24 * 60 * 60)->condition('c2', 'EveApi.status = ?', 'success')->where(array('c1', 'c2'), 'and')->find();
$eveApis->populateRelation('EveCharacter');
foreach ($eveApis as $eveApi) {
$characters = array();
$eveApi->setStatus('');
try {
$characters = $this->getCharacters($eveApi);
$eveApi->setStatus('success');
} catch (\Pheal\Exceptions\PhealException $e) {
$eveApi->setStatus('An exception occured. ' . get_real_class($e) . ': ' . $e->getMessage());
}
$eveApi->setLastComputed(time());
$connection = $this->getPropelConnection();
try {
$connection->beginTransaction();
foreach ($characters as $character) {
$eveCharacter = $this->getSubentity2($eveApi, 'EveCharacter', $character, 'characterID', 'CharId');
$eveCharacter->setCharName($character->name);
$eveCharacter->setCharId($character->characterID);
$eveCharacter->setCorpName($this->tryGetProperty($character, 'corporationName'));
$eveCharacter->setCorpId($this->tryGetProperty($character, 'corporationID'));
$eveCharacter->setAllyName($this->tryGetProperty($character, 'allianceName'));
$eveCharacter->setAllyId($this->tryGetProperty($character, 'allianceID'));
$this->prepareSubentitySave3($connection, $eveApi, 'EveCharacter', $eveCharacter);
}
$this->cleanupOldEnties($eveApi, 'EveCharacter', $characters, 'characterID', 'CharId');
$eveApi->save($connection);
$connection->commit();
} catch (Exception $e) {
$connection->rollBack();
throw $e;
}
}
sleep(30);
}
}
示例13: get4relation
public static function get4relation($model_to, array $conditions, \Orm\Model $model_obj_from)
{
if (!class_exists($model_to)) {
throw new \FuelException('Class not found : ' . $model_to);
}
$model_to = get_real_class($model_to);
$query = $model_to::query();
foreach ($conditions as $property_to => $froms) {
foreach ($froms as $value_from => $type) {
$query->where($property_to, \Site_Model::get_value_for_observer_setting($model_obj_from, $value_from, $type));
}
}
return $query->get();
}