sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public static function statusbar( $str, $height = null, $last_line_to_opposing_stream = true ) {
if( $height < 0 ) {
$height = Misc::rows() + $height + 1;
}
if( !$height ) {
if( defined('STATUSBAR_HEIGHT') ) {
$height = STATUSBAR_HEIGHT; //@todo: backwards compatibility with some of my older code, rem... | Render a statusbar stack
@staticvar bool $lines A stack of previously added lines
@param string $str The status to add
@param null|int $height The height of the status menu to render
@param bool $last_line_to_opposing_stream Send the last line of the status to the oposite stream (STDERR/STDOUT) | entailment |
public static function progressbar( $title, $numerator, $denominator, $line, $time_id = null, $color = 'cyan' ) {
static $timer = array();
if( $time_id ) {
if( !isset($timer[$time_id]) || $timer[$time_id]['last_numerator'] > $numerator ) {
$timer[$time_id] = array( 'start' => microtime(true) );
}
$time... | Draw a Progress Bar
@staticvar array $timer
@param string $title
@param int $numerator
@param int $denominator
@param int $line Which row of the terminal to render
@param int|null $time_id
@param string $color | entailment |
public static function histogram( $title, $numerator, $denominator, $line, $hist_id, $color = 'normal', $full_color = 'red' ) {
$levels = array( ' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█' );
static $hist = false;
if( !$hist || !$hist[$hist_id] ) {
$hist[$hist_id] = array_fill(0, Misc::cols(), $levels[0]);
... | Draw a Histogram
@param string $title
@param int $numerator
@param int $denominator
@param int $line
@param int $hist_id
@param string $color
@param string $full_color | entailment |
public function viewElements(FieldItemListInterface $items, $langcode)
{
$elements = [];
foreach ($items as $delta => $item) {
$elements['data'] = [
'#theme' => 'site_commerce_settings_default_formatter',
'#new' => $item->new,
'#appearanc... | {@inheritdoc} | entailment |
public function update(Listener $listener, Fluent $extension, array $input)
{
if (! Extension::started($extension->get('name'))) {
return $listener->suspend(404);
}
$validation = $this->validator->with($input, ["orchestra.validate: extension.{$extension->get('name')}"]);
... | Update an extension configuration.
@param \Orchestra\Contracts\Extension\Listener\Configure $listener
@param \Illuminate\Support\Fluent $extension
@param array $input
@return mixed | entailment |
public function view(UserViewerListener $listener, array $input = [])
{
$search = [
'keyword' => $input['q'] ?? '',
'roles' => $input['roles'] ?? [],
];
// Get Users (with roles) and limit it to only 30 results for
// pagination. Don't you just love it when p... | View list users page.
@param \Orchestra\Contracts\Foundation\Listener\Account\UserViewer $listener
@param array $input
@return mixed | entailment |
public function edit(UserUpdaterListener $listener, $id)
{
$eloquent = Foundation::make('orchestra.user')->findOrFail($id);
$form = $this->presenter->form($eloquent, 'update');
$this->fireEvent('form', [$eloquent, $form]);
return $listener->showUserChanger(\compact('eloquent', 'for... | View edit user page.
@param \Orchestra\Contracts\Foundation\Listener\Account\UserUpdater $listener
@param string|int $id
@return mixed | entailment |
public function store(UserCreatorListener $listener, array $input)
{
$validation = $this->validator->on('create')->with($input);
if ($validation->fails()) {
return $listener->createUserFailedValidation($validation->getMessageBag());
}
$user = Foundation::make('orchestra... | Store a user.
@param \Orchestra\Contracts\Foundation\Listener\Account\UserCreator $listener
@param array $input
@return mixed | entailment |
public function update(UserUpdaterListener $listener, $id, array $input)
{
// Check if provided id is the same as hidden id, just a pre-caution.
if ((string) $id !== $input['id']) {
return $listener->abortWhenUserMismatched();
}
$validation = $this->validator->on('update... | Update a user.
@param \Orchestra\Contracts\Foundation\Listener\Account\UserUpdater $listener
@param string|int $id
@param array $input
@return mixed | entailment |
public function destroy(UserRemoverListener $listener, $id)
{
$user = Foundation::make('orchestra.user')->findOrFail($id);
// Avoid self-deleting accident.
if ((string) $user->id === (string) Auth::user()->id) {
return $listener->selfDeletionFailed();
}
try {
... | Destroy a user.
@param \Orchestra\Contracts\Foundation\Listener\Account\UserRemover $listener
@param string|int $id
@return mixed | entailment |
protected function saving(Eloquent $user, $input = [], $type = 'create')
{
$beforeEvent = ($type === 'create' ? 'creating' : 'updating');
$afterEvent = ($type === 'create' ? 'created' : 'updated');
$user->fullname = $input['fullname'];
$user->email = $input['email'];
$this-... | Save the user.
@param \Orchestra\Model\User $user
@param array $input
@param string $type
@return bool | entailment |
public function saveNodeValue(NodePath $nodePath, string $property, $value)
{
try {
$this->data = $this->storeValue($nodePath, $this->data, $property, $value);
} catch (InconsistentValueException $e) {
if ($property == 'nodeType') {
$node = $this->getNode($nod... | Save a single property value for a given node.
@param NodePath $nodePath Node Path.
@param string $property Property name (e.g. 'nodeType')
@param mixed $value Scalar value.
@throws InconsistentValueException | entailment |
private function storeValue(NodePath $nodePath, array $data, string $property, $value) : array
{
$nodePath = $nodePath->popFirst($nodeName);
$nodeName = $this->encodeNodeName($nodeName);
if (!isset($data[$nodeName])) {
$data[$nodeName] = [];
}
if ($nodePath->isEmp... | Store a particular value of a particular property for a given node.
@param NodePath $nodePath Node Path
@param array $data Structure data.
@param string $property Name of the property (e.g. 'nodeType')
@param mixed $value Scalar value of the property.
@return array Structure data
@throws InconsistentValueException In c... | entailment |
private function handleUpgrade(array $node, NodePath $nodePath, string $newType)
{
if ((($node['nodeType'] == 'array') || ($newType == 'array')) && $this->autoUpgradeToArray) {
$this->checkArrayUpgrade($node, $nodePath, $newType);
// copy all properties to the array
if (!... | Upgrade a node to array
@param array $node
@param NodePath $nodePath
@param string $newType
@throws JsonParserException | entailment |
public function saveNode(NodePath $nodePath, array $node)
{
$this->data = $this->storeNode($nodePath, $this->data, $node);
} | Store a complete node data in the structure.
@param NodePath $nodePath Node path.
@param array $node Node data. | entailment |
private function storeNode(NodePath $nodePath, array $data, array $node) : array
{
$nodePath = $nodePath->popFirst($nodeName);
$nodeName = $this->encodeNodeName($nodeName);
if ($nodePath->isEmpty()) {
$data[$nodeName] = $node;
} else {
if (isset($data[$nodeNam... | Store a complete node data in the structure.
@param NodePath $nodePath Node path.
@param array $data Structure data.
@param array $node Node data.
@return array Structure data.
@throws JsonParserException In case the node path is not valid. | entailment |
public function getData()
{
foreach ($this->data as $value) {
$this->validateDefinitions($value);
}
return ['data' => $this->data, 'parent_aliases' => $this->parentAliases];
} | Return complete structure.
@return array | entailment |
public function getNode(NodePath $nodePath, array $data = null)
{
if (empty($data)) {
$data = $this->data;
}
$nodePath = $nodePath->popFirst($nodeName);
$nodeName = $this->encodeNodeName($nodeName);
if (!isset($data[$nodeName])) {
return null;
... | Get structure of a particular node.
@param NodePath $nodePath Node path.
@param array $data Optional structure data (for recursive call).
@return array|null Null in case the node path does not exist. | entailment |
public function getNodeProperty(NodePath $nodePath, string $property)
{
$data = $this->getNode($nodePath);
if (isset($data[$property])) {
return $data[$property];
} else {
return null;
}
} | Return a particular property of the node.
@param NodePath $nodePath Node path
@param string $property Property name (e.g. 'nodeType')
@return mixed Property value or null if the node or property does not exist. | entailment |
private function getNodeChildrenProperties(NodePath $nodePath, string $property) : array
{
$nodeData = $this->getNode($nodePath);
$result = [];
if (!empty($nodeData)) {
if ($nodeData['nodeType'] == 'object') {
foreach ($nodeData as $itemName => $value) {
... | Return a particular property of a the children of the node.
@param NodePath $nodePath Node path
@param string $property Property name (e.g. 'nodeType').
@return array | entailment |
public function getColumnTypes(NodePath $nodePath)
{
$values = $this->getNodeChildrenProperties($nodePath, 'nodeType');
$result = [];
foreach ($values as $key => $value) {
if ($key === self::ARRAY_NAME) {
$result[self::DATA_COLUMN] = $value;
} else {
... | Get columns from a node and return their data types.
@param NodePath $nodePath
@return array Index is column name, value is data type. | entailment |
public function generateHeaderNames()
{
foreach ($this->data as $baseType => &$baseArray) {
foreach ($baseArray as $nodeName => &$nodeData) {
if (is_array($nodeData)) {
$nodeName = $this->decodeNodeName($nodeName);
$this->generateHeaderName... | Generate header names for the whole structure. | entailment |
public function getParentTargetName(string $name)
{
if (empty($this->parentAliases[$name])) {
return $name;
}
return $this->parentAliases[$name];
} | Get new name of a parent column
@param $name
@return mixed | entailment |
private function getSafeName(string $name) : string
{
$name = preg_replace('/[^A-Za-z0-9-]/', '_', $name);
if (strlen($name) > 64) {
if (str_word_count($name) > 1 && preg_match_all('/\b(\w)/', $name, $m)) {
// Create an "acronym" from first letters
$short ... | If necessary, change the name to a safe to store in database.
@param string $name
@return string | entailment |
private function getUniqueName(string $baseType, string $headerName) : string
{
if (isset($this->headerIndex[$baseType][$headerName])) {
$newName = $headerName;
$i = 0;
while (isset($this->headerIndex[$baseType][$newName])) {
$newName = $headerName . '_u' ... | If necessary change the name to a unique one.
@param string $baseType
@param string $headerName
@return string | entailment |
private function generateHeaderName(array &$data, NodePath $nodePath, string $parentName, string $baseType)
{
if (empty($data['headerNames'])) {
// write only once, because generateHeaderName may be called repeatedly
if ($parentName != self::ARRAY_NAME) {
// do not ge... | Generate header name for a node and sub-nodes.
@param array $data Node data
@param NodePath $nodePath
@param string $parentName
@param string $baseType | entailment |
public function load(array $definitions)
{
$this->data = $definitions['data'] ?? [];
$this->parentAliases = $definitions['parent_aliases'] ?? [];
foreach ($this->data as $value) {
$this->validateDefinitions($value);
}
} | Load structure data.
@param array $definitions | entailment |
public function configure($model, $name)
{
return $this->form->of("orchestra.extension: {$name}", function (FormGrid $form) use ($model, $name) {
$form->setup($this, "orchestra::extensions/{$name}/configure", $model);
$handles = data_get($model, 'handles', $this->extension->option($... | Form View Generator for Orchestra\Extension.
@param \Illuminate\Support\Fluent $model
@param string $name
@return \Orchestra\Contracts\Html\Form\Builder | entailment |
public function getState()
{
return (isset($this->raw['state']) && ! empty($this->raw['state']))
? (string) $this->raw['state']
: null;
} | Возвращает статус ответа от B2B.
@return null|string | entailment |
public function count()
{
return isset($this->raw['size'])
? (int) $this->raw['size']
: (isset($this->raw['data']) && is_array($this->raw['data'])
? count($this->raw['data'])
: null);
} | Возвращает количество вхождений в ответе от B2B.
@return int|null | entailment |
public static function getCatalogByTerm($term_current, $limit = 4) {
$build = [];
$pids = [];
$site_commerces = [];
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$db = \Drupal::database();
// Дочерние термины для которого получаем перечень товаров.
$terms = \Drupal... | Страница каталога с товарами по категории. | entailment |
public static function getCatalog($vid = "site_commerce") {
$query = \Drupal::database()->select('taxonomy_term_field_data', 'n');
$query->fields('n', array('tid'));
$query->condition('n.vid', $vid);
$query->orderBy('n.weight', 'ASC');
$query->innerJoin('taxonomy_term__parent', 'h', 'h.entity_id=n.... | Страница отображения категорий каталога по названию словаря. | entailment |
public static function getCatalogChildrenList($tid) {
$db = \Drupal::database();
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
$terms_result = [];
// Дочерние термины для которого получаем перечень товаров.
$terms = \Drupal::entityTypeManager()->getStorage('taxono... | Список дочерних категорий по номеру категории-родителя. | entailment |
public function handle(Foundation $foundation, Memory $memory)
{
$this->setupApplication();
$this->refreshApplication($foundation, $memory);
$this->optimizeApplication();
} | Execute the console command.
@param \Orchestra\Contracts\Foundation\Foundation $foundation
@param \Orchestra\Contracts\Memory\Provider $memory
@return void | entailment |
protected function refreshApplication(Foundation $foundation, Memory $memory): void
{
if (! $foundation->installed()) {
$this->error('Abort as application is not installed!');
return;
}
$this->call('extension:detect', ['--quiet' => true]);
try {
... | Refresh application for Orchestra Platform.
@param \Orchestra\Contracts\Foundation\Foundation $foundation
@param \Orchestra\Contracts\Memory\Provider $memory
@return void | entailment |
protected function optimizeApplication(): void
{
$this->info('Optimizing application for Orchestra Platform');
$this->call('config:clear');
$this->call('route:clear');
if ($this->laravel->environment('production') && ! $this->option('no-cache')) {
$this->call('config:ca... | Optimize application for Orchestra Platform.
@return void | entailment |
public function viewElements(FieldItemListInterface $items, $langcode)
{
$elements = [];
foreach ($items as $delta => $item) {
$elements['data'] = [
'#theme' => 'site_commerce_cart_default_formatter',
'#visible' => $item->visible,
'#event... | {@inheritdoc} | entailment |
public function set($key, $values, $replace = true)
{
parent::set($key, $values, $replace);
$this->updateRequest();
} | Sets a header by name.
@param string $key
@param string|array $values
@param bool $replace | entailment |
protected function updateRequest()
{
$headers = [];
foreach ($this->all() as $key => $values) {
foreach ($values as $value) {
$headers[] = $key.': '.$value;
}
}
$this->request->setOption(CURLOPT_HTTPHEADER, $headers);
} | Updates the headers in the associated request. | entailment |
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->getEntity();
$content = array();
foreach (\Drupal::entityTypeManager()->getStorage('site_commerce_type')->loadMultiple() as $type) {
$content[] = $type->id();
}
$duplicate = $entity->createDuplicateT... | {@inheritdoc} | entailment |
protected function authorize(?string $action = null): bool
{
return $this->foundation->memory()->get('site.registrable', false);
} | Check authorization.
@param string $action
@return bool | entailment |
public static function getCharacteristicsByTerm($term, $position) {
$build = [];
$pids = [];
$site_commerces = [];
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$database = \Drupal::database();
} | Страница характеристик по категории. | entailment |
public function submitForm(array &$form, FormStateInterface $form_state) {
$database = Database::getConnection();
$term = $form_state->getValues()['term'];
$scheme = 'public';
$inputFileName = $scheme . '://export/templates/getPrice.xls';
$reader = IOFactory::createReader("Xls");
$spreadsheet... | {@inheritdoc} | entailment |
protected function changePermission(string $path, $mode = 0755, bool $recursively = false): void
{
$filesystem = $this->getContainer()['files'];
$filesystem->chmod($path, $mode);
if ($recursively === false) {
return;
}
$lists = $filesystem->allFiles($path);
... | Change CHMOD permission.
@param string $path
@param int $mode
@param bool $recursively
@return void | entailment |
protected function prepareDirectory(string $path, $mode = 0755): void
{
$filesystem = $this->getContainer()['files'];
if (! $filesystem->isDirectory($path)) {
$filesystem->makeDirectory($path, $mode, true);
}
} | Prepare destination directory.
@param string $path
@param int $mode
@return void | entailment |
protected function basePath(string $path): string
{
// This set of preg_match would filter ftp' user is not accessing
// exact path as path('public'), in most shared hosting ftp' user
// would only gain access to it's /home/username directory.
if (\preg_match('/^\/(home)\/([a-zA-Z0-9... | Get base path for FTP.
@param string $path
@return string | entailment |
protected function destination(string $name, bool $recursively = false): Fluent
{
$filesystem = $this->getContainer()['files'];
$publicPath = $this->basePath($this->getContainer()['path.public']);
// Start chmod from public/packages directory, if the extension folder
// is yet to b... | Check upload path.
@param string $name
@param bool $recursively
@return \Illuminate\Support\Fluent | entailment |
public function update(Processor $processor, $user)
{
return $processor->update($this, $user, Input::all());
} | Update the user.
PUT (:orchestra)/users/$user
@param \Orchestra\Foundation\Processors\User $processor
@param int|string $user
@return mixed | entailment |
protected function getVates(){
return [
self::TAX_NONE,
self::TAX_VAT0,
self::TAX_VAT10,
self::TAX_VAT110,
self::TAX_VAT118,
self::TAX_VAT18,
];
} | Получить все возможные налоговые ставки | entailment |
protected function getVatAmount($amount, $vat){
switch($vat){
case self::TAX_NONE:
case self::TAX_VAT0:
return round(0, 2);
case self::TAX_VAT10:
case self::TAX_VAT110:
return round($amount * 10 / 110, 2);
case self::TAX... | Получить сумму налога
@param float $amount | entailment |
public function processNode(Node $node, Scope $scope): array
{
$messages = [];
$nodeIdentifier = $node->name;
if (null === $nodeIdentifier) {
return $messages;
}
$name = $nodeIdentifier->name;
if (0 === \strpos($name, 'AnonymousClass')) {
... | @param \PhpParser\Node\Stmt\ClassLike $node
@param \PHPStan\Analyser\Scope $scope
@return string[] errors | entailment |
protected function registerAssembleCommand()
{
$this->app->singleton('orchestra.commands.assemble', function (Application $app) {
$foundation = $app->make('orchestra.app');
return new AssembleCommand($foundation, $foundation->memory());
});
} | Register the command.
@return void | entailment |
public function reports($auth_token, $report_uid, $detailed = true, $with_content = true)
{
return new B2BResponse($this->client->apiRequest(
'get',
sprintf('dev/user/reports/%s', urlencode((string) $report_uid)),
[
'_detailed' => (bool) $detailed ? 'true'... | Запрос отчетов в режиме имитации.
@param string $auth_token Токен безопасности
@param string $report_uid UID отчета
@param bool $detailed Детализация
@param bool $with_content Включить контент в ответ
@throws B2BApiException
@return B2BResponse | entailment |
public function getStackValueWithDot($path, $default = null)
{
if (($current = $this->getAccessorStack()) && is_array($current)) {
$p = strtok((string) $path, '.');
while ($p !== false) {
if (! isset($current[$p])) {
return $default;
... | Возвращает значение из стека данных, обращаясь к нему с помощью dot-нотации.
@param string $path
@param mixed|null $default
@return array|mixed|null | entailment |
public function handle($request, Closure $next)
{
$this->beforeSendingThroughPipeline();
$response = $next($request);
$this->afterSendingThroughPipeline();
return $response;
} | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | entailment |
public static function rowcol( $row = 1, $col = 1 ) {
$row = intval($row);
$col = intval($col);
if( $row < 0 ) {
$row = Misc::rows() + $row + 1;
}
if( $col < 0 ) {
$col = Misc::cols() + $col + 1;
}
fwrite(self::$stream, "\033[{$row};{$col}f");
} | Move the cursor to a specific row and column
@param int $row
@param int $col | entailment |
public static function wrap( $wrap = true ) {
if( $wrap ) {
fwrite(self::$stream, "\033[?7h");
} else {
fwrite(self::$stream, "\033[?7l");
}
} | Enable/Disable Auto-Wrap
@param bool $wrap | entailment |
public function buildForm(array $form, FormStateInterface $form_state, $gid = 0) {
// Загружаем группу по идентификатору.
$group = $this->database->characteristicsReadGroup($gid);
// Скрытые поля.
$form['group'] = array(
'#type' => 'value',
'#value' => $group,
);
// Вспомогательный... | {@inheritdoc} | entailment |
public function submitForm(array &$form, FormStateInterface $form_state) {
$group = $form_state->getValue('group');
$title = trim($form_state->getValue('title'));
$description = trim($form_state->getValue('description'));
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
// Вы... | {@inheritdoc} | entailment |
protected function convertToArray($value)
{
// Если получен массив - то просто кидаем его в raw
if (\is_array($value)) {
return $value;
}
if (\is_string($value)) {
// Если влетела строка - то считаем что это json, и пытаемся его разобрать
$json = ... | Преобразует прилетевший в метод объект - в массив. В противном случае вернёт null.
@param array|string|Response|object|null $value
@return array|null | entailment |
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->getEntity();
$duplicate = $entity->createDuplicate();
$duplicate->setTitle($this->t('Duplicate') . ": " . $duplicate->label());
$duplicate->save();
$form_state->setRedirect('entity.site_... | {@inheritdoc}
Delete the entity and log the event. log() replaces the watchdog. | entailment |
public function buildForm(array $form, FormStateInterface $form_state, $pid = 0, $clone_pid = 0) {
$form['#theme'] = 'site_commerce_product_version_form';
// Получаем объект товара.
// Позиция к которой будет привязан товар.
$site_commerce = \Drupal::entityTypeManager()->getStorage('site_commerce');
... | {@inheritdoc} | entailment |
public function submitForm(array &$form, FormStateInterface $form_state) {
$database = Database::getConnection();
// Позиция для клонирования.
$position_clone = $form_state->getValue('position_clone');
// Позиция товара для привязки.
$position = $form_state->getValue('position');
// Введенные... | {@inheritdoc} | entailment |
protected function registerPublisher(): void
{
$this->app->singleton('orchestra.publisher', function (Application $app) {
$memory = $app->make('orchestra.platform.memory');
return (new PublisherManager($app))->attach($memory);
});
} | Register the service provider for publisher.
@return void | entailment |
protected function registerRoleEloquent(): void
{
$this->app->bind('orchestra.role', function () {
$model = $this->getConfig('models.role', Role::class);
return new $model();
});
} | Register the service provider for user.
@return void | entailment |
protected function registerUserEloquent(): void
{
$this->app->bind('orchestra.user', function () {
$model = $this->getConfig('models.user', User::class);
return new $model();
});
} | Register the service provider for user.
@return void | entailment |
public function autocomplete(Request $request) {
// Получаем строку запроса ($_GET['q']).
$string = $request->query->get('q');
$matches = [];
$matches_id = [];
if ($string) {
$string_array = explode(" ", $string);
$request = '';
$arguments = array();
$i = 1;
$count_ar... | {@inheritdoc} | entailment |
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = [];
$element['group'] = array(
'#type' => 'select',
'#title' => $this->t('Price group'),
'#options' => array('0' => $... | {@inheritdoc} | entailment |
public function getActiveFrom()
{
return ! empty($value = $this->getContentValue('active_from', null))
? $this->convertToCarbon($value)
: null;
} | Возвращает дату/время, с которого активен.
@return Carbon|null | entailment |
public function getActiveTo()
{
return ! empty($value = $this->getContentValue('active_to', null))
? $this->convertToCarbon($value)
: null;
} | Возвращает дату/время, по которые активен.
@return Carbon|null | entailment |
public function edit(Listener $listener)
{
$user = Auth::user();
$form = $this->presenter->profile($user, 'orchestra::account');
$this->fireEvent('form', [$user, $form]);
return $listener->showProfileChanger(['eloquent' => $user, 'form' => $form]);
} | Get account/profile information.
@param \Orchestra\Contracts\Foundation\Listener\Account\ProfileUpdater $listener
@return mixed | entailment |
public function update(Listener $listener, array $input)
{
$user = Auth::user();
if (! $this->validateCurrentUser($user, $input)) {
return $listener->abortWhenUserMismatched();
}
$validation = $this->validator->on('update')->with($input);
if ($validation->fails... | Update profile information.
@param \Orchestra\Contracts\Foundation\Listener\Account\ProfileUpdater $listener
@param array $input
@return mixed | entailment |
protected function saving($user, array $input)
{
$user->setAttribute('email', $input['email']);
$user->setAttribute('fullname', $input['fullname']);
$this->fireEvent('updating', [$user]);
$this->fireEvent('saving', [$user]);
$user->saveOrFail();
$this->fireEvent('u... | Save user profile.
@param \Orchestra\Foundation\Auth\User $user
@param array $input
@return void | entailment |
public function countProducts($status = 1, $tid = 0) {
$query = $this->connection->select('site_commerce_field_data', 'n');
if ($status < 2) {
$query->condition('n.status', $status);
}
$query->addExpression('COUNT(pid)', 'pid_count');
$tids = [];
if ($term = \Drupal\taxonomy\Entity\Term::... | Возвращает количество товаров в зависимости от статуса и категории.
@param int $status
@param int $tid
@return void | entailment |
public function loadProducts($tid, $status = 1) {
$loadProducts = &drupal_static(__FUNCTION__);
if (!isset($loadProducts)) {
$query = $this->connection->select('site_commerce_field_data', 'n');
$query->fields('n', array('pid', 'title'));
if ($status < 2) {
$query->condition('n.status',... | Возвращает объекты товаров в зависимости от статуса и категории.
@param int $status
@param int $tid
@return void | entailment |
public function priceEditorUpdate($data) {
$site_commerce = \Drupal::entityTypeManager()->getStorage('site_commerce')->load($data['pid']);
$site_commerce->field_cost->from = $data['from'];
$site_commerce->field_cost->value = $data['value'];
$site_commerce->field_quantity->unit = $data['unit'];
$site... | Обновляет значение параметров в редакторе цен. | entailment |
public function positionSetWeight($entry) {
$update = $this->connection->update('site_commerce_field_data')
->fields(array('weight' => $entry['weight']))
->condition('pid', $entry['pid']);
return $update->execute();
} | Обновляет вес позиции привязанных к категории. | entailment |
public function loadFile($type, $id) {
$query = $this->connection->select('file_usage', 'n');
$query->fields('n', array('fid'));
$query->condition('n.module', 'site_commerce');
$query->condition('n.type', $type);
$query->condition('n.id', $id);
$fid = $query->execute()->fetchField();
$file =... | Загружает информацию о файле. | entailment |
public function characteristicsCreateGroup($entry) {
$insert = $this->connection->insert('site_commerce_characteristics_group')->fields($entry);
return $insert->execute();
} | Создает группу характеристик товара. | entailment |
public function characteristicsUpdateGroup($entry) {
$update = $this->connection->update('site_commerce_characteristics_group')
->fields($entry)
->condition('gid', $entry['gid']);
return $update->execute();
} | Обновляет группу характеристик товара. | entailment |
public function characteristicsDeleteGroup($gid) {
// Удаляем из таблиц, в которых используется группа.
$query = $this->connection->delete('site_commerce_characteristics_group');
$query->condition('gid', $gid);
$query->execute();
$query = $this->connection->delete('site_commerce_characteristics_gro... | Удаляет характеристику товара. | entailment |
public function characteristicsCreateGroupIndex($entry) {
$insert = $this->connection->insert('site_commerce_characteristics_group_index')->fields($entry);
return $insert->execute();
} | Создает привязку группы характеристик товара к категории товаров. | entailment |
public function characteristicsReadGroupIndex($gid) {
$query = $this->connection->select('site_commerce_characteristics_group_index', 'n');
$query->fields('n');
$query->condition('gid', $gid);
return $query->execute()->fetchObject();
} | Загружает привязку группы характеристик к категории товаров. | entailment |
public function characteristicsUpdateGroupIndex($entry) {
$update = $this->connection->update('site_commerce_characteristics_group_index')
->fields($entry)
->condition('tid', $entry['tid'])
->condition('gid', $entry['gid']);
return $update->execute();
} | Обновляет привязку группы характеристики товара к категории. | entailment |
public function characteristicsCreateItem($entry) {
$insert = $this->connection->insert('site_commerce_characteristics_item')->fields($entry);
return $insert->execute();
} | Создает характеристику товара. | entailment |
public function characteristicsUpdateItem($entry) {
$update = $this->connection->update('site_commerce_characteristics_item')
->fields($entry)
->condition('cid', $entry['cid']);
return $update->execute();
} | Обновляет характеристику товара. | entailment |
public function characteristicsDeleteItem($cid) {
// Удаляем из таблиц, в которых используется параметр.
$query = $this->connection->delete('site_commerce_characteristics_item');
$query->condition('cid', $cid);
$query->execute();
$query = $this->connection->delete('site_commerce_characteristics_ite... | Удаляет характеристику товара. | entailment |
public function characteristicsCreateItemIndex($entry) {
$insert = $this->connection->insert('site_commerce_characteristics_item_index')->fields($entry);
return $insert->execute();
} | Создает привязку характеристики товара к группе характеристик. | entailment |
public function characteristicsReadItemIndex($cid) {
$query = $this->connection->select('site_commerce_characteristics_item_index', 'n');
$query->fields('n');
$query->condition('cid', $cid);
return $query->execute()->fetchObject();
} | Загружает привязку характеристики товара к группе характеристик. Возвращает массив. | entailment |
public function characteristicsUpdateItemIndex($entry) {
$update = $this->connection->update('site_commerce_characteristics_item_index')
->fields($entry)
->condition('cid', $entry['cid'])
->condition('gid', $entry['gid']);
return $update->execute();
} | Обновляет привязку характеристики товара к группе характеристик. | entailment |
public function characteristicsReadGroups() {
$query = $this->connection->select('site_commerce_characteristics_group', 'n');
$query->fields('n', array('gid', 'title'));
$loadGroups = $query->execute()->fetchAllKeyed();
return $loadGroups;
} | Загружает все группы характеристик. Возвращает массив. | entailment |
public function characteristicsReadGroupsByCategory($tid) {
$query = $this->connection->select('site_commerce_characteristics_group', 'n');
$query->fields('n', array('gid', 'title'));
$query->join('site_commerce_characteristics_group_index', 'i', 'n.gid = i.gid');
$query->condition('i.tid', $tid);
$... | Загружает все группы характеристик по категории. Возвращает массив. | entailment |
public function characteristicsReadItems($gid) {
$query = $this->connection->select('site_commerce_characteristics_item_index', 'n');
$query->fields('n', array('cid'));
$query->condition('n.gid', $gid);
$query->join('site_commerce_characteristics_item', 'i', 'n.cid = i.cid');
$query->fields('i', arr... | Загружает все характеристики по выбранной группе характеристик. | entailment |
public function characteristicsProductReadItems($pid, $gid) {
// Получаем группы параметры.
$query = $this->connection->select('site_commerce_characteristics_data', 'n');
$query->fields('n', array('cid'));
$query->condition('n.pid', $pid);
$query->condition('n.gid', $gid);
$query->join('site_com... | Загружает все активные характеристики по выбранной группе характеристик и товару. | entailment |
public function characteristicDataCreateItem($entry) {
$insert = $this->connection->insert('site_commerce_characteristics_data')->fields($entry);
return $insert->execute();
} | Создает привязку характеристики к товару. | entailment |
public function characteristicDataReadItem($pid, $cid) {
$query = $this->connection->select('site_commerce_characteristics_data', 'n');
$query->fields('n');
$query->condition('n.cid', $cid);
$query->condition('n.pid', $pid);
return $query->execute()->fetchObject();
} | Загружает привязку характеристики к товару. | entailment |
public function characteristicDataUpdateItem($entry) {
$update = $this->connection->update('site_commerce_characteristics_data')
->fields($entry)
->condition('cid', $entry['cid'])
->condition('pid', $entry['pid']);
return $update->execute();
} | Обновляет привязку характеристики к товару. | entailment |
public function characteristicDataReadProductItems($pid, $parametr = 0) {
// Получаем группы параметры.
$query = $this->connection->select('site_commerce_characteristics_data', 'n');
$query->fields('n', ['gid']);
$query->condition('n.pid', $pid);
$query->join('site_commerce_characteristics_group_ind... | Загружает объекты характеристик. | entailment |
protected function addRequiredForSecretField(ValidatorResolver $resolver, $field, $hidden)
{
$resolver->sometimes($field, 'required', function ($input) use ($hidden) {
return $input->$hidden == 'yes';
});
} | Add required for secret or password field.
@param \Illuminate\Contracts\Validation\Validator $resolver
@param string $field
@param string $hidden
@return void | entailment |
public function show(Listener $listener)
{
$panes = $this->widget->make('pane.orchestra');
return $listener->showDashboard(['panes' => $panes]);
} | View dashboard.
@param \Orchestra\Contracts\Foundation\Listener\Account\ProfileDashboard $listener
@return mixed | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.