_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q264200
|
Roles.assignToUser
|
test
|
public function assignToUser(User $user)
{
if ($this->belongsToUser($user)) {
|
php
|
{
"resource": ""
}
|
q264201
|
HttpCodes.isSuccessful
|
test
|
public static function isSuccessful($code)
{
switch($code) {
case self::HTTP_OK:
case self::HTTP_CREATED:
case self::HTTP_ACCEPTED:
case self::HTTP_NONAUTHORITATIVE_INFORMATION:
case self::HTTP_NO_CONTENT:
case
|
php
|
{
"resource": ""
}
|
q264202
|
PageIdentifiers.getCurrentTemplateName
|
test
|
public function getCurrentTemplateName()
{
if (!($currentTemplate = basename((string) Registry::getRequest()->getRequestEscapedParameter('tpl')))) {
// in case template was not defined in request
$currentTemplate =
|
php
|
{
"resource": ""
}
|
q264203
|
Role.form
|
test
|
public function form(Eloquent $model = null)
{
$this->breadcrumb->onRoleCreateOREdi
|
php
|
{
"resource": ""
}
|
q264204
|
Role.edit
|
test
|
public function edit(Eloquent $eloquent, array $available = array())
{
publish('acl', ['js/control.js']);
$id = $eloquent->id;
$instances = $this->container->make('antares.acl')->all();
$form = $this->form($eloquent);
$modules = $this->adapter->modules();
$collection = $this->container->make('antares.memory')->make('collector')->all();
|
php
|
{
"resource": ""
}
|
q264205
|
User.create
|
test
|
public function create(UserCreatorListener $listener)
{
$eloquent = Foundation::make('antares.user');
$form
|
php
|
{
"resource": ""
}
|
q264206
|
User.edit
|
test
|
public function edit(UserUpdaterListener $listener, $id)
{
$eloquent = Foundation::make('antares.user');
if ($id !== auth()->user()->id) {
$eloquent = $eloquent->where('id', $id)->withoutGlobalScopes()->whereHas('roles', function ($query) {
$role = user()->roles->first();
$roles = $role->getChilds();
$roles[] = $role->id;
$query->whereIn('role_id', array_values($roles));
|
php
|
{
"resource": ""
}
|
q264207
|
User.store
|
test
|
public function store(UserCreatorListener $listener, array $input)
{
$user = Foundation::make('antares.user');
$user->status = Eloquent::UNVERIFIED;
$user->password = $input['password'];
$form = $this->presenter->form($user);
if (!$form->isValid()) {
return $listener->createUserFailedValidation($form->getMessageBag());
}
|
php
|
{
"resource": ""
}
|
q264208
|
User.update
|
test
|
public function update(UserUpdaterListener $listener, $id, array $input)
{
if ((string) $id !== $input['id']) {
return $listener->abortWhenUserMismatched();
}
$user = Foundation::make('antares.user')->withoutGlobalScopes()->findOrFail($id);
!empty($input['password']) && $user->password = $input['password'];
try {
$this->saving($user,
|
php
|
{
"resource": ""
}
|
q264209
|
User.destroy
|
test
|
public function destroy(UserRemoverListener $listener, $id)
{
if (user()->id == $id) {
return $listener->userDeletionFailed(['error' => trans('antares/acl::messages.unable_to_delete_self')]);
}
$user = Foundation::make('antares.user');
if (app('antares.acl')->make('antares/acl')->can('login-as-user')) {
$user = $user->withoutGlobalScopes();
}
$user = $user->findOrFail($id);
if ((string) $user->id === (string) Auth::user()->id) {
return $listener->selfDeletionFailed();
}
try {
|
php
|
{
"resource": ""
}
|
q264210
|
User.saving
|
test
|
protected function saving(Eloquent $user, $input = [], $type = 'create')
{
$beforeEvent = ($type === 'create' ? 'creating' : 'updating');
$afterEvent = ($type === 'create' ? 'created' : 'updated');
$user->firstname = $input['firstname'];
$user->lastname = $input['lastname'];
$user->email = $input['email'];
if (isset($input['status'])) {
$user->status = $input['status'];
}
if ($user->exists && !isset($input['status'])) {
$user->status = 0;
}
|
php
|
{
"resource": ""
}
|
q264211
|
SitePath.isWithinPath
|
test
|
public function isWithinPath($path) {
$path = SiteUrl::normalizePath($path);
$current_path = $this->getPath() .
|
php
|
{
"resource": ""
}
|
q264212
|
Type.getRegisteredType
|
test
|
protected function getRegisteredType()
{
if (empty($this->registered_type)) {
$this->registered_type = $this->pool->getRegisteredType($this->getType());
|
php
|
{
"resource": ""
}
|
q264213
|
Type.getEtag
|
test
|
public function getEtag($visitor_identifier, $use_cache = true)
{
$timestamp_field = $this->getTimestampField();
if ($timestamp_field && ($this->tag === false || !$use_cache)) {
|
php
|
{
"resource": ""
}
|
q264214
|
Type.getTimestampField
|
test
|
public function getTimestampField()
{
if ($this->timestamp_field === null) {
$fields = $this->pool->getTypeFields($this->getRegisteredType());
if (in_array('updated_at', $fields)) {
$this->timestamp_field = 'updated_at';
} elseif (in_array('created_at', $fields))
|
php
|
{
"resource": ""
}
|
q264215
|
Type.getTimestampHash
|
test
|
public function getTimestampHash($timestamp_field)
{
if (!$this->isReady()) {
throw new LogicException('Collection is not ready');
}
$table_name = $this->getTableName();
$conditions = $this->getConditions() ? " WHERE {$this->getConditions()}" : '';
if ($this->count() > 0) {
if ($join_expression = $this->getJoinExpression()) {
return sha1($this->connection->executeFirstCell("SELECT GROUP_CONCAT($table_name.$timestamp_field ORDER BY $table_name.id SEPARATOR ',') AS 'timestamp_hash' FROM $table_name $join_expression $conditions"));
|
php
|
{
"resource": ""
}
|
q264216
|
Type.execute
|
test
|
public function execute()
{
if (!$this->isReady()) {
throw new LogicException('Collection is not ready');
}
if (is_callable($this->pre_execute_callback)) {
$ids = $this->executeIds();
if ($ids_count = count($ids)) {
call_user_func($this->pre_execute_callback, $ids);
if ($ids_count > 1000) {
$sql = $this->getSelectSql(); // Don't escape more than 1000 ID-s using DB::escape(), let MySQL do the dirty work instead of PHP
} else {
$escaped_ids = $this->connection->escapeValue($ids);
|
php
|
{
"resource": ""
}
|
q264217
|
Type.executeIds
|
test
|
public function executeIds()
{
if (!$this->isReady()) {
throw new LogicException('Collection is not ready');
}
if ($this->ids === false) {
$this->ids = $this->connection->executeFirstColumn($this->getSelectSql(false));
|
php
|
{
"resource": ""
}
|
q264218
|
Type.count
|
test
|
public function count()
{
if (!$this->isReady()) {
throw new LogicException('Collection is not ready');
}
$table_name = $this->connection->escapeTableName($this->getTableName());
$conditions = $this->getConditions() ? " WHERE
|
php
|
{
"resource": ""
}
|
q264219
|
Type.getTableName
|
test
|
public function getTableName()
{
if (empty($this->table_name)) {
$this->table_name
|
php
|
{
"resource": ""
}
|
q264220
|
Type.getOrderBy
|
test
|
public function getOrderBy()
{
if ($this->order_by === false) {
$this->order_by =
|
php
|
{
"resource": ""
}
|
q264221
|
Type.&
|
test
|
public function &orderBy($value)
{
if ($value === null || $value) {
$this->order_by = $value;
} else {
|
php
|
{
"resource": ""
}
|
q264222
|
Type.getConditions
|
test
|
public function getConditions()
{
if ($this->conditions_as_string === false) {
switch (count($this->conditions)) {
case 0:
$this->conditions_as_string = '';
break;
case 1:
$this->conditions_as_string = $this->conditions[0];
break;
default:
|
php
|
{
"resource": ""
}
|
q264223
|
Type.&
|
test
|
public function &where($pattern, ...$arguments)
{
if (empty($pattern)) {
throw new InvalidArgumentException('Pattern argument is required');
}
if (is_string($pattern)) {
$this->conditions[] = $this->connection->prepareConditions(array_merge([$pattern], $arguments));
} elseif (is_array($pattern)) {
if (!empty($arguments)) {
throw new LogicException('When pattern is an array, no extra arguments are allowed');
}
$this->conditions[] = $this->connection->prepareConditions($pattern);
|
php
|
{
"resource": ""
}
|
q264224
|
Type.&
|
test
|
public function &setJoinTable($table_name, $join_field = null)
{
$this->join_table = $table_name;
if (empty($this->target_join_field)) {
if (is_string($join_field) && $join_field) {
$this->setTargetJoinField($join_field);
} elseif (is_array($join_field)) {
if (count($join_field) == 2 && !empty($join_field[0]) && !empty($join_field[1])) {
$this->setSourceJoinField($join_field[0]);
|
php
|
{
"resource": ""
}
|
q264225
|
Authorization.edit
|
test
|
public function edit($listener, $metric)
{
publish('acl', ['js/control.js']);
$collection = [];
$instances = $this->acl->all();
$eloquent = null;
foreach ($instances as $name => $instance) {
$collection[$name] = $this->getAuthorizationName($name);
|
php
|
{
"resource": ""
}
|
q264226
|
Authorization.update
|
test
|
public function update($listener, array $input)
{
$all = $this->acl->all();
if (is_null($all)) {
return $listener->aclVerificationFailed();
}
$roleId = key($input['acl']);
$role = $this->foundation->make('antares.role')->query()->where('id', $roleId)->firstOrFail();
$roleName = $role->name;
$allowed = array_keys($input['acl'][$roleId]);
foreach ($all as $component => $details) {
$acl = $this->acl->get($component);
$actions = $details->actions->get();
|
php
|
{
"resource": ""
}
|
q264227
|
AbstractDaemon.setLogger
|
test
|
public function setLogger($log = self::SYSLOG)
{
if ($log === self::FILES || $log === self::FILES_DEBUG) {
$log_file = strtr(static::DEFAULT_LOG_FILE, [
'{name}' => $this->name,
]);
$this->logger = new Loggers\FilesLogger($log_file);
|
php
|
{
"resource": ""
}
|
q264228
|
AbstractDaemon.start
|
test
|
public function start()
{
$this->ensureNotLocked();
$pid = $this->fork();
// return pid
if ($pid > 0)
return $pid;
|
php
|
{
"resource": ""
}
|
q264229
|
AbstractDaemon.stop
|
test
|
public function stop()
{
$lock_data = $this->getStatus();
if ($lock_data === false)
|
php
|
{
"resource": ""
}
|
q264230
|
AbstractDaemon.kill
|
test
|
public function kill()
{
$lock_data = $this->getStatus();
if ($lock_data === false)
|
php
|
{
"resource": ""
}
|
q264231
|
Finder.&
|
test
|
public function &where($pattern, ...$arguments)
{
if (!is_string($pattern)) {
throw new InvalidArgumentException('Conditions pattern needs to be string');
}
|
php
|
{
"resource": ""
}
|
q264232
|
Finder.getWhere
|
test
|
public function getWhere()
{
switch (count($this->where)) {
case 0:
return '';
case 1:
return $this->where[0];
default:
|
php
|
{
"resource": ""
}
|
q264233
|
Finder.count
|
test
|
public function count()
{
$table_name = $this->getEscapedTableName();
$sql = "SELECT COUNT($table_name.`id`) AS 'row_count' FROM $table_name";
if ($this->join) {
$sql .= " $this->join";
|
php
|
{
"resource": ""
}
|
q264234
|
Finder.first
|
test
|
public function first()
{
if ($this->offset === null) {
$this->offset = 0;
|
php
|
{
"resource": ""
}
|
q264235
|
Finder.ids
|
test
|
public function ids()
{
$ids = $this->connection->executeFirstColumn($this->getSelectIdsSql());
|
php
|
{
"resource": ""
}
|
q264236
|
Finder.execute
|
test
|
public function execute()
{
$select_sql = $this->getSelectSql();
if ($this->loadByTypeField()) {
$return_by = ConnectionInterface::RETURN_OBJECT_BY_FIELD;
$return_by_value = 'type';
} else {
$return_by = ConnectionInterface::RETURN_OBJECT_BY_CLASS;
$return_by_value = $this->type;
}
if ($this->hasContainer()) {
return
|
php
|
{
"resource": ""
}
|
q264237
|
Finder.loadByTypeField
|
test
|
private function loadByTypeField()
{
if ($this->load_by_type_field === null) {
$this->load_by_type_field
|
php
|
{
"resource": ""
}
|
q264238
|
Finder.getSelectFieldsSql
|
test
|
private function getSelectFieldsSql($escaped_field_names)
{
$result = "SELECT $escaped_field_names FROM " . $this->getEscapedTableName();
if ($this->join) {
$result .= " $this->join";
}
|
php
|
{
"resource": ""
}
|
q264239
|
ModulesAdapter.modules
|
test
|
public function modules()
{
$memory = app('antares.memory');
$configuration = $memory->make('component');
$extensions = $configuration->get('extensions.active');
$coreActions = $configuration->get('acl_antares.actions');
$data = [
[
'name' => 'antares',
'namespace' => 'antares',
'full_name' => 'Core Platform',
'description' => 'Application engine',
'actions' => $coreActions
]
];
foreach ($extensions as $extension) {
$named = app('antares.extension')->getAvailableExtensions()->findByName($extension['fullname']);
|
php
|
{
"resource": ""
}
|
q264240
|
ModulesAdapter.smashResource
|
test
|
protected function smashResource($name, $resource, $item, $controller, &$return)
{
$pattern = "{$name}::{$resource}::";
if (starts_with($item, $pattern)) {
$id = $this->collector->id($item);
$actionForm = preg_replace("/{$pattern}/", '', $item);
|
php
|
{
"resource": ""
}
|
q264241
|
RoleManager.defineAllPermissions
|
test
|
public function defineAllPermissions()
{
foreach ($this->getPermissions() as $permission) {
Gate::define(
$permission->name,
function ($user, ...$arguments) use ($permission) {
foreach ($permission->roles as $role) {
if ($role->belongsToUser($user)) {
if (!empty($permission->class)
AND !empty($permission->method)
AND class_exists($permission->class)
) {
$container = resolve($permission->class);
if (method_exists($container, $permission->method)) {
array_unshift($arguments, $user);
|
php
|
{
"resource": ""
}
|
q264242
|
RoleManager.assignRole
|
test
|
public function assignRole($user, $role)
{
if (is_int($user) and !$user = User::where('id', $user)->first()) {
return false;
}
if (is_int($role) and !$role = Roles::where('id', $role)->first()) {
return false;
}
if (is_string($role) and !$role
|
php
|
{
"resource": ""
}
|
q264243
|
RoleManager.removeRole
|
test
|
public function removeRole($user, $role)
{
if (is_int($user) and !$user = User::where('id', $user)->first()) {
return false;
}
if (is_int($role) and !$role = Roles::where('id', $role)->first()) {
|
php
|
{
"resource": ""
}
|
q264244
|
Role.create
|
test
|
public function create($listener)
{
$eloquent = $this->model;
$form
|
php
|
{
"resource": ""
}
|
q264245
|
Role.edit
|
test
|
public function edit($listener, $id)
{
$eloquent = $this->model->findOrFail($id);
$data
|
php
|
{
"resource": ""
}
|
q264246
|
Role.store
|
test
|
public function store($listener, array $input)
{
$role = $this->model;
$form = $this->presenter->form($role);
if (!$form->isValid()) {
return $listener->storeValidationFailed($form->getMessageBag());
}
try {
$this->saving($role, $input, 'create');
|
php
|
{
"resource": ""
}
|
q264247
|
Role.update
|
test
|
public function update($listener, array $input, $id)
{
if ((int) $id !== (int) $input['id']) {
return $listener->userVerificationFailed();
}
$role = $this->model->findOrFail($id);
$form = $this->presenter->form($role);
if (!$form->isValid()) {
return $listener->updateValidationFailed($form->getMessageBag(), $id);
}
|
php
|
{
"resource": ""
}
|
q264248
|
Role.destroy
|
test
|
public function destroy($listener, $id)
{
$role = $this->model->findOrFail($id);
try {
if ($role->users->count() > 0) {
throw new Exception('Unable to delete group with assigned users.');
}
DB::transaction(function () use ($role) {
$role->delete();
});
} catch (Exception $e)
|
php
|
{
"resource": ""
}
|
q264249
|
Role.saving
|
test
|
protected function saving(Eloquent $role, $input = [], $type = 'create')
{
$beforeEvent = ($type === 'create' ? 'creating' : 'updating');
$afterEvent = ($type === 'create' ? 'created' : 'updated');
$name = $input['name'];
$role->fill([
'name' => snake_case($name, '-'),
'full_name' => $name,
'area' => array_get($input, 'area'),
'description' => $input['description']
]);
if (!$role->exists && isset($input['roles'])) {
$role->parent_id = $input['roles'];
}
|
php
|
{
"resource": ""
}
|
q264250
|
Role.import
|
test
|
protected function import(array $input, Model $role)
{
if (isset($input['import']) && !is_null($from = $input['roles'])) {
$permission = $this->foundation->make('antares.auth.permission');
$permissions = $permission->where('role_id', $from)->get();
$permissions->each(function(Model $model) use($permission, $role) {
$attributes
|
php
|
{
"resource": ""
}
|
q264251
|
Role.acl
|
test
|
public function acl($id)
{
$eloquent = $this->model->findOrFail($id);
|
php
|
{
"resource": ""
}
|
q264252
|
SqlScriptCache.clearAnalyticsData
|
test
|
public function clearAnalyticsData()
{
$this->clear(self::ADBACK_ANALYTICS_SCRIPT);
|
php
|
{
"resource": ""
}
|
q264253
|
SqlScriptCache.clearMessageData
|
test
|
public function clearMessageData()
{
$this->clear(self::ADBACK_MESSAGE_SCRIPT);
|
php
|
{
"resource": ""
}
|
q264254
|
ModulesPane.make
|
test
|
public function make()
{
$extensions = app('antares.memory')->make('component')->get('extensions.active');
$data = [
[
'name' => 'core_platform',
'full_name' => 'Core Platform',
'handles' => handles('antares::acl/acl')
]
];
foreach ($extensions as $extension) {
$name = $extension['name'];
if ($name == 'control') {
|
php
|
{
"resource": ""
}
|
q264255
|
RoleController.edit
|
test
|
public function edit(Roles $role)
{
$this->authorize('edit_role');
$valueList = $role->permissions()->get()->pluck('id')->toArray();
return view(
'RoleManager::role.edit',
['role'
|
php
|
{
"resource": ""
}
|
q264256
|
Administrators.scopeRoles
|
test
|
protected function scopeRoles(&$builder)
{
return (config('antares/acl::allow_register_with_other_roles')) ? $builder->administrators() :
$builder->with('roles')->whereNotNull('tbl_users.id')->whereHas('roles', function ($query)
|
php
|
{
"resource": ""
}
|
q264257
|
Administrators.statuses
|
test
|
protected function statuses()
{
$statuses = User::withoutGlobalScopes()
->select([DB::raw('count(id) as counter'), 'status'])
->whereNull('tbl_users.deleted_at');
$this->scopeRoles($statuses);
$result = $statuses->groupBy('status')->get()->pluck('counter', 'status')->toArray();
return [
'all' => trans('antares/foundation::messages.statuses.all'),
|
php
|
{
"resource": ""
}
|
q264258
|
Administrators.getActionsColumn
|
test
|
protected function getActionsColumn($canUpdateUser, $canDeleteUser, $canLoginAsUser)
{
return function ($row) use($canUpdateUser, $canDeleteUser, $canLoginAsUser) {
$html = app('html');
$this->tableActions = [];
$user = user();
if ($canUpdateUser) {
$url = ($user->id === $row->id) ? 'antares/foundation::/account' : "antares::acl/index/users/{$row->id}/edit";
$this->addTableAction('edit', $row, $html->link(handles($url), trans('antares/foundation::label.edit'), ['data-icon' => 'edit']));
}
if (!is_null($user) && $user->id !== $row->id and $canDeleteUser) {
$this->addTableAction('delete', $row, $html->create('li', $html->link(handles("antares::acl/index/users/{$row->id}/delete", ['csrf' => true]), trans('antares/foundation::label.delete'), [
'class' => 'triggerable confirm',
'data-icon' => 'delete',
'data-title' => trans("antares/acl::messages.users.delete.are_you_sure"),
'data-description' => trans("antares/acl::messages.users.delete.deleteing_description", ["fullname" => $row->fullname])
])));
|
php
|
{
"resource": ""
}
|
q264259
|
Administrators.userRoles
|
test
|
protected function userRoles($row)
{
return function ($row) {
$roles = $row->roles;
$value = [];
foreach ($roles as $role) {
$value[] = app('html')->create('span', e($role->full_name), [
'class' => 'label-basic label-basic--info'
|
php
|
{
"resource": ""
}
|
q264260
|
Pool.&
|
test
|
public function &modify(EntityInterface &$instance, array $attributes = null, $save = true)
{
if ($instance->isNew()) {
throw new RuntimeException('Only objects that are saved to database can be modified');
}
$registered_type = $this->requireRegisteredType(get_class($instance));
$instance =
|
php
|
{
"resource": ""
}
|
q264261
|
Pool.&
|
test
|
protected function &getProducerForRegisteredType($registered_type)
{
if (empty($this->producers[$registered_type])) {
if (empty($this->default_producer)) {
$default_producer_class = $this->getDefaultProducerClass();
$this->default_producer = new $default_producer_class($this->connection, $this);
if ($this->default_producer instanceof ContainerAccessInterface && $this->hasContainer()) {
|
php
|
{
"resource": ""
}
|
q264262
|
Pool.registerProducer
|
test
|
public function registerProducer($type, ProducerInterface $producer)
{
$registered_type = $this->requireRegisteredType($type);
if (empty($this->producers[$registered_type])) {
if ($producer instanceof ContainerAccessInterface && $this->hasContainer()) {
$producer->setContainer($this->getContainer());
}
|
php
|
{
"resource": ""
}
|
q264263
|
Pool.registerProducerByClass
|
test
|
public function registerProducerByClass($type, $producer_class)
{
if (class_exists($producer_class)) {
$producer_class_reflection = new ReflectionClass($producer_class);
if ($producer_class_reflection->implementsInterface(ProducerInterface::class)) {
$this->registerProducer($type, new $producer_class($this->connection, $this));
} else {
|
php
|
{
"resource": ""
}
|
q264264
|
Pool.&
|
test
|
public function &getById($type, $id, $use_cache = true)
{
$registered_type = $this->requireRegisteredType($type);
$id = (int) $id;
if ($id < 1) {
throw new InvalidArgumentException('ID is expected to be a number larger than 0');
}
if (isset($this->objects_pool[$registered_type][$id]) && $use_cache) {
return $this->objects_pool[$registered_type][$id];
} else {
$type_fields = $this->getTypeFields($registered_type);
if ($row = $this->connection->executeFirstRow($this->getSelectOneByType($registered_type), [$id])) {
$object_class = in_array('type', $type_fields) ? $row['type'] : $type;
/** @var object|EntityInterface $object */
$object = new $object_class($this->connection, $this, $this->log);
|
php
|
{
"resource": ""
}
|
q264265
|
Pool.&
|
test
|
public function &mustGetById($type, $id, $use_cache = true)
{
$result = $this->getById($type, $id, $use_cache);
if (empty($result)) {
|
php
|
{
"resource": ""
}
|
q264266
|
Pool.&
|
test
|
private function &addToObjectPool($registered_type, $id, &$value_to_store)
{
if (empty($this->objects_pool[$registered_type])) {
|
php
|
{
"resource": ""
}
|
q264267
|
Pool.remember
|
test
|
public function remember(EntityInterface &$object)
{
if ($object->isLoaded()) {
$this->addToObjectPool($this->requireRegisteredType(get_class($object)), $object->getId(), $object);
} else {
|
php
|
{
"resource": ""
}
|
q264268
|
Pool.count
|
test
|
public function count($type, $conditions = null)
{
$this->requireRegisteredType($type);
if ($conditions = $this->connection->prepareConditions($conditions)) {
return $this->connection->executeFirstCell('SELECT COUNT(`id`) AS "row_count" FROM ' . $this->getTypeTable($type, true) . " WHERE $conditions");
|
php
|
{
"resource": ""
}
|
q264269
|
Pool.find
|
test
|
public function find($type)
{
$registered_type = $this->requireRegisteredType($type);
$default_finder_class = $this->getDefaultFinderClass();
/** @var Finder $finder */
$finder = new $default_finder_class($this->connection, $this, $this->log, $registered_type);
|
php
|
{
"resource": ""
}
|
q264270
|
Pool.getSelectOneByType
|
test
|
private function getSelectOneByType($type)
{
if (empty($this->types[$type]['sql_select_by_ids'])) {
$this->types[$type]['sql_select_by_ids'] = 'SELECT ' . $this->getEscapedTypeFields($type) . ' FROM '
|
php
|
{
"resource": ""
}
|
q264271
|
Pool.getEscapedTypeFields
|
test
|
public function getEscapedTypeFields($type)
{
return $this->getTypeProperty($type, 'escaped_fields', function () use ($type) {
$table_name = $this->getTypeTable($type, true);
$escaped_field_names = [];
foreach ($this->getTypeFields($type) as $field_name) {
$escaped_field_names[] = $table_name . '.' . $this->connection->escapeFieldName($field_name);
|
php
|
{
"resource": ""
}
|
q264272
|
Pool.getEscapedTypeOrderBy
|
test
|
public function getEscapedTypeOrderBy($type)
{
return $this->getTypeProperty($type, 'escaped_order_by', function () use ($type) {
$table_name = $this->getTypeTable($type, true);
return implode(',', array_map(function ($field_name) use ($table_name) {
if (substr($field_name, 0, 1) == '!') {
|
php
|
{
"resource": ""
}
|
q264273
|
Pool.getTraitNamesByType
|
test
|
public function getTraitNamesByType($type)
{
if (empty($this->types[$type]['traits'])) {
$this->types[$type]['traits'] =
|
php
|
{
"resource": ""
}
|
q264274
|
Pool.recursiveGetTraitNames
|
test
|
private function recursiveGetTraitNames(ReflectionClass $class, array &$trait_names)
{
$trait_names = array_merge($trait_names, $class->getTraitNames());
if ($class->getParentClass()) {
|
php
|
{
"resource": ""
}
|
q264275
|
ControlsAdapter.adaptee
|
test
|
public function adaptee(Grid &$grid, array $controls = array(), Fluent $model)
{
if (empty($controls)) {
return false;
}
$grid->fieldset(function (Fieldset $fieldset) use($controls, $model) {
$editable = $model->get('editable', []);
$displayable = $model->get('displayable', []);
foreach ($controls as $control) {
$name = $control['name'];
$fieldset->control($control['type'], $name)
->label($control['label'])
->value($control['value'])
->attributes(['disabled' => 'disabled', 'readonly' => 'readonly']);
$fieldset->control('input:checkbox', 'editable[' . $name . ']')
->value($control['value'])
|
php
|
{
"resource": ""
}
|
q264276
|
ControlsAdapter.checked
|
test
|
protected function checked(array $control, array $displayable)
{
if (empty($displayable)) {
return ['checked' => 'checked'];
}
foreach ($displayable as $item) {
if ($control['name']
|
php
|
{
"resource": ""
}
|
q264277
|
ActivePageEntityPreparator.prepareEntity
|
test
|
public function prepareEntity($parameters)
{
$this->activePageEntity->setPageid($this->getPageIdentifiers()->getPageId());
$this->activePageEntity->setLangid(Registry::getLang()->getBaseLanguage());
$domain = str_ireplace('www.', '', parse_url(Registry::getConfig()->getShopUrl(), PHP_URL_HOST));
|
php
|
{
"resource": ""
}
|
q264278
|
ActivePageEntityPreparator.setLoginsTracking
|
test
|
private function setLoginsTracking()
{
$currentView = Registry::getConfig()->getActiveView();
$functionName = $currentView->getFncName();
if ('login_noredirect' ==
|
php
|
{
"resource": ""
}
|
q264279
|
ActivePageEntityPreparator.setEmailTracking
|
test
|
private function setEmailTracking()
{
$hashedEmail = $this->activeUserDataProvider->getActiveUserHashedEmail();
|
php
|
{
"resource": ""
}
|
q264280
|
SiteUrl.getSitePath
|
test
|
public function getSitePath($url, $match_scheme = true) {
$ret = $this->analyzeUrl($url);
if (!$ret || !$ret['path_within_site'] || ($ret['site_host'] !== $ret['host'])) {
return false;
}
if ($match_scheme && ($ret['scheme']
|
php
|
{
"resource": ""
}
|
q264281
|
SiteUrl.analyzeUrl
|
test
|
public function analyzeUrl($url) {
$url = trim($url);
if (!preg_match('~^(https?)\\://([^/]+)(/.*|$)~', $url, $m)) {
return false;
}
list (, $scheme, $host, $path) = $m;
$path = self::normalizePath($path);
$segments = ($path === '') ? array() : explode('/', $path);
$ret = [
'site_scheme' => $this->scheme,
'site_host' => $this->host,
'site_url_segments' => $this->url_segments,
'host' => $host,
'scheme' => $scheme,
'path_within_site' => false,
'url_segments' => $segments,
'url_segments_within_site' => [],
|
php
|
{
"resource": ""
}
|
q264282
|
CategoryPathBuilder.getBasketProductCategoryPath
|
test
|
public function getBasketProductCategoryPath($product)
{
$categoryPath = '';
if ($category = $product->getCategory()) {
$table = $category->getViewName();
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
$query = "select {$table}.oxtitle as oxtitle from {$table}
where {$table}.oxleft <= " . $database->quote($category->oxcategories__oxleft->value) . " and
|
php
|
{
"resource": ""
}
|
q264283
|
Entity.areFieldValuesSame
|
test
|
private function areFieldValuesSame($value_1, $value_2)
{
if (($value_1 instanceof DateValueInterface && $value_2 instanceof DateValueInterface) || ($value_1 instanceof DateTimeValueInterface && $value_2 instanceof DateTimeValueInterface)) {
|
php
|
{
"resource": ""
}
|
q264284
|
Entity.loadFromRow
|
test
|
public function loadFromRow(array $row)
{
if (empty($row)) {
throw new InvalidArgumentException('Database row expected');
}
$this->startLoading();
$found_generated_fields = [];
foreach ($row as $k => $v) {
if ($this->isGeneratedField($k)) {
$found_generated_fields[] = $k;
} elseif ($this->fieldExists($k)) {
$this->setFieldValue($k, $v);
}
}
if (!empty($found_generated_fields)) {
$generated_field_values = [];
$value_caster = $this->getGeneratedFieldsValueCaster();
|
php
|
{
"resource": ""
}
|
q264285
|
Entity.copy
|
test
|
public function copy($save = false)
{
$object_class = get_class($this);
/** @var EntityInterface $copy */
$copy = new $object_class($this->connection, $this->pool, $this->log);
|
php
|
{
"resource": ""
}
|
q264286
|
Entity.revertField
|
test
|
public function revertField($field)
{
if ($this->isModifiedField($field)) {
$this->setFieldValue($field, $this->getOldFieldValue($field)); // revert field value
if
|
php
|
{
"resource": ""
}
|
q264287
|
Entity.getOldFieldValue
|
test
|
public function getOldFieldValue($field)
{
return isset($this->old_values[$field])
|
php
|
{
"resource": ""
}
|
q264288
|
Entity.&
|
test
|
public function &setFieldValue($field, $value)
{
if ($this->fieldExists($field)) {
if ($field === 'id') {
$value = $value === null ? null : (int) $value;
}
if ($value === null && array_key_exists($field, $this->default_field_values)) {
throw new InvalidArgumentException("Value of '$field' can't be null");
}
if (!$this->isLoading()) {
$this->triggerEvent('on_prepare_field_value_before_set', [$field, &$value]);
}
if (!array_key_exists($field, $this->values) || ($this->values[$field] !== $value)) {
// If we are loading object there is no need to remember if this field
// was modified, if PK has been updated and old value. We just skip that
|
php
|
{
"resource": ""
}
|
q264289
|
Entity.insert
|
test
|
private function insert()
{
$last_insert_id = $this->connection->insert($this->table_name, $this->values);
if (empty($this->values[$this->auto_increment])) {
|
php
|
{
"resource": ""
}
|
q264290
|
Entity.update
|
test
|
private function update()
{
if (count($this->modified_fields)) {
$updates = [];
foreach ($this->modified_fields as $modified_field) {
$updates[$modified_field] = $this->values[$modified_field];
}
if ($this->primary_key_modified) {
$old_id = isset($this->old_values['id']) ? $this->old_values['id'] : $this->getId();
if ($this->pool->exists(get_class($this), $this->getId())) {
throw new LogicException('Object #' . $this->getId() . " can't be overwritten");
} else {
|
php
|
{
"resource": ""
}
|
q264291
|
Entity.refreshGeneratedFieldValues
|
test
|
private function refreshGeneratedFieldValues($id)
{
$result = [];
if (!empty($this->generated_fields)) {
$result = $this->connection->selectFirstRow($this->getTableName(), $this->generated_fields, $this->getWherePartById($id));
|
php
|
{
"resource": ""
}
|
q264292
|
Validator.compareValues
|
test
|
protected function compareValues($field_name, $reference_value, $allow_null, callable $compare_with, $validation_failed_message)
{
if (empty($field_name)) {
throw new InvalidArgumentException("Value '$field_name' is not a valid field name");
}
if (array_key_exists($field_name, $this->field_values)) {
if ($this->field_values[$field_name] === null) {
|
php
|
{
"resource": ""
}
|
q264293
|
SlimRouter.generateUri
|
test
|
public function generateUri(string $name, array $substitutions = [], array $options = []): string
{
$this->injectRoutes();
if (! $this->router->hasNamedRoute($name)) {
throw new Exception\RuntimeException(sprintf(
'Cannot generate URI based
|
php
|
{
"resource": ""
}
|
q264294
|
RolesController.storeSucceed
|
test
|
public function storeSucceed(Role $role)
{
$message = trans('antares/acl::response.roles.created', ['name' => $role->name]);
|
php
|
{
"resource": ""
}
|
q264295
|
ValidationException.getFieldErrors
|
test
|
public function getFieldErrors($field)
{
return isset($this->errors[$field])
|
php
|
{
"resource": ""
}
|
q264296
|
ValidationException.hasError
|
test
|
public function hasError($field)
{
return
|
php
|
{
"resource": ""
}
|
q264297
|
ValidationException.&
|
test
|
public function &addError($error, $field = self::ANY_FIELD)
{
if (empty($field)) {
$field = self::ANY_FIELD;
|
php
|
{
"resource": ""
}
|
q264298
|
ProductTitlePreparator.prepareProductTitle
|
test
|
public function prepareProductTitle($product)
{
$title = $product->oxarticles__oxtitle->value;
if ($product->oxarticles__oxvarselect->value) {
|
php
|
{
"resource": ""
}
|
q264299
|
EntityModifierByCurrentAction.modifyByContactController
|
test
|
protected function modifyByContactController()
{
/** @var \OxidEsales\Eshop\Application\Controller\ContactController $currentController */
$currentController = Registry::getConfig()->getActiveView();
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.